diff --git a/.code-spell-ignore b/.code-spell-ignore new file mode 100644 index 00000000000..c3c1a3a08c6 --- /dev/null +++ b/.code-spell-ignore @@ -0,0 +1,20 @@ +aanother +acount +addrss +afile +aline +anumber +ans +aother +aparent +apending +asender +asent +ect +intialize +nd +ot +shashes +ue +unknwn +unsecure diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b385b343178..4f21eb6bf0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -74,12 +74,31 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 # v1 with: use-verbose-mode: 'yes' max-depth: 3 + spell-check: + runs-on: ubuntu-22.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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + submodules: true + - name: Bootstrap + run: | + python -m pip install --upgrade pip + pip install codespell + - name: Check + run: | + script/code-spell check + cmake-version: runs-on: ubuntu-20.04 steps: @@ -88,7 +107,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -128,7 +147,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -147,7 +166,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -166,14 +185,14 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: repository: ARMmbed/mbedtls ref: v3.2.1 @@ -219,7 +238,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -260,7 +279,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -293,7 +312,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -331,7 +350,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -359,7 +378,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -395,7 +414,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -421,7 +440,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Install unzip diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 88d6deafee0..84d2109ff14 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -59,14 +59,14 @@ jobs: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - 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@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.3.3 + uses: github/codeql-action/init@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -80,6 +80,6 @@ jobs: ./script/test build - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.3.3 + uses: github/codeql-action/analyze@0225834cc549ee0ca93cb085b92954821a145866 # v2.3.5 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 46786d4669b..e827099bd6a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -59,7 +59,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true diff --git a/.github/workflows/makefile-check.yml b/.github/workflows/makefile-check.yml index 6972074492e..8474a8c4cfa 100644 --- a/.github/workflows/makefile-check.yml +++ b/.github/workflows/makefile-check.yml @@ -52,7 +52,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Check diff --git a/.github/workflows/otbr.yml b/.github/workflows/otbr.yml index 9cab9ad97fe..1a808f3be6e 100644 --- a/.github/workflows/otbr.yml +++ b/.github/workflows/otbr.yml @@ -62,7 +62,7 @@ jobs: # of OMR prefix and Domain prefix is not deterministic. BORDER_ROUTING: 0 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Build OTBR Docker @@ -172,7 +172,7 @@ jobs: NAT64: ${{ matrix.nat64 }} MAX_JOBS: 3 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Build OTBR Docker env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -223,7 +223,7 @@ jobs: - thread-border-router runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -238,7 +238,7 @@ jobs: script/test combine_coverage - name: Upload Coverage continue-on-error: true - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/otci.yml b/.github/workflows/otci.yml index 46f07450e8c..77642b1f770 100644 --- a/.github/workflows/otci.yml +++ b/.github/workflows/otci.yml @@ -61,7 +61,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | sudo rm /etc/apt/sources.list.d/* && sudo apt-get update diff --git a/.github/workflows/otns.yml b/.github/workflows/otns.yml index ba09fbdce58..c9a9d946d22 100644 --- a/.github/workflows/otns.yml +++ b/.github/workflows/otns.yml @@ -62,8 +62,8 @@ jobs: 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 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: go-version: "1.20" - name: Set up Python @@ -102,8 +102,8 @@ jobs: name: Examples runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: go-version: "1.20" - name: Set up Python @@ -165,8 +165,8 @@ jobs: 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 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: go-version: "1.20" - name: Set up Python @@ -213,7 +213,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | sudo apt-get --no-install-recommends install -y lcov diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml index ded9e81def7..f260f039557 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/posix.yml @@ -56,7 +56,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat @@ -139,7 +139,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -166,38 +166,6 @@ jobs: name: cov-thread-cert path: tmp/coverage.info - ncp-rcp-migrate: - 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 expect lcov - - name: Build - run: | - ./bootstrap - script/check-ncp-rcp-migrate build - - name: Run - run: | - script/check-ncp-rcp-migrate check - - name: Generate Coverage - run: | - ./script/test generate_coverage gcc - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - name: cov-ncp-rcp-migrate - path: tmp/coverage.info - pty-linux: name: pty-linux OT_DAEMON=${{ matrix.OT_DAEMON }} runs-on: ubuntu-20.04 @@ -215,7 +183,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | sudo rm /etc/apt/sources.list.d/* && sudo apt-get update @@ -264,7 +232,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | rm -f /usr/local/bin/2to3 @@ -294,7 +262,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -318,7 +286,6 @@ jobs: upload-coverage: needs: - expects-linux - - ncp-rcp-migrate - pty-linux - thread-cert runs-on: ubuntu-20.04 @@ -328,7 +295,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -341,7 +308,7 @@ jobs: run: | script/test combine_coverage - name: Upload Coverage - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 5a241f4a9f3..4bd4a49448f 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -60,12 +60,12 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3 + uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0 with: results_file: results.sarif results_format: sarif @@ -95,6 +95,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.1.27 + uses: github/codeql-action/upload-sarif@0225834cc549ee0ca93cb085b92954821a145866 # 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 d996c0e6320..65030d5949a 100644 --- a/.github/workflows/simulation-1.1.yml +++ b/.github/workflows/simulation-1.1.yml @@ -59,7 +59,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -90,7 +90,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -138,7 +138,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -188,7 +188,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -231,7 +231,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -270,7 +270,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap run: | sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat @@ -300,7 +300,7 @@ jobs: path: tmp/coverage.info ot-commissioner: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: THREAD_VERSION: 1.1 steps: @@ -309,7 +309,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -360,7 +360,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -402,7 +402,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -415,7 +415,7 @@ jobs: run: | script/test combine_coverage - name: Upload Coverage - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/simulation-1.2.yml b/.github/workflows/simulation-1.2.yml index cbf2c9ee132..25d28c8c861 100644 --- a/.github/workflows/simulation-1.2.yml +++ b/.github/workflows/simulation-1.2.yml @@ -70,7 +70,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -131,7 +131,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -195,7 +195,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -239,7 +239,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -287,7 +287,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -347,7 +347,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -360,7 +360,7 @@ jobs: run: | script/test combine_coverage - name: Upload Coverage - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml index 71afb0d2b68..de97e010763 100644 --- a/.github/workflows/size.yml +++ b/.github/workflows/size.yml @@ -53,7 +53,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Bootstrap if: "github.event_name == 'push'" run: | diff --git a/.github/workflows/toranj.yml b/.github/workflows/toranj.yml index 83cf71254f8..efa9aff42a3 100644 --- a/.github/workflows/toranj.yml +++ b/.github/workflows/toranj.yml @@ -63,7 +63,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -71,6 +71,8 @@ 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 ninja-build lcov + python3 -m pip install -r tests/scripts/thread-cert/requirements.txt - name: Build & Run run: | top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh @@ -92,7 +94,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -124,7 +126,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -138,8 +140,15 @@ jobs: python3 -m pip install -r tests/scripts/thread-cert/requirements.txt - name: Build & Run run: | - ./tests/toranj/build.sh cmake + ./tests/toranj/build.sh all ninja test + # Validate posix builds with different radio configs + git clean -dfx + ./tests/toranj/build.sh posix-15.4 + git clean -dfx + ./tests/toranj/build.sh posix-15.4+trel + git clean -dfx + ./tests/toranj/build.sh posix-trel upload-coverage: needs: @@ -151,7 +160,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -164,7 +173,7 @@ jobs: run: | script/test combine_coverage - name: Upload Coverage - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index aa9c3008e2f..37d83959d11 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -53,7 +53,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Build @@ -71,7 +71,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -108,7 +108,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Bootstrap @@ -121,7 +121,7 @@ jobs: run: | script/test combine_coverage - name: Upload Coverage - uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3 + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 with: files: final.info fail_ci_if_error: true diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index 47828d36b46..10a30dfe8dc 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -49,7 +49,7 @@ jobs: with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: submodules: true - name: Check diff --git a/CMakeLists.txt b/CMakeLists.txt index 15659e86c5e..c966aa75317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,14 +108,18 @@ 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" "1.3.1") -if(${OT_THREAD_VERSION} EQUAL "1.1") +if(${OT_THREAD_VERSION} STREQUAL "1.1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_1") -elseif(${OT_THREAD_VERSION} EQUAL "1.2") + message(STATUS "Thread Version: 1.1 (OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_1)") +elseif(${OT_THREAD_VERSION} STREQUAL "1.2") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2") -elseif(${OT_THREAD_VERSION} EQUAL "1.3") + message(STATUS "Thread Version: 1.2 (OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2)") +elseif(${OT_THREAD_VERSION} STREQUAL "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") + message(STATUS "Thread Version: 1.3 (OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3)") +elseif(${OT_THREAD_VERSION} STREQUAL "1.3.1") target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3_1") + message(STATUS "Thread Version: 1.3.1 (OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3_1)") else() message(FATAL_ERROR "Thread version unknown: ${OT_THREAD_VERSION}") endif() diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 014224bfd75..0fa2af8aa86 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1144,7 +1144,7 @@ HTML_STYLESHEET = # defined cascading style sheet that is included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. +# standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet file to the output directory. For an example # see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -2029,7 +2029,7 @@ PREDEFINED = __attribute__(x)= EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an +# remove all references to function-like macros that are alone on a line, have an # all uppercase name, and do not end with a semicolon. Such function macros are # typically used for boiler-plate code, and will confuse the parser if not # removed. diff --git a/doc/ot_api_doc.h b/doc/ot_api_doc.h index 58e09a95412..d6ce51e47f5 100644 --- a/doc/ot_api_doc.h +++ b/doc/ot_api_doc.h @@ -142,6 +142,7 @@ * @defgroup api-mesh-diag Mesh Diagnostics * @defgroup api-ncp Network Co-Processor * @defgroup api-network-time Network Time Synchronization + * @defgroup api-radio Radio Statistics * @defgroup api-random-group Random Number Generator * * @{ diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index 96c407aeda2..2c7c4d59ec5 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -42,6 +42,7 @@ 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}) +message(STATUS OT_THREAD_VERSION=${OT_THREAD_VERSION}) set(OT_CONFIG_VALUES "" @@ -89,6 +90,7 @@ 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_DHCP6_PD OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE "dhcpv6 pd support in 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") diff --git a/examples/apps/cli/main.c b/examples/apps/cli/main.c index cc52d9ab7eb..461d987c1db 100644 --- a/examples/apps/cli/main.c +++ b/examples/apps/cli/main.c @@ -42,7 +42,7 @@ #include "lib/platform/reset_util.h" /** - * This function initializes the CLI app. + * Initializes the CLI app. * * @param[in] aInstance The OpenThread instance structure. * diff --git a/examples/apps/ncp/main.c b/examples/apps/ncp/main.c index 9c21c57bb90..0f388951148 100644 --- a/examples/apps/ncp/main.c +++ b/examples/apps/ncp/main.c @@ -38,7 +38,7 @@ #include "lib/platform/reset_util.h" /** - * This function initializes the NCP app. + * Initializes the NCP app. * * @param[in] aInstance The OpenThread instance structure. * diff --git a/examples/platforms/openthread-system.h b/examples/platforms/openthread-system.h index de8b2d13b36..90503ecd3d9 100644 --- a/examples/platforms/openthread-system.h +++ b/examples/platforms/openthread-system.h @@ -42,7 +42,7 @@ extern "C" { #endif /** - * This function performs all platform-specific initialization of OpenThread's drivers. + * Performs all platform-specific initialization of OpenThread's drivers. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function * when initialization of OpenThread's drivers is most appropriate. @@ -54,7 +54,7 @@ extern "C" { void otSysInit(int argc, char *argv[]); /** - * This function performs all platform-specific deinitialization for OpenThread's drivers. + * Performs all platform-specific deinitialization for OpenThread's drivers. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function * when deinitialization of OpenThread's drivers is most appropriate. @@ -63,7 +63,7 @@ void otSysInit(int argc, char *argv[]); void otSysDeinit(void); /** - * This function returns true if a pseudo-reset was requested. + * Returns true if a pseudo-reset was requested. * * In such a case, the main loop should shut down and re-initialize the OpenThread instance. * @@ -74,7 +74,7 @@ void otSysDeinit(void); bool otSysPseudoResetWasRequested(void); /** - * This function performs all platform-specific processing for OpenThread's example applications. + * Performs all platform-specific processing for OpenThread's example applications. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function * in the main loop when processing OpenThread's drivers is most appropriate. @@ -85,7 +85,7 @@ bool otSysPseudoResetWasRequested(void); void otSysProcessDrivers(otInstance *aInstance); /** - * This function is called whenever platform drivers needs processing. + * Is called whenever platform drivers needs processing. * * @note This function is not handled by the OpenThread library. Instead, the system/RTOS should handle this function * and schedule a call to `otSysProcessDrivers()`. diff --git a/examples/platforms/simulation/openthread-core-simulation-config.h b/examples/platforms/simulation/openthread-core-simulation-config.h index f71383008a3..252a41a1ec7 100644 --- a/examples/platforms/simulation/openthread-core-simulation-config.h +++ b/examples/platforms/simulation/openthread-core-simulation-config.h @@ -285,4 +285,15 @@ #define OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE 1 #endif +/** + * @def OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + * + * Set to 1 to enable support for Radio Statistics. Note that this option only works for OPENTHREAD_FTD and + * OPENTHREAD_MTD. + * + */ +#ifndef OPENTHREAD_CONFIG_RADIO_STATS_ENABLE +#define OPENTHREAD_CONFIG_RADIO_STATS_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 0fa32fddc88..0592b14295d 100644 --- a/examples/platforms/simulation/platform-simulation.h +++ b/examples/platforms/simulation/platform-simulation.h @@ -91,13 +91,13 @@ enum extern uint32_t gNodeId; /** - * This function initializes the alarm service used by OpenThread. + * Initializes the alarm service used by OpenThread. * */ void platformAlarmInit(uint32_t aSpeedUpFactor); /** - * This function retrieves the time remaining until the alarm fires. + * Retrieves the time remaining until the alarm fires. * * @param[out] aTimeout A pointer to the timeval struct. * @@ -105,7 +105,7 @@ void platformAlarmInit(uint32_t aSpeedUpFactor); void platformAlarmUpdateTimeout(struct timeval *aTimeout); /** - * This function performs alarm driver processing. + * Performs alarm driver processing. * * @param[in] aInstance The OpenThread instance structure. * @@ -113,7 +113,7 @@ void platformAlarmUpdateTimeout(struct timeval *aTimeout); void platformAlarmProcess(otInstance *aInstance); /** - * This function returns the duration to the next alarm event time (in micro seconds) + * Returns the duration to the next alarm event time (in micro seconds) * * @returns The duration (in micro seconds) to the next alarm event. * @@ -121,7 +121,7 @@ void platformAlarmProcess(otInstance *aInstance); uint64_t platformAlarmGetNext(void); /** - * This function returns the current alarm time. + * Returns the current alarm time. * * @returns The current alarm time. * @@ -129,7 +129,7 @@ uint64_t platformAlarmGetNext(void); uint64_t platformAlarmGetNow(void); /** - * This function advances the alarm time by @p aDelta. + * Advances the alarm time by @p aDelta. * * @param[in] aDelta The amount of time to advance. * @@ -137,19 +137,19 @@ uint64_t platformAlarmGetNow(void); void platformAlarmAdvanceNow(uint64_t aDelta); /** - * This function initializes the radio service used by OpenThread. + * Initializes the radio service used by OpenThread. * */ void platformRadioInit(void); /** - * This function shuts down the radio service used by OpenThread. + * Shuts down the radio service used by OpenThread. * */ void platformRadioDeinit(void); /** - * This function inputs a received radio frame. + * Inputs a received radio frame. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aBuf A pointer to the received radio frame. @@ -159,7 +159,7 @@ void platformRadioDeinit(void); void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLength); /** - * This function updates the file descriptor sets with file descriptors used by the radio driver. + * Updates the file descriptor sets with file descriptors used by the radio driver. * * @param[in,out] aReadFdSet A pointer to the read file descriptors. * @param[in,out] aWriteFdSet A pointer to the write file descriptors. @@ -170,7 +170,7 @@ void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLen void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, struct timeval *aTimeout, int *aMaxFd); /** - * This function performs radio driver processing. + * Performs radio driver processing. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aReadFdSet A pointer to the read file descriptors. @@ -180,7 +180,7 @@ void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, struct ti void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet); /** - * This function initializes the random number service used by OpenThread. + * Initializes the random number service used by OpenThread. * */ void platformRandomInit(void); @@ -194,7 +194,7 @@ void platformRandomInit(void); void platformLoggingSetFileName(const char *aName); /** - * This function initializes the platform logging service. + * Initializes the platform logging service. * * @param[in] aName The log module name to set with syslog. * @@ -202,13 +202,13 @@ void platformLoggingSetFileName(const char *aName); void platformLoggingInit(const char *aName); /** - * This function finalizes the platform logging service. + * Finalizes the platform logging service. * */ void platformLoggingDeinit(void); /** - * This function updates the file descriptor sets with file descriptors used by the UART driver. + * Updates the file descriptor sets with file descriptors used by the UART driver. * * @param[in,out] aReadFdSet A pointer to the read file descriptors. * @param[in,out] aWriteFdSet A pointer to the write file descriptors. @@ -218,19 +218,19 @@ void platformLoggingDeinit(void); void platformUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aErrorFdSet, int *aMaxFd); /** - * This function performs radio driver processing. + * Performs radio driver processing. * */ void platformUartProcess(void); /** - * This function restores the Uart. + * Restores the Uart. * */ void platformUartRestore(void); /** - * This function sends a simulation event. + * Sends a simulation event. * * @param[in] aEvent A pointer to the simulation event to send * @@ -238,7 +238,7 @@ void platformUartRestore(void); void otSimSendEvent(const struct Event *aEvent); /** - * This function sends Uart data through simulation. + * Sends Uart data through simulation. * * @param[in] aData A pointer to the UART data. * @param[in] aLength Length of UART data. @@ -247,7 +247,7 @@ void otSimSendEvent(const struct Event *aEvent); void otSimSendUartWriteEvent(const uint8_t *aData, uint16_t aLength); /** - * This function checks if radio transmitting is pending. + * Checks if radio transmitting is pending. * * @returns Whether radio transmitting is pending. * @@ -255,7 +255,7 @@ void otSimSendUartWriteEvent(const uint8_t *aData, uint16_t aLength); bool platformRadioIsTransmitPending(void); /** - * This function parses an environment variable as an unsigned 16-bit integer. + * 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. @@ -269,7 +269,7 @@ void parseFromEnvAsUint16(const char *aEnvName, uint16_t *aValue); #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This function initializes the TREL service. + * Initializes the TREL service. * * @param[in] aSpeedUpFactor The time speed-up factor. * @@ -277,13 +277,13 @@ void parseFromEnvAsUint16(const char *aEnvName, uint16_t *aValue); void platformTrelInit(uint32_t aSpeedUpFactor); /** - * This function shuts down the TREL service. + * Shuts down the TREL service. * */ void platformTrelDeinit(void); /** - * This function updates the file descriptor sets with file descriptors used by the TREL. + * Updates the file descriptor sets with file descriptors used by the TREL. * * @param[in,out] aReadFdSet A pointer to the read file descriptors. * @param[in,out] aWriteFdSet A pointer to the write file descriptors. @@ -294,7 +294,7 @@ void platformTrelDeinit(void); void platformTrelUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, struct timeval *aTimeout, int *aMaxFd); /** - * This function performs TREL processing. + * Performs TREL processing. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aReadFdSet A pointer to the read file descriptors. diff --git a/examples/platforms/simulation/system.c b/examples/platforms/simulation/system.c index 0e86aaae439..535cb1cac0f 100644 --- a/examples/platforms/simulation/system.c +++ b/examples/platforms/simulation/system.c @@ -64,7 +64,7 @@ static void handleSignal(int aSignal) } /** - * This enumeration defines the argument return values. + * Defines the argument return values. * */ enum diff --git a/examples/platforms/utils/code_utils.h b/examples/platforms/utils/code_utils.h index 90c4827e05b..d9ed6a2ee41 100644 --- a/examples/platforms/utils/code_utils.h +++ b/examples/platforms/utils/code_utils.h @@ -72,7 +72,7 @@ } while (0) /** - * This macro calculates the number of elements in an array. + * Calculates the number of elements in an array. * * @param[in] aArray Name of the array variable. * diff --git a/examples/platforms/utils/link_metrics.cpp b/examples/platforms/utils/link_metrics.cpp index 84be0d7c377..301fc08c59e 100644 --- a/examples/platforms/utils/link_metrics.cpp +++ b/examples/platforms/utils/link_metrics.cpp @@ -49,7 +49,7 @@ class LinkMetricsDataInfo : public LinkedListEntry, public public: /** - * Construtor. + * Constructor. * */ LinkMetricsDataInfo(void) { Clear(); }; @@ -71,7 +71,7 @@ class LinkMetricsDataInfo : public LinkedListEntry, public } /** - * This method gets Link Metrics data stored in this object. + * Gets Link Metrics data stored in this object. * * TODO: Currently the order of Link Metircs data is fixed. Will update it to follow the order specified in TLV. * @@ -114,7 +114,7 @@ class LinkMetricsDataInfo : public LinkedListEntry, public } /** - * This method gets the length of Link Metrics Data. + * Gets the length of Link Metrics Data. * * @returns The number of bytes for the data. * @@ -126,7 +126,7 @@ class LinkMetricsDataInfo : public LinkedListEntry, public } /** - * This method gets the metrics configured for the Enhanced-ACK Based Probing. + * Gets the metrics configured for the Enhanced-ACK Based Probing. * * @returns The metrics configured. * diff --git a/examples/platforms/utils/link_metrics.h b/examples/platforms/utils/link_metrics.h index 099d64b440f..1cde18b9fa0 100644 --- a/examples/platforms/utils/link_metrics.h +++ b/examples/platforms/utils/link_metrics.h @@ -48,7 +48,7 @@ extern "C" { #endif /** - * This method initializes the Link Metrics util module. + * Initializes the Link Metrics util module. * * @param[in] aNoiseFloor The noise floor used by Link Metrics. It should be set to the platform's * noise floor (measured noise floor, receiver sensitivity or a constant). @@ -57,16 +57,16 @@ extern "C" { void otLinkMetricsInit(int8_t aNoiseFloor); /** - * This method sets/clears Enhanced-ACK Based Probing for a specific Initiator. + * Sets/clears Enhanced-ACK Based Probing for a specific Initiator. * - * This method can start/stop Enhanced-ACK Based Probing for a neighbor that has the address @p aShortAddress and + * Can start/stop Enhanced-ACK Based Probing for a neighbor that has the address @p aShortAddress and * @p aExtAddress. Once the Probing is started, the device would record the Link Metrics data of link layer frames * sent from that neighbor and include the data into header IE in Enhanced-ACK sent to that neighbor. * * @param[in] aShortAddress The short address of the Initiator. * @param[in] aExtAddress A pointer to the extended address of the Initiator. * @param[in] aLinkMetrics Flags specifying what metrics to query (Pdu Count would be omitted). When - * @p aLinkMetrics is eqaul to `0`, this method clears the Initiator. + * @p aLinkMetrics is equal to `0`, this method clears the Initiator. * * @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing. * @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `nullptr`. @@ -79,10 +79,10 @@ otError otLinkMetricsConfigureEnhAckProbing(otShortAddress aShortAddress, otLinkMetrics aLinkMetrics); /** - * This method generates the Link Metrics data (assessed for the acknowledged frame) bytes that would be included in + * Generates the Link Metrics data (assessed for the acknowledged frame) bytes that would be included in * Vendor-Specific IE. * - * This method first checks what Link Metrics are specified by the Initiator indicated by @p aMacAddress. And then + * First checks what Link Metrics are specified by the Initiator indicated by @p aMacAddress. And then * write the values to @p aData. * * @param[in] aMacAddress The Mac address of the Initiator. @@ -98,7 +98,7 @@ otError otLinkMetricsConfigureEnhAckProbing(otShortAddress aShortAddress, uint8_t otLinkMetricsEnhAckGenData(const otMacAddress *aMacAddress, uint8_t aLqi, int8_t aRssi, uint8_t *aData); /** - * This method returns the data length of Enhanced-ACK Based Probing for a specific Initiator. + * Returns the data length of Enhanced-ACK Based Probing for a specific Initiator. * * @param[in] aMacAddress The Mac address of the Initiator. * diff --git a/examples/platforms/utils/logging_rtt.c b/examples/platforms/utils/logging_rtt.c index 32d79f5af7c..0c720519d51 100644 --- a/examples/platforms/utils/logging_rtt.c +++ b/examples/platforms/utils/logging_rtt.c @@ -167,7 +167,7 @@ void utilsLogRttOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char logString[length++] = '\n'; // Write user log to the RTT memory block. - SEGGER_RTT_WriteNoLock(0, logString, length); + SEGGER_RTT_WriteNoLock(LOG_RTT_BUFFER_INDEX, logString, length); exit: return; diff --git a/examples/platforms/utils/logging_rtt.h b/examples/platforms/utils/logging_rtt.h index 19f6babc7ea..ea8b380ec12 100644 --- a/examples/platforms/utils/logging_rtt.h +++ b/examples/platforms/utils/logging_rtt.h @@ -124,7 +124,7 @@ void utilsLogRttInit(void); void utilsLogRttDeinit(void); /** - * This function outputs logs to SEGGER RTT. + * Outputs logs to SEGGER RTT. * * @param[in] aLogLevel The log level. * @param[in] aLogRegion The log region. diff --git a/examples/platforms/utils/mac_frame.h b/examples/platforms/utils/mac_frame.h index 1853ed1a185..5fba6ecea52 100644 --- a/examples/platforms/utils/mac_frame.h +++ b/examples/platforms/utils/mac_frame.h @@ -43,7 +43,7 @@ extern "C" { #endif /** - * This enumeration specifies the IEEE 802.15.4 Address type. + * Specifies the IEEE 802.15.4 Address type. * */ typedef enum @@ -54,7 +54,7 @@ typedef enum } otMacAddressType; /** - * This structure represents an IEEE 802.15.4 short or extended Address. + * Represents an IEEE 802.15.4 short or extended Address. * */ typedef struct otMacAddress @@ -176,7 +176,7 @@ otError otMacFrameGetDstAddr(const otRadioFrame *aFrame, otMacAddress *aMacAddre uint8_t otMacFrameGetSequence(const otRadioFrame *aFrame); /** - * This function performs AES CCM on the frame which is going to be sent. + * Performs AES CCM on the frame which is going to be sent. * * @param[in] aFrame A pointer to the MAC frame buffer that is going to be sent. * @param[in] aExtAddress A pointer to the extended address, which will be used to generate nonce diff --git a/include/Makefile.am b/include/Makefile.am index 6ce6a7dffe0..6f18341b543 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -78,6 +78,7 @@ openthread_headers = \ openthread/netdiag.h \ openthread/network_time.h \ openthread/ping_sender.h \ + openthread/radio_stats.h \ openthread/random_crypto.h \ openthread/random_noncrypto.h \ openthread/server.h \ @@ -100,6 +101,7 @@ dist_openthread_HEADERS = $(openthread_headers) ot_platform_headers = \ openthread/platform/alarm-micro.h \ openthread/platform/alarm-milli.h \ + openthread/platform/border_routing.h \ openthread/platform/crypto.h \ openthread/platform/debug_uart.h \ openthread/platform/diag.h \ diff --git a/include/openthread/BUILD.gn b/include/openthread/BUILD.gn index fba1dfe9c93..5bc1c09677b 100644 --- a/include/openthread/BUILD.gn +++ b/include/openthread/BUILD.gn @@ -84,6 +84,7 @@ source_set("openthread") { "ping_sender.h", "platform/alarm-micro.h", "platform/alarm-milli.h", + "platform/border_routing.h", "platform/crypto.h", "platform/debug_uart.h", "platform/diag.h", @@ -104,6 +105,7 @@ source_set("openthread") { "platform/toolchain.h", "platform/trel.h", "platform/udp.h", + "radio_stats.h", "random_crypto.h", "random_noncrypto.h", "server.h", diff --git a/include/openthread/backbone_router.h b/include/openthread/backbone_router.h index 23cb4d426a0..a057dc4edb4 100644 --- a/include/openthread/backbone_router.h +++ b/include/openthread/backbone_router.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This structure represents Backbone Router configuration. + * Represents Backbone Router configuration. * */ typedef struct otBackboneRouterConfig @@ -64,7 +64,7 @@ typedef struct otBackboneRouterConfig } otBackboneRouterConfig; /** - * This function gets the Primary Backbone Router information in the Thread Network. + * Gets the Primary Backbone Router information in the Thread Network. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aConfig A pointer to where to put Primary Backbone Router information. diff --git a/include/openthread/backbone_router_ftd.h b/include/openthread/backbone_router_ftd.h index d4041d68af6..88cfe0a3875 100644 --- a/include/openthread/backbone_router_ftd.h +++ b/include/openthread/backbone_router_ftd.h @@ -161,7 +161,7 @@ otError otBackboneRouterSetConfig(otInstance *aInstance, const otBackboneRouterC otError otBackboneRouterRegister(otInstance *aInstance); /** - * This method returns the Backbone Router registration jitter value. + * Returns the Backbone Router registration jitter value. * * @returns The Backbone Router registration jitter value. * @@ -171,7 +171,7 @@ otError otBackboneRouterRegister(otInstance *aInstance); uint8_t otBackboneRouterGetRegistrationJitter(otInstance *aInstance); /** - * This method sets the Backbone Router registration jitter value. + * Sets the Backbone Router registration jitter value. * * @param[in] aJitter the Backbone Router registration jitter value to set. * @@ -181,7 +181,7 @@ uint8_t otBackboneRouterGetRegistrationJitter(otInstance *aInstance); void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitter); /** - * This method gets the local Domain Prefix configuration. + * Gets the local Domain Prefix configuration. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aConfig A pointer to the Domain Prefix configuration. @@ -193,7 +193,7 @@ void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitte otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig); /** - * This method configures response status for next DUA registration. + * Configures response status for next DUA registration. * * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * Only used for test and certification. @@ -235,7 +235,7 @@ typedef enum } otBackboneRouterMulticastListenerEvent; /** - * This function pointer is called whenever the Multicast Listeners change. + * Pointer is called whenever the Multicast Listeners change. * * @param[in] aContext The user context pointer. * @param[in] aEvent The Multicast Listener event. @@ -247,7 +247,7 @@ typedef void (*otBackboneRouterMulticastListenerCallback)(void const otIp6Address *aAddress); /** - * This method sets the Backbone Router Multicast Listener callback. + * Sets the Backbone Router Multicast Listener callback. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to the Multicast Listener callback. @@ -302,7 +302,7 @@ otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6A typedef uint16_t otBackboneRouterMulticastListenerIterator; ///< Used to iterate through Multicast Listeners. /** - * This structure represents a Backbone Router Multicast Listener info. + * Represents a Backbone Router Multicast Listener info. * */ typedef struct otBackboneRouterMulticastListenerInfo @@ -312,7 +312,7 @@ typedef struct otBackboneRouterMulticastListenerInfo } otBackboneRouterMulticastListenerInfo; /** - * This function gets the next Multicast Listener info (using an iterator). + * Gets the next Multicast Listener info (using an iterator). * * @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 @@ -346,7 +346,7 @@ typedef enum } otBackboneRouterNdProxyEvent; /** - * This function pointer is called whenever the Nd Proxy changed. + * Pointer is called whenever the Nd Proxy changed. * * @param[in] aContext The user context pointer. * @param[in] aEvent The ND Proxy event. @@ -359,7 +359,7 @@ typedef void (*otBackboneRouterNdProxyCallback)(void *aCo const otIp6Address *aDua); /** - * This method sets the Backbone Router ND Proxy callback. + * Sets the Backbone Router ND Proxy callback. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to the ND Proxy callback. @@ -382,7 +382,7 @@ typedef struct otBackboneRouterNdProxyInfo } otBackboneRouterNdProxyInfo; /** - * This method gets the Backbone Router ND Proxy info. + * Gets the Backbone Router ND Proxy info. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDua The Domain Unicast Address. @@ -408,7 +408,7 @@ typedef enum } otBackboneRouterDomainPrefixEvent; /** - * This function pointer is called whenever the Domain Prefix changed. + * Pointer is called whenever the Domain Prefix changed. * * @param[in] aContext The user context pointer. * @param[in] aEvent The Domain Prefix event. @@ -419,7 +419,7 @@ typedef void (*otBackboneRouterDomainPrefixCallback)(void otBackboneRouterDomainPrefixEvent aEvent, const otIp6Prefix *aDomainPrefix); /** - * This method sets the Backbone Router Domain Prefix callback. + * Sets the Backbone Router Domain Prefix callback. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to the Domain Prefix callback. diff --git a/include/openthread/border_agent.h b/include/openthread/border_agent.h index e412f6d8eea..4ffbc9c6c21 100644 --- a/include/openthread/border_agent.h +++ b/include/openthread/border_agent.h @@ -58,7 +58,19 @@ extern "C" { #define OT_BORDER_AGENT_ID_LENGTH (16) /** - * This enumeration defines the Border Agent state. + * @struct otBorderAgentId + * + * Represents a Border Agent ID. + * + */ +OT_TOOL_PACKED_BEGIN +struct otBorderAgentId +{ + uint8_t mId[OT_BORDER_AGENT_ID_LENGTH]; +} OT_TOOL_PACKED_END; + +/** + * Defines the Border Agent state. * */ typedef enum otBorderAgentState @@ -97,14 +109,32 @@ uint16_t otBorderAgentGetUdpPort(otInstance *aInstance); * * @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. + * @retval OT_ERROR_NONE If successfully retrieved the Border Agent ID. + * @retval ... If failed to retrieve the Border Agent ID. + * + * @sa otBorderAgentSetId + * + */ +otError otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId); + +/** + * Sets the Border Agent ID. + * + * The Border Agent ID will be saved in persistent storage and survive reboots. It's required to + * set the ID only once after factory reset. If the ID has never been set by calling this function, + * a random ID will be generated and returned when `otBorderAgentGetId` is called. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[out] aId A pointer to the Border Agent ID. + * + * @retval OT_ERROR_NONE If successfully set the Border Agent ID. + * @retval ... If failed to set the Border Agent ID. + * + * @sa otBorderAgentGetId * */ -otError otBorderAgentGetId(otInstance *aInstance, uint8_t *aId, uint16_t *aLength); +otError otBorderAgentSetId(otInstance *aInstance, const otBorderAgentId *aId); /** * @} diff --git a/include/openthread/border_router.h b/include/openthread/border_router.h index a945f91fb29..d07febac076 100644 --- a/include/openthread/border_router.h +++ b/include/openthread/border_router.h @@ -54,7 +54,7 @@ extern "C" { */ /** - * This method provides a full or stable copy of the local Thread Network Data. + * Provides a full or stable copy of the local 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. @@ -94,7 +94,7 @@ otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRoute otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix); /** - * This function gets the next On Mesh Prefix in the local Network Data. + * Gets the next On Mesh Prefix in the local 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 @@ -139,7 +139,7 @@ otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfi otError otBorderRouterRemoveRoute(otInstance *aInstance, const otIp6Prefix *aPrefix); /** - * This function gets the next external route in the local Network Data. + * Gets the next external route in the local 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 @@ -168,6 +168,35 @@ otError otBorderRouterGetNextRoute(otInstance *aInstance, */ otError otBorderRouterRegister(otInstance *aInstance); +/** + * Function pointer callback which is invoked when Network Data (local or leader) gets full. + * + * @param[in] aContext A pointer to arbitrary context information. + * + */ +typedef void (*otBorderRouterNetDataFullCallback)(void *aContext); + +/** + * Sets the callback to indicate when Network Data gets full. + * + * Requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. + * + * The callback is invoked whenever: + * - The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it cannot + * add to Network Data (running out of space). + * - The device is acting as a BR and new entries cannot be added to its local Network Data. + * - The device is acting as a BR and tries to register its local Network Data entries with the leader, but determines + * that its local entries will not fit. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aCallback The callback. + * @param[in] aContext A pointer to arbitrary context information used with @p aCallback. + * + */ +void otBorderRouterSetNetDataFullCallback(otInstance *aInstance, + otBorderRouterNetDataFullCallback aCallback, + void *aContext); + /** * @} * diff --git a/include/openthread/border_routing.h b/include/openthread/border_routing.h index 961554ea5aa..2de6dde3aea 100644 --- a/include/openthread/border_routing.h +++ b/include/openthread/border_routing.h @@ -73,7 +73,7 @@ extern "C" { */ /** - * This structure represents an iterator to iterate through the Border Router's discovered prefix table. + * Represents an iterator to iterate through the Border Router's discovered prefix table. * * The fields in this type are opaque (intended for use by OpenThread core only) and therefore should not be * accessed or used by caller. @@ -89,7 +89,7 @@ typedef struct otBorderRoutingPrefixTableIterator } otBorderRoutingPrefixTableIterator; /** - * This structure represents an entry from the discovered prefix table. + * Represents an entry from the discovered prefix table. * * The entries in the discovered table track the Prefix/Route Info Options in the received Router Advertisement messages * from other routers on infrastructure link. @@ -107,7 +107,7 @@ typedef struct otBorderRoutingPrefixTableEntry } otBorderRoutingPrefixTableEntry; /** - * This enumeration represents the state of Border Routing Manager. + * Represents the state of Border Routing Manager. * */ typedef enum @@ -119,7 +119,18 @@ typedef enum } otBorderRoutingState; /** - * This method initializes the Border Routing Manager on given infrastructure interface. + * This enumeration represents the state of DHCPv6 Prefix Delegation State. + * + */ +typedef enum +{ + OT_BORDER_ROUTING_DHCP6_PD_STATE_DISABLED, ///< DHCPv6 PD is disabled on the border router. + OT_BORDER_ROUTING_DHCP6_PD_STATE_STOPPED, ///< DHCPv6 PD in enabled but won't try to request and publish a prefix. + OT_BORDER_ROUTING_DHCP6_PD_STATE_RUNNING, ///< DHCPv6 PD is enabled and will try to request and publish a prefix. +} otBorderRoutingDhcp6PdState; + +/** + * Initializes the Border Routing Manager on given infrastructure interface. * * @note This method MUST be called before any other otBorderRouting* APIs. * @@ -163,7 +174,7 @@ otError otBorderRoutingSetEnabled(otInstance *aInstance, bool aEnabled); otBorderRoutingState otBorderRoutingGetState(otInstance *aInstance); /** - * This function gets the current preference used when advertising Route Info Options (RIO) in Router Advertisement + * 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: @@ -179,7 +190,7 @@ otBorderRoutingState otBorderRoutingGetState(otInstance *aInstance); otRoutePreference otBorderRoutingGetRouteInfoOptionPreference(otInstance *aInstance); /** - * This function explicitly sets the preference to use when advertising Route Info Options (RIO) in Router + * Explicitly sets the preference to use when advertising Route Info Options (RIO) in Router * Advertisement messages sent over the infrastructure link. * * After a call to this function, BR will use the given preference for all its advertised RIOs. The preference can be @@ -192,7 +203,7 @@ otRoutePreference otBorderRoutingGetRouteInfoOptionPreference(otInstance *aInsta void otBorderRoutingSetRouteInfoOptionPreference(otInstance *aInstance, otRoutePreference aPreference); /** - * This function clears a previously set preference value for advertised Route Info Options. + * 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. @@ -209,15 +220,40 @@ void otBorderRoutingClearRouteInfoOptionPreference(otInstance *aInstance); * Thread network if there isn't already an OMR prefix. This prefix can be reached * from the local Wi-Fi or Ethernet network. * + * Note: When DHCPv6 PD is enabled, the border router may publish the prefix from + * DHCPv6 PD. + * * @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 OMR prefix. * + * @sa otBorderRoutingGetPdOmrPrefix + * */ otError otBorderRoutingGetOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix); +/** + * Gets the DHCPv6 Prefix Delegation (PD) provided off-mesh-routable (OMR) prefix. + * + * Only mPrefix, mValidLifetime and mPreferredLifetime fields are used in the returned prefix info. + * + * `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` must be enabled. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[out] aPrefixInfo A pointer to where the prefix info will be output to. + * + * @retval OT_ERROR_NONE Successfully retrieved the OMR prefix. + * @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet. + * @retval OT_ERROR_NOT_FOUND There are no valid PD prefix on this BR. + * + * @sa otBorderRoutingGetOmrPrefix + * @sa otPlatBorderRoutingProcessIcmp6Ra + * + */ +otError otBorderRoutingGetPdOmrPrefix(otInstance *aInstance, otBorderRoutingPrefixTableEntry *aPrefixInfo); + /** * Gets the currently favored Off-Mesh-Routable (OMR) Prefix. * @@ -296,7 +332,7 @@ otError otBorderRoutingGetFavoredNat64Prefix(otInstance *aInstance, otRoutePreference *aPreference); /** - * This function initializes an `otBorderRoutingPrefixTableIterator`. + * Initializes an `otBorderRoutingPrefixTableIterator`. * * An iterator MUST be initialized before it is used. * @@ -312,7 +348,7 @@ otError otBorderRoutingGetFavoredNat64Prefix(otInstance *aInstance, void otBorderRoutingPrefixTableInitIterator(otInstance *aInstance, otBorderRoutingPrefixTableIterator *aIterator); /** - * This function iterates over the entries in the Border Router's discovered prefix table. + * Iterates over the entries in the Border Router's discovered prefix table. * * @param[in] aInstance The OpenThread instance. * @param[in,out] aIterator A pointer to the iterator. @@ -326,6 +362,17 @@ otError otBorderRoutingGetNextPrefixTableEntry(otInstance otBorderRoutingPrefixTableIterator *aIterator, otBorderRoutingPrefixTableEntry *aEntry); +/** + * Enables / Disables DHCPv6 Prefix Delegation. + * + * `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` must be enabled. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aEnabled Whether to accept platform generated RA messages. + * + */ +void otBorderRoutingDhcp6PdSetEnabled(otInstance *aInstance, bool aEnabled); + /** * @} * diff --git a/include/openthread/channel_manager.h b/include/openthread/channel_manager.h index 73074580680..6afe3a4aa7e 100644 --- a/include/openthread/channel_manager.h +++ b/include/openthread/channel_manager.h @@ -69,7 +69,7 @@ extern "C" { void otChannelManagerRequestChannelChange(otInstance *aInstance, uint8_t aChannel); /** - * This function gets the channel from the last successful call to `otChannelManagerRequestChannelChange()` + * Gets the channel from the last successful call to `otChannelManagerRequestChannelChange()` * * @returns The last requested channel or zero if there has been no channel change request yet. * @@ -77,7 +77,7 @@ void otChannelManagerRequestChannelChange(otInstance *aInstance, uint8_t aChanne uint8_t otChannelManagerGetRequestedChannel(otInstance *aInstance); /** - * This function gets the delay (in seconds) used by Channel Manager for a channel change. + * Gets the delay (in seconds) used by Channel Manager for a channel change. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -102,7 +102,7 @@ uint16_t otChannelManagerGetDelay(otInstance *aInstance); otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay); /** - * This function requests that `ChannelManager` checks and selects a new channel and starts a channel change. + * 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 on collected channel quality info). @@ -144,7 +144,7 @@ otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQu void otChannelManagerSetAutoChannelSelectionEnabled(otInstance *aInstance, bool aEnabled); /** - * This function indicates whether the auto-channel-selection functionality is enabled or not. + * Indicates whether the auto-channel-selection functionality is enabled or not. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -166,7 +166,7 @@ bool otChannelManagerGetAutoChannelSelectionEnabled(otInstance *aInstance); otError otChannelManagerSetAutoChannelSelectionInterval(otInstance *aInstance, uint32_t aInterval); /** - * This function gets the period interval (in seconds) used by auto-channel-selection functionality. + * Gets the period interval (in seconds) used by auto-channel-selection functionality. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/channel_monitor.h b/include/openthread/channel_monitor.h index 12fa92af167..d69033ad159 100644 --- a/include/openthread/channel_monitor.h +++ b/include/openthread/channel_monitor.h @@ -82,7 +82,7 @@ extern "C" { otError otChannelMonitorSetEnabled(otInstance *aInstance, bool aEnabled); /** - * This function indicates whether the Channel Monitoring operation is enabled and running. + * Indicates whether the Channel Monitoring operation is enabled and running. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/cli.h b/include/openthread/cli.h index 8d9a5f3c239..07bd92a3739 100644 --- a/include/openthread/cli.h +++ b/include/openthread/cli.h @@ -46,7 +46,7 @@ extern "C" { #endif /** - * This structure represents a CLI command. + * Represents a CLI command. * */ typedef struct otCliCommand @@ -68,7 +68,7 @@ typedef struct otCliCommand */ /** - * This function pointer is called to notify about Console output. + * Pointer is called to notify about Console output. * * @param[out] aContext A user context pointer. * @param[in] aFormat The format string. @@ -90,7 +90,7 @@ typedef int (*otCliOutputCallback)(void *aContext, const char *aFormat, va_list void otCliInit(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext); /** - * This method is called to feed in a console input line. + * Is called to feed in a console input line. * * @param[in] aBuf A pointer to a null-terminated string. * diff --git a/include/openthread/coap.h b/include/openthread/coap.h index 30faca6f8ad..e494c3c6aa1 100644 --- a/include/openthread/coap.h +++ b/include/openthread/coap.h @@ -151,7 +151,7 @@ typedef enum otCoapOptionType } otCoapOptionType; /** - * This structure represents a CoAP option. + * Represents a CoAP option. * */ typedef struct otCoapOption @@ -161,7 +161,7 @@ typedef struct otCoapOption } otCoapOption; /** - * This structure acts as an iterator for CoAP options + * Acts as an iterator for CoAP options * */ typedef struct otCoapOptionIterator @@ -329,7 +329,7 @@ typedef enum otCoapBlockSzx } otCoapBlockSzx; /** - * This function pointer is called when a CoAP response is received or on the request timeout. + * Pointer is called when a CoAP response is received or on the request timeout. * * @param[in] aContext A pointer to application-specific context. * @param[in] aMessage A pointer to the message buffer containing the response. NULL if no response was received. @@ -347,7 +347,7 @@ typedef void (*otCoapResponseHandler)(void *aContext, otError aResult); /** - * This function pointer is called when a CoAP request with a given Uri-Path is received. + * Pointer is called when a CoAP request with a given Uri-Path is received. * * @param[in] aContext A pointer to arbitrary context information. * @param[in] aMessage A pointer to the message. @@ -357,9 +357,9 @@ typedef void (*otCoapResponseHandler)(void *aContext, typedef void (*otCoapRequestHandler)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); /** - * This function pointer is called when a CoAP message with an block-wise transfer option is received. + * Pointer is called when a CoAP message with an block-wise transfer option is received. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * @param[in] aContext A pointer to application-specific context. @@ -383,9 +383,9 @@ typedef otError (*otCoapBlockwiseReceiveHook)(void *aContext, uint32_t aTotalLength); /** - * This function pointer is called before the next block in a block-wise transfer is sent. + * Pointer is called before the next block in a block-wise transfer is sent. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * @param[in] aContext A pointer to application-specific context. @@ -409,7 +409,7 @@ typedef otError (*otCoapBlockwiseTransmitHook)(void *aContext, bool *aMore); /** - * This structure represents a CoAP resource. + * Represents a CoAP resource. * */ typedef struct otCoapResource @@ -421,7 +421,7 @@ typedef struct otCoapResource } otCoapResource; /** - * This structure represents a CoAP resource with block-wise transfer. + * Represents a CoAP resource with block-wise transfer. * */ typedef struct otCoapBlockwiseResource @@ -445,7 +445,7 @@ typedef struct otCoapBlockwiseResource } otCoapBlockwiseResource; /** - * This structure represents the CoAP transmission parameters. + * Represents the CoAP transmission parameters. * * @note mAckTimeout * ((2 ** (mMaxRetransmit + 1)) - 1) * (mAckRandomFactorNumerator / mAckRandomFactorDenominator) * must not exceed what can be represented by a uint32_t (0xffffffff). This limitation allows OpenThread to @@ -483,7 +483,7 @@ typedef struct otCoapTxParameters } otCoapTxParameters; /** - * This function initializes the CoAP header. + * Initializes the CoAP header. * * @param[in,out] aMessage A pointer to the CoAP message to initialize. * @param[in] aType CoAP message type. @@ -493,7 +493,7 @@ typedef struct otCoapTxParameters void otCoapMessageInit(otMessage *aMessage, otCoapType aType, otCoapCode aCode); /** - * This function initializes a response message. + * Initializes a response message. * * @note Both message ID and token are set according to @p aRequest. * @@ -509,7 +509,7 @@ void otCoapMessageInit(otMessage *aMessage, otCoapType aType, otCoapCode aCode); otError otCoapMessageInitResponse(otMessage *aResponse, const otMessage *aRequest, otCoapType aType, otCoapCode aCode); /** - * This function sets the Token value and length in a header. + * Sets the Token value and length in a header. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aToken A pointer to the Token value. @@ -522,7 +522,7 @@ otError otCoapMessageInitResponse(otMessage *aResponse, const otMessage *aReques otError otCoapMessageSetToken(otMessage *aMessage, const uint8_t *aToken, uint8_t aTokenLength); /** - * This function sets the Token length and randomizes its value. + * Sets the Token length and randomizes its value. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aTokenLength The Length of a Token to set. @@ -531,7 +531,7 @@ otError otCoapMessageSetToken(otMessage *aMessage, const uint8_t *aToken, uint8_ void otCoapMessageGenerateToken(otMessage *aMessage, uint8_t aTokenLength); /** - * This function appends the Content Format CoAP option as specified in + * Appends the Content Format CoAP option as specified in * https://tools.ietf.org/html/rfc7252#page-92. This *must* be called before * setting otCoapMessageSetPayloadMarker if a payload is to be included in the * message. @@ -552,7 +552,7 @@ void otCoapMessageGenerateToken(otMessage *aMessage, uint8_t aTokenLength); otError otCoapMessageAppendContentFormatOption(otMessage *aMessage, otCoapOptionContentFormat aContentFormat); /** - * This function appends a CoAP option in a header. + * Appends a CoAP option in a header. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aNumber The CoAP Option number. @@ -567,7 +567,7 @@ otError otCoapMessageAppendContentFormatOption(otMessage *aMessage, otCoapOption otError otCoapMessageAppendOption(otMessage *aMessage, uint16_t aNumber, uint16_t aLength, const void *aValue); /** - * This function appends an unsigned integer CoAP option as specified in + * Appends an unsigned integer CoAP option as specified in * https://tools.ietf.org/html/rfc7252#section-3.2 * * @param[in,out] aMessage A pointer to the CoAP message. @@ -583,7 +583,7 @@ otError otCoapMessageAppendOption(otMessage *aMessage, uint16_t aNumber, uint16_ otError otCoapMessageAppendUintOption(otMessage *aMessage, uint16_t aNumber, uint32_t aValue); /** - * This function appends an Observe option. + * Appends an Observe option. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aObserve Observe field value. @@ -596,7 +596,7 @@ otError otCoapMessageAppendUintOption(otMessage *aMessage, uint16_t aNumber, uin otError otCoapMessageAppendObserveOption(otMessage *aMessage, uint32_t aObserve); /** - * This function appends a Uri-Path option. + * Appends a Uri-Path option. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aUriPath A pointer to a NULL-terminated string. @@ -609,7 +609,7 @@ otError otCoapMessageAppendObserveOption(otMessage *aMessage, uint32_t aObserve) otError otCoapMessageAppendUriPathOptions(otMessage *aMessage, const char *aUriPath); /** - * This function converts a CoAP Block option SZX field to the actual block size + * Converts a CoAP Block option SZX field to the actual block size * * @param[in] aSize Block size exponent. * @@ -619,7 +619,7 @@ otError otCoapMessageAppendUriPathOptions(otMessage *aMessage, const char *aUriP uint16_t otCoapBlockSizeFromExponent(otCoapBlockSzx aSize); /** - * This function appends a Block2 option + * Appends a Block2 option * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aNum Current block number. @@ -634,7 +634,7 @@ uint16_t otCoapBlockSizeFromExponent(otCoapBlockSzx aSize); otError otCoapMessageAppendBlock2Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize); /** - * This function appends a Block1 option + * Appends a Block1 option * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aNum Current block number. @@ -649,7 +649,7 @@ otError otCoapMessageAppendBlock2Option(otMessage *aMessage, uint32_t aNum, bool otError otCoapMessageAppendBlock1Option(otMessage *aMessage, uint32_t aNum, bool aMore, otCoapBlockSzx aSize); /** - * This function appends a Proxy-Uri option. + * Appends a Proxy-Uri option. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aUriPath A pointer to a NULL-terminated string. @@ -662,7 +662,7 @@ otError otCoapMessageAppendBlock1Option(otMessage *aMessage, uint32_t aNum, bool otError otCoapMessageAppendProxyUriOption(otMessage *aMessage, const char *aUriPath); /** - * This function appends a Max-Age option. + * Appends a Max-Age option. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aMaxAge The Max-Age value. @@ -675,7 +675,7 @@ otError otCoapMessageAppendProxyUriOption(otMessage *aMessage, const char *aUriP otError otCoapMessageAppendMaxAgeOption(otMessage *aMessage, uint32_t aMaxAge); /** - * This function appends a single Uri-Query option. + * Appends a single Uri-Query option. * * @param[in,out] aMessage A pointer to the CoAP message. * @param[in] aUriQuery A pointer to NULL-terminated string, which should contain a single key=value pair. @@ -687,7 +687,7 @@ otError otCoapMessageAppendMaxAgeOption(otMessage *aMessage, uint32_t aMaxAge); otError otCoapMessageAppendUriQueryOption(otMessage *aMessage, const char *aUriQuery); /** - * This function adds Payload Marker indicating beginning of the payload to the CoAP header. + * Adds Payload Marker indicating beginning of the payload to the CoAP header. * * @param[in,out] aMessage A pointer to the CoAP message. * @@ -698,7 +698,7 @@ otError otCoapMessageAppendUriQueryOption(otMessage *aMessage, const char *aUriQ otError otCoapMessageSetPayloadMarker(otMessage *aMessage); /** - * This function returns the Type value. + * Returns the Type value. * * @param[in] aMessage A pointer to the CoAP message. * @@ -708,7 +708,7 @@ otError otCoapMessageSetPayloadMarker(otMessage *aMessage); otCoapType otCoapMessageGetType(const otMessage *aMessage); /** - * This function returns the Code value. + * Returns the Code value. * * @param[in] aMessage A pointer to the CoAP message. * @@ -718,7 +718,7 @@ otCoapType otCoapMessageGetType(const otMessage *aMessage); otCoapCode otCoapMessageGetCode(const otMessage *aMessage); /** - * This function sets the Code value. + * Sets the Code value. * * @param[in,out] aMessage A pointer to the CoAP message to initialize. * @param[in] aCode CoAP message code. @@ -727,7 +727,7 @@ otCoapCode otCoapMessageGetCode(const otMessage *aMessage); void otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode); /** - * This method returns the CoAP Code as human readable string. + * Returns the CoAP Code as human readable string. * * @param[in] aMessage A pointer to the CoAP message. * @@ -737,7 +737,7 @@ void otCoapMessageSetCode(otMessage *aMessage, otCoapCode aCode); const char *otCoapMessageCodeToString(const otMessage *aMessage); /** - * This function returns the Message ID value. + * Returns the Message ID value. * * @param[in] aMessage A pointer to the CoAP message. * @@ -747,7 +747,7 @@ const char *otCoapMessageCodeToString(const otMessage *aMessage); uint16_t otCoapMessageGetMessageId(const otMessage *aMessage); /** - * This function returns the Token length. + * Returns the Token length. * * @param[in] aMessage A pointer to the CoAP message. * @@ -757,7 +757,7 @@ uint16_t otCoapMessageGetMessageId(const otMessage *aMessage); uint8_t otCoapMessageGetTokenLength(const otMessage *aMessage); /** - * This function returns a pointer to the Token value. + * Returns a pointer to the Token value. * * @param[in] aMessage A pointer to the CoAP message. * @@ -767,7 +767,7 @@ uint8_t otCoapMessageGetTokenLength(const otMessage *aMessage); const uint8_t *otCoapMessageGetToken(const otMessage *aMessage); /** - * This function initialises an iterator for the options in the given message. + * Initialises an iterator for the options in the given message. * * @param[in,out] aIterator A pointer to the CoAP message option iterator. * @param[in] aMessage A pointer to the CoAP message. @@ -779,7 +779,7 @@ const uint8_t *otCoapMessageGetToken(const otMessage *aMessage); otError otCoapOptionIteratorInit(otCoapOptionIterator *aIterator, const otMessage *aMessage); /** - * This function returns a pointer to the first option matching the specified option number. + * Returns a pointer to the first option matching the specified option number. * * @param[in] aIterator A pointer to the CoAP message option iterator. * @param[in] aOption The option number sought. @@ -790,7 +790,7 @@ otError otCoapOptionIteratorInit(otCoapOptionIterator *aIterator, const otMessag const otCoapOption *otCoapOptionIteratorGetFirstOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption); /** - * This function returns a pointer to the first option. + * Returns a pointer to the first option. * * @param[in,out] aIterator A pointer to the CoAP message option iterator. * @@ -800,7 +800,7 @@ const otCoapOption *otCoapOptionIteratorGetFirstOptionMatching(otCoapOptionItera const otCoapOption *otCoapOptionIteratorGetFirstOption(otCoapOptionIterator *aIterator); /** - * This function returns a pointer to the next option matching the specified option number. + * Returns a pointer to the next option matching the specified option number. * * @param[in] aIterator A pointer to the CoAP message option iterator. * @param[in] aOption The option number sought. @@ -811,7 +811,7 @@ const otCoapOption *otCoapOptionIteratorGetFirstOption(otCoapOptionIterator *aIt const otCoapOption *otCoapOptionIteratorGetNextOptionMatching(otCoapOptionIterator *aIterator, uint16_t aOption); /** - * This function returns a pointer to the next option. + * Returns a pointer to the next option. * * @param[in,out] aIterator A pointer to the CoAP message option iterator. * @@ -821,7 +821,7 @@ const otCoapOption *otCoapOptionIteratorGetNextOptionMatching(otCoapOptionIterat const otCoapOption *otCoapOptionIteratorGetNextOption(otCoapOptionIterator *aIterator); /** - * This function fills current option value into @p aValue assuming the current value is an unsigned integer encoded + * Fills current option value into @p aValue assuming the current value is an unsigned integer encoded * according to https://tools.ietf.org/html/rfc7252#section-3.2 * * @param[in,out] aIterator A pointer to the CoAP message option iterator. @@ -836,7 +836,7 @@ const otCoapOption *otCoapOptionIteratorGetNextOption(otCoapOptionIterator *aIte otError otCoapOptionIteratorGetOptionUintValue(otCoapOptionIterator *aIterator, uint64_t *aValue); /** - * This function fills current option value into @p aValue. + * Fills current option value into @p aValue. * * @param[in,out] aIterator A pointer to the CoAP message option iterator. * @param[out] aValue A pointer to a buffer to receive the option value. @@ -848,7 +848,7 @@ otError otCoapOptionIteratorGetOptionUintValue(otCoapOptionIterator *aIterator, otError otCoapOptionIteratorGetOptionValue(otCoapOptionIterator *aIterator, void *aValue); /** - * This function creates a new CoAP message. + * Creates a new CoAP message. * * @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. @@ -862,7 +862,7 @@ otError otCoapOptionIteratorGetOptionValue(otCoapOptionIterator *aIterator, void otMessage *otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSettings); /** - * This function sends a CoAP request with custom transmission parameters. + * Sends a CoAP request with custom transmission parameters. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -891,9 +891,9 @@ otError otCoapSendRequestWithParameters(otInstance *aInstance, const otCoapTxParameters *aTxParameters); /** - * This function sends a CoAP request block-wise with custom transmission parameters. + * Sends a CoAP request block-wise with custom transmission parameters. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * If a response for a request is expected, respective function and context information should be provided. @@ -923,9 +923,9 @@ otError otCoapSendRequestBlockWiseWithParameters(otInstance *aIn otCoapBlockwiseReceiveHook aReceiveHook); /** - * This function sends a CoAP request block-wise. + * Sends a CoAP request block-wise. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * If a response for a request is expected, respective function and context information should be provided. @@ -958,7 +958,7 @@ static inline otError otCoapSendRequestBlockWise(otInstance *aIn } /** - * This function sends a CoAP request. + * Sends a CoAP request. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -984,7 +984,7 @@ static inline otError otCoapSendRequest(otInstance *aInstance, } /** - * This function starts the CoAP server. + * Starts the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPort The local UDP port to bind to. @@ -996,7 +996,7 @@ static inline otError otCoapSendRequest(otInstance *aInstance, otError otCoapStart(otInstance *aInstance, uint16_t aPort); /** - * This function stops the CoAP server. + * Stops the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1006,7 +1006,7 @@ otError otCoapStart(otInstance *aInstance, uint16_t aPort); otError otCoapStop(otInstance *aInstance); /** - * This function adds a resource to the CoAP server. + * Adds a resource to the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -1015,7 +1015,7 @@ otError otCoapStop(otInstance *aInstance); void otCoapAddResource(otInstance *aInstance, otCoapResource *aResource); /** - * This function removes a resource from the CoAP server. + * Removes a resource from the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -1024,7 +1024,7 @@ void otCoapAddResource(otInstance *aInstance, otCoapResource *aResource); void otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource); /** - * This function adds a block-wise resource to the CoAP server. + * Adds a block-wise resource to the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -1033,7 +1033,7 @@ void otCoapRemoveResource(otInstance *aInstance, otCoapResource *aResource); void otCoapAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource); /** - * This function removes a block-wise resource from the CoAP server. + * Removes a block-wise resource from the CoAP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -1042,7 +1042,7 @@ void otCoapAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource * void otCoapRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource); /** - * This function sets the default handler for unhandled CoAP requests. + * Sets the default handler for unhandled CoAP requests. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aHandler A function pointer that shall be called when an unhandled request arrives. @@ -1052,7 +1052,7 @@ void otCoapRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResourc void otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext); /** - * This function sends a CoAP response from the server with custom transmission parameters. + * Sends a CoAP response from the server with custom transmission parameters. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMessage A pointer to the CoAP response to send. @@ -1069,9 +1069,9 @@ otError otCoapSendResponseWithParameters(otInstance *aInstance, const otCoapTxParameters *aTxParameters); /** - * This function sends a CoAP response block-wise from the server with custom transmission parameters. + * Sends a CoAP response block-wise from the server with custom transmission parameters. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -1093,9 +1093,9 @@ otError otCoapSendResponseBlockWiseWithParameters(otInstance *aI otCoapBlockwiseTransmitHook aTransmitHook); /** - * This function sends a CoAP response block-wise from the server. + * Sends a CoAP response block-wise from the server. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -1119,7 +1119,7 @@ static inline otError otCoapSendResponseBlockWise(otInstance *aI } /** - * This function sends a CoAP response from the server. + * Sends a CoAP response from the server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMessage A pointer to the CoAP response to send. diff --git a/include/openthread/coap_secure.h b/include/openthread/coap_secure.h index 6f424096a59..6a96ea3d754 100644 --- a/include/openthread/coap_secure.h +++ b/include/openthread/coap_secure.h @@ -68,7 +68,7 @@ extern "C" { #define OT_DEFAULT_COAP_SECURE_PORT 5684 ///< Default CoAP Secure port, as specified in RFC 7252 /** - * This function pointer is called when the DTLS connection state changes. + * Pointer is called when the DTLS connection state changes. * * @param[in] aConnected true, if a connection was established, false otherwise. * @param[in] aContext A pointer to arbitrary context information. @@ -77,7 +77,7 @@ extern "C" { typedef void (*otHandleCoapSecureClientConnect)(bool aConnected, void *aContext); /** - * This function starts the CoAP Secure service. + * Starts the CoAP Secure service. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPort The local UDP port to bind to. @@ -88,7 +88,7 @@ typedef void (*otHandleCoapSecureClientConnect)(bool aConnected, void *aContext) otError otCoapSecureStart(otInstance *aInstance, uint16_t aPort); /** - * This function stops the CoAP Secure server. + * Stops the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -96,7 +96,7 @@ otError otCoapSecureStart(otInstance *aInstance, uint16_t aPort); void otCoapSecureStop(otInstance *aInstance); /** - * This method sets the Pre-Shared Key (PSK) and cipher suite + * Sets the Pre-Shared Key (PSK) and cipher suite * DTLS_PSK_WITH_AES_128_CCM_8. * * @note This function requires the build-time feature `MBEDTLS_KEY_EXCHANGE_PSK_ENABLED` to be enabled. @@ -115,7 +115,7 @@ void otCoapSecureSetPsk(otInstance *aInstance, uint16_t aPskIdLength); /** - * This method returns the peer x509 certificate base64 encoded. + * Returns the peer x509 certificate base64 encoded. * * @note This function requires the build-time features `MBEDTLS_BASE64_C` and * `MBEDTLS_SSL_KEEP_PEER_CERTIFICATE` to be enabled. @@ -136,7 +136,7 @@ otError otCoapSecureGetPeerCertificateBase64(otInstance *aInstance, size_t aCertBufferSize); /** - * This method sets the authentication mode for the coap secure connection. + * Sets the authentication mode for the coap secure connection. * * Disable or enable the verification of peer certificate. * Must be called before start. @@ -148,7 +148,7 @@ otError otCoapSecureGetPeerCertificateBase64(otInstance *aInstance, void otCoapSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertificate); /** - * This method sets the local device's X509 certificate with corresponding private key for + * Sets the local device's X509 certificate with corresponding private key for * DTLS session with DTLS_ECDHE_ECDSA_WITH_AES_128_CCM_8. * * @note This function requires `MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=1`. @@ -167,7 +167,7 @@ void otCoapSecureSetCertificate(otInstance *aInstance, uint32_t aPrivateKeyLength); /** - * This method sets the trusted top level CAs. It is needed for validating the + * Sets the trusted top level CAs. It is needed for validating the * certificate of the peer. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. @@ -184,7 +184,7 @@ void otCoapSecureSetCaCertificateChain(otInstance *aInstance, uint32_t aX509CaCertChainLength); /** - * This method initializes DTLS session with a peer. + * Initializes DTLS session with a peer. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aSockAddr A pointer to the remote socket address. @@ -201,7 +201,7 @@ otError otCoapSecureConnect(otInstance *aInstance, void *aContext); /** - * This method stops the DTLS connection. + * Stops the DTLS connection. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -209,7 +209,7 @@ otError otCoapSecureConnect(otInstance *aInstance, void otCoapSecureDisconnect(otInstance *aInstance); /** - * This method indicates whether or not the DTLS session is connected. + * Indicates whether or not the DTLS session is connected. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -220,7 +220,7 @@ void otCoapSecureDisconnect(otInstance *aInstance); bool otCoapSecureIsConnected(otInstance *aInstance); /** - * This method indicates whether or not the DTLS session is active. + * Indicates whether or not the DTLS session is active. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -231,9 +231,9 @@ bool otCoapSecureIsConnected(otInstance *aInstance); bool otCoapSecureIsConnectionActive(otInstance *aInstance); /** - * This method sends a CoAP request block-wise over secure DTLS connection. + * Sends a CoAP request block-wise over secure DTLS connection. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * If a response for a request is expected, respective function and context information should be provided. @@ -260,7 +260,7 @@ otError otCoapSecureSendRequestBlockWise(otInstance *aInstance, otCoapBlockwiseReceiveHook aReceiveHook); /** - * This method sends a CoAP request over secure DTLS connection. + * Sends a CoAP request over secure DTLS connection. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -282,7 +282,7 @@ otError otCoapSecureSendRequest(otInstance *aInstance, void *aContext); /** - * This function adds a resource to the CoAP Secure server. + * Adds a resource to the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -291,7 +291,7 @@ otError otCoapSecureSendRequest(otInstance *aInstance, void otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource); /** - * This function removes a resource from the CoAP Secure server. + * Removes a resource from the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -300,7 +300,7 @@ void otCoapSecureAddResource(otInstance *aInstance, otCoapResource *aResource); void otCoapSecureRemoveResource(otInstance *aInstance, otCoapResource *aResource); /** - * This function adds a block-wise resource to the CoAP Secure server. + * Adds a block-wise resource to the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -309,7 +309,7 @@ void otCoapSecureRemoveResource(otInstance *aInstance, otCoapResource *aResource void otCoapSecureAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource); /** - * This function removes a block-wise resource from the CoAP Secure server. + * Removes a block-wise resource from the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aResource A pointer to the resource. @@ -318,7 +318,7 @@ void otCoapSecureAddBlockWiseResource(otInstance *aInstance, otCoapBlockwiseReso void otCoapSecureRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseResource *aResource); /** - * This function sets the default handler for unhandled CoAP Secure requests. + * Sets the default handler for unhandled CoAP Secure requests. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aHandler A function pointer that shall be called when an unhandled request arrives. @@ -328,7 +328,7 @@ void otCoapSecureRemoveBlockWiseResource(otInstance *aInstance, otCoapBlockwiseR void otCoapSecureSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandler, void *aContext); /** - * This method sets the connected callback to indicate, when + * Sets the connected callback to indicate, when * a Client connect to the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -341,9 +341,9 @@ void otCoapSecureSetClientConnectedCallback(otInstance *aIns void *aContext); /** - * This function sends a CoAP response block-wise from the CoAP Secure server. + * Sends a CoAP response block-wise from the CoAP Secure server. * - * This function is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration + * Is available when OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE configuration * is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -363,7 +363,7 @@ otError otCoapSecureSendResponseBlockWise(otInstance *aInstance, otCoapBlockwiseTransmitHook aTransmitHook); /** - * This function sends a CoAP response from the CoAP Secure server. + * Sends a CoAP response from the CoAP Secure server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMessage A pointer to the CoAP response to send. diff --git a/include/openthread/commissioner.h b/include/openthread/commissioner.h index 9bf09b814b3..9f714b389d7 100644 --- a/include/openthread/commissioner.h +++ b/include/openthread/commissioner.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This enumeration defines the Commissioner State. + * Defines the Commissioner State. * */ typedef enum otCommissionerState @@ -67,7 +67,7 @@ typedef enum otCommissionerState } otCommissionerState; /** - * This enumeration defines a Joiner Event on the Commissioner. + * Defines a Joiner Event on the Commissioner. * */ typedef enum otCommissionerJoinerEvent @@ -87,7 +87,7 @@ typedef enum otCommissionerJoinerEvent #define OT_STEERING_DATA_MAX_LENGTH 16 ///< Max steering data length (bytes) /** - * This structure represents the steering data. + * Represents the steering data. * */ typedef struct otSteeringData @@ -97,7 +97,7 @@ typedef struct otSteeringData } otSteeringData; /** - * This structure represents a Commissioning Dataset. + * Represents a Commissioning Dataset. * */ typedef struct otCommissioningDataset @@ -116,7 +116,7 @@ typedef struct otCommissioningDataset #define OT_JOINER_MAX_PSKD_LENGTH 32 ///< Maximum string length of a Joiner PSKd (does not include null char). /** - * This structure represents a Joiner PSKd. + * Represents a Joiner PSKd. * */ typedef struct otJoinerPskd @@ -125,7 +125,7 @@ typedef struct otJoinerPskd } otJoinerPskd; /** - * This enumeration defines a Joiner Info Type. + * Defines a Joiner Info Type. * */ typedef enum otJoinerInfoType @@ -136,7 +136,7 @@ typedef enum otJoinerInfoType } otJoinerInfoType; /** - * This structure represents a Joiner Info. + * Represents a Joiner Info. * */ typedef struct otJoinerInfo @@ -152,7 +152,7 @@ typedef struct otJoinerInfo } otJoinerInfo; /** - * This function pointer is called whenever the commissioner state changes. + * Pointer is called whenever the commissioner state changes. * * @param[in] aState The Commissioner state. * @param[in] aContext A pointer to application-specific context. @@ -161,7 +161,7 @@ typedef struct otJoinerInfo typedef void (*otCommissionerStateCallback)(otCommissionerState aState, void *aContext); /** - * This function pointer is called whenever the joiner state changes. + * Pointer is called whenever the joiner state changes. * * @param[in] aEvent The joiner event type. * @param[in] aJoinerInfo A pointer to the Joiner Info. @@ -175,7 +175,7 @@ typedef void (*otCommissionerJoinerCallback)(otCommissionerJoinerEvent aEvent, void *aContext); /** - * This function enables the Thread Commissioner role. + * Enables the Thread Commissioner role. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aStateCallback A pointer to a function that is called when the commissioner state changes. @@ -193,7 +193,7 @@ otError otCommissionerStart(otInstance *aInstance, void *aCallbackContext); /** - * This function disables the Thread Commissioner role. + * Disables the Thread Commissioner role. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -204,7 +204,7 @@ otError otCommissionerStart(otInstance *aInstance, otError otCommissionerStop(otInstance *aInstance); /** - * This function returns the Commissioner Id. + * Returns the Commissioner Id. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -214,7 +214,7 @@ otError otCommissionerStop(otInstance *aInstance); const char *otCommissionerGetId(otInstance *aInstance); /** - * This function sets the Commissioner Id. + * Sets the Commissioner Id. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aId A pointer to a string character array. Must be null terminated. @@ -227,7 +227,7 @@ const char *otCommissionerGetId(otInstance *aInstance); otError otCommissionerSetId(otInstance *aInstance, const char *aId); /** - * This function adds a Joiner entry. + * Adds a Joiner entry. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. @@ -248,7 +248,7 @@ otError otCommissionerAddJoiner(otInstance *aInstance, uint32_t aTimeout); /** - * This function adds a Joiner entry with a given Joiner Discerner value. + * Adds a Joiner entry with a given Joiner Discerner value. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDiscerner A pointer to the Joiner Discerner. @@ -269,7 +269,7 @@ otError otCommissionerAddJoinerWithDiscerner(otInstance *aInstance, uint32_t aTimeout); /** - * This method get joiner info at aIterator position. + * Get joiner info at aIterator position. * * @param[in] aInstance A pointer to instance. * @param[in,out] aIterator A pointer to the Joiner Info iterator context. @@ -282,7 +282,7 @@ otError otCommissionerAddJoinerWithDiscerner(otInstance *aInstance, otError otCommissionerGetNextJoinerInfo(otInstance *aInstance, uint16_t *aIterator, otJoinerInfo *aJoiner); /** - * This function removes a Joiner entry. + * Removes a Joiner entry. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. @@ -298,7 +298,7 @@ otError otCommissionerGetNextJoinerInfo(otInstance *aInstance, uint16_t *aIterat otError otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aEui64); /** - * This function removes a Joiner entry. + * Removes a Joiner entry. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDiscerner A pointer to the Joiner Discerner. @@ -314,7 +314,7 @@ otError otCommissionerRemoveJoiner(otInstance *aInstance, const otExtAddress *aE otError otCommissionerRemoveJoinerWithDiscerner(otInstance *aInstance, const otJoinerDiscerner *aDiscerner); /** - * This function gets the Provisioning URL. + * Gets the Provisioning URL. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -324,7 +324,7 @@ otError otCommissionerRemoveJoinerWithDiscerner(otInstance *aInstance, const otJ const char *otCommissionerGetProvisioningUrl(otInstance *aInstance); /** - * This function sets the Provisioning URL. + * Sets the Provisioning URL. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aProvisioningUrl A pointer to the Provisioning URL (may be NULL to set as empty string). @@ -336,7 +336,7 @@ const char *otCommissionerGetProvisioningUrl(otInstance *aInstance); otError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aProvisioningUrl); /** - * This function sends an Announce Begin message. + * Sends an Announce Begin message. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aChannelMask The channel mask value. @@ -358,7 +358,7 @@ otError otCommissionerAnnounceBegin(otInstance *aInstance, const otIp6Address *aAddress); /** - * This function pointer is called when the Commissioner receives an Energy Report. + * Pointer is called when the Commissioner receives an Energy Report. * * @param[in] aChannelMask The channel mask value. * @param[in] aEnergyList A pointer to the energy measurement list. @@ -372,7 +372,7 @@ typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask, void *aContext); /** - * This function sends an Energy Scan Query message. + * Sends an Energy Scan Query message. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aChannelMask The channel mask value. @@ -400,7 +400,7 @@ otError otCommissionerEnergyScan(otInstance *aInstance, void *aContext); /** - * This function pointer is called when the Commissioner receives a PAN ID Conflict message. + * Pointer is called when the Commissioner receives a PAN ID Conflict message. * * @param[in] aPanId The PAN ID value. * @param[in] aChannelMask The channel mask value. @@ -410,7 +410,7 @@ otError otCommissionerEnergyScan(otInstance *aInstance, typedef void (*otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aChannelMask, void *aContext); /** - * This function sends a PAN ID Query message. + * Sends a PAN ID Query message. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPanId The PAN ID to query. @@ -434,7 +434,7 @@ otError otCommissionerPanIdQuery(otInstance *aInstance, void *aContext); /** - * This function sends MGMT_COMMISSIONER_GET. + * Sends MGMT_COMMISSIONER_GET. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aTlvs A pointer to TLVs. @@ -448,7 +448,7 @@ otError otCommissionerPanIdQuery(otInstance *aInstance, otError otCommissionerSendMgmtGet(otInstance *aInstance, const uint8_t *aTlvs, uint8_t aLength); /** - * This function sends MGMT_COMMISSIONER_SET. + * Sends MGMT_COMMISSIONER_SET. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDataset A pointer to commissioning dataset. @@ -466,7 +466,7 @@ otError otCommissionerSendMgmtSet(otInstance *aInstance, uint8_t aLength); /** - * This function returns the Commissioner Session ID. + * Returns the Commissioner Session ID. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -476,7 +476,7 @@ otError otCommissionerSendMgmtSet(otInstance *aInstance, uint16_t otCommissionerGetSessionId(otInstance *aInstance); /** - * This function returns the Commissioner State. + * Returns the Commissioner State. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/crypto.h b/include/openthread/crypto.h index b2629267e93..112d3bd35b4 100644 --- a/include/openthread/crypto.h +++ b/include/openthread/crypto.h @@ -58,13 +58,13 @@ extern "C" { /** * @struct otCryptoSha256Hash * - * This structure represents a SHA-256 hash. + * Represents a SHA-256 hash. * */ typedef otPlatCryptoSha256Hash otCryptoSha256Hash; /** - * This function performs HMAC computation. + * Performs HMAC computation. * * @param[in] aKey A pointer to the key. * @param[in] aBuf A pointer to the input buffer. @@ -75,7 +75,7 @@ typedef otPlatCryptoSha256Hash otCryptoSha256Hash; void otCryptoHmacSha256(const otCryptoKey *aKey, const uint8_t *aBuf, uint16_t aBufLength, otCryptoSha256Hash *aHash); /** - * This method performs AES CCM computation. + * Performs AES CCM computation. * * @param[in] aKey A pointer to the key. * @param[in] aTagLength Length of tag in bytes. diff --git a/include/openthread/dataset.h b/include/openthread/dataset.h index efd18bc4b66..8be3be98f0b 100644 --- a/include/openthread/dataset.h +++ b/include/openthread/dataset.h @@ -58,7 +58,7 @@ extern "C" { /** * @struct otNetworkKey * - * This structure represents a Thread Network Key. + * Represents a Thread Network Key. * */ OT_TOOL_PACKED_BEGIN @@ -68,7 +68,7 @@ struct otNetworkKey } OT_TOOL_PACKED_END; /** - * This structure represents a Thread Network Key. + * Represents a Thread Network Key. * */ typedef struct otNetworkKey otNetworkKey; @@ -82,7 +82,7 @@ typedef otCryptoKeyRef otNetworkKeyRef; ///< Reference to Key #define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes) /** - * This structure represents a Network Name. + * Represents a Network Name. * * The `otNetworkName` is a null terminated C string (i.e., `m8` char array MUST end with null char `\0`). * @@ -95,7 +95,7 @@ typedef struct otNetworkName #define OT_EXT_PAN_ID_SIZE 8 ///< Size of a Thread PAN ID (bytes) /** - * This structure represents an Extended PAN ID. + * Represents an Extended PAN ID. * */ OT_TOOL_PACKED_BEGIN @@ -105,7 +105,7 @@ struct otExtendedPanId } OT_TOOL_PACKED_END; /** - * This structure represents an Extended PAN ID. + * Represents an Extended PAN ID. * */ typedef struct otExtendedPanId otExtendedPanId; @@ -113,7 +113,7 @@ typedef struct otExtendedPanId otExtendedPanId; #define OT_MESH_LOCAL_PREFIX_SIZE OT_IP6_PREFIX_SIZE ///< Size of the Mesh Local Prefix (bytes) /** - * This structure represents a Mesh Local Prefix. + * Represents a Mesh Local Prefix. * */ typedef otIp6NetworkPrefix otMeshLocalPrefix; @@ -121,7 +121,7 @@ typedef otIp6NetworkPrefix otMeshLocalPrefix; #define OT_PSKC_MAX_SIZE 16 ///< Maximum size of the PSKc (bytes) /** - * This structure represents PSKc. + * Represents PSKc. * */ OT_TOOL_PACKED_BEGIN @@ -131,7 +131,7 @@ struct otPskc } OT_TOOL_PACKED_END; /** - * This structure represents a PSKc. + * Represents a PSKc. * */ typedef struct otPskc otPskc; @@ -143,7 +143,7 @@ typedef struct otPskc otPskc; typedef otCryptoKeyRef otPskcRef; ///< Reference to Key /** - * This structure represent Security Policy. + * Represent Security Policy. * */ typedef struct otSecurityPolicy @@ -163,7 +163,7 @@ typedef struct otSecurityPolicy } otSecurityPolicy; /** - * This type represents Channel Mask. + * Represents Channel Mask. * */ typedef uint32_t otChannelMask; @@ -196,7 +196,7 @@ typedef uint32_t otChannelMask; #define OT_CHANNEL_26_MASK (1 << 26) ///< Channel 26 /** - * This structure represents presence of different components in Active or Pending Operational Dataset. + * Represents presence of different components in Active or Pending Operational Dataset. * */ typedef struct otOperationalDatasetComponents @@ -216,7 +216,7 @@ typedef struct otOperationalDatasetComponents } otOperationalDatasetComponents; /** - * This structure represents a Thread Dataset timestamp component. + * Represents a Thread Dataset timestamp component. * */ typedef struct otTimestamp @@ -227,7 +227,7 @@ typedef struct otTimestamp } otTimestamp; /** - * This structure represents an Active or Pending Operational Dataset. + * Represents an Active or Pending Operational Dataset. * * Components in Dataset are optional. `mComponents` structure specifies which components are present in the Dataset. * @@ -256,7 +256,7 @@ typedef struct otOperationalDataset #define OT_OPERATIONAL_DATASET_MAX_LENGTH 254 /** - * This structure represents an Active or Pending Operational Dataset. + * Represents an Active or Pending Operational Dataset. * * The Operational Dataset is TLV encoded as specified by Thread. * @@ -268,7 +268,7 @@ typedef struct otOperationalDatasetTlvs } otOperationalDatasetTlvs; /** - * This enumeration represents meshcop TLV types. + * Represents meshcop TLV types. * */ typedef enum otMeshcopTlvType @@ -316,7 +316,7 @@ typedef enum otMeshcopTlvType } otMeshcopTlvType; /** - * This function pointer is called when a response to a MGMT_SET request is received or times out. + * Pointer is called when a response to a MGMT_SET request is received or times out. * * @param[in] aResult A result of the operation. * @param[in] aContext A pointer to application-specific context. @@ -331,7 +331,7 @@ typedef enum otMeshcopTlvType typedef void (*otDatasetMgmtSetCallback)(otError aResult, void *aContext); /** - * This function indicates whether a valid network is present in the Active Operational Dataset or not. + * Indicates whether a valid network is present in the Active Operational Dataset or not. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -353,7 +353,7 @@ bool otDatasetIsCommissioned(otInstance *aInstance); otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset); /** - * 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. @@ -391,7 +391,7 @@ otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs * otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *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. * @@ -417,7 +417,7 @@ otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aD otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset); /** - * This function gets the Pending Operational Dataset. + * Gets the Pending Operational Dataset. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed. @@ -429,7 +429,7 @@ otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDataset otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset); /** - * This function gets the Pending Operational Dataset. + * Gets the Pending Operational Dataset. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aDataset A pointer to where the Pending Operational Dataset will be placed. @@ -454,7 +454,7 @@ otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *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. @@ -549,7 +549,7 @@ otError otDatasetSendMgmtPendingSet(otInstance *aInstance, void *aContext); /** - * This function generates PSKc from a given pass-phrase, network name, and extended PAN ID. + * Generates PSKc from a given pass-phrase, network name, and extended PAN ID. * * PSKc is used to establish the Commissioner Session. * diff --git a/include/openthread/dataset_updater.h b/include/openthread/dataset_updater.h index cb16c33ac3c..f9b7f64ae09 100644 --- a/include/openthread/dataset_updater.h +++ b/include/openthread/dataset_updater.h @@ -69,7 +69,7 @@ extern "C" { typedef void (*otDatasetUpdaterCallback)(otError aError, void *aContext); /** - * This function requests an update to Operational Dataset. + * Requests an update to Operational Dataset. * * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled. * @@ -94,7 +94,7 @@ otError otDatasetUpdaterRequestUpdate(otInstance *aInstance, void *aContext); /** - * This function cancels an ongoing (if any) Operational Dataset update request. + * Cancels an ongoing (if any) Operational Dataset update request. * * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled. * @@ -104,7 +104,7 @@ otError otDatasetUpdaterRequestUpdate(otInstance *aInstance, void otDatasetUpdaterCancelUpdate(otInstance *aInstance); /** - * This function indicates whether there is an ongoing Operation Dataset update request. + * Indicates whether there is an ongoing Operation Dataset update request. * * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled. * diff --git a/include/openthread/diag.h b/include/openthread/diag.h index 98c708e3425..217abf6cb38 100644 --- a/include/openthread/diag.h +++ b/include/openthread/diag.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This function processes a factory diagnostics command line. + * Processes a factory diagnostics command line. * * The output of this function (the content written to @p aOutput) MUST terminate with `\0` and the `\0` is within the * output buffer. @@ -75,7 +75,7 @@ otError otDiagProcessCmd(otInstance *aInstance, size_t aOutputMaxLen); /** - * This function processes a factory diagnostics command line. + * Processes a factory diagnostics command line. * * The output of this function (the content written to @p aOutput) MUST terminate with `\0` and the `\0` is within the * output buffer. @@ -94,7 +94,7 @@ otError otDiagProcessCmd(otInstance *aInstance, otError otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen); /** - * This function indicates whether or not the factory diagnostics mode is enabled. + * Indicates whether or not the factory diagnostics mode is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/dns.h b/include/openthread/dns.h index 22f3fc2b74f..d57a0f4c108 100644 --- a/include/openthread/dns.h +++ b/include/openthread/dns.h @@ -63,7 +63,7 @@ extern "C" { #define OT_DNS_TXT_KEY_MAX_LENGTH 9 ///< Recommended maximum length of TXT record key string (RFC 6763 - section 6.4). /** - * This structure represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3). + * Represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3). * * The string buffers pointed to by `mKey` and `mValue` MUST persist and remain unchanged after an instance of such * structure is passed to OpenThread (as part of `otSrpClientService` instance). @@ -95,7 +95,7 @@ typedef struct otDnsTxtEntry } otDnsTxtEntry; /** - * This structure represents an iterator for TXT record entires (key/value pairs). + * Represents an iterator for TXT record entries (key/value pairs). * * The data fields in this structure are intended for use by OpenThread core and caller should not read or change them. * @@ -108,7 +108,7 @@ typedef struct otDnsTxtEntryIterator } otDnsTxtEntryIterator; /** - * This function initializes a TXT record iterator. + * Initializes a TXT record iterator. * * The buffer pointer @p aTxtData and its content MUST persist and remain unchanged while @p aIterator object * is being used. @@ -121,7 +121,7 @@ typedef struct otDnsTxtEntryIterator void otDnsInitTxtEntryIterator(otDnsTxtEntryIterator *aIterator, const uint8_t *aTxtData, uint16_t aTxtDataLength); /** - * This function parses the TXT data from an iterator and gets the next TXT record entry (key/value pair). + * Parses the TXT data from an iterator and gets the next TXT record entry (key/value pair). * * The @p aIterator MUST be initialized using `otDnsInitTxtEntryIterator()` before calling this function and the TXT * data buffer used to initialize the iterator MUST persist and remain unchanged. Otherwise the behavior of this @@ -142,7 +142,7 @@ void otDnsInitTxtEntryIterator(otDnsTxtEntryIterator *aIterator, const uint8_t * otError otDnsGetNextTxtEntry(otDnsTxtEntryIterator *aIterator, otDnsTxtEntry *aEntry); /** - * This function enables/disables the "DNS name compression" mode. + * Enables/disables the "DNS name compression" mode. * * 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. @@ -158,7 +158,7 @@ otError otDnsGetNextTxtEntry(otDnsTxtEntryIterator *aIterator, otDnsTxtEntry *aE void otDnsSetNameCompressionEnabled(bool aEnabled); /** - * This function indicates whether the "DNS name compression" mode is enabled or not. + * Indicates whether the "DNS name compression" mode is enabled or not. * * This is intended for testing only and available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` config is enabled. * diff --git a/include/openthread/dns_client.h b/include/openthread/dns_client.h index c790bc18c00..0fd3458045e 100644 --- a/include/openthread/dns_client.h +++ b/include/openthread/dns_client.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This enumeration type represents the "Recursion Desired" (RD) flag in an `otDnsQueryConfig`. + * Type represents the "Recursion Desired" (RD) flag in an `otDnsQueryConfig`. * */ typedef enum @@ -67,7 +67,7 @@ typedef enum } otDnsRecursionFlag; /** - * This enumeration type represents the NAT64 mode in an `otDnsQueryConfig`. + * Type represents the NAT64 mode in an `otDnsQueryConfig`. * * The NAT64 mode indicates whether to allow or disallow NAT64 address translation during DNS client address resolution. * This mode is only used when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled. @@ -81,7 +81,7 @@ typedef enum } otDnsNat64Mode; /** - * This enumeration type represents the service resolution mode in an `otDnsQueryConfig`. + * 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. @@ -98,7 +98,7 @@ typedef enum } otDnsServiceMode; /** - * This enumeration type represents the DNS transport protocol in an `otDnsQueryConfig`. + * 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. * @@ -111,7 +111,7 @@ typedef enum } otDnsTransportProto; /** - * This structure represents a DNS query configuration. + * Represents a DNS query configuration. * * Any of the fields in this structure can be set to zero to indicate that it is not specified. How the unspecified * fields are treated is determined by the function which uses the instance of `otDnsQueryConfig`. @@ -129,7 +129,7 @@ typedef struct otDnsQueryConfig } otDnsQueryConfig; /** - * This function gets the current default query config used by DNS client. + * Gets the current default query config used by DNS client. * * When OpenThread stack starts, the default DNS query config is determined from a set of OT config options such as * `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS`, `_DEFAULT_SERVER_PORT`, `_DEFAULT_RESPONSE_TIMEOUT`, etc. @@ -143,7 +143,7 @@ typedef struct otDnsQueryConfig const otDnsQueryConfig *otDnsClientGetDefaultConfig(otInstance *aInstance); /** - * This function sets the default query config on DNS client. + * Sets the default query config on DNS client. * * @note Any ongoing query will continue to use the config from when it was started. The new default config will be * used for any future DNS queries. @@ -169,7 +169,7 @@ const otDnsQueryConfig *otDnsClientGetDefaultConfig(otInstance *aInstance); void otDnsClientSetDefaultConfig(otInstance *aInstance, const otDnsQueryConfig *aConfig); /** - * This type is an opaque representation of a response to an address resolution DNS query. + * An opaque representation of a response to an address resolution DNS query. * * Pointers to instance of this type are provided from callback `otDnsAddressCallback`. * @@ -177,7 +177,7 @@ void otDnsClientSetDefaultConfig(otInstance *aInstance, const otDnsQueryConfig * typedef struct otDnsAddressResponse otDnsAddressResponse; /** - * This function pointer is called when a DNS response is received for an address resolution query. + * Pointer is called when a DNS response is received for an address resolution query. * * Within this callback the user can use `otDnsAddressResponseGet{Item}()` functions along with the @p aResponse * pointer to get more info about the response. @@ -217,7 +217,7 @@ typedef struct otDnsAddressResponse otDnsAddressResponse; typedef void (*otDnsAddressCallback)(otError aError, const otDnsAddressResponse *aResponse, void *aContext); /** - * This function sends an address resolution DNS query for AAAA (IPv6) record(s) for a given host name. + * Sends an address resolution DNS query for AAAA (IPv6) record(s) for a given host name. * * The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as * the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The @@ -242,9 +242,9 @@ otError otDnsClientResolveAddress(otInstance *aInstance, const otDnsQueryConfig *aConfig); /** - * This function sends an address resolution DNS query for A (IPv4) record(s) for a given host name. + * Sends an address resolution DNS query for A (IPv4) record(s) for a given host name. * - * This function requires and is available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled. + * Requires and is available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled. * * When a successful response is received, the addresses are returned from @p aCallback as NAT64 IPv6 translated * versions of the IPv4 addresses from the query response. @@ -272,9 +272,9 @@ otError otDnsClientResolveIp4Address(otInstance *aInstance, const otDnsQueryConfig *aConfig); /** - * This function gets the full host name associated with an address resolution DNS response. + * Gets the full host name associated with an address resolution DNS response. * - * This function MUST only be used from `otDnsAddressCallback`. + * MUST only be used from `otDnsAddressCallback`. * * @param[in] aResponse A pointer to the response. * @param[out] aNameBuffer A buffer to char array to output the full host name (MUST NOT be NULL). @@ -289,9 +289,9 @@ otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse, uint16_t aNameBufferSize); /** - * This function gets an IPv6 address associated with an address resolution DNS response. + * Gets an IPv6 address associated with an address resolution DNS response. * - * This function MUST only be used from `otDnsAddressCallback`. + * MUST only be used from `otDnsAddressCallback`. * * The response may include multiple IPv6 address records. @p aIndex can be used to iterate through the list of * addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is @@ -315,7 +315,7 @@ otError otDnsAddressResponseGetAddress(const otDnsAddressResponse *aResponse, uint32_t *aTtl); /** - * This type is an opaque representation of a response to a browse (service instance enumeration) DNS query. + * An opaque representation of a response to a browse (service instance enumeration) DNS query. * * Pointers to instance of this type are provided from callback `otDnsBrowseCallback`. * @@ -323,7 +323,7 @@ otError otDnsAddressResponseGetAddress(const otDnsAddressResponse *aResponse, typedef struct otDnsBrowseResponse otDnsBrowseResponse; /** - * This function pointer is called when a DNS response is received for a browse (service instance enumeration) query. + * Pointer is called when a DNS response is received for a browse (service instance enumeration) query. * * Within this callback the user can use `otDnsBrowseResponseGet{Item}()` functions along with the @p aResponse * pointer to get more info about the response. @@ -341,7 +341,7 @@ typedef struct otDnsBrowseResponse otDnsBrowseResponse; typedef void (*otDnsBrowseCallback)(otError aError, const otDnsBrowseResponse *aResponse, void *aContext); /** - * This structure provides info for a DNS service instance. + * Provides info for a DNS service instance. * */ typedef struct otDnsServiceInfo @@ -361,9 +361,9 @@ typedef struct otDnsServiceInfo } otDnsServiceInfo; /** - * This function sends a DNS browse (service instance enumeration) query for a given service name. + * Sends a DNS browse (service instance enumeration) query for a given service name. * - * This function is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled. + * Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled. * * The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as * the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The @@ -386,9 +386,9 @@ otError otDnsClientBrowse(otInstance *aInstance, const otDnsQueryConfig *aConfig); /** - * This function gets the service name associated with a DNS browse (service instance enumeration) response. + * Gets the service name associated with a DNS browse (service instance enumeration) response. * - * This function MUST only be used from `otDnsBrowseCallback`. + * MUST only be used from `otDnsBrowseCallback`. * * @param[in] aResponse A pointer to the response. * @param[out] aNameBuffer A buffer to char array to output the service name (MUST NOT be NULL). @@ -403,9 +403,9 @@ otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse, uint16_t aNameBufferSize); /** - * This function gets a service instance associated with a DNS browse (service instance enumeration) response. + * Gets a service instance associated with a DNS browse (service instance enumeration) response. * - * This function MUST only be used from `otDnsBrowseCallback`. + * MUST only be used from `otDnsBrowseCallback`. * * The response may include multiple service instance records. @p aIndex can be used to iterate through the list. Index * zero gives the the first record. When we reach end of the list, `OT_ERROR_NOT_FOUND` is returned. @@ -430,9 +430,9 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon uint8_t aLabelBufferSize); /** - * This function gets info for a service instance from a DNS browse (service instance enumeration) response. + * Gets info for a service instance from a DNS browse (service instance enumeration) response. * - * This function MUST only be used from `otDnsBrowseCallback`. + * MUST only be used from `otDnsBrowseCallback`. * * 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 @@ -462,9 +462,9 @@ otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse, otDnsServiceInfo *aServiceInfo); /** - * This function gets the host IPv6 address from a DNS browse (service instance enumeration) response. + * Gets the host IPv6 address from a DNS browse (service instance enumeration) response. * - * This function MUST only be used from `otDnsBrowseCallback`. + * MUST only be used from `otDnsBrowseCallback`. * * The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the list of * addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is @@ -489,7 +489,7 @@ otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse, uint32_t *aTtl); /** - * This type is an opaque representation of a response to a service instance resolution DNS query. + * An opaque representation of a response to a service instance resolution DNS query. * * Pointers to instance of this type are provided from callback `otDnsAddressCallback`. * @@ -497,7 +497,7 @@ otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse, typedef struct otDnsServiceResponse otDnsServiceResponse; /** - * This function pointer is called when a DNS response is received for a service instance resolution query. + * Pointer is called when a DNS response is received for a service instance resolution query. * * Within this callback the user can use `otDnsServiceResponseGet{Item}()` functions along with the @p aResponse * pointer to get more info about the response. @@ -515,9 +515,9 @@ typedef struct otDnsServiceResponse otDnsServiceResponse; typedef void (*otDnsServiceCallback)(otError aError, const otDnsServiceResponse *aResponse, void *aContext); /** - * This function sends a DNS service instance resolution query for a given service instance. + * Starts a DNS service instance resolution for a given service instance. * - * This function is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled. + * Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled. * * The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as * the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The @@ -555,9 +555,46 @@ otError otDnsClientResolveService(otInstance *aInstance, const otDnsQueryConfig *aConfig); /** - * This function gets the service instance name associated with a DNS service instance resolution response. + * Starts a DNS service instance resolution for a given service instance, with a potential follow-up + * address resolution for the host name discovered for the service instance. * - * This function MUST only be used from `otDnsServiceCallback`. + * Is available when `OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE` is enabled. + * + * The @p aConfig can be NULL. In this case the default config (from `otDnsClientGetDefaultConfig()`) will be used as + * 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. This function cannot be used with + * `mServiceMode` in DNS config set to `OT_DNS_SERVICE_MODE_TXT` (i.e., querying for TXT record only) and will return + * `OT_ERROR_INVALID_ARGS`. + * + * Behaves similarly to `otDnsClientResolveService()` sending queries for SRV and TXT records. However, + * if the server/resolver does not provide AAAA/A records for the host name in the response to SRV query (in the + * Additional Data section), it will perform host name resolution (sending an AAAA query) for the discovered host name + * from the SRV record. The callback @p aCallback is invoked when responses for all queries are received (i.e., both + * service and host address resolutions are finished). + * + * @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). + * @param[in] aCallback A function pointer that shall be called on response reception or time-out. + * @param[in] aContext A pointer to arbitrary context information. + * @param[in] aConfig A pointer to the config to use for this query. + * + * @retval OT_ERROR_NONE Query sent successfully. @p aCallback will be invoked to report the status. + * @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query. + * @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is NULL, or @p aConfig is invalid. + * + */ +otError otDnsClientResolveServiceAndHostAddress(otInstance *aInstance, + const char *aInstanceLabel, + const char *aServiceName, + otDnsServiceCallback aCallback, + void *aContext, + const otDnsQueryConfig *aConfig); + +/** + * Gets the service instance name associated with a DNS service instance resolution response. + * + * MUST only be used from `otDnsServiceCallback`. * * @param[in] aResponse A pointer to the response. * @param[out] aLabelBuffer A buffer to char array to output the service instance label (MUST NOT be NULL). @@ -577,15 +614,18 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse uint16_t aNameBufferSize); /** - * This function gets info for a service instance from a DNS service instance resolution response. + * Gets info for a service instance from a DNS service instance resolution response. * - * This function MUST only be used from `otDnsServiceCallback`. + * MUST only be used from a `otDnsServiceCallback` triggered from `otDnsClientResolveService()` or + * `otDnsClientResolveServiceAndHostAddress()`. * - * 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. + * When this is is used from a `otDnsClientResolveService()` callback, the DNS response from server/resolver may + * include AAAA records in its Additional Data section for the 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 parse AAAA record(s) if included in the response. If it is not included `mHostAddress` is set + * to all zeros (unspecified address). To also resolve the host address, user can use the DNS client API function + * `otDnsClientResolveServiceAndHostAddress()` which will perform service resolution followed up by a host name + * address resolution query (when AAAA records are not provided by server/resolver in the SRV query response). * * - 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 @@ -609,9 +649,9 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse otError otDnsServiceResponseGetServiceInfo(const otDnsServiceResponse *aResponse, otDnsServiceInfo *aServiceInfo); /** - * This function gets the host IPv6 address from a DNS service instance resolution response. + * Gets the host IPv6 address from a DNS service instance resolution response. * - * This function MUST only be used from `otDnsServiceCallback`. + * MUST only be used from `otDnsServiceCallback`. * * The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the list of * addresses. Index zero gets the first address and so on. When we reach end of the list, `OT_ERROR_NOT_FOUND` is diff --git a/include/openthread/dnssd_server.h b/include/openthread/dnssd_server.h index cd6463c2355..98f83d6940d 100644 --- a/include/openthread/dnssd_server.h +++ b/include/openthread/dnssd_server.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This function is called when a DNS-SD query subscribes one of: + * Is called when a DNS-SD query subscribes one of: * 1. a service name. * 2. a service instance name. * 3. a host name. @@ -83,7 +83,7 @@ extern "C" { typedef void (*otDnssdQuerySubscribeCallback)(void *aContext, const char *aFullName); /** - * This function is called when a DNS-SD query unsubscribes one of: + * Is called when a DNS-SD query unsubscribes one of: * 1. a service name. * 2. a service instance name. * 3. a host name. @@ -107,7 +107,7 @@ typedef void (*otDnssdQueryUnsubscribeCallback)(void *aContext, const char *aFul typedef void otDnssdQuery; /** - * This structure represents information of a discovered service instance for a DNS-SD query. + * Represents information of a discovered service instance for a DNS-SD query. * */ typedef struct otDnssdServiceInstanceInfo @@ -125,7 +125,7 @@ typedef struct otDnssdServiceInstanceInfo } otDnssdServiceInstanceInfo; /** - * This structure represents information of a discovered host for a DNS-SD query. + * Represents information of a discovered host for a DNS-SD query. * */ typedef struct otDnssdHostInfo @@ -136,7 +136,7 @@ typedef struct otDnssdHostInfo } otDnssdHostInfo; /** - * This enumeration specifies a DNS-SD query type. + * Specifies a DNS-SD query type. * */ typedef enum @@ -148,7 +148,7 @@ typedef enum } otDnssdQueryType; /** - * This structure contains the counters of DNS-SD server. + * Contains the counters of DNS-SD server. * */ typedef struct otDnssdCounters @@ -164,7 +164,7 @@ typedef struct otDnssdCounters } otDnssdCounters; /** - * This function sets DNS-SD server query callbacks. + * Sets DNS-SD server query callbacks. * * The DNS-SD server calls @p aSubscribe to subscribe to a service or service instance to resolve a DNS-SD query and @p * aUnsubscribe to unsubscribe when the query is resolved or timeout. @@ -183,7 +183,7 @@ void otDnssdQuerySetCallbacks(otInstance *aInstance, void *aContext); /** - * This function notifies a discovered service instance. + * Notifies a discovered service instance. * * The external query resolver (e.g. Discovery Proxy) should call this function to notify OpenThread core of the * subscribed services or service instances. @@ -199,7 +199,7 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance *aIn const char *aServiceFullName, otDnssdServiceInstanceInfo *aInstanceInfo); /** - * This function notifies a discovered host. + * Notifies a discovered host. * * The external query resolver (e.g. Discovery Proxy) should call this function to notify OpenThread core of the * subscribed hosts. @@ -214,7 +214,7 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance *aIn void otDnssdQueryHandleDiscoveredHost(otInstance *aInstance, const char *aHostFullName, otDnssdHostInfo *aHostInfo); /** - * This function acquires the next query in the DNS-SD server. + * Acquires the next query in the DNS-SD server. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aQuery The query pointer. Pass NULL to get the first query. @@ -225,7 +225,7 @@ void otDnssdQueryHandleDiscoveredHost(otInstance *aInstance, const char *aHostFu const otDnssdQuery *otDnssdGetNextQuery(otInstance *aInstance, const otDnssdQuery *aQuery); /** - * This function acquires the DNS-SD query type and name for a specific query. + * Acquires the DNS-SD query type and name for a specific query. * * @param[in] aQuery The query pointer acquired from `otDnssdGetNextQuery`. * @param[out] aNameOutput The name output buffer, which should be `OT_DNS_MAX_NAME_SIZE` bytes long. @@ -236,7 +236,7 @@ const otDnssdQuery *otDnssdGetNextQuery(otInstance *aInstance, const otDnssdQuer otDnssdQueryType otDnssdGetQueryTypeAndName(const otDnssdQuery *aQuery, char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE]); /** - * This function returns the counters of the DNS-SD server. + * Returns the counters of the DNS-SD server. * * @param[in] aInstance The OpenThread instance structure. * diff --git a/include/openthread/error.h b/include/openthread/error.h index 66cb3c5b552..d54d7bac66f 100644 --- a/include/openthread/error.h +++ b/include/openthread/error.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This enumeration represents error codes used throughout OpenThread. + * Represents error codes used throughout OpenThread. * */ typedef enum OT_MUST_USE_RESULT otError @@ -251,7 +251,7 @@ typedef enum OT_MUST_USE_RESULT otError } otError; /** - * This function converts an otError enum into a string. + * Converts an otError enum into a string. * * @param[in] aError An otError enum. * diff --git a/include/openthread/history_tracker.h b/include/openthread/history_tracker.h index 79a255a77ac..08dc8d9c283 100644 --- a/include/openthread/history_tracker.h +++ b/include/openthread/history_tracker.h @@ -60,7 +60,7 @@ extern "C" { #define OT_HISTORY_TRACKER_ENTRY_AGE_STRING_SIZE 21 ///< Recommended size for string representation of an entry age. /** - * This type represents an iterator to iterate through a history list. + * Represents an iterator to iterate through a history list. * * The fields in this type are opaque (intended for use by OpenThread core) and therefore should not be accessed/used * by caller. @@ -75,7 +75,7 @@ typedef struct otHistoryTrackerIterator } otHistoryTrackerIterator; /** - * This structure represents Thread network info. + * Represents Thread network info. * */ typedef struct otHistoryTrackerNetworkInfo @@ -87,7 +87,7 @@ typedef struct otHistoryTrackerNetworkInfo } otHistoryTrackerNetworkInfo; /** - * This enumeration defines the events for an IPv6 (unicast or multicast) address info (i.e., whether address is added + * Defines the events for an IPv6 (unicast or multicast) address info (i.e., whether address is added * or removed). * */ @@ -98,7 +98,7 @@ typedef enum } otHistoryTrackerAddressEvent; /** - * This structure represent a unicast IPv6 address info. + * Represent a unicast IPv6 address info. * */ typedef struct otHistoryTrackerUnicastAddressInfo @@ -114,7 +114,7 @@ typedef struct otHistoryTrackerUnicastAddressInfo } otHistoryTrackerUnicastAddressInfo; /** - * This structure represent an IPv6 multicast address info. + * Represent an IPv6 multicast address info. * */ typedef struct otHistoryTrackerMulticastAddressInfo @@ -137,7 +137,7 @@ enum }; /** - * This structure represents a RX/TX IPv6 message info. + * Represents a RX/TX IPv6 message info. * * Some of the fields in this struct are applicable to a RX message or a TX message only, e.g., `mAveRxRss` is the * average RSS of all fragment frames that form a received message and is only applicable for a RX message. @@ -161,7 +161,7 @@ typedef struct otHistoryTrackerMessageInfo } otHistoryTrackerMessageInfo; /** - * This enumeration defines the events in a neighbor info (i.e. whether neighbor is added, removed, or changed). + * Defines the events in a neighbor info (i.e. whether neighbor is added, removed, or changed). * * Event `OT_HISTORY_TRACKER_NEIGHBOR_EVENT_RESTORING` is applicable to child neighbors only. It is triggered after * the device (re)starts and when the previous children list is retrieved from non-volatile settings and the device @@ -177,7 +177,7 @@ typedef enum } otHistoryTrackerNeighborEvent; /** - * This structure represents a neighbor info. + * Represents a neighbor info. * */ typedef struct otHistoryTrackerNeighborInfo @@ -193,7 +193,7 @@ typedef struct otHistoryTrackerNeighborInfo } otHistoryTrackerNeighborInfo; /** - * This enumeration defines the events in a router info (i.e. whether router is added, removed, or changed). + * Defines the events in a router info (i.e. whether router is added, removed, or changed). * */ typedef enum @@ -209,7 +209,7 @@ typedef enum #define OT_HISTORY_TRACKER_INFINITE_PATH_COST 0 ///< Infinite path cost - used in `otHistoryTrackerRouterInfo`. /** - * This structure represents a router table entry event. + * Represents a router table entry event. * */ typedef struct otHistoryTrackerRouterInfo @@ -222,7 +222,7 @@ typedef struct otHistoryTrackerRouterInfo } otHistoryTrackerRouterInfo; /** - * This enumeration defines the events for a Network Data entry (i.e., whether an entry is added or removed). + * Defines the events for a Network Data entry (i.e., whether an entry is added or removed). * */ typedef enum @@ -232,7 +232,7 @@ typedef enum } otHistoryTrackerNetDataEvent; /** - * This structure represent a Network Data on mesh prefix info. + * Represent a Network Data on mesh prefix info. * */ typedef struct otHistoryTrackerOnMeshPrefixInfo @@ -242,7 +242,7 @@ typedef struct otHistoryTrackerOnMeshPrefixInfo } otHistoryTrackerOnMeshPrefixInfo; /** - * This structure represent a Network Data extern route info. + * Represent a Network Data extern route info. * */ typedef struct otHistoryTrackerExternalRouteInfo @@ -252,7 +252,7 @@ typedef struct otHistoryTrackerExternalRouteInfo } otHistoryTrackerExternalRouteInfo; /** - * This function initializes an `otHistoryTrackerIterator`. + * Initializes an `otHistoryTrackerIterator`. * * An iterator MUST be initialized before it is used. * @@ -268,7 +268,7 @@ typedef struct otHistoryTrackerExternalRouteInfo void otHistoryTrackerInitIterator(otHistoryTrackerIterator *aIterator); /** - * This function iterates over the entries in the network info history list. + * Iterates over the entries in the network info 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. @@ -285,7 +285,7 @@ const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInsta uint32_t *aEntryAge); /** - * This function iterates over the entries in the unicast address history list. + * Iterates over the entries in the unicast address 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. @@ -303,7 +303,7 @@ const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressH uint32_t *aEntryAge); /** - * This function iterates over the entries in the multicast address history list. + * Iterates over the entries in the multicast address 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. @@ -321,7 +321,7 @@ const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddr uint32_t *aEntryAge); /** - * This function iterates over the entries in the RX message history list. + * Iterates over the entries in the RX message 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. @@ -338,7 +338,7 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance uint32_t *aEntryAge); /** - * This function iterates over the entries in the TX message history list. + * Iterates over the entries in the TX message 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. @@ -355,7 +355,7 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance uint32_t *aEntryAge); /** - * This function iterates over the entries in the neighbor history list. + * Iterates over the entries in the neighbor 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. @@ -372,7 +372,7 @@ const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otIns uint32_t *aEntryAge); /** - * This function iterates over the entries in the router history list. + * 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. @@ -389,7 +389,7 @@ const otHistoryTrackerRouterInfo *otHistoryTrackerIterateRouterHistory(otInstanc uint32_t *aEntryAge); /** - * This function iterates over the entries in the Network Data on mesh prefix entry history list. + * Iterates over the entries in the Network Data on mesh prefix entry 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. @@ -406,7 +406,7 @@ const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHisto uint32_t *aEntryAge); /** - * This function iterates over the entries in the Network Data external route entry history list. + * Iterates over the entries in the Network Data external route entry 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. @@ -424,7 +424,7 @@ const otHistoryTrackerExternalRouteInfo *otHistoryTrackerIterateExternalRouteHis uint32_t *aEntryAge); /** - * This function converts a given entry age to a human-readable string. + * Converts a given entry age to a human-readable string. * * The entry age string follows the format "::." for hours, minutes, seconds and millisecond (if * shorter than one day) or "
days ::." (if longer than one day). diff --git a/include/openthread/icmp6.h b/include/openthread/icmp6.h index 38bd6a6a166..32f8c6a1b50 100644 --- a/include/openthread/icmp6.h +++ b/include/openthread/icmp6.h @@ -80,12 +80,13 @@ typedef enum otIcmp6Code OT_ICMP6_CODE_FRAGM_REAS_TIME_EX = 1, ///< Fragment Reassembly Time Exceeded } otIcmp6Code; -#define OT_ICMP6_HEADER_DATA_SIZE 4 ///< Size of an message specific data of ICMPv6 Header. +#define OT_ICMP6_HEADER_DATA_SIZE 4 ///< Size of ICMPv6 Header. +#define OT_ICMP6_ROUTER_ADVERT_MIN_SIZE 16 ///< Size of a Router Advertisement message without any options. /** * @struct otIcmp6Header * - * This structure represents an ICMPv6 header. + * Represents an ICMPv6 header. * */ OT_TOOL_PACKED_BEGIN @@ -103,7 +104,7 @@ struct otIcmp6Header } OT_TOOL_PACKED_END; /** - * This type represents an ICMPv6 header. + * Represents an ICMPv6 header. * */ typedef struct otIcmp6Header otIcmp6Header; @@ -123,7 +124,7 @@ typedef void (*otIcmp6ReceiveCallback)(void *aContext, const otIcmp6Header *aIcmpHeader); /** - * This structure implements ICMPv6 message handler. + * Implements ICMPv6 message handler. * */ typedef struct otIcmp6Handler @@ -146,7 +147,7 @@ typedef enum otIcmp6EchoMode } otIcmp6EchoMode; /** - * This function indicates whether or not ICMPv6 Echo processing is enabled. + * Indicates whether or not ICMPv6 Echo processing is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -159,7 +160,7 @@ typedef enum otIcmp6EchoMode otIcmp6EchoMode otIcmp6GetEchoMode(otInstance *aInstance); /** - * This function sets whether or not ICMPv6 Echo processing is enabled. + * Sets whether or not ICMPv6 Echo processing is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMode The ICMPv6 Echo processing mode. @@ -168,7 +169,7 @@ otIcmp6EchoMode otIcmp6GetEchoMode(otInstance *aInstance); void otIcmp6SetEchoMode(otInstance *aInstance, otIcmp6EchoMode aMode); /** - * This function registers a handler to provide received ICMPv6 messages. + * Registers a handler to provide received ICMPv6 messages. * * @note A handler structure @p aHandler has to be stored in persistent (static) memory. * OpenThread does not make a copy of handler structure. @@ -181,7 +182,7 @@ void otIcmp6SetEchoMode(otInstance *aInstance, otIcmp6EchoMode aMode); otError otIcmp6RegisterHandler(otInstance *aInstance, otIcmp6Handler *aHandler); /** - * This function sends an ICMPv6 Echo Request via the Thread interface. + * Sends an ICMPv6 Echo Request via the Thread interface. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMessage A pointer to the message buffer containing the ICMPv6 payload. diff --git a/include/openthread/instance.h b/include/openthread/instance.h index 580f334c532..b835b4b328b 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 (322) +#define OPENTHREAD_API_VERSION (335) /** * @addtogroup api-instance @@ -66,17 +66,17 @@ extern "C" { */ /** - * This structure represents the OpenThread instance structure. + * Represents the OpenThread instance structure. */ typedef struct otInstance otInstance; /** - * This function initializes the OpenThread library. + * Initializes the OpenThread library. * - * This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be * called before any other calls to OpenThread. * - * This function is available and can only be used when support for multiple OpenThread instances is enabled. + * Is available and can only be used when support for multiple OpenThread instances is enabled. * * @param[in] aInstanceBuffer The buffer for OpenThread to use for allocating the otInstance structure. * @param[in,out] aInstanceBufferSize On input, the size of aInstanceBuffer. On output, if not enough space for @@ -90,12 +90,12 @@ typedef struct otInstance otInstance; otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize); /** - * This function initializes the static single instance of the OpenThread library. + * Initializes the static single instance of the OpenThread library. * - * This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be * called before any other calls to OpenThread. * - * This function is available and can only be used when support for multiple OpenThread instances is disabled. + * Is available and can only be used when support for multiple OpenThread instances is disabled. * * @returns A pointer to the single OpenThread instance. * @@ -103,7 +103,18 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize); otInstance *otInstanceInitSingle(void); /** - * This function indicates whether or not the instance is valid/initialized. + * Gets the instance identifier. + * + * The instance identifier is set to a random value when the instance is constructed, and then its value will not + * change after initialization. + * + * @returns The instance identifier. + * + */ +uint32_t otInstanceGetId(otInstance *aInstance); + +/** + * Indicates whether or not the instance is valid/initialized. * * The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single * instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes @@ -117,7 +128,7 @@ otInstance *otInstanceInitSingle(void); bool otInstanceIsInitialized(otInstance *aInstance); /** - * This function disables the OpenThread library. + * Disables the OpenThread library. * * Call this function when OpenThread is no longer in use. * @@ -127,9 +138,9 @@ bool otInstanceIsInitialized(otInstance *aInstance); void otInstanceFinalize(otInstance *aInstance); /** - * This function returns the current instance uptime (in msec). + * Returns the current instance uptime (in msec). * - * This function requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. * * The uptime is given as number of milliseconds since OpenThread instance was initialized. * @@ -143,9 +154,9 @@ uint64_t otInstanceGetUptime(otInstance *aInstance); #define OT_UPTIME_STRING_SIZE 24 ///< Recommended size for string representation of uptime. /** - * This function returns the current instance uptime as a human-readable string. + * Returns the current instance uptime as a human-readable string. * - * This function requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. * * The string follows the format "::." for hours, minutes, seconds and millisecond (if uptime is * shorter than one day) or "
d.::." (if longer than a day). @@ -161,7 +172,7 @@ uint64_t otInstanceGetUptime(otInstance *aInstance); void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize); /** - * This enumeration defines flags that are passed as part of `otStateChangedCallback`. + * Defines flags that are passed as part of `otStateChangedCallback`. * */ enum @@ -200,14 +211,14 @@ enum }; /** - * This type represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*` + * Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*` * definitions. * */ typedef uint32_t otChangedFlags; /** - * This function pointer is called to notify certain configuration or state changes within OpenThread. + * Pointer is called to notify certain configuration or state changes within OpenThread. * * @param[in] aFlags A bit-field indicating specific state that has changed. See `OT_CHANGED_*` definitions. * @param[in] aContext A pointer to application-specific context. @@ -216,7 +227,7 @@ typedef uint32_t otChangedFlags; typedef void (*otStateChangedCallback)(otChangedFlags aFlags, void *aContext); /** - * This function registers a callback to indicate when certain configuration or state changes within OpenThread. + * Registers a callback to indicate when certain configuration or state changes within OpenThread. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. @@ -230,7 +241,7 @@ typedef void (*otStateChangedCallback)(otChangedFlags aFlags, void *aContext); otError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext); /** - * This function removes a callback to indicate when certain configuration or state changes within OpenThread. + * Removes a callback to indicate when certain configuration or state changes within OpenThread. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. @@ -240,7 +251,7 @@ otError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext); /** - * This method triggers a platform reset. + * Triggers a platform reset. * * The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the * `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory. @@ -259,7 +270,7 @@ void otInstanceReset(otInstance *aInstance); void otInstanceFactoryReset(otInstance *aInstance); /** - * This method resets the internal states of the OpenThread radio stack. + * Resets the internal states of the OpenThread radio stack. * * Callbacks and configurations are preserved. * @@ -271,7 +282,7 @@ void otInstanceFactoryReset(otInstance *aInstance); void otInstanceResetRadioStack(otInstance *aInstance); /** - * This function erases all the OpenThread persistent info (network settings) stored on non-volatile memory. + * Erases all the OpenThread persistent info (network settings) stored on non-volatile memory. * Erase is successful only if the device is in `disabled` state/role. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -283,7 +294,7 @@ void otInstanceResetRadioStack(otInstance *aInstance); otError otInstanceErasePersistentInfo(otInstance *aInstance); /** - * This function gets the OpenThread version string. + * Gets the OpenThread version string. * * @returns A pointer to the OpenThread version. * @@ -291,7 +302,7 @@ otError otInstanceErasePersistentInfo(otInstance *aInstance); const char *otGetVersionString(void); /** - * This function gets the OpenThread radio version string. + * Gets the OpenThread radio version string. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/ip6.h b/include/openthread/ip6.h index c04bdc2cacd..e34205f46c2 100644 --- a/include/openthread/ip6.h +++ b/include/openthread/ip6.h @@ -56,11 +56,13 @@ extern "C" { #define OT_IP6_PREFIX_BITSIZE (OT_IP6_PREFIX_SIZE * 8) ///< Size of an IPv6 prefix (bits) #define OT_IP6_IID_SIZE 8 ///< Size of an IPv6 Interface Identifier (bytes) #define OT_IP6_ADDRESS_SIZE 16 ///< Size of an IPv6 address (bytes) +#define OT_IP6_HEADER_SIZE 40 ///< Size of an IPv6 header (bytes) +#define OT_IP6_HEADER_PROTO_OFFSET 6 ///< Offset of the proto field in the IPv6 header (bytes) /** * @struct otIp6InterfaceIdentifier * - * This structure represents the Interface Identifier of an IPv6 address. + * Represents the Interface Identifier of an IPv6 address. * */ OT_TOOL_PACKED_BEGIN @@ -75,7 +77,7 @@ struct otIp6InterfaceIdentifier } OT_TOOL_PACKED_END; /** - * This structure represents the Interface Identifier of an IPv6 address. + * Represents the Interface Identifier of an IPv6 address. * */ typedef struct otIp6InterfaceIdentifier otIp6InterfaceIdentifier; @@ -83,7 +85,7 @@ typedef struct otIp6InterfaceIdentifier otIp6InterfaceIdentifier; /** * @struct otIp6NetworkPrefix * - * This structure represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). + * Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). * */ OT_TOOL_PACKED_BEGIN @@ -93,7 +95,7 @@ struct otIp6NetworkPrefix } OT_TOOL_PACKED_END; /** - * This structure represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). + * Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). * */ typedef struct otIp6NetworkPrefix otIp6NetworkPrefix; @@ -101,7 +103,7 @@ typedef struct otIp6NetworkPrefix otIp6NetworkPrefix; /** * @struct otIp6AddressComponents * - * This structure represents the components of an IPv6 address. + * Represents the components of an IPv6 address. * */ OT_TOOL_PACKED_BEGIN @@ -112,7 +114,7 @@ struct otIp6AddressComponents } OT_TOOL_PACKED_END; /** - * This structure represents the components of an IPv6 address. + * Represents the components of an IPv6 address. * */ typedef struct otIp6AddressComponents otIp6AddressComponents; @@ -120,7 +122,7 @@ typedef struct otIp6AddressComponents otIp6AddressComponents; /** * @struct otIp6Address * - * This structure represents an IPv6 address. + * Represents an IPv6 address. * */ OT_TOOL_PACKED_BEGIN @@ -136,13 +138,13 @@ struct otIp6Address } OT_TOOL_PACKED_END; /** - * This structure represents an IPv6 address. + * Represents an IPv6 address. * */ typedef struct otIp6Address otIp6Address; /** - * This structure represents an IPv6 prefix. + * Represents an IPv6 prefix. * */ OT_TOOL_PACKED_BEGIN @@ -153,7 +155,7 @@ struct otIp6Prefix } OT_TOOL_PACKED_END; /** - * This structure represents an IPv6 prefix. + * Represents an IPv6 prefix. * */ typedef struct otIp6Prefix otIp6Prefix; @@ -171,7 +173,7 @@ enum }; /** - * This structure represents an IPv6 network interface unicast address. + * Represents an IPv6 network interface unicast address. * */ typedef struct otNetifAddress @@ -188,7 +190,7 @@ typedef struct otNetifAddress } otNetifAddress; /** - * This structure represents an IPv6 network interface multicast address. + * Represents an IPv6 network interface multicast address. * */ typedef struct otNetifMulticastAddress @@ -198,7 +200,7 @@ typedef struct otNetifMulticastAddress } otNetifMulticastAddress; /** - * This structure represents an IPv6 socket address. + * Represents an IPv6 socket address. * */ typedef struct otSockAddr @@ -220,7 +222,7 @@ enum }; /** - * This structure represents the local and peer IPv6 socket addresses. + * Represents the local and peer IPv6 socket addresses. * */ typedef struct otMessageInfo @@ -420,7 +422,7 @@ otMessage *otIp6NewMessageFromBuffer(otInstance *aInstance, const otMessageSettings *aSettings); /** - * This function pointer is called when an IPv6 datagram is received. + * Pointer is called when an IPv6 datagram 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 @@ -431,7 +433,7 @@ otMessage *otIp6NewMessageFromBuffer(otInstance *aInstance, typedef void (*otIp6ReceiveCallback)(otMessage *aMessage, void *aContext); /** - * This function registers a callback to provide received IPv6 datagrams. + * Registers a callback to provide received IPv6 datagrams. * * By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to * change the Thread control traffic filter setting. @@ -450,7 +452,7 @@ void otIp6SetReceiveCallback(otInstance *aInstance, otIp6ReceiveCallback aCallba /** * @struct otIp6AddressInfo * - * This structure represents IPv6 address information. + * Represents IPv6 address information. * */ typedef struct otIp6AddressInfo @@ -462,7 +464,7 @@ typedef struct otIp6AddressInfo } otIp6AddressInfo; /** - * This function pointer is called when an internal IPv6 address is added or removed. + * Pointer is called when an internal IPv6 address is added or removed. * * @param[in] aAddressInfo A pointer to the IPv6 address information. * @param[in] aIsAdded TRUE if the @p aAddress was added, FALSE if @p aAddress was removed. @@ -472,7 +474,7 @@ typedef struct otIp6AddressInfo typedef void (*otIp6AddressCallback)(const otIp6AddressInfo *aAddressInfo, bool aIsAdded, void *aContext); /** - * This function registers a callback to notify internal IPv6 address changes. + * Registers a callback to notify internal IPv6 address changes. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to a function that is called when an internal IPv6 address is added or @@ -483,7 +485,7 @@ typedef void (*otIp6AddressCallback)(const otIp6AddressInfo *aAddressInfo, bool void otIp6SetAddressCallback(otInstance *aInstance, otIp6AddressCallback aCallback, void *aCallbackContext); /** - * This function indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + * Indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams * via the callback specified in otIp6SetReceiveCallback(). * * @param[in] aInstance A pointer to an OpenThread instance. @@ -497,7 +499,7 @@ void otIp6SetAddressCallback(otInstance *aInstance, otIp6AddressCallback aCallba bool otIp6IsReceiveFilterEnabled(otInstance *aInstance); /** - * This function sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + * Sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams * via the callback specified in otIp6SetReceiveCallback(). * * @param[in] aInstance A pointer to an OpenThread instance. @@ -510,7 +512,7 @@ bool otIp6IsReceiveFilterEnabled(otInstance *aInstance); void otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled); /** - * This function sends an IPv6 datagram via the Thread interface. + * Sends an IPv6 datagram 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. @@ -530,7 +532,7 @@ void otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled); otError otIp6Send(otInstance *aInstance, otMessage *aMessage); /** - * This function adds a port to the allowed unsecured port list. + * Adds a port to the allowed unsecured port list. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPort The port value. @@ -543,7 +545,7 @@ otError otIp6Send(otInstance *aInstance, otMessage *aMessage); otError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort); /** - * This function removes a port from the allowed unsecure port list. + * Removes a port from the allowed unsecure port list. * * @note This function removes @p aPort by overwriting @p aPort with the element after @p aPort in the internal port * list. Be careful when calling otIp6GetUnsecurePorts() followed by otIp6RemoveUnsecurePort() to remove unsecure @@ -560,7 +562,7 @@ otError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort); otError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort); /** - * This function removes all ports from the allowed unsecure port list. + * Removes all ports from the allowed unsecure port list. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -568,7 +570,7 @@ otError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort); void otIp6RemoveAllUnsecurePorts(otInstance *aInstance); /** - * This function returns a pointer to the unsecure port list. + * Returns a pointer to the unsecure port list. * * @note Port value 0 is used to indicate an invalid entry. * @@ -605,7 +607,7 @@ bool otIp6IsAddressEqual(const otIp6Address *aFirst, const otIp6Address *aSecond bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond); /** - * This function converts a human-readable IPv6 address string into a binary representation. + * Converts a human-readable IPv6 address string into a binary representation. * * @param[in] aString A pointer to a NULL-terminated string. * @param[out] aAddress A pointer to an IPv6 address. @@ -617,7 +619,7 @@ bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond otError otIp6AddressFromString(const char *aString, otIp6Address *aAddress); /** - * This function converts a human-readable IPv6 prefix string into a binary representation. + * 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. @@ -634,7 +636,7 @@ otError otIp6PrefixFromString(const char *aString, otIp6Prefix *aPrefix); #define OT_IP6_ADDRESS_STRING_SIZE 40 ///< Recommended size for string representation of an IPv6 address. /** - * This function converts a given IPv6 address to a human-readable string. + * Converts a given IPv6 address to a human-readable string. * * The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x"). * @@ -651,7 +653,7 @@ void otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t #define OT_IP6_SOCK_ADDR_STRING_SIZE 48 ///< Recommended size for string representation of an IPv6 socket address. /** - * This function converts a given IPv6 socket address to a human-readable string. + * Converts a given IPv6 socket address to a human-readable string. * * 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, @@ -670,7 +672,7 @@ void otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t #define OT_IP6_PREFIX_STRING_SIZE 45 ///< Recommended size for string representation of an IPv6 prefix. /** - * This function converts a given IPv6 prefix to a human-readable string. + * Converts a given IPv6 prefix to a human-readable string. * * The IPv6 address string is formatted as "%x:%x:%x:...[::]/plen". * @@ -685,7 +687,7 @@ void otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t void otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize); /** - * This function returns the prefix match length (bits) for two IPv6 addresses. + * Returns the prefix match length (bits) for two IPv6 addresses. * * @param[in] aFirst A pointer to the first IPv6 address. * @param[in] aSecond A pointer to the second IPv6 address. @@ -696,7 +698,7 @@ 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. + * 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. @@ -706,7 +708,7 @@ uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond void otIp6GetPrefix(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix); /** - * This function indicates whether or not a given IPv6 address is the Unspecified Address. + * Indicates whether or not a given IPv6 address is the Unspecified Address. * * @param[in] aAddress A pointer to an IPv6 address. * @@ -717,7 +719,7 @@ void otIp6GetPrefix(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix * bool otIp6IsAddressUnspecified(const otIp6Address *aAddress); /** - * This function perform OpenThread source address selection. + * Perform OpenThread source address selection. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in,out] aMessageInfo A pointer to the message information. @@ -729,9 +731,9 @@ bool otIp6IsAddressUnspecified(const otIp6Address *aAddress); otError otIp6SelectSourceAddress(otInstance *aInstance, otMessageInfo *aMessageInfo); /** - * This function indicates whether the SLAAC module is enabled or not. + * Indicates whether the SLAAC module is enabled or not. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` to be enabled. + * `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. * * @retval TRUE SLAAC module is enabled. * @retval FALSE SLAAC module is disabled. @@ -740,9 +742,9 @@ otError otIp6SelectSourceAddress(otInstance *aInstance, otMessageInfo *aMessageI bool otIp6IsSlaacEnabled(otInstance *aInstance); /** - * This function enables/disables the SLAAC module. + * Enables/disables the SLAAC module. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` to be enabled. + * `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. * * When SLAAC module is enabled, SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface. * When SLAAC module is disabled any previously added SLAAC address is removed. @@ -754,7 +756,7 @@ bool otIp6IsSlaacEnabled(otInstance *aInstance); void otIp6SetSlaacEnabled(otInstance *aInstance, bool aEnabled); /** - * This function pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added. + * Pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added. * * `otIp6SetSlaacPrefixFilter()` can be used to set the filter handler. The filter handler is invoked by SLAAC module * when it is about to add a SLAAC address based on a prefix. Its boolean return value determines whether the address @@ -770,9 +772,9 @@ void otIp6SetSlaacEnabled(otInstance *aInstance, bool aEnabled); typedef bool (*otIp6SlaacPrefixFilter)(otInstance *aInstance, const otIp6Prefix *aPrefix); /** - * This function sets the SLAAC module filter handler. + * Sets the SLAAC module filter handler. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` to be enabled. + * `OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE` build-time feature must be enabled. * * The filter handler is called by SLAAC module when it is about to add a SLAAC address based on a prefix to decide * whether the address should be added or not. @@ -788,7 +790,7 @@ typedef bool (*otIp6SlaacPrefixFilter)(otInstance *aInstance, const otIp6Prefix void otIp6SetSlaacPrefixFilter(otInstance *aInstance, otIp6SlaacPrefixFilter aFilter); /** - * This function pointer is called with results of `otIp6RegisterMulticastListeners`. + * Pointer is called with results of `otIp6RegisterMulticastListeners`. * * @param[in] aContext A pointer to the user context. * @param[in] aError OT_ERROR_NONE when successfully sent MLR.req and received MLR.rsp, @@ -810,10 +812,10 @@ typedef void (*otIp6RegisterMulticastListenersCallback)(void *aCon #define OT_IP6_MAX_MLR_ADDRESSES 15 ///< Max number of IPv6 addresses supported by Multicast Listener Registration. /** - * This function registers Multicast Listeners to Primary Backbone Router. + * Registers Multicast Listeners to Primary Backbone Router. * - * Note: only available when both `OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE` and - * `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE` are enabled) + * `OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE` and `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE` + * must be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aAddresses A Multicast Address Array to register. @@ -843,9 +845,9 @@ otError otIp6RegisterMulticastListeners(otInstance * void *aContext); /** - * This function sets the Mesh Local IID (for test purpose). + * Sets the Mesh Local IID (for test purpose). * - * Only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. + * `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` must be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aIid A pointer to the Mesh Local IID to set. @@ -857,7 +859,7 @@ otError otIp6RegisterMulticastListeners(otInstance * otError otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid); /** - * This function converts a given IP protocol number to a human-readable string. + * Converts a given IP protocol number to a human-readable string. * * @param[in] aIpProto An IP protocol number (`OT_IP6_PROTO_*` enumeration). * @@ -867,7 +869,7 @@ otError otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifi const char *otIp6ProtoToString(uint8_t aIpProto); /** - * This structure represents the counters for packets and bytes. + * Represents the counters for packets and bytes. * */ typedef struct otPacketsAndBytes @@ -877,7 +879,7 @@ typedef struct otPacketsAndBytes } otPacketsAndBytes; /** - * This structure represents the counters of packets forwarded via Border Routing. + * Represents the counters of packets forwarded via Border Routing. * */ typedef struct otBorderRoutingCounters @@ -897,7 +899,7 @@ typedef struct otBorderRoutingCounters /** * Gets the Border Routing counters. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` to be enabled. + * `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` build-time feature must be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/jam_detection.h b/include/openthread/jam_detection.h index f27669ce001..e49f8b430e7 100644 --- a/include/openthread/jam_detection.h +++ b/include/openthread/jam_detection.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This function pointer is called if signal jam detection is enabled and a jam is detected. + * Pointer is called if signal jam detection is enabled and a jam is detected. * * @param[in] aJamState Current jam state (`true` if jam is detected, `false` otherwise). * @param[in] aContext A pointer to application-specific context. diff --git a/include/openthread/joiner.h b/include/openthread/joiner.h index 586e88f5486..dc4b09c8252 100644 --- a/include/openthread/joiner.h +++ b/include/openthread/joiner.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This enumeration defines the Joiner State. + * Defines the Joiner State. * */ typedef enum otJoinerState @@ -72,7 +72,7 @@ typedef enum otJoinerState #define OT_JOINER_MAX_DISCERNER_LENGTH 64 ///< Maximum length of a Joiner Discerner in bits. /** - * This structure represents a Joiner Discerner. + * Represents a Joiner Discerner. * */ typedef struct otJoinerDiscerner @@ -82,7 +82,7 @@ typedef struct otJoinerDiscerner } otJoinerDiscerner; /** - * This function pointer is called to notify the completion of a join operation. + * Pointer is called to notify the completion of a join operation. * * @param[in] aError OT_ERROR_NONE if the join process succeeded. * OT_ERROR_SECURITY if the join process failed due to security credentials. @@ -188,7 +188,7 @@ otError otJoinerSetDiscerner(otInstance *aInstance, otJoinerDiscerner *aDiscerne const otJoinerDiscerner *otJoinerGetDiscerner(otInstance *aInstance); /** - * This function converts a given joiner state enumeration value to a human-readable string. + * Converts a given joiner state enumeration value to a human-readable string. * * @param[in] aState The joiner state. * diff --git a/include/openthread/link.h b/include/openthread/link.h index 289cf858ba7..1aa1c4804eb 100644 --- a/include/openthread/link.h +++ b/include/openthread/link.h @@ -55,7 +55,7 @@ extern "C" { #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. + * Represents link-specific information for messages received from the Thread radio. * */ typedef struct otThreadLinkInfo @@ -97,7 +97,7 @@ typedef enum otMacFilterAddressMode } otMacFilterAddressMode; /** - * This structure represents a Mac Filter entry. + * Represents a Mac Filter entry. * */ typedef struct otMacFilterEntry @@ -107,7 +107,7 @@ typedef struct otMacFilterEntry } otMacFilterEntry; /** - * This structure represents the MAC layer counters. + * Represents the MAC layer counters. * */ typedef struct otMacCounters @@ -374,7 +374,7 @@ typedef struct otMacCounters } otMacCounters; /** - * This structure represents a received IEEE 802.15.4 Beacon. + * Represents a received IEEE 802.15.4 Beacon. * */ typedef struct otActiveScanResult @@ -398,7 +398,7 @@ typedef struct otActiveScanResult } otActiveScanResult; /** - * This structure represents an energy scan result. + * Represents an energy scan result. * */ typedef struct otEnergyScanResult @@ -408,7 +408,7 @@ typedef struct otEnergyScanResult } otEnergyScanResult; /** - * This function pointer is called during an IEEE 802.15.4 Active Scan when an IEEE 802.15.4 Beacon is received or + * Pointer is called during an IEEE 802.15.4 Active Scan when an IEEE 802.15.4 Beacon is received or * the scan completes. * * @param[in] aResult A valid pointer to the beacon information or NULL when the active scan completes. @@ -418,7 +418,7 @@ typedef struct otEnergyScanResult typedef void (*otHandleActiveScanResult)(otActiveScanResult *aResult, void *aContext); /** - * This function starts an IEEE 802.15.4 Active Scan + * Starts an IEEE 802.15.4 Active Scan * * @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). @@ -437,7 +437,7 @@ otError otLinkActiveScan(otInstance *aInstance, void *aCallbackContext); /** - * This function indicates whether or not an IEEE 802.15.4 Active Scan is currently in progress. + * Indicates whether or not an IEEE 802.15.4 Active Scan is currently in progress. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -446,7 +446,7 @@ otError otLinkActiveScan(otInstance *aInstance, bool otLinkIsActiveScanInProgress(otInstance *aInstance); /** - * This function pointer is called during an IEEE 802.15.4 Energy Scan when the result for a channel is ready or the + * Pointer is called during an IEEE 802.15.4 Energy Scan when the result for a channel is ready or the * scan completes. * * @param[in] aResult A valid pointer to the energy scan result information or NULL when the energy scan completes. @@ -456,7 +456,7 @@ bool otLinkIsActiveScanInProgress(otInstance *aInstance); typedef void (*otHandleEnergyScanResult)(otEnergyScanResult *aResult, void *aContext); /** - * This function starts an IEEE 802.15.4 Energy Scan + * Starts an IEEE 802.15.4 Energy Scan * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aScanChannels A bit vector indicating on which channels to perform energy scan. @@ -475,7 +475,7 @@ otError otLinkEnergyScan(otInstance *aInstance, void *aCallbackContext); /** - * This function indicates whether or not an IEEE 802.15.4 Energy Scan is currently in progress. + * Indicates whether or not an IEEE 802.15.4 Energy Scan is currently in progress. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -485,7 +485,7 @@ otError otLinkEnergyScan(otInstance *aInstance, bool otLinkIsEnergyScanInProgress(otInstance *aInstance); /** - * This function enqueues an IEEE 802.15.4 Data Request message for transmission. + * Enqueues an IEEE 802.15.4 Data Request message for transmission. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -497,7 +497,7 @@ bool otLinkIsEnergyScanInProgress(otInstance *aInstance); otError otLinkSendDataRequest(otInstance *aInstance); /** - * This function indicates whether or not an IEEE 802.15.4 MAC is in the transmit state. + * Indicates whether or not an IEEE 802.15.4 MAC is in the transmit state. * * MAC module is in the transmit state during CSMA/CA procedure, CCA, Data, Beacon or Data Request frame transmission * and receiving an ACK of a transmitted frame. MAC module is not in the transmit state during transmission of an ACK @@ -525,7 +525,7 @@ uint8_t otLinkGetChannel(otInstance *aInstance); /** * Set the IEEE 802.15.4 channel * - * This function succeeds only when Thread protocols are disabled. A successful call to this function invalidates the + * Succeeds only when Thread protocols are disabled. A successful call to this function invalidates the * Active and Pending Operational Datasets in non-volatile memory. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -553,7 +553,7 @@ uint32_t otLinkGetSupportedChannelMask(otInstance *aInstance); /** * Set the supported channel mask of MAC layer. * - * This function succeeds only when Thread protocols are disabled. + * Succeeds only when Thread protocols are disabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aChannelMask The supported channel mask (bit 0 or lsb mapping to channel 0, and so on). @@ -613,7 +613,7 @@ otPanId otLinkGetPanId(otInstance *aInstance); /** * Set the IEEE 802.15.4 PAN ID. * - * This function succeeds only when Thread protocols are disabled. A successful call to this function also invalidates + * Succeeds only when Thread protocols are disabled. A successful call to this function also invalidates * the Active and Pending Operational Datasets in non-volatile memory. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -674,7 +674,7 @@ otError otLinkSetPollPeriod(otInstance *aInstance, uint32_t aPollPeriod); otShortAddress otLinkGetShortAddress(otInstance *aInstance); /** - * This method returns the maximum number of frame retries during direct transmission. + * Returns the maximum number of frame retries during direct transmission. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -684,7 +684,7 @@ otShortAddress otLinkGetShortAddress(otInstance *aInstance); uint8_t otLinkGetMaxFrameRetriesDirect(otInstance *aInstance); /** - * This method sets the maximum number of frame retries during direct transmission. + * Sets the maximum number of frame retries during direct transmission. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMaxFrameRetriesDirect The maximum number of retries during direct transmission. @@ -693,7 +693,7 @@ uint8_t otLinkGetMaxFrameRetriesDirect(otInstance *aInstance); void otLinkSetMaxFrameRetriesDirect(otInstance *aInstance, uint8_t aMaxFrameRetriesDirect); /** - * This method returns the maximum number of frame retries during indirect transmission. + * Returns the maximum number of frame retries during indirect transmission. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -703,7 +703,7 @@ void otLinkSetMaxFrameRetriesDirect(otInstance *aInstance, uint8_t aMaxFrameRetr uint8_t otLinkGetMaxFrameRetriesIndirect(otInstance *aInstance); /** - * This method sets the maximum number of frame retries during indirect transmission. + * Sets the maximum number of frame retries during indirect transmission. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMaxFrameRetriesIndirect The maximum number of retries during indirect transmission. @@ -712,9 +712,9 @@ uint8_t otLinkGetMaxFrameRetriesIndirect(otInstance *aInstance); void otLinkSetMaxFrameRetriesIndirect(otInstance *aInstance, uint8_t aMaxFrameRetriesIndirect); /** - * This function gets the address mode of MAC filter. + * Gets the address mode of MAC filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -724,9 +724,9 @@ void otLinkSetMaxFrameRetriesIndirect(otInstance *aInstance, uint8_t aMaxFrameRe otMacFilterAddressMode otLinkFilterGetAddressMode(otInstance *aInstance); /** - * This function sets the address mode of MAC filter. + * Sets the address mode of MAC filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMode The address mode to set. @@ -735,9 +735,9 @@ otMacFilterAddressMode otLinkFilterGetAddressMode(otInstance *aInstance); void otLinkFilterSetAddressMode(otInstance *aInstance, otMacFilterAddressMode aMode); /** - * This method adds an Extended Address to MAC filter. + * Adds an Extended Address to MAC filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aExtAddress A pointer to the Extended Address (MUST NOT be NULL). @@ -749,9 +749,9 @@ void otLinkFilterSetAddressMode(otInstance *aInstance, otMacFilterAddressMode aM otError otLinkFilterAddAddress(otInstance *aInstance, const otExtAddress *aExtAddress); /** - * This method removes an Extended Address from MAC filter. + * Removes an Extended Address from MAC filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * No action is performed if there is no existing entry in Filter matching the given Extended Address. * @@ -762,9 +762,9 @@ otError otLinkFilterAddAddress(otInstance *aInstance, const otExtAddress *aExtAd void otLinkFilterRemoveAddress(otInstance *aInstance, const otExtAddress *aExtAddress); /** - * This method clears all the Extended Addresses from MAC filter. + * Clears all the Extended Addresses from MAC filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -772,9 +772,9 @@ void otLinkFilterRemoveAddress(otInstance *aInstance, const otExtAddress *aExtAd void otLinkFilterClearAddresses(otInstance *aInstance); /** - * This method gets an in-use address filter entry. + * Gets an in-use address filter entry. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in,out] aIterator A pointer to the MAC filter iterator context. To get the first in-use address filter @@ -788,10 +788,10 @@ void otLinkFilterClearAddresses(otInstance *aInstance); otError otLinkFilterGetNextAddress(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry); /** - * This method adds a fixed received signal strength (in dBm) entry for the messages from a given Extended Address in + * Adds a fixed received signal strength (in dBm) entry for the messages from a given Extended Address in * MAC Filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address. MUST NOT be NULL. @@ -804,9 +804,9 @@ otError otLinkFilterGetNextAddress(otInstance *aInstance, otMacFilterIterator *a otError otLinkFilterAddRssIn(otInstance *aInstance, const otExtAddress *aExtAddress, int8_t aRss); /** - * This method removes a MAC Filter entry for fixed received signal strength setting for a given Extended Address. + * Removes a MAC Filter entry for fixed received signal strength setting for a given Extended Address. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * No action is performed if there is no existing entry in Filter matching the given Extended Address. * @@ -817,9 +817,9 @@ otError otLinkFilterAddRssIn(otInstance *aInstance, const otExtAddress *aExtAddr void otLinkFilterRemoveRssIn(otInstance *aInstance, const otExtAddress *aExtAddress); /** - * This method sets the default received signal strength (in dBm) on MAC Filter. + * Sets the default received signal strength (in dBm) on MAC Filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * The default RSS value is used for all received frames from addresses for which there is no explicit RSS-IN entry * in the Filter list (added using `otLinkFilterAddRssIn()`). @@ -831,9 +831,9 @@ void otLinkFilterRemoveRssIn(otInstance *aInstance, const otExtAddress *aExtAddr void otLinkFilterSetDefaultRssIn(otInstance *aInstance, int8_t aRss); /** - * This method clears any previously set default received signal strength (in dBm) on MAC Filter. + * Clears any previously set default received signal strength (in dBm) on MAC Filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -841,9 +841,9 @@ void otLinkFilterSetDefaultRssIn(otInstance *aInstance, int8_t aRss); void otLinkFilterClearDefaultRssIn(otInstance *aInstance); /** - * This method clears all the received signal strength entries (including default RSS-in) on MAC Filter. + * Clears all the received signal strength entries (including default RSS-in) on MAC Filter. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -851,9 +851,9 @@ void otLinkFilterClearDefaultRssIn(otInstance *aInstance); void otLinkFilterClearAllRssIn(otInstance *aInstance); /** - * This method gets an in-use RssIn filter entry. + * Gets an in-use RssIn filter entry. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in,out] aIterator A pointer to the MAC filter iterator context. MUST NOT be NULL. @@ -869,9 +869,9 @@ void otLinkFilterClearAllRssIn(otInstance *aInstance); otError otLinkFilterGetNextRssIn(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry); /** - * This function enables/disables IEEE 802.15.4 radio filter mode. + * Enables/disables IEEE 802.15.4 radio filter mode. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * The radio filter is mainly intended for testing. It can be used to temporarily block all tx/rx on the 802.15.4 radio. * When radio filter is enabled, radio is put to sleep instead of receive (to ensure device does not receive any frame @@ -885,9 +885,9 @@ otError otLinkFilterGetNextRssIn(otInstance *aInstance, otMacFilterIterator *aIt void otLinkSetRadioFilterEnabled(otInstance *aInstance, bool aFilterEnabled); /** - * This function indicates whether the IEEE 802.15.4 radio filter is enabled or not. + * Indicates whether the IEEE 802.15.4 radio filter is enabled or not. * - * This function is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. + * Is available when OPENTHREAD_CONFIG_MAC_FILTER_ENABLE configuration is enabled. * * @retval TRUE If the radio filter is enabled. * @retval FALSE If the radio filter is disabled. @@ -896,7 +896,7 @@ void otLinkSetRadioFilterEnabled(otInstance *aInstance, bool aFilterEnabled); bool otLinkIsRadioFilterEnabled(otInstance *aInstance); /** - * This method converts received signal strength to link quality. + * Converts received signal strength to link quality. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aRss The received signal strength value to be converted. @@ -907,7 +907,7 @@ bool otLinkIsRadioFilterEnabled(otInstance *aInstance); uint8_t otLinkConvertRssToLinkQuality(otInstance *aInstance, int8_t aRss); /** - * This method converts link quality to typical received signal strength. + * Converts link quality to typical received signal strength. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aLinkQuality LinkQuality value, should be in range [0,3]. @@ -918,9 +918,9 @@ uint8_t otLinkConvertRssToLinkQuality(otInstance *aInstance, int8_t aRss); int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality); /** - * This method gets histogram of retries for a single direct packet until success. + * Gets histogram of retries for a single direct packet until success. * - * This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. + * Is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aNumberOfEntries A pointer to where the size of returned histogram array is placed. @@ -931,9 +931,9 @@ int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries); /** - * This method gets histogram of retries for a single indirect packet until success. + * Gets histogram of retries for a single indirect packet until success. * - * This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. + * Is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aNumberOfEntries A pointer to where the size of returned histogram array is placed. @@ -945,9 +945,9 @@ const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, ui const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries); /** - * This method clears histogram statistics for direct and indirect transmissions. + * Clears histogram statistics for direct and indirect transmissions. * - * This function is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. + * Is valid when OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE configuration is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -973,7 +973,7 @@ const otMacCounters *otLinkGetCounters(otInstance *aInstance); void otLinkResetCounters(otInstance *aInstance); /** - * This function pointer is called when an IEEE 802.15.4 frame is received. + * Pointer is called when an IEEE 802.15.4 frame is received. * * @note This callback is called after FCS processing and @p aFrame may not contain the actual FCS that was received. * @@ -987,7 +987,7 @@ void otLinkResetCounters(otInstance *aInstance); typedef void (*otLinkPcapCallback)(const otRadioFrame *aFrame, bool aIsTx, void *aContext); /** - * This function registers a callback to provide received raw IEEE 802.15.4 frames. + * Registers a callback to provide received raw IEEE 802.15.4 frames. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame or @@ -998,7 +998,7 @@ typedef void (*otLinkPcapCallback)(const otRadioFrame *aFrame, bool aIsTx, void void otLinkSetPcapCallback(otInstance *aInstance, otLinkPcapCallback aPcapCallback, void *aCallbackContext); /** - * This function indicates whether or not promiscuous mode is enabled at the link layer. + * Indicates whether or not promiscuous mode is enabled at the link layer. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1009,7 +1009,7 @@ void otLinkSetPcapCallback(otInstance *aInstance, otLinkPcapCallback aPcapCallba bool otLinkIsPromiscuous(otInstance *aInstance); /** - * This function enables or disables the link layer promiscuous mode. + * Enables or disables the link layer promiscuous mode. * * @note Promiscuous mode may only be enabled when the Thread interface is disabled. * @@ -1024,7 +1024,7 @@ bool otLinkIsPromiscuous(otInstance *aInstance); otError otLinkSetPromiscuous(otInstance *aInstance, bool aPromiscuous); /** - * This function gets the CSL channel. + * Gets the CSL channel. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1047,7 +1047,7 @@ uint8_t otLinkCslGetChannel(otInstance *aInstance); otError otLinkCslSetChannel(otInstance *aInstance, uint8_t aChannel); /** - * This function gets the CSL period. + * Gets the CSL period. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1069,7 +1069,7 @@ uint16_t otLinkCslGetPeriod(otInstance *aInstance); otError otLinkCslSetPeriod(otInstance *aInstance, uint16_t aPeriod); /** - * This function gets the CSL timeout. + * Gets the CSL timeout. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1091,7 +1091,7 @@ uint32_t otLinkCslGetTimeout(otInstance *aInstance); otError otLinkCslSetTimeout(otInstance *aInstance, uint32_t aTimeout); /** - * This function returns the current CCA (Clear Channel Assessment) failure rate. + * Returns the current CCA (Clear Channel Assessment) failure rate. * * The rate is maintained over a window of (roughly) last `OPENTHREAD_CONFIG_CCA_FAILURE_RATE_AVERAGING_WINDOW` * frame transmissions. @@ -1102,7 +1102,7 @@ otError otLinkCslSetTimeout(otInstance *aInstance, uint32_t aTimeout); uint16_t otLinkGetCcaFailureRate(otInstance *aInstance); /** - * This function enables or disables the link layer. + * Enables or disables the link layer. * * @note The link layer may only be enabled / disabled when the Thread Interface is disabled. * @@ -1117,7 +1117,7 @@ uint16_t otLinkGetCcaFailureRate(otInstance *aInstance); otError otLinkSetEnabled(otInstance *aInstance, bool aEnable); /** - * This function indicates whether or not the link layer is enabled. + * Indicates whether or not the link layer is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1128,9 +1128,9 @@ otError otLinkSetEnabled(otInstance *aInstance, bool aEnable); bool otLinkIsEnabled(otInstance *aInstance); /** - * This function instructs the device to send an empty IEEE 802.15.4 data frame. + * Instructs the device to send an empty IEEE 802.15.4 data frame. * - * This function is only supported on an Rx-Off-When-Idle device to send an empty data frame to its parent. + * Is only supported on an Rx-Off-When-Idle device to send an empty data frame to its parent. * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. diff --git a/include/openthread/link_metrics.h b/include/openthread/link_metrics.h index fc9a7f00912..f5813fc9d37 100644 --- a/include/openthread/link_metrics.h +++ b/include/openthread/link_metrics.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This structure represents the result (value) for a Link Metrics query. + * Represents the result (value) for a Link Metrics query. * */ typedef struct otLinkMetricsValues @@ -70,7 +70,7 @@ typedef struct otLinkMetricsValues } otLinkMetricsValues; /** - * This structure represents which frames are accounted in a Forward Tracking Series. + * Represents which frames are accounted in a Forward Tracking Series. * */ typedef struct otLinkMetricsSeriesFlags @@ -108,7 +108,7 @@ typedef enum otLinkMetricsStatus } otLinkMetricsStatus; /** - * This function pointer is called when a Link Metrics report is received. + * Pointer is called when a Link Metrics report is received. * * @param[in] aSource A pointer to the source address. * @param[in] aMetricsValues A pointer to the Link Metrics values (the query result). @@ -121,7 +121,7 @@ typedef void (*otLinkMetricsReportCallback)(const otIp6Address *aSource, uint8_t aStatus, void *aContext); /** - * This function pointer is called when a Link Metrics Management Response is received. + * Pointer is called when a Link Metrics Management Response is received. * * @param[in] aSource A pointer to the source address. * @param[in] aStatus The status code in the response. @@ -131,7 +131,7 @@ typedef void (*otLinkMetricsReportCallback)(const otIp6Address *aSource, typedef void (*otLinkMetricsMgmtResponseCallback)(const otIp6Address *aSource, uint8_t aStatus, void *aContext); /** - * This function pointer is called when Enh-ACK Probing IE is received. + * Pointer is called when Enh-ACK Probing IE is received. * * @param[in] aShortAddress The Mac short address of the Probing Subject. * @param[in] aExtAddress A pointer to the Mac extended address of the Probing Subject. @@ -145,7 +145,7 @@ typedef void (*otLinkMetricsEnhAckProbingIeReportCallback)(otShortAddress void *aContext); /** - * This function sends an MLE Data Request to query Link Metrics. + * Sends an MLE Data Request to query Link Metrics. * * It could be either Single Probe or Forward Tracking Series. * @@ -198,7 +198,7 @@ otError otLinkMetricsConfigForwardTrackingSeries(otInstance void *aCallbackContext); /** - * This function sends an MLE Link Metrics Management Request to configure/clear an Enhanced-ACK Based Probing. + * Sends an MLE Link Metrics Management Request to configure/clear an Enhanced-ACK Based Probing. * This functionality requires OT_LINK_METRICS_INITIATOR feature enabled. * * @param[in] aInstance A pointer to an OpenThread instance. diff --git a/include/openthread/link_raw.h b/include/openthread/link_raw.h index e69bd3c4d16..246b8dbc1ee 100644 --- a/include/openthread/link_raw.h +++ b/include/openthread/link_raw.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This function pointer on receipt of a IEEE 802.15.4 frame. + * Pointer on receipt of a IEEE 802.15.4 frame. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aFrame A pointer to the received frame or NULL if the receive operation was aborted. @@ -63,7 +63,7 @@ extern "C" { typedef void (*otLinkRawReceiveDone)(otInstance *aInstance, otRadioFrame *aFrame, otError aError); /** - * This function enables/disables the raw link-layer. + * Enables/disables the raw link-layer. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to a function called on receipt of a IEEE 802.15.4 frame. NULL to disable the @@ -77,7 +77,7 @@ typedef void (*otLinkRawReceiveDone)(otInstance *aInstance, otRadioFrame *aFrame otError otLinkRawSetReceiveDone(otInstance *aInstance, otLinkRawReceiveDone aCallback); /** - * This function indicates whether or not the raw link-layer is enabled. + * Indicates whether or not the raw link-layer is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -88,7 +88,7 @@ otError otLinkRawSetReceiveDone(otInstance *aInstance, otLinkRawReceiveDone aCal bool otLinkRawIsEnabled(otInstance *aInstance); /** - * This function gets the status of promiscuous mode. + * Gets the status of promiscuous mode. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -99,7 +99,7 @@ bool otLinkRawIsEnabled(otInstance *aInstance); bool otLinkRawGetPromiscuous(otInstance *aInstance); /** - * This function enables or disables promiscuous mode. + * Enables or disables promiscuous mode. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aEnable A value to enable or disable promiscuous mode. @@ -160,7 +160,7 @@ bool otLinkRawIsTransmittingOrScanning(otInstance *aInstance); /** * The radio transitions from Transmit to Receive. - * This method returns a pointer to the transmit buffer. + * Returns a pointer to the transmit buffer. * * The caller forms the IEEE 802.15.4 frame in this buffer then calls otLinkRawTransmit() * to request transmission. @@ -173,7 +173,7 @@ bool otLinkRawIsTransmittingOrScanning(otInstance *aInstance); otRadioFrame *otLinkRawGetTransmitBuffer(otInstance *aInstance); /** - * This function pointer on receipt of a IEEE 802.15.4 frame. + * Pointer on receipt of a IEEE 802.15.4 frame. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aFrame A pointer to the frame that was transmitted. @@ -191,7 +191,7 @@ typedef void (*otLinkRawTransmitDone)(otInstance *aInstance, otError aError); /** - * This method begins the transmit sequence on the radio. + * Begins the transmit sequence on the radio. * * The caller must form the IEEE 802.15.4 frame in the buffer provided by otLinkRawGetTransmitBuffer() before * requesting transmission. The channel and transmit power are also included in the otRadioFrame structure. @@ -230,7 +230,7 @@ int8_t otLinkRawGetRssi(otInstance *aInstance); otRadioCaps otLinkRawGetCaps(otInstance *aInstance); /** - * This function pointer on receipt of a IEEE 802.15.4 frame. + * Pointer on receipt of a IEEE 802.15.4 frame. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. @@ -239,7 +239,7 @@ otRadioCaps otLinkRawGetCaps(otInstance *aInstance); typedef void (*otLinkRawEnergyScanDone)(otInstance *aInstance, int8_t aEnergyScanMaxRssi); /** - * This method begins the energy scan sequence on the radio. + * Begins the energy scan sequence on the radio. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aScanChannel The channel to perform the energy scan on. @@ -367,7 +367,7 @@ 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 + * 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. diff --git a/include/openthread/logging.h b/include/openthread/logging.h index b581b27021e..143a0d51118 100644 --- a/include/openthread/logging.h +++ b/include/openthread/logging.h @@ -53,7 +53,7 @@ extern "C" { */ /** - * This function returns the current log level. + * Returns the current log level. * * If dynamic log level feature `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is enabled, this function returns the * currently set dynamic log level. Otherwise, this function returns the build-time configured log level. @@ -64,7 +64,7 @@ extern "C" { otLogLevel otLoggingGetLevel(void); /** - * This function sets the log level. + * Sets the log level. * * @note This function requires `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`. * @@ -77,9 +77,9 @@ otLogLevel otLoggingGetLevel(void); otError otLoggingSetLevel(otLogLevel aLogLevel); /** - * This function emits a log message at critical log level. + * Emits a log message at critical log level. * - * This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log + * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log * level is below critical, this function does not emit any log message. * * @param[in] aFormat The format string. @@ -89,9 +89,9 @@ otError otLoggingSetLevel(otLogLevel aLogLevel); void otLogCritPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2); /** - * This function emits a log message at warning log level. + * Emits a log message at warning log level. * - * This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log + * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log * level is below warning, this function does not emit any log message. * * @param[in] aFormat The format string. @@ -101,9 +101,9 @@ void otLogCritPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHE void otLogWarnPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2); /** - * This function emits a log message at note log level. + * Emits a log message at note log level. * - * This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log + * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log * level is below note, this function does not emit any log message. * * @param[in] aFormat The format string. @@ -113,9 +113,9 @@ void otLogWarnPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHE void otLogNotePlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2); /** - * This function emits a log message at info log level. + * Emits a log message at info log level. * - * This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log + * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log * level is below info, this function does not emit any log message. * * @param[in] aFormat The format string. @@ -125,9 +125,9 @@ void otLogNotePlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHE void otLogInfoPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2); /** - * This function emits a log message at debug log level. + * Emits a log message at debug log level. * - * This function is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log + * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log * level is below debug, this function does not emit any log message. * * @param[in] aFormat The format string. @@ -137,7 +137,7 @@ void otLogInfoPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHE void otLogDebgPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2); /** - * This function generates a memory dump at critical log level. + * Generates a memory dump at critical log level. * * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below * critical this function does not emit any log message. @@ -150,7 +150,7 @@ void otLogDebgPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHE void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength); /** - * This function generates a memory dump at warning log level. + * Generates a memory dump at warning log level. * * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below * warning this function does not emit any log message. @@ -163,7 +163,7 @@ void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength); void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength); /** - * This function generates a memory dump at note log level. + * Generates a memory dump at note log level. * * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below * note this function does not emit any log message. @@ -176,7 +176,7 @@ void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength); void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength); /** - * This function generates a memory dump at info log level. + * Generates a memory dump at info log level. * * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below * info this function does not emit any log message. @@ -189,7 +189,7 @@ void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength); void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength); /** - * This function generates a memory dump at debug log level. + * Generates a memory dump at debug log level. * * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below * debug this function does not emit any log message. @@ -202,9 +202,9 @@ void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength); void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength); /** - * This function emits a log message at a given log level. + * Emits a log message at a given log level. * - * This function is intended for use by CLI only. If `OPENTHREAD_CONFIG_LOG_CLI` is not set or the current log + * Is intended for use by CLI only. If `OPENTHREAD_CONFIG_LOG_CLI` is not set or the current log * level is below the given log level, this function does not emit any log message. * * @param[in] aLogLevel The log level. diff --git a/include/openthread/mesh_diag.h b/include/openthread/mesh_diag.h index dd613d1fa6e..cd9cb350980 100644 --- a/include/openthread/mesh_diag.h +++ b/include/openthread/mesh_diag.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This structure represents the set of configurations used when discovering mesh topology indicating which items to + * Represents the set of configurations used when discovering mesh topology indicating which items to * discover. * */ @@ -66,7 +66,7 @@ typedef struct otMeshDiagDiscoverConfig } otMeshDiagDiscoverConfig; /** - * This type is an opaque iterator to iterate over list of IPv6 addresses of a router. + * An opaque iterator to iterate over list of IPv6 addresses of a router. * * Pointers to instance of this type are provided in `otMeshDiagRouterInfo`. * @@ -74,7 +74,7 @@ typedef struct otMeshDiagDiscoverConfig typedef struct otMeshDiagIp6AddrIterator otMeshDiagIp6AddrIterator; /** - * This type is an opaque iterator to iterate over list of children of a router. + * An opaque iterator to iterate over list of children of a router. * * Pointers to instance of this type are provided in `otMeshDiagRouterInfo`. * @@ -91,7 +91,7 @@ typedef struct otMeshDiagChildIterator otMeshDiagChildIterator; #define OT_MESH_DIAG_VERSION_UNKNOWN 0xffff /** - * This type represents information about a router in Thread mesh. + * Represents information about a router in Thread mesh. * */ typedef struct otMeshDiagRouterInfo @@ -142,7 +142,7 @@ typedef struct otMeshDiagRouterInfo } otMeshDiagRouterInfo; /** - * This type represents information about a discovered child in Thread mesh. + * Represents information about a discovered child in Thread mesh. * */ typedef struct otMeshDiagChildInfo @@ -155,7 +155,7 @@ typedef struct otMeshDiagChildInfo } otMeshDiagChildInfo; /** - * This function pointer type represents the callback used by `otMeshDiagDiscoverTopology()` to provide information + * 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 @@ -171,7 +171,7 @@ typedef struct otMeshDiagChildInfo typedef void (*otMeshDiagDiscoverCallback)(otError aError, otMeshDiagRouterInfo *aRouterInfo, void *aContext); /** - * This function starts network topology discovery. + * 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). @@ -190,7 +190,7 @@ otError otMeshDiagDiscoverTopology(otInstance *aInstance, void *aContext); /** - * This function cancels an ongoing topology discovery if there is one, otherwise no action. + * 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. * @@ -198,7 +198,7 @@ otError otMeshDiagDiscoverTopology(otInstance *aInstance, void otMeshDiagCancel(otInstance *aInstance); /** - * This function iterates through the discovered IPv6 address of a router. + * 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). @@ -210,7 +210,7 @@ void otMeshDiagCancel(otInstance *aInstance); otError otMeshDiagGetNextIp6Address(otMeshDiagIp6AddrIterator *aIterator, otIp6Address *aIp6Address); /** - * This function iterates through the discovered children of a router. + * 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). diff --git a/include/openthread/message.h b/include/openthread/message.h index 0826ddb3177..6bdf5f1bece 100644 --- a/include/openthread/message.h +++ b/include/openthread/message.h @@ -53,13 +53,13 @@ extern "C" { */ /** - * This type is an opaque representation of an OpenThread message buffer. + * An opaque representation of an OpenThread message buffer. * */ typedef struct otMessage otMessage; /** - * This enumeration defines the OpenThread message priority levels. + * Defines the OpenThread message priority levels. * */ typedef enum otMessagePriority @@ -70,7 +70,7 @@ typedef enum otMessagePriority } otMessagePriority; /** - * This structure represents a message settings. + * Represents a message settings. * */ typedef struct otMessageSettings @@ -170,7 +170,7 @@ uint16_t otMessageGetOffset(const otMessage *aMessage); void otMessageSetOffset(otMessage *aMessage, uint16_t aOffset); /** - * This function indicates whether or not link security is enabled for the message. + * Indicates whether or not link security is enabled for the message. * * @param[in] aMessage A pointer to a message buffer. * @@ -181,7 +181,7 @@ void otMessageSetOffset(otMessage *aMessage, uint16_t aOffset); bool otMessageIsLinkSecurityEnabled(const otMessage *aMessage); /** - * This function sets/forces the message to be forwarded using direct transmission. + * Sets/forces the message to be forwarded using direct transmission. * Default setting for a new message is `false`. * * @param[in] aMessage A pointer to a message buffer. @@ -192,7 +192,7 @@ bool otMessageIsLinkSecurityEnabled(const otMessage *aMessage); void otMessageSetDirectTransmission(otMessage *aMessage, bool aEnabled); /** - * This function returns the average RSS (received signal strength) associated with the message. + * Returns the average RSS (received signal strength) associated with the message. * * @returns The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available. * @@ -263,7 +263,7 @@ uint16_t otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength); /** - * This structure represents an OpenThread message queue. + * Represents an OpenThread message queue. */ typedef struct { @@ -271,7 +271,7 @@ typedef struct } otMessageQueue; /** - * This structure represents information about a message queue. + * Represents information about a message queue. * */ typedef struct otMessageQueueInfo @@ -282,7 +282,7 @@ typedef struct otMessageQueueInfo } otMessageQueueInfo; /** - * This structure represents the message buffer information for different queues used by OpenThread stack. + * Represents the message buffer information for different queues used by OpenThread stack. * */ typedef struct otBufferInfo @@ -310,7 +310,7 @@ typedef struct otBufferInfo /** * Initialize the message queue. * - * This function MUST be called once and only once for a `otMessageQueue` instance before any other `otMessageQueue` + * MUST be called once and only once for a `otMessageQueue` instance before any other `otMessageQueue` * functions. The behavior is undefined if other queue APIs are used with an `otMessageQueue` before it being * initialized or if it is initialized more than once. * @@ -320,7 +320,7 @@ typedef struct otBufferInfo void otMessageQueueInit(otMessageQueue *aQueue); /** - * This function adds a message to the end of the given message queue. + * Adds a message to the end of the given message queue. * * @param[in] aQueue A pointer to the message queue. * @param[in] aMessage The message to add. @@ -329,7 +329,7 @@ void otMessageQueueInit(otMessageQueue *aQueue); void otMessageQueueEnqueue(otMessageQueue *aQueue, otMessage *aMessage); /** - * This function adds a message at the head/front of the given message queue. + * Adds a message at the head/front of the given message queue. * * @param[in] aQueue A pointer to the message queue. * @param[in] aMessage The message to add. @@ -338,7 +338,7 @@ void otMessageQueueEnqueue(otMessageQueue *aQueue, otMessage *aMessage); void otMessageQueueEnqueueAtHead(otMessageQueue *aQueue, otMessage *aMessage); /** - * This function removes a message from the given message queue. + * Removes a message from the given message queue. * * @param[in] aQueue A pointer to the message queue. * @param[in] aMessage The message to remove. @@ -347,7 +347,7 @@ void otMessageQueueEnqueueAtHead(otMessageQueue *aQueue, otMessage *aMessage); void otMessageQueueDequeue(otMessageQueue *aQueue, otMessage *aMessage); /** - * This function returns a pointer to the message at the head of the queue. + * Returns a pointer to the message at the head of the queue. * * @param[in] aQueue A pointer to a message queue. * @@ -357,7 +357,7 @@ void otMessageQueueDequeue(otMessageQueue *aQueue, otMessage *aMessage); otMessage *otMessageQueueGetHead(otMessageQueue *aQueue); /** - * This function returns a pointer to the next message in the queue by iterating forward (from head to tail). + * Returns a pointer to the next message in the queue by iterating forward (from head to tail). * * @param[in] aQueue A pointer to a message queue. * @param[in] aMessage A pointer to current message buffer. diff --git a/include/openthread/multi_radio.h b/include/openthread/multi_radio.h index 13930f58c5f..9ad35723bbb 100644 --- a/include/openthread/multi_radio.h +++ b/include/openthread/multi_radio.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This type represents information associated with a radio link. + * Represents information associated with a radio link. * */ typedef struct otRadioLinkInfo @@ -61,7 +61,7 @@ typedef struct otRadioLinkInfo } otRadioLinkInfo; /** - * This type represents multi radio link information associated with a neighbor. + * Represents multi radio link information associated with a neighbor. * */ typedef struct otMultiRadioNeighborInfo @@ -73,9 +73,9 @@ typedef struct otMultiRadioNeighborInfo } otMultiRadioNeighborInfo; /** - * This function gets the multi radio link information associated with a neighbor with a given Extended Address. + * Gets the multi radio link information associated with a neighbor with a given Extended Address. * - * This function requires the multi radio link feature to be enabled (please see `config/radio_link.h`). + * `OPENTHREAD_CONFIG_MULTI_RADIO` must be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aExtAddress The Extended Address of neighbor. diff --git a/include/openthread/nat64.h b/include/openthread/nat64.h index cd1eec2996e..1e69da6e856 100644 --- a/include/openthread/nat64.h +++ b/include/openthread/nat64.h @@ -57,7 +57,7 @@ extern "C" { /** * @struct otIp4Address * - * This structure represents an IPv4 address. + * Represents an IPv4 address. * */ OT_TOOL_PACKED_BEGIN @@ -71,7 +71,7 @@ struct otIp4Address } OT_TOOL_PACKED_END; /** - * This structure represents an IPv4 address. + * Represents an IPv4 address. * */ typedef struct otIp4Address otIp4Address; @@ -79,7 +79,7 @@ typedef struct otIp4Address otIp4Address; /** * @struct otIp4Cidr * - * This structure represents an IPv4 CIDR block. + * Represents an IPv4 CIDR block. * */ typedef struct otIp4Cidr @@ -317,7 +317,7 @@ otMessage *otIp4NewMessage(otInstance *aInstance, const otMessageSettings *aSett /** * 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. + * 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. @@ -358,7 +358,7 @@ otError otNat64SetIp4Cidr(otInstance *aInstance, const otIp4Cidr *aCidr); otError otNat64Send(otInstance *aInstance, otMessage *aMessage); /** - * This function pointer is called when an IPv4 datagram (translated by NAT64 translator) is received. + * 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 @@ -436,7 +436,7 @@ void otIp4AddressToString(const otIp4Address *aAddress, char *aBuffer, uint16_t #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. + * 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. diff --git a/include/openthread/ncp.h b/include/openthread/ncp.h index 4576c7fd330..7e07fa29013 100644 --- a/include/openthread/ncp.h +++ b/include/openthread/ncp.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This function pointer is called to send HDLC encoded NCP data. + * Pointer is called to send HDLC encoded NCP data. * * @param[in] aBuf A pointer to a buffer with an output. * @param[in] aBufLength A length of the output data stored in the buffer. @@ -66,13 +66,13 @@ extern "C" { typedef int (*otNcpHdlcSendCallback)(const uint8_t *aBuf, uint16_t aBufLength); /** - * This function is called after NCP send finished. + * Is called after NCP send finished. * */ void otNcpHdlcSendDone(void); /** - * This function is called after HDLC encoded NCP data received. + * Is called after HDLC encoded NCP data received. * * @param[in] aBuf A pointer to a buffer. * @param[in] aBufLength The length of the data stored in the buffer. @@ -100,7 +100,7 @@ void otNcpSpiInit(otInstance *aInstance); /** * @brief Send data to the host via a specific stream. * - * This function attempts to send the given data to the host + * Attempts to send the given data to the host * using the given aStreamId. This is useful for reporting * error messages, implementing debug/diagnostic consoles, * and potentially other types of datastreams. @@ -149,7 +149,7 @@ void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFo typedef bool (*otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount); /** - * This method registers peek/poke delegate functions with NCP module. + * Registers peek/poke delegate functions with NCP module. * * The delegate functions are called by NCP module to decide whether to allow peek or poke of a specific memory region. * If the delegate pointer is set to NULL, it allows peek/poke operation for any address. diff --git a/include/openthread/netdata.h b/include/openthread/netdata.h index ba999211495..ea1791e9070 100644 --- a/include/openthread/netdata.h +++ b/include/openthread/netdata.h @@ -53,7 +53,7 @@ extern "C" { typedef uint32_t otNetworkDataIterator; ///< Used to iterate through Network Data information. /** - * This structure represents a Border Router configuration. + * Represents a Border Router configuration. */ typedef struct otBorderRouterConfig { @@ -72,7 +72,7 @@ typedef struct otBorderRouterConfig } otBorderRouterConfig; /** - * This structure represents 6LoWPAN Context ID information associated with a prefix in Network Data. + * Represents 6LoWPAN Context ID information associated with a prefix in Network Data. * */ typedef struct otLowpanContextInfo @@ -83,7 +83,7 @@ typedef struct otLowpanContextInfo } otLowpanContextInfo; /** - * This structure represents an External Route configuration. + * Represents an External Route configuration. * */ typedef struct otExternalRouteConfig @@ -111,7 +111,7 @@ typedef enum otRoutePreference #define OT_SERVER_DATA_MAX_SIZE 248 ///< Max size of Server Data in bytes. Theoretical limit, practically much lower. /** - * This structure represents a Server configuration. + * Represents a Server configuration. * */ typedef struct otServerConfig @@ -123,7 +123,7 @@ typedef struct otServerConfig } otServerConfig; /** - * This structure represents a Service configuration. + * Represents a Service configuration. * */ typedef struct otServiceConfig diff --git a/include/openthread/netdata_publisher.h b/include/openthread/netdata_publisher.h index 10346c25494..60df1f658a4 100644 --- a/include/openthread/netdata_publisher.h +++ b/include/openthread/netdata_publisher.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This enumeration represents the events reported from the Publisher callbacks. + * Represents the events reported from the Publisher callbacks. * */ typedef enum otNetDataPublisherEvent @@ -65,7 +65,7 @@ typedef enum otNetDataPublisherEvent } otNetDataPublisherEvent; /** - * This function pointer type defines the callback used to notify when a "DNS/SRP Service" entry is added to or removed + * Pointer type defines the callback used to notify when a "DNS/SRP Service" entry is added to or removed * from the Thread Network Data. * * On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there are @@ -79,7 +79,7 @@ typedef enum otNetDataPublisherEvent typedef void (*otNetDataDnsSrpServicePublisherCallback)(otNetDataPublisherEvent aEvent, void *aContext); /** - * This function pointer type defines the callback used to notify when a prefix (on-mesh or external route) entry is + * Pointer type defines the callback used to notify when a prefix (on-mesh or external route) entry is * added to or removed from the Thread Network Data. * * On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there are @@ -95,9 +95,9 @@ typedef void (*otNetDataPrefixPublisherCallback)(otNetDataPublisherEvent aEvent, void *aContext); /** - * This function requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. * * A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from * earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions). @@ -109,14 +109,14 @@ typedef void (*otNetDataPrefixPublisherCallback)(otNetDataPublisherEvent aEvent, void otNetDataPublishDnsSrpServiceAnycast(otInstance *aInstance, uint8_t aSequenceNUmber); /** - * This function requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. * * A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from * earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions). * - * This function publishes the "DNS/SRP Service Unicast Address" by including the address and port info in the Service + * Publishes the "DNS/SRP Service Unicast Address" by including the address and port info in the Service * TLV data. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -127,9 +127,9 @@ void otNetDataPublishDnsSrpServiceAnycast(otInstance *aInstance, uint8_t aSequen void otNetDataPublishDnsSrpServiceUnicast(otInstance *aInstance, const otIp6Address *aAddress, uint16_t aPort); /** - * This function requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. * * A call to this function will remove and replace any previous "DNS/SRP Service" entry that was being published (from * earlier call to any of `otNetDataPublishDnsSrpService{Type}()` functions). @@ -145,9 +145,9 @@ void otNetDataPublishDnsSrpServiceUnicast(otInstance *aInstance, const otIp6Addr void otNetDataPublishDnsSrpServiceUnicastMeshLocalEid(otInstance *aInstance, uint16_t aPort); /** - * This function indicates whether or not currently the "DNS/SRP Service" entry is added to the Thread Network Data. + * Indicates whether or not currently the "DNS/SRP Service" entry is added to the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -158,12 +158,12 @@ void otNetDataPublishDnsSrpServiceUnicastMeshLocalEid(otInstance *aInstance, uin bool otNetDataIsDnsSrpServiceAdded(otInstance *aInstance); /** - * This function sets a callback for notifying when a published "DNS/SRP Service" is actually added to or removed from + * Sets a callback for notifying when a published "DNS/SRP Service" is actually added to or removed from * the Thread Network Data. * * A subsequent call to this function replaces any previously set callback function. * - * This function requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback The callback function pointer (can be NULL if not needed). @@ -186,9 +186,9 @@ void otNetDataSetDnsSrpServicePublisherCallback(otInstance void otNetDataUnpublishDnsSrpService(otInstance *aInstance); /** - * This function requests an on-mesh prefix to be published in the Thread Network Data. + * Requests an on-mesh prefix to be published in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. * * Only stable entries can be published (i.e.,`aConfig.mStable` MUST be TRUE). * @@ -213,9 +213,9 @@ void otNetDataUnpublishDnsSrpService(otInstance *aInstance); otError otNetDataPublishOnMeshPrefix(otInstance *aInstance, const otBorderRouterConfig *aConfig); /** - * This function requests an external route prefix to be published in the Thread Network Data. + * Requests an external route prefix to be published in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. * * Only stable entries can be published (i.e.,`aConfig.mStable` MUST be TRUE). * @@ -238,9 +238,9 @@ 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. + * Replaces a previously published external route in the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. + * 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 @@ -274,10 +274,10 @@ otError otNetDataReplacePublishedExternalRoute(otInstance *aIns const otExternalRouteConfig *aConfig); /** - * This function indicates whether or not currently a published prefix entry (on-mesh or external route) is added to + * Indicates whether or not currently a published prefix entry (on-mesh or external route) is added to * the Thread Network Data. * - * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aPrefix A pointer to the prefix (MUST NOT be NULL). @@ -289,12 +289,12 @@ otError otNetDataReplacePublishedExternalRoute(otInstance *aIns bool otNetDataIsPrefixAdded(otInstance *aInstance, const otIp6Prefix *aPrefix); /** - * This function sets a callback for notifying when a published prefix entry is actually added to or removed from + * Sets a callback for notifying when a published prefix entry is actually added to or removed from * the Thread Network Data. * * A subsequent call to this function replaces any previously set callback function. * - * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. + * Requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback The callback function pointer (can be NULL if not needed). diff --git a/include/openthread/netdiag.h b/include/openthread/netdiag.h index 76e523bcd2b..03563eaa5c7 100644 --- a/include/openthread/netdiag.h +++ b/include/openthread/netdiag.h @@ -97,7 +97,7 @@ enum typedef uint16_t otNetworkDiagIterator; ///< Used to iterate through Network Diagnostic TLV. /** - * This structure represents a Network Diagnostic Connectivity value. + * Represents a Network Diagnostic Connectivity value. * */ typedef struct otNetworkDiagConnectivity @@ -149,7 +149,7 @@ typedef struct otNetworkDiagConnectivity } otNetworkDiagConnectivity; /** - * This structure represents a Network Diagnostic Route data. + * Represents a Network Diagnostic Route data. * */ typedef struct otNetworkDiagRouteData @@ -161,7 +161,7 @@ typedef struct otNetworkDiagRouteData } otNetworkDiagRouteData; /** - * This structure represents a Network Diagnostic Route TLV value. + * Represents a Network Diagnostic Route TLV value. * */ typedef struct otNetworkDiagRoute @@ -183,7 +183,7 @@ typedef struct otNetworkDiagRoute } otNetworkDiagRoute; /** - * This structure represents a Network Diagnostic Mac Counters value. + * Represents a Network Diagnostic Mac Counters value. * * See RFC 2863 for definitions of member fields. * @@ -202,7 +202,7 @@ typedef struct otNetworkDiagMacCounters } otNetworkDiagMacCounters; /** - * This structure represents a Network Diagnostic Child Table Entry. + * Represents a Network Diagnostic Child Table Entry. * */ typedef struct otNetworkDiagChildEntry @@ -232,7 +232,7 @@ typedef struct otNetworkDiagChildEntry } otNetworkDiagChildEntry; /** - * This structure represents a Network Diagnostic TLV. + * Represents a Network Diagnostic TLV. * */ typedef struct otNetworkDiagTlv @@ -285,7 +285,7 @@ typedef struct otNetworkDiagTlv } otNetworkDiagTlv; /** - * This function gets the next Network Diagnostic TLV in the message. + * Gets the next Network Diagnostic TLV in the message. * * Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`. * @@ -306,7 +306,7 @@ otError otThreadGetNextDiagnosticTlv(const otMessage *aMessage, otNetworkDiagTlv *aNetworkDiagTlv); /** - * This function pointer is called when Network Diagnostic Get response is received. + * Pointer is called when Network Diagnostic Get response is received. * * @param[in] aError The error when failed to get the response. * @param[in] aMessage A pointer to the message buffer containing the received Network Diagnostic diff --git a/include/openthread/network_time.h b/include/openthread/network_time.h index e20a9d5a34a..7d5d153c5c6 100644 --- a/include/openthread/network_time.h +++ b/include/openthread/network_time.h @@ -53,7 +53,7 @@ extern "C" { */ /** - * This enumeration represents OpenThread time synchronization status. + * Represents OpenThread time synchronization status. * */ typedef enum otNetworkTimeStatus @@ -64,7 +64,7 @@ typedef enum otNetworkTimeStatus } otNetworkTimeStatus; /** - * This function pointer is called when a network time sync or status change occurs. + * Pointer is called when a network time sync or status change occurs. * */ typedef void (*otNetworkTimeSyncCallbackFn)(void *aCallbackContext); @@ -89,7 +89,7 @@ otNetworkTimeStatus otNetworkTimeGet(otInstance *aInstance, uint64_t *aNetworkTi /** * Set the time synchronization period. * - * This function can only be called while Thread protocols are disabled. + * Can only be called while Thread protocols are disabled. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aTimeSyncPeriod The time synchronization period, in seconds. @@ -113,7 +113,7 @@ uint16_t otNetworkTimeGetSyncPeriod(otInstance *aInstance); /** * Set the time synchronization XTAL accuracy threshold for Router-Capable device. * - * This function can only be called while Thread protocols are disabled. + * Can only be called while Thread protocols are disabled. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aXTALThreshold The XTAL accuracy threshold for Router, in PPM. diff --git a/include/openthread/ping_sender.h b/include/openthread/ping_sender.h index a0e30ca9aea..174cccc25c5 100644 --- a/include/openthread/ping_sender.h +++ b/include/openthread/ping_sender.h @@ -56,7 +56,7 @@ extern "C" { */ /** - * This structure represents a ping reply. + * Represents a ping reply. * */ typedef struct otPingSenderReply @@ -69,7 +69,7 @@ typedef struct otPingSenderReply } otPingSenderReply; /** - * This structure represents statistics of a ping request. + * Represents statistics of a ping request. * */ typedef struct otPingSenderStatistics @@ -83,7 +83,7 @@ typedef struct otPingSenderStatistics } otPingSenderStatistics; /** - * This function pointer type specifies the callback to notify receipt of a ping reply. + * Pointer type specifies the callback to notify receipt of a ping reply. * * @param[in] aReply A pointer to a `otPingSenderReply` containing info about the received ping reply. * @param[in] aContext A pointer to application-specific context. @@ -92,7 +92,7 @@ typedef struct otPingSenderStatistics typedef void (*otPingSenderReplyCallback)(const otPingSenderReply *aReply, void *aContext); /** - * This function pointer type specifies the callback to report the ping statistics. + * Pointer type specifies the callback to report the ping statistics. * * @param[in] aStatistics A pointer to a `otPingSenderStatistics` containing info about the received ping * statistics. @@ -102,7 +102,7 @@ typedef void (*otPingSenderReplyCallback)(const otPingSenderReply *aReply, void typedef void (*otPingSenderStatisticsCallback)(const otPingSenderStatistics *aStatistics, void *aContext); /** - * This structure represents a ping request configuration. + * Represents a ping request configuration. * */ typedef struct otPingSenderConfig @@ -123,7 +123,7 @@ typedef struct otPingSenderConfig } otPingSenderConfig; /** - * This function starts a ping. + * Starts a ping. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aConfig The ping config to use. @@ -137,7 +137,7 @@ typedef struct otPingSenderConfig otError otPingSenderPing(otInstance *aInstance, const otPingSenderConfig *aConfig); /** - * This function stops an ongoing ping. + * Stops an ongoing ping. * * @param[in] aInstance A pointer to an OpenThread instance. * diff --git a/include/openthread/platform/alarm-micro.h b/include/openthread/platform/alarm-micro.h index c165a40331a..9bbe05d19a6 100644 --- a/include/openthread/platform/alarm-micro.h +++ b/include/openthread/platform/alarm-micro.h @@ -53,7 +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]. + * For @p aT0, the platform MUST support all values in [0, 2^32-1]. + * For @p aDt, the platform MUST support all values in [0, 2^31-1]. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aT0 The reference time. diff --git a/include/openthread/platform/alarm-milli.h b/include/openthread/platform/alarm-milli.h index 0ddd9180bf5..48fb08cf26f 100644 --- a/include/openthread/platform/alarm-milli.h +++ b/include/openthread/platform/alarm-milli.h @@ -56,7 +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]. + * For @p aT0 the platform MUST support all values in [0, 2^32-1]. + * For @p aDt, the platform MUST support all values in [0, 2^31-1]. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aT0 The reference time. diff --git a/include/openthread/platform/border_routing.h b/include/openthread/platform/border_routing.h new file mode 100644 index 00000000000..eeb825c0d87 --- /dev/null +++ b/include/openthread/platform/border_routing.h @@ -0,0 +1,72 @@ +/* + * 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 includes the platform abstraction for border routing manager. + */ + +#ifndef OPENTHREAD_PLATFORM_BORDER_ROUTER_H_ +#define OPENTHREAD_PLATFORM_BORDER_ROUTER_H_ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Handles ICMP6 RA messages received on the Thread interface on the platform. + * + * The `aMessage` should point to a buffer of a valid ICMPv6 message (without IP headers) with router advertisement as + * the value of type field of the message. + * + * When DHCPv6 PD is disabled, the message will be dropped silently. + * + * Note: RA messages will not be forwarded into Thread networks, while for many platforms, RA messages is the way of + * distributing a prefix and other infomations to the downstream network. The typical usecase of this function is to + * handle the router advertisement messages sent by the platform as a result of DHCPv6 Prefix Delegation. + * + * Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE`. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aMessage A pointer to an ICMPv6 RouterAdvertisement message. + * @param[in] aLength The length of ICMPv6 RouterAdvertisement message. + * + */ +extern void otPlatBorderRoutingProcessIcmp6Ra(otInstance *aInstance, const uint8_t *aMessage, uint16_t aLength); + +#ifdef __cplusplus +} +#endif + +#endif // OPENTHREAD_PLATFORM_BORDER_ROUTER_H_ diff --git a/include/openthread/platform/crypto.h b/include/openthread/platform/crypto.h index 0bccc38b866..8762fc2ce60 100644 --- a/include/openthread/platform/crypto.h +++ b/include/openthread/platform/crypto.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This enumeration defines the key types. + * Defines the key types. * */ typedef enum @@ -67,7 +67,7 @@ typedef enum } otCryptoKeyType; /** - * This enumeration defines the key algorithms. + * Defines the key algorithms. * */ typedef enum @@ -79,7 +79,7 @@ typedef enum } otCryptoKeyAlgorithm; /** - * This enumeration defines the key usage flags. + * Defines the key usage flags. * */ enum @@ -93,7 +93,7 @@ enum }; /** - * This enumeration defines the key storage types. + * Defines the key storage types. * */ typedef enum @@ -111,7 +111,7 @@ typedef uint32_t otCryptoKeyRef; /** * @struct otCryptoKey * - * This structure represents the Key Material required for Crypto operations. + * Represents the Key Material required for Crypto operations. * */ typedef struct otCryptoKey @@ -124,7 +124,7 @@ typedef struct otCryptoKey /** * @struct otCryptoContext * - * This structure stores the context object for platform APIs. + * Stores the context object for platform APIs. * */ typedef struct otCryptoContext @@ -142,7 +142,7 @@ typedef struct otCryptoContext /** * @struct otPlatCryptoSha256Hash * - * This structure represents a SHA-256 hash. + * Represents a SHA-256 hash. * */ OT_TOOL_PACKED_BEGIN @@ -152,7 +152,7 @@ struct otPlatCryptoSha256Hash } OT_TOOL_PACKED_END; /** - * This structure represents a SHA-256 hash. + * Represents a SHA-256 hash. * */ typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash; @@ -166,7 +166,7 @@ typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash; /** * @struct otPlatCryptoEcdsaKeyPair * - * This structure represents an ECDSA key pair (public and private keys). + * Represents an ECDSA key pair (public and private keys). * * The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915). * @@ -186,7 +186,7 @@ typedef struct otPlatCryptoEcdsaKeyPair /** * @struct otPlatCryptoEcdsaPublicKey * - * This struct represents a ECDSA public key. + * Represents a ECDSA public key. * * The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4). * @@ -208,7 +208,7 @@ typedef struct otPlatCryptoEcdsaPublicKey otPlatCryptoEcdsaPublicKey; /** * @struct otPlatCryptoEcdsaSignature * - * This struct represents an ECDSA signature. + * 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). @@ -616,7 +616,7 @@ otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair, /** * 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. + * 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 @@ -656,7 +656,7 @@ otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey, /** * 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. + * 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 diff --git a/include/openthread/platform/debug_uart.h b/include/openthread/platform/debug_uart.h index b0410aff54c..a2643d68e38 100644 --- a/include/openthread/platform/debug_uart.h +++ b/include/openthread/platform/debug_uart.h @@ -104,7 +104,7 @@ void otPlatDebugUart_vprintf(const char *fmt, va_list ap); * Platform specific write single byte to Debug Uart * This should not perform CR/LF mapping. * - * This function MUST be implemented by the platform + * MUST be implemented by the platform * * @param[in] c what to transmit */ @@ -114,7 +114,7 @@ void otPlatDebugUart_putchar_raw(int c); * Poll/test debug uart if a key has been pressed. * It would be common to a stub function that returns 0. * - * This function MUST be implemented by the platform + * MUST be implemented by the platform * * @retval zero - nothing ready * @retval nonzero - otPlatDebugUart_getc() will succeed. @@ -124,7 +124,7 @@ int otPlatDebugUart_kbhit(void); /** * Poll/Read a byte from the debug uart * - * This function MUST be implemented by the platform + * MUST be implemented by the platform * * @retval (negative) no data available, see otPlatDebugUart_kbhit() * @retval (0x00..0x0ff) data byte value diff --git a/include/openthread/platform/diag.h b/include/openthread/platform/diag.h index 6f65f8234fb..7bc22994648 100644 --- a/include/openthread/platform/diag.h +++ b/include/openthread/platform/diag.h @@ -57,7 +57,7 @@ extern "C" { */ /** - * This enumeration defines the gpio modes. + * Defines the gpio modes. * */ typedef enum @@ -67,7 +67,7 @@ typedef enum } otGpioMode; /** - * This function processes a factory diagnostics command line. + * Processes a factory diagnostics command line. * * The output of this function (the content written to @p aOutput) MUST terminate with `\0` and the `\0` is within the * output buffer. @@ -90,7 +90,7 @@ otError otPlatDiagProcess(otInstance *aInstance, size_t aOutputMaxLen); /** - * This function enables/disables the factory diagnostics mode. + * Enables/disables the factory diagnostics mode. * * @param[in] aMode TRUE to enable diagnostics mode, FALSE otherwise. * @@ -98,7 +98,7 @@ otError otPlatDiagProcess(otInstance *aInstance, void otPlatDiagModeSet(bool aMode); /** - * This function indicates whether or not factory diagnostics mode is enabled. + * Indicates whether or not factory diagnostics mode is enabled. * * @returns TRUE if factory diagnostics mode is enabled, FALSE otherwise. * @@ -106,7 +106,7 @@ void otPlatDiagModeSet(bool aMode); bool otPlatDiagModeGet(void); /** - * This function sets the channel to use for factory diagnostics. + * Sets the channel to use for factory diagnostics. * * @param[in] aChannel The channel value. * @@ -114,7 +114,7 @@ bool otPlatDiagModeGet(void); void otPlatDiagChannelSet(uint8_t aChannel); /** - * This function sets the transmit power to use for factory diagnostics. + * Sets the transmit power to use for factory diagnostics. * * @param[in] aTxPower The transmit power value. * @@ -122,7 +122,7 @@ void otPlatDiagChannelSet(uint8_t aChannel); void otPlatDiagTxPowerSet(int8_t aTxPower); /** - * This function processes the received radio frame. + * Processes the received radio frame. * * @param[in] aInstance The OpenThread instance for current request. * @param[in] aFrame The received radio frame. @@ -132,7 +132,7 @@ void otPlatDiagTxPowerSet(int8_t aTxPower); void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError); /** - * This function processes the alarm event. + * Processes the alarm event. * * @param[in] aInstance The OpenThread instance for current request. * @@ -140,7 +140,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro void otPlatDiagAlarmCallback(otInstance *aInstance); /** - * This function sets the gpio value. + * Sets the gpio value. * * @param[in] aGpio The gpio number. * @param[in] aValue true to set the gpio to high level, or false otherwise. @@ -155,7 +155,7 @@ void otPlatDiagAlarmCallback(otInstance *aInstance); otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue); /** - * This function gets the gpio value. + * Gets the gpio value. * * @param[in] aGpio The gpio number. * @param[out] aValue A pointer where to put gpio value. @@ -170,7 +170,7 @@ otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue); otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue); /** - * This function sets the gpio mode. + * Sets the gpio mode. * * @param[in] aGpio The gpio number. * @param[out] aMode The gpio mode. @@ -185,7 +185,7 @@ otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue); otError otPlatDiagGpioSetMode(uint32_t aGpio, otGpioMode aMode); /** - * This function gets the gpio mode. + * Gets the gpio mode. * * @param[in] aGpio The gpio number. * @param[out] aMode A pointer where to put gpio mode. diff --git a/include/openthread/platform/dso_transport.h b/include/openthread/platform/dso_transport.h index 348ee828a99..4e005895c5b 100644 --- a/include/openthread/platform/dso_transport.h +++ b/include/openthread/platform/dso_transport.h @@ -47,7 +47,7 @@ extern "C" { #endif /** - * This structure represents a DSO connection. + * Represents a DSO connection. * * It is an opaque struct (the platform implementation only deals with pointers to this struct). * @@ -55,7 +55,7 @@ extern "C" { typedef struct otPlatDsoConnection otPlatDsoConnection; /** - * This function can be used by DSO platform implementation to get the the OpenThread instance associated with a + * Can be used by DSO platform implementation to get the the OpenThread instance associated with a * connection instance. * * @param[in] aConnection A pointer to the DSO connection. @@ -66,7 +66,7 @@ typedef struct otPlatDsoConnection otPlatDsoConnection; extern otInstance *otPlatDsoGetInstance(otPlatDsoConnection *aConnection); /** - * This function starts or stops listening for incoming connection requests on transport layer. + * Starts or stops listening for incoming connection requests on transport layer. * * For DNS-over-TLS, the transport layer MUST listen on port 853 and follow RFC 7858. * @@ -79,10 +79,10 @@ extern otInstance *otPlatDsoGetInstance(otPlatDsoConnection *aConnection); void otPlatDsoEnableListening(otInstance *aInstance, bool aEnable); /** - * This function is a callback from the DSO platform to indicate an incoming connection request when listening is + * Is a callback from the DSO platform to indicate an incoming connection request when listening is * enabled. * - * This function determines whether or not to accept the connection request. It returns a non-null `otPlatDsoConnection` + * Determines whether or not to accept the connection request. It returns a non-null `otPlatDsoConnection` * pointer if the request is to be accepted, or `NULL` if the request is to be rejected. * * If a non-null connection pointer is returned, the platform layer MUST continue establishing the connection with the @@ -98,7 +98,7 @@ void otPlatDsoEnableListening(otInstance *aInstance, bool aEnable); extern otPlatDsoConnection *otPlatDsoAccept(otInstance *aInstance, const otSockAddr *aPeerSockAddr); /** - * This function requests the platform layer to initiate establishing a connection with a peer. + * Requests the platform layer to initiate establishing a connection with a peer. * * The platform reports the outcome by invoking `otPlatDsoHandleConnected()` callback on success or * `otPlatDsoHandleDisconnected()` callback (on failure). @@ -110,7 +110,7 @@ extern otPlatDsoConnection *otPlatDsoAccept(otInstance *aInstance, const otSockA void otPlatDsoConnect(otPlatDsoConnection *aConnection, const otSockAddr *aPeerSockAddr); /** - * This function is a callback from the platform layer to indicate that a connection is successfully established. + * Is a callback from the platform layer to indicate that a connection is successfully established. * * It MUST be called either after accepting an incoming connection (`otPlatDsoAccept`) or after a `otPlatDsoConnect()` * call. @@ -123,12 +123,12 @@ void otPlatDsoConnect(otPlatDsoConnection *aConnection, const otSockAddr *aPeerS extern void otPlatDsoHandleConnected(otPlatDsoConnection *aConnection); /** - * This function sends a DSO message to the peer on a connection. + * Sends a DSO message to the peer on a connection. * - * This function is used only after the connection is successfully established (after `otPlatDsoHandleConnected()` + * Is used only after the connection is successfully established (after `otPlatDsoHandleConnected()` * callback). * - * This function passes the ownership of the @p aMessage to the DSO platform layer, and the platform implementation is + * Passes the ownership of the @p aMessage to the DSO platform layer, and the platform implementation is * expected to free the message once it is no longer needed. * * The @p aMessage contains the DNS message (starting with DNS header). Note that it does not contain the the length @@ -142,12 +142,12 @@ extern void otPlatDsoHandleConnected(otPlatDsoConnection *aConnection); void otPlatDsoSend(otPlatDsoConnection *aConnection, otMessage *aMessage); /** - * This function is a callback from the platform layer to indicate that a DNS message was received over a connection. + * Is a callback from the platform layer to indicate that a DNS message was received over a connection. * * The platform MUST call this function only after the connection is successfully established (after callback * `otPlatDsoHandleConnected()` is invoked). * - * This function passes the ownership of the @p aMessage from the DSO platform layer to OpenThread. OpenThread will + * Passes the ownership of the @p aMessage from the DSO platform layer to OpenThread. OpenThread will * free the message when no longer needed. * * The @p aMessage MUST contain the DNS message (starting with DNS header) and not include the length field that may @@ -160,7 +160,7 @@ void otPlatDsoSend(otPlatDsoConnection *aConnection, otMessage *aMessage); extern void otPlatDsoHandleReceive(otPlatDsoConnection *aConnection, otMessage *aMessage); /** - * This enumeration defines disconnect modes. + * Defines disconnect modes. * */ typedef enum @@ -170,7 +170,7 @@ typedef enum } otPlatDsoDisconnectMode; /** - * This function requests a connection to be disconnected. + * Requests a connection to be disconnected. * * After calling this function, the DSO platform implementation MUST NOT maintain `aConnection` pointer (platform * MUST NOT call any callbacks using this `Connection` pointer anymore). In particular, calling `otPlatDsoDisconnect()` @@ -183,7 +183,7 @@ typedef enum void otPlatDsoDisconnect(otPlatDsoConnection *aConnection, otPlatDsoDisconnectMode aMode); /** - * This function is a callback from the platform layer to indicate that peer closed/aborted the connection or the + * Is a callback from the platform layer to indicate that peer closed/aborted the connection or the * connection establishment failed (e.g., peer rejected a connection request). * * After calling this function, the DSO platform implementation MUST NOT maintain `aConnection` pointer (platform diff --git a/include/openthread/platform/entropy.h b/include/openthread/platform/entropy.h index 0271d1baca1..f86ced7b380 100644 --- a/include/openthread/platform/entropy.h +++ b/include/openthread/platform/entropy.h @@ -56,7 +56,7 @@ extern "C" { /** * Fill buffer with entropy. * - * This function MUST be implemented using a true random number generator (TRNG). + * MUST be implemented using a true random number generator (TRNG). * * @param[out] aOutput A pointer to where the true random values are placed. Must not be NULL. * @param[in] aOutputLength Size of @p aBuffer. diff --git a/include/openthread/platform/flash.h b/include/openthread/platform/flash.h index bbb7f3e70ee..64fc86093d8 100644 --- a/include/openthread/platform/flash.h +++ b/include/openthread/platform/flash.h @@ -38,7 +38,7 @@ extern "C" { #endif /** - * This function initializes the flash driver. + * Initializes the flash driver. * * @param[in] aInstance The OpenThread instance structure. * @@ -46,7 +46,7 @@ extern "C" { void otPlatFlashInit(otInstance *aInstance); /** - * This function gets the size of the swap space. + * Gets the size of the swap space. * * @param[in] aInstance The OpenThread instance structure. * @@ -56,7 +56,7 @@ void otPlatFlashInit(otInstance *aInstance); uint32_t otPlatFlashGetSwapSize(otInstance *aInstance); /** - * This function erases the swap space indicated by @p aSwapIndex. + * Erases the swap space indicated by @p aSwapIndex. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aSwapIndex A value in [0, 1] that indicates the swap space. @@ -65,7 +65,7 @@ uint32_t otPlatFlashGetSwapSize(otInstance *aInstance); void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex); /** - * This function reads @p aSize bytes into @p aData. + * Reads @p aSize bytes into @p aData. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aSwapIndex A value in [0, 1] that indicates the swap space. @@ -77,7 +77,7 @@ void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex); void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize); /** - * This function writes @p aSize bytes from @p aData. + * Writes @p aSize bytes from @p aData. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aSwapIndex A value in [0, 1] that indicates the swap space. diff --git a/include/openthread/platform/infra_if.h b/include/openthread/platform/infra_if.h index 5d2c50f1504..4241efd0690 100644 --- a/include/openthread/platform/infra_if.h +++ b/include/openthread/platform/infra_if.h @@ -57,7 +57,7 @@ extern "C" { */ /** - * This method tells whether an infra interface has the given IPv6 address assigned. + * Tells whether an infra interface has the given IPv6 address assigned. * * @param[in] aInfraIfIndex The index of the infra interface. * @param[in] aAddress The IPv6 address. @@ -68,7 +68,7 @@ extern "C" { bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddress); /** - * This method sends an ICMPv6 Neighbor Discovery message on given infrastructure interface. + * Sends an ICMPv6 Neighbor Discovery message on given infrastructure interface. * * See RFC 4861: https://tools.ietf.org/html/rfc4861. * @@ -150,7 +150,7 @@ 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. + * 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. diff --git a/include/openthread/platform/logging.h b/include/openthread/platform/logging.h index adf123f444a..20235dfe26e 100644 --- a/include/openthread/platform/logging.h +++ b/include/openthread/platform/logging.h @@ -107,13 +107,13 @@ extern "C" { #define OT_LOG_LEVEL_DEBG 5 /** - * This type represents the log level. + * Represents the log level. * */ typedef int otLogLevel; /** - * This enumeration represents log regions. + * Represents log regions. * * The support for log region is removed and instead each core module can define its own name to appended to the logs. * However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it @@ -148,7 +148,7 @@ typedef enum otLogRegion } otLogRegion; /** - * This function outputs logs. + * Outputs logs. * * Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE` * as @p aLogRegion. @@ -162,7 +162,7 @@ typedef enum otLogRegion void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...); /** - * This function handles OpenThread log level changes. + * Handles OpenThread log level changes. * * This platform function is called whenever the OpenThread log level changes. * This platform function is optional since an empty weak implementation has been provided. diff --git a/include/openthread/platform/memory.h b/include/openthread/platform/memory.h index 39b9e87e5ff..1f0e4227af1 100644 --- a/include/openthread/platform/memory.h +++ b/include/openthread/platform/memory.h @@ -63,7 +63,7 @@ extern "C" { * memory each and returns a pointer to the allocated memory. The allocated memory is filled with bytes * of value zero." * - * This function is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE. + * Is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE. * * @param[in] aNum The number of blocks to allocate * @param[in] aSize The size of each block to allocate @@ -76,7 +76,7 @@ void *otPlatCAlloc(size_t aNum, size_t aSize); /** * Frees memory that was dynamically allocated. * - * This function is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE. + * Is required for OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE. * * @param[in] aPtr A pointer the memory blocks to free. The pointer may be NULL. */ diff --git a/include/openthread/platform/messagepool.h b/include/openthread/platform/messagepool.h index 6f369c721b5..5058871df0d 100644 --- a/include/openthread/platform/messagepool.h +++ b/include/openthread/platform/messagepool.h @@ -54,7 +54,7 @@ extern "C" { #endif /** - * This struct represents an OpenThread message buffer. + * Represents an OpenThread message buffer. * */ typedef struct otMessageBuffer @@ -65,7 +65,7 @@ typedef struct otMessageBuffer /** * Initialize the platform implemented message pool. * - * This function is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. + * Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aMinNumFreeBuffers An uint16 containing the minimum number of free buffers desired by OpenThread. @@ -77,7 +77,7 @@ void otPlatMessagePoolInit(otInstance *aInstance, uint16_t aMinNumFreeBuffers, s /** * Allocate a buffer from the platform managed buffer pool. * - * This function is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. + * Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. * * The returned buffer instance MUST have at least `aBufferSize` bytes (as specified in `otPlatMessagePoolInit()`). * @@ -89,9 +89,9 @@ void otPlatMessagePoolInit(otInstance *aInstance, uint16_t aMinNumFreeBuffers, s otMessageBuffer *otPlatMessagePoolNew(otInstance *aInstance); /** - * This function is used to free a buffer back to the platform managed buffer pool. + * Is used to free a buffer back to the platform managed buffer pool. * - * This function is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. + * Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aBuffer The buffer to free. @@ -102,7 +102,7 @@ void otPlatMessagePoolFree(otInstance *aInstance, otMessageBuffer *aBuffer); /** * Get the number of free buffers. * - * This function is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. + * Is used when `OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT` is enabled. * * @param[in] aInstance A pointer to the OpenThread instance. * diff --git a/include/openthread/platform/misc.h b/include/openthread/platform/misc.h index 99c3ed3f532..7fbee54b1fd 100644 --- a/include/openthread/platform/misc.h +++ b/include/openthread/platform/misc.h @@ -54,7 +54,7 @@ extern "C" { */ /** - * This function performs a software reset on the platform, if supported. + * Performs a software reset on the platform, if supported. * * @param[in] aInstance The OpenThread instance structure. * @@ -83,7 +83,7 @@ typedef enum } otPlatResetReason; /** - * This function returns the reason for the last platform reset. + * Returns the reason for the last platform reset. * * @param[in] aInstance The OpenThread instance structure. * @@ -91,7 +91,7 @@ typedef enum otPlatResetReason otPlatGetResetReason(otInstance *aInstance); /** - * This function provides a platform specific implementation for assert. + * Provides a platform specific implementation for assert. * * @param[in] aFilename The name of the file where the assert occurred. * @param[in] aLineNumber The line number in the file where the assert occurred. @@ -100,7 +100,7 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance); void otPlatAssertFail(const char *aFilename, int aLineNumber); /** - * This function performs a platform specific operation to wake the host MCU. + * Performs a platform specific operation to wake the host MCU. * This is used only for NCP configurations. * */ @@ -163,7 +163,7 @@ typedef enum } otPlatMcuPowerState; /** - * This function sets the desired MCU power state. + * Sets the desired MCU power state. * * This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` * is enabled. @@ -178,7 +178,7 @@ typedef enum otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState); /** - * This function gets the current desired MCU power state. + * Gets the current desired MCU power state. * * This is only applicable and used for NCP configuration when `OPENTHREAD_CONFIG_NCP_ENABLE_MCU_POWER_STATE_CONTROL` * is enabled. diff --git a/include/openthread/platform/otns.h b/include/openthread/platform/otns.h index 6d862e24cc4..19b206b2eae 100644 --- a/include/openthread/platform/otns.h +++ b/include/openthread/platform/otns.h @@ -54,7 +54,7 @@ extern "C" { */ /** - * This function exports status information to OTNS. + * Exports status information to OTNS. * * The status information is represented by a null-terminated string with format recognizable by OTNS. * Each call to `otPlatOtnsStatus` can send multiple statuses, separated by ';', e.x. "parid=577fbc37;lrid=5". diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h index d4d18e12e66..578f9946033 100644 --- a/include/openthread/platform/radio.h +++ b/include/openthread/platform/radio.h @@ -88,7 +88,7 @@ enum }; /** - * This enumeration defines the channel page. + * Defines the channel page. * */ enum @@ -100,7 +100,7 @@ enum }; /** - * This enumeration defines the frequency band channel range. + * Defines the frequency band channel range. * */ enum @@ -114,7 +114,7 @@ enum }; /** - * This type represents radio capabilities. + * Represents radio capabilities. * * The value is a bit-field indicating the capabilities supported by the radio. See `OT_RADIO_CAPS_*` definitions. * @@ -122,7 +122,7 @@ enum typedef uint8_t otRadioCaps; /** - * This enumeration defines constants that are used to indicate different radio capabilities. See `otRadioCaps`. + * Defines constants that are used to indicate different radio capabilities. See `otRadioCaps`. * */ enum @@ -141,13 +141,13 @@ enum #define OT_PANID_BROADCAST 0xffff ///< IEEE 802.15.4 Broadcast PAN ID /** - * This type represents the IEEE 802.15.4 PAN ID. + * Represents the IEEE 802.15.4 PAN ID. * */ typedef uint16_t otPanId; /** - * This type represents the IEEE 802.15.4 Short Address. + * Represents the IEEE 802.15.4 Short Address. * */ typedef uint16_t otShortAddress; @@ -155,7 +155,7 @@ typedef uint16_t otShortAddress; #define OT_EXT_ADDRESS_SIZE 8 ///< Size of an IEEE 802.15.4 Extended Address (bytes) /** - * This enumeration defines constants about size of header IE in ACK. + * Defines constants about size of header IE in ACK. * */ enum @@ -172,7 +172,7 @@ enum /** * @struct otExtAddress * - * This structure represents the IEEE 802.15.4 Extended Address. + * Represents the IEEE 802.15.4 Extended Address. * */ OT_TOOL_PACKED_BEGIN @@ -182,7 +182,7 @@ struct otExtAddress } OT_TOOL_PACKED_END; /** - * This structure represents the IEEE 802.15.4 Extended Address. + * Represents the IEEE 802.15.4 Extended Address. * */ typedef struct otExtAddress otExtAddress; @@ -192,7 +192,7 @@ typedef struct otExtAddress otExtAddress; /** * @struct otMacKey * - * This structure represents a MAC Key. + * Represents a MAC Key. * */ OT_TOOL_PACKED_BEGIN @@ -202,13 +202,13 @@ struct otMacKey } OT_TOOL_PACKED_END; /** - * This structure represents a MAC Key. + * Represents a MAC Key. * */ typedef struct otMacKey otMacKey; /** - * This type represents a MAC Key Ref used by PSA. + * Represents a MAC Key Ref used by PSA. * */ typedef otCryptoKeyRef otMacKeyRef; @@ -216,7 +216,7 @@ typedef otCryptoKeyRef otMacKeyRef; /** * @struct otMacKeyMaterial * - * This structure represents a MAC Key. + * Represents a MAC Key. * */ typedef struct otMacKeyMaterial @@ -229,7 +229,7 @@ typedef struct otMacKeyMaterial } otMacKeyMaterial; /** - * This enumeration defines constants about key types. + * Defines constants about key types. * */ typedef enum @@ -239,7 +239,7 @@ typedef enum } otRadioKeyType; /** - * This structure represents the IEEE 802.15.4 Header IE (Information Element) related information of a radio frame. + * Represents the IEEE 802.15.4 Header IE (Information Element) related information of a radio frame. */ typedef struct otRadioIeInfo { @@ -249,7 +249,7 @@ typedef struct otRadioIeInfo } otRadioIeInfo; /** - * This structure represents an IEEE 802.15.4 radio frame. + * Represents an IEEE 802.15.4 radio frame. */ typedef struct otRadioFrame { @@ -369,7 +369,7 @@ typedef struct otRadioFrame } otRadioFrame; /** - * This structure represents the state of a radio. + * Represents the state of a radio. * Initially, a radio is in the Disabled state. */ typedef enum otRadioState @@ -399,7 +399,7 @@ typedef enum otRadioState */ /** - * This structure represents radio coexistence metrics. + * Represents radio coexistence metrics. */ typedef struct otRadioCoexMetrics { @@ -425,7 +425,7 @@ typedef struct otRadioCoexMetrics } otRadioCoexMetrics; /** - * This structure represents what metrics are specified to query. + * Represents what metrics are specified to query. * */ typedef struct otLinkMetrics @@ -627,7 +627,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable); /** * Update MAC keys and key index * - * This function is used when radio provides OT_RADIO_CAPS_TRANSMIT_SEC capability. + * Is used when radio provides OT_RADIO_CAPS_TRANSMIT_SEC capability. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aKeyIdMode The key ID mode. @@ -647,9 +647,9 @@ void otPlatRadioSetMacKey(otInstance *aInstance, otRadioKeyType aKeyType); /** - * This method sets the current MAC frame counter value. + * Sets the current MAC frame counter value. * - * This function is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + * 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. @@ -658,9 +658,9 @@ 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. + * 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. + * 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. @@ -710,7 +710,7 @@ uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance); /** * Get current state of the radio. * - * This function is not required by OpenThread. It may be used for debugging and/or application-specific purposes. + * Is not required by OpenThread. It may be used for debugging and/or application-specific purposes. * * @note This function may be not implemented. It does not affect OpenThread. * @@ -804,7 +804,7 @@ extern void otPlatRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, /** * The radio driver calls this method to notify OpenThread diagnostics module of a received frame. * - * This function is used when diagnostics is enabled. + * Is used when diagnostics is enabled. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. @@ -881,7 +881,7 @@ extern void otPlatRadioTxDone(otInstance *aInstance, otRadioFrame *aFrame, otRad /** * The radio driver calls this method to notify OpenThread diagnostics module that the transmission has completed. * - * This function is used when diagnostics is enabled. + * Is used when diagnostics is enabled. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aFrame A pointer to the frame that was transmitted. @@ -905,14 +905,14 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance); /** * Begin the energy scan sequence on the radio. * - * This function is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. * * @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. * */ @@ -921,7 +921,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 /** * The radio driver calls this method to notify OpenThread that the energy scan is complete. * - * This function is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. @@ -1036,7 +1036,7 @@ uint32_t otPlatRadioGetPreferredChannelMask(otInstance *aInstance); /** * Enable the radio coex. * - * This function is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aEnabled TRUE to enable the radio coex, FALSE otherwise. @@ -1050,7 +1050,7 @@ otError otPlatRadioSetCoexEnabled(otInstance *aInstance, bool aEnabled); /** * Check whether radio coex is enabled or not. * - * This function is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. * * @param[in] aInstance The OpenThread instance structure. * @@ -1062,7 +1062,7 @@ bool otPlatRadioIsCoexEnabled(otInstance *aInstance); /** * Get the radio coexistence metrics. * - * This function is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. * * @param[in] aInstance The OpenThread instance structure. * @param[out] aCoexMetrics A pointer to the coexistence metrics structure. diff --git a/include/openthread/platform/settings.h b/include/openthread/platform/settings.h index a9ca05de4e0..5a1783c5464 100644 --- a/include/openthread/platform/settings.h +++ b/include/openthread/platform/settings.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This enumeration defines the keys of settings. + * Defines the keys of settings. * * Note: When adding a new settings key, if the settings corresponding to the key contains security sensitive * information, the developer MUST add the key to the array `aSensitiveKeys` which is passed in @@ -90,7 +90,7 @@ enum /** * Performs any initialization for the settings subsystem, if necessary. * - * This function also sets the sensitive keys that should be stored in the secure area. + * Also sets the sensitive keys that should be stored in the secure area. * * Note that the memory pointed by @p aSensitiveKeys MUST not be released before @p aInstance is destroyed. * @@ -113,13 +113,13 @@ void otPlatSettingsDeinit(otInstance *aInstance); /** * Fetches the value of a setting. * - * This function fetches the value of the setting identified + * Fetches the value of the setting identified * by @p aKey and write it to the memory pointed to by aValue. * It then writes the length to the integer pointed to by * @p aValueLength. The initial value of @p aValueLength is the * maximum number of bytes to be written to @p aValue. * - * This function can be used to check for the existence of + * Can be used to check for the existence of * a key without fetching the value by setting @p aValue and * @p aValueLength to NULL. You can also check the length of * the setting without fetching it by setting only aValue @@ -149,7 +149,7 @@ otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint /** * Sets or replaces the value of a setting. * - * This function sets or replaces the value of a setting + * Sets or replaces the value of a setting * identified by @p aKey. * * Calling this function successfully may cause unrelated @@ -178,7 +178,7 @@ otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *a /** * Adds a value to a setting. * - * This function adds the value to a setting + * Adds the value to a setting * identified by @p aKey, without replacing any existing * values. * @@ -214,7 +214,7 @@ otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *a /** * Removes a setting from the setting store. * - * This function deletes a specific value from the + * Deletes a specific value from the * setting identified by aKey from the settings store. * * Note that the underlying implementation is not required @@ -235,7 +235,7 @@ otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex); /** * Removes all settings from the setting store. * - * This function deletes all settings from the settings + * Deletes all settings from the settings * store, resetting it to its initial factory state. * * @param[in] aInstance The OpenThread instance structure. diff --git a/include/openthread/platform/spi-slave.h b/include/openthread/platform/spi-slave.h index 551d7016350..c3e4cb8fc8e 100644 --- a/include/openthread/platform/spi-slave.h +++ b/include/openthread/platform/spi-slave.h @@ -126,7 +126,7 @@ void otPlatSpiSlaveDisable(void); * Prepare data for the next SPI transaction. Data pointers MUST remain valid until the transaction complete callback * is called by the SPI slave driver, or until after the next call to `otPlatSpiSlavePrepareTransaction()`. * - * This function may be called more than once before the SPI master initiates the transaction. Each *successful* call + * May be called more than once before the SPI master initiates the transaction. Each *successful* call * to this function will cause the previous values from earlier calls to be discarded. * * Not calling this function after a completed transaction is the same as if this function was previously called with diff --git a/include/openthread/platform/toolchain.h b/include/openthread/platform/toolchain.h index d8b0308ef87..383aefbb327 100644 --- a/include/openthread/platform/toolchain.h +++ b/include/openthread/platform/toolchain.h @@ -113,10 +113,10 @@ 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 + * 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: + * 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);` * diff --git a/include/openthread/platform/trel.h b/include/openthread/platform/trel.h index 6515b98d591..b372fded542 100644 --- a/include/openthread/platform/trel.h +++ b/include/openthread/platform/trel.h @@ -58,7 +58,7 @@ extern "C" { */ /** - * This function initializes and enables TREL platform layer. + * Initializes and enables TREL platform layer. * * Upon this call, the platform layer MUST perform the following: * @@ -87,7 +87,7 @@ extern "C" { void otPlatTrelEnable(otInstance *aInstance, uint16_t *aUdpPort); /** - * This function disables TREL platform layer. + * Disables TREL platform layer. * * After this call, the platform layer MUST stop DNS-SD browse on the service name "_trel._udp", stop advertising the * TREL DNS-SD service (from `otPlatTrelRegisterService()`) and MUST close the UDP socket used to receive TREL messages. @@ -98,7 +98,7 @@ void otPlatTrelEnable(otInstance *aInstance, uint16_t *aUdpPort); void otPlatTrelDisable(otInstance *aInstance); /** - * This structure represents a TREL peer info discovered using DNS-SD browse on the service name "_trel._udp". + * Represents a TREL peer info discovered using DNS-SD browse on the service name "_trel._udp". * */ typedef struct otPlatTrelPeerInfo @@ -145,7 +145,7 @@ typedef struct otPlatTrelPeerInfo extern void otPlatTrelHandleDiscoveredPeerInfo(otInstance *aInstance, const otPlatTrelPeerInfo *aInfo); /** - * This function registers a new service to be advertised using DNS-SD [RFC6763]. + * Registers a new service to be advertised using DNS-SD [RFC6763]. * * The service name is "_trel._udp". The platform should use its own hostname, which when combined with the service * name and the local DNS-SD domain name will produce the full service instance name, for example @@ -170,7 +170,7 @@ extern void otPlatTrelHandleDiscoveredPeerInfo(otInstance *aInstance, const otPl void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint8_t *aTxtData, uint8_t aTxtLength); /** - * This function requests a TREL UDP packet to be sent to a given destination. + * Requests a TREL UDP packet to be sent to a given destination. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aUdpPayload A pointer to UDP payload. @@ -184,7 +184,7 @@ void otPlatTrelSend(otInstance *aInstance, const otSockAddr *aDestSockAddr); /** - * This function is a callback from platform to notify of a received TREL UDP packet. + * Is a callback from platform to notify of a received TREL UDP packet. * * @note The buffer content (up to its specified length) may get changed during processing by OpenThread core (e.g., * decrypted in place), so the platform implementation should expect that after returning from this function the diff --git a/include/openthread/platform/udp.h b/include/openthread/platform/udp.h index b1dae45c799..59d1fc7e46b 100644 --- a/include/openthread/platform/udp.h +++ b/include/openthread/platform/udp.h @@ -42,7 +42,7 @@ extern "C" { #endif /** - * This function initializes the UDP socket by platform. + * Initializes the UDP socket by platform. * * @param[in] aUdpSocket A pointer to the UDP socket. * @@ -53,7 +53,7 @@ extern "C" { otError otPlatUdpSocket(otUdpSocket *aUdpSocket); /** - * This function closes the UDP socket by platform. + * Closes the UDP socket by platform. * * @param[in] aUdpSocket A pointer to the UDP socket. * @@ -64,7 +64,7 @@ otError otPlatUdpSocket(otUdpSocket *aUdpSocket); otError otPlatUdpClose(otUdpSocket *aUdpSocket); /** - * This function binds the UDP socket by platform. + * Binds the UDP socket by platform. * * @param[in] aUdpSocket A pointer to the UDP socket. * @@ -75,7 +75,7 @@ otError otPlatUdpClose(otUdpSocket *aUdpSocket); otError otPlatUdpBind(otUdpSocket *aUdpSocket); /** - * This function binds the UDP socket to a platform network interface. + * Binds the UDP socket to a platform network interface. * * Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used. * @@ -89,7 +89,7 @@ otError otPlatUdpBind(otUdpSocket *aUdpSocket); otError otPlatUdpBindToNetif(otUdpSocket *aUdpSocket, otNetifIdentifier aNetifIdentifier); /** - * This function connects UDP socket by platform. + * Connects UDP socket by platform. * * @param[in] aUdpSocket A pointer to the UDP socket. * @@ -100,7 +100,7 @@ otError otPlatUdpBindToNetif(otUdpSocket *aUdpSocket, otNetifIdentifier aNetifId otError otPlatUdpConnect(otUdpSocket *aUdpSocket); /** - * This function sends UDP payload by platform. + * Sends UDP payload by platform. * * @param[in] aUdpSocket A pointer to the UDP socket. * @param[in] aMessage A pointer to the message to send. @@ -113,7 +113,7 @@ otError otPlatUdpConnect(otUdpSocket *aUdpSocket); otError otPlatUdpSend(otUdpSocket *aUdpSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo); /** - * This function configures the UDP socket to join a UDP multicast group. + * Configures the UDP socket to join a UDP multicast group. * * Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used. * @@ -130,7 +130,7 @@ otError otPlatUdpJoinMulticastGroup(otUdpSocket *aUdpSocket, const otIp6Address *aAddress); /** - * This function configures the UDP socket to leave a UDP multicast group. + * Configures the UDP socket to leave a UDP multicast group. * * Note: only available when `OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE` is used. * diff --git a/include/openthread/radio_stats.h b/include/openthread/radio_stats.h new file mode 100644 index 00000000000..f6877a90274 --- /dev/null +++ b/include/openthread/radio_stats.h @@ -0,0 +1,99 @@ +/* + * 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 includes the OpenThread API for radio stats module. + */ + +#ifndef OPENTHREAD_RADIO_STATS_H_ +#define OPENTHREAD_RADIO_STATS_H_ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup api-radio + * + * @{ + * + */ + +/** + * Contains the statistics of radio. + * + */ +typedef struct otRadioTimeStats +{ + uint64_t mDisabledTime; ///< The total time that radio is in disabled state, in unit of microseconds. + uint64_t mSleepTime; ///< The total time that radio is in sleep state, in unit of microseconds. + uint64_t mTxTime; ///> The total time that radio is doing transmission, in unit of microseconds. + uint64_t mRxTime; ///> The total time that radio is in receive state, in unit of microseconds. +} otRadioTimeStats; + +/** + * Gets the radio statistics. + * + * The radio statistics include the time when the radio is in TX/RX/Sleep state. These times are in units of + * microseconds. All times are calculated from the last reset of radio statistics. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns A const pointer to the otRadioTimeStats struct that contains the data. + * + */ +const otRadioTimeStats *otRadioTimeStatsGet(otInstance *aInstance); + +/** + * Resets the radio statistics. + * + * All times are reset to 0. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * + */ +void otRadioTimeStatsReset(otInstance *aInstance); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_RADIO_STATS_H_ diff --git a/include/openthread/random_crypto.h b/include/openthread/random_crypto.h index 937136a782b..0c9dc58238c 100644 --- a/include/openthread/random_crypto.h +++ b/include/openthread/random_crypto.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This function fills a given buffer with cryptographically secure random bytes. + * 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). diff --git a/include/openthread/random_noncrypto.h b/include/openthread/random_noncrypto.h index 40bb2600e54..0b353ca78d3 100644 --- a/include/openthread/random_noncrypto.h +++ b/include/openthread/random_noncrypto.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This function generates and returns a random `uint32_t` value. + * Generates and returns a random `uint32_t` value. * * @returns A random `uint32_t` value. * @@ -60,7 +60,7 @@ extern "C" { uint32_t otRandomNonCryptoGetUint32(void); /** - * This function generates and returns a random byte. + * Generates and returns a random byte. * * @returns A random `uint8_t` value. * @@ -68,7 +68,7 @@ uint32_t otRandomNonCryptoGetUint32(void); uint8_t otRandomNonCryptoGetUint8(void); /** - * This function generates and returns a random `uint16_t` value. + * Generates and returns a random `uint16_t` value. * * @returns A random `uint16_t` value. * @@ -76,7 +76,7 @@ uint8_t otRandomNonCryptoGetUint8(void); uint16_t otRandomNonCryptoGetUint16(void); /** - * This function generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`. * * @param[in] aMin A minimum value (this value can be included in returned random result). * @param[in] aMax A maximum value (this value is excluded from returned random result). @@ -86,7 +86,7 @@ uint16_t otRandomNonCryptoGetUint16(void); uint8_t otRandomNonCryptoGetUint8InRange(uint8_t aMin, uint8_t aMax); /** - * This function generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`. * * @note The returned random value can include the @p aMin value but excludes the @p aMax. * @@ -98,7 +98,7 @@ uint8_t otRandomNonCryptoGetUint8InRange(uint8_t aMin, uint8_t aMax); uint16_t otRandomNonCryptoGetUint16InRange(uint16_t aMin, uint16_t aMax); /** - * This function generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`. * * @note The returned random value can include the @p aMin value but excludes the @p aMax. * @@ -111,7 +111,7 @@ uint16_t otRandomNonCryptoGetUint16InRange(uint16_t aMin, uint16_t aMax); uint32_t otRandomNonCryptoGetUint32InRange(uint32_t aMin, uint32_t aMax); /** - * This function fills a given buffer with random bytes. + * Fills a given buffer with 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). @@ -120,7 +120,7 @@ uint32_t otRandomNonCryptoGetUint32InRange(uint32_t aMin, uint32_t aMax); void otRandomNonCryptoFillBuffer(uint8_t *aBuffer, uint16_t aSize); /** - * This function adds a random jitter within a given range to a given value. + * Adds a random jitter within a given range to a given value. * * @param[in] aValue A value to which the random jitter is added. * @param[in] aJitter Maximum jitter. Random jitter is selected from the range `[-aJitter, aJitter]`. diff --git a/include/openthread/server.h b/include/openthread/server.h index 3ce11170523..28cb56325ff 100644 --- a/include/openthread/server.h +++ b/include/openthread/server.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This method provides a full or stable copy of the local Thread Network Data. + * Provides a full or stable copy of the local 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. @@ -100,7 +100,7 @@ otError otServerRemoveService(otInstance *aInstance, uint8_t aServiceDataLength); /** - * This function gets the next service in the local Network Data. + * Gets the next service in the local 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 diff --git a/include/openthread/sntp.h b/include/openthread/sntp.h index 34b26c28c67..98f9e86a5c3 100644 --- a/include/openthread/sntp.h +++ b/include/openthread/sntp.h @@ -57,7 +57,7 @@ extern "C" { #define OT_SNTP_DEFAULT_SERVER_PORT 123 ///< Defines default SNTP Server port. /** - * This structure implements SNTP Query parameters. + * Implements SNTP Query parameters. * */ typedef struct otSntpQuery @@ -66,7 +66,7 @@ typedef struct otSntpQuery } otSntpQuery; /** - * This function pointer is called when a SNTP response is received. + * Pointer is called when a SNTP response is received. * * @param[in] aContext A pointer to application-specific context. * @param[in] aTime Specifies the time at the server when the response left for the client, in UNIX time. @@ -83,9 +83,9 @@ typedef struct otSntpQuery typedef void (*otSntpResponseHandler)(void *aContext, uint64_t aTime, otError aResult); /** - * This function sends a SNTP query. + * Sends a SNTP query. * - * This function is available only if feature `OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE` is enabled. + * Is available only if feature `OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE` is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aQuery A pointer to specify SNTP query parameters. @@ -99,7 +99,7 @@ otError otSntpClientQuery(otInstance *aInstance, void *aContext); /** - * This function sets the unix era number. + * Sets the unix era number. * * The default value of unix era is set to 0. The subsequent eras start after year 2106. * diff --git a/include/openthread/srp_client.h b/include/openthread/srp_client.h index beaa062250a..6eac2b1a851 100644 --- a/include/openthread/srp_client.h +++ b/include/openthread/srp_client.h @@ -53,7 +53,7 @@ extern "C" { */ /** - * This enumeration specifies an SRP client item (service or host info) state. + * Specifies an SRP client item (service or host info) state. * */ typedef enum @@ -69,7 +69,7 @@ typedef enum } otSrpClientItemState; /** - * This structure represents an SRP client host info. + * Represents an SRP client host info. * */ typedef struct otSrpClientHostInfo @@ -82,7 +82,7 @@ typedef struct otSrpClientHostInfo } otSrpClientHostInfo; /** - * This structure represents an SRP client service. + * Represents an SRP client service. * * The values in this structure, including the string buffers for the names and the TXT record entries, MUST persist * and stay constant after an instance of this structure is passed to OpenThread from `otSrpClientAddService()` or @@ -119,7 +119,7 @@ typedef struct otSrpClientService } otSrpClientService; /** - * This function pointer type defines the callback used by SRP client to notify user of changes/events/errors. + * Pointer type defines the callback used by SRP client to notify user of changes/events/errors. * * This callback is invoked on a successful registration of an update (i.e., add/remove of host-info and/or some * service(s)) with the SRP server, or if there is a failure or error (e.g., server rejects a update request or client @@ -180,7 +180,7 @@ typedef void (*otSrpClientCallback)(otError aError, void *aContext); /** - * This function pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped. + * Pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped. * * This is only used when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled. * @@ -195,7 +195,7 @@ typedef void (*otSrpClientCallback)(otError aError, typedef void (*otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, void *aContext); /** - * This function starts the SRP client operation. + * Starts the SRP client operation. * * SRP client will prepare and send "SRP Update" message to the SRP server once all the following conditions are met: * @@ -222,9 +222,9 @@ typedef void (*otSrpClientAutoStartCallback)(const otSockAddr *aServerSockAddr, otError otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAddr); /** - * This function stops the SRP client operation. + * Stops the SRP client operation. * - * This function stops any further interactions with the SRP server. Note that it does not remove or clear host info + * Stops any further interactions with the SRP server. Note that it does not remove or clear host info * and/or list of services. It marks all services to be added/removed again once the client is (re)started. * * @param[in] aInstance A pointer to the OpenThread instance. @@ -233,7 +233,7 @@ otError otSrpClientStart(otInstance *aInstance, const otSockAddr *aServerSockAdd void otSrpClientStop(otInstance *aInstance); /** - * This function indicates whether the SRP client is running or not. + * Indicates whether the SRP client is running or not. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -243,7 +243,7 @@ void otSrpClientStop(otInstance *aInstance); bool otSrpClientIsRunning(otInstance *aInstance); /** - * This function gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP + * Gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP * client. * * If the client is not running, the address is unspecified (all zero) with zero port number. @@ -256,7 +256,7 @@ bool otSrpClientIsRunning(otInstance *aInstance); const otSockAddr *otSrpClientGetServerAddress(otInstance *aInstance); /** - * This function sets the callback to notify caller of events/changes from SRP client. + * Sets the callback to notify caller of events/changes from SRP client. * * The SRP client allows a single callback to be registered. So consecutive calls to this function will overwrite any * previously set callback functions. @@ -269,7 +269,7 @@ const otSockAddr *otSrpClientGetServerAddress(otInstance *aInstance); void otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback, void *aContext); /** - * This function enables the auto-start mode. + * Enables the auto-start mode. * * This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled. * @@ -310,7 +310,7 @@ void otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback void otSrpClientEnableAutoStartMode(otInstance *aInstance, otSrpClientAutoStartCallback aCallback, void *aContext); /** - * This function disables the auto-start mode. + * Disables the auto-start mode. * * This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled. * @@ -325,7 +325,7 @@ void otSrpClientEnableAutoStartMode(otInstance *aInstance, otSrpClientAutoStartC void otSrpClientDisableAutoStartMode(otInstance *aInstance); /** - * This function indicates the current state of auto-start mode (enabled or disabled). + * Indicates the current state of auto-start mode (enabled or disabled). * * This is only available when auto-start feature `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` is enabled. * @@ -337,7 +337,7 @@ void otSrpClientDisableAutoStartMode(otInstance *aInstance); bool otSrpClientIsAutoStartModeEnabled(otInstance *aInstance); /** - * This function gets the TTL value in every record included in SRP update requests. + * Gets the TTL value in every record included in SRP update requests. * * Note that this is the TTL requested by the SRP client. The server may choose to accept a different TTL. * @@ -352,7 +352,7 @@ bool otSrpClientIsAutoStartModeEnabled(otInstance *aInstance); uint32_t otSrpClientGetTtl(otInstance *aInstance); /** - * This function sets the TTL value in every record included in SRP update requests. + * Sets the TTL value in every record included in SRP update requests. * * Changing the TTL does not impact the TTL of already registered services/host-info. * It only affects future SRP update messages (i.e., adding new services and/or refreshes of the existing services). @@ -365,7 +365,7 @@ uint32_t otSrpClientGetTtl(otInstance *aInstance); void otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl); /** - * This function gets the default lease interval used in SRP update requests. + * Gets the default lease interval used in SRP update requests. * * The default interval is used only for `otSrpClientService` instances with `mLease` set to zero. * @@ -380,7 +380,7 @@ void otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl); uint32_t otSrpClientGetLeaseInterval(otInstance *aInstance); /** - * This function sets the default lease interval used in SRP update requests. + * Sets the default lease interval used in SRP update requests. * * The default interval is used only for `otSrpClientService` instances with `mLease` set to zero. * @@ -395,7 +395,7 @@ uint32_t otSrpClientGetLeaseInterval(otInstance *aInstance); void otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval); /** - * This function gets the default key lease interval used in SRP update requests. + * 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. * @@ -410,7 +410,7 @@ void otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval); uint32_t otSrpClientGetKeyLeaseInterval(otInstance *aInstance); /** - * This function sets the default key lease interval used in SRP update requests. + * 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. * @@ -425,7 +425,7 @@ uint32_t otSrpClientGetKeyLeaseInterval(otInstance *aInstance); void otSrpClientSetKeyLeaseInterval(otInstance *aInstance, uint32_t aInterval); /** - * This function gets the host info. + * Gets the host info. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -435,7 +435,7 @@ void otSrpClientSetKeyLeaseInterval(otInstance *aInstance, uint32_t aInterval); const otSrpClientHostInfo *otSrpClientGetHostInfo(otInstance *aInstance); /** - * This function sets the host name label. + * Sets the host name label. * * After a successful call to this function, `otSrpClientCallback` will be called to report the status of host info * registration with SRP server. @@ -458,7 +458,7 @@ const otSrpClientHostInfo *otSrpClientGetHostInfo(otInstance *aInstance); otError otSrpClientSetHostName(otInstance *aInstance, const char *aName); /** - * This function enables auto host address mode. + * Enables auto host address mode. * * When enabled host IPv6 addresses are automatically set by SRP client using all the unicast addresses on Thread netif * excluding all link-local and mesh-local addresses. If there is no valid address, then Mesh Local EID address is @@ -479,7 +479,7 @@ otError otSrpClientSetHostName(otInstance *aInstance, const char *aName); otError otSrpClientEnableAutoHostAddress(otInstance *aInstance); /** - * This function sets/updates the list of host IPv6 address. + * Sets/updates the list of host IPv6 address. * * Host IPv6 addresses can be set/changed before start or during operation of SRP client (e.g. to add/remove or change * a previously registered host address), except when the host info is being removed (client is busy handling a remove @@ -508,7 +508,7 @@ otError otSrpClientEnableAutoHostAddress(otInstance *aInstance); otError otSrpClientSetHostAddresses(otInstance *aInstance, const otIp6Address *aIp6Addresses, uint8_t aNumAddresses); /** - * This function adds a service to be registered with server. + * Adds a service to be registered with server. * * After a successful call to this function, `otSrpClientCallback` will be called to report the status of the service * addition/registration with SRP server. @@ -535,7 +535,7 @@ otError otSrpClientSetHostAddresses(otInstance *aInstance, const otIp6Address *a otError otSrpClientAddService(otInstance *aInstance, otSrpClientService *aService); /** - * This function requests a service to be unregistered with server. + * Requests a service to be unregistered with server. * * After a successful call to this function, `otSrpClientCallback` will be called to report the status of remove * request with SRP server. @@ -556,14 +556,14 @@ otError otSrpClientAddService(otInstance *aInstance, otSrpClientService *aServic otError otSrpClientRemoveService(otInstance *aInstance, otSrpClientService *aService); /** - * This function clears a service, immediately removing it from the client service list. + * Clears a service, immediately removing it from the client service list. * * Unlike `otSrpClientRemoveService()` which sends an update message to the server to remove the service, this function * clears the service from the client's service list without any interaction with the server. On a successful call to * this function, the `otSrpClientCallback` will NOT be called and the @p aService entry can be reclaimed and re-used * by the caller immediately. * - * This function can be used along with a subsequent call to `otSrpClientAddService()` (potentially reusing the same @p + * Can be used along with a subsequent call to `otSrpClientAddService()` (potentially reusing the same @p * aService entry with the same service and instance names) to update some of the parameters in an existing service. * * @param[in] aInstance A pointer to the OpenThread instance. @@ -576,7 +576,7 @@ otError otSrpClientRemoveService(otInstance *aInstance, otSrpClientService *aSer otError otSrpClientClearService(otInstance *aInstance, otSrpClientService *aService); /** - * This function gets the list of services being managed by client. + * Gets the list of services being managed by client. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -586,7 +586,7 @@ otError otSrpClientClearService(otInstance *aInstance, otSrpClientService *aServ const otSrpClientService *otSrpClientGetServices(otInstance *aInstance); /** - * This function starts the remove process of the host info and all services. + * Starts the remove process of the host info and all services. * * After returning from this function, `otSrpClientCallback` will be called to report the status of remove request with * SRP server. @@ -619,7 +619,7 @@ const otSrpClientService *otSrpClientGetServices(otInstance *aInstance); otError otSrpClientRemoveHostAndServices(otInstance *aInstance, bool aRemoveKeyLease, bool aSendUnregToServer); /** - * This function clears all host info and all the services. + * Clears all host info and all the services. * * Unlike `otSrpClientRemoveHostAndServices()` which sends an update message to the server to remove all the info, this * function clears all the info immediately without any interaction with the server. @@ -630,9 +630,9 @@ otError otSrpClientRemoveHostAndServices(otInstance *aInstance, bool aRemoveKeyL void otSrpClientClearHostAndServices(otInstance *aInstance); /** - * This function gets the domain name being used by SRP client. + * Gets the domain name being used by SRP client. * - * This function requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled. + * Requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled. * * If domain name is not set, "default.service.arpa" will be used. * @@ -644,9 +644,9 @@ void otSrpClientClearHostAndServices(otInstance *aInstance); const char *otSrpClientGetDomainName(otInstance *aInstance); /** - * This function sets the domain name to be used by SRP client. + * Sets the domain name to be used by SRP client. * - * This function requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled. + * Requires `OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE` to be enabled. * * If not set "default.service.arpa" will be used. * @@ -666,7 +666,7 @@ const char *otSrpClientGetDomainName(otInstance *aInstance); otError otSrpClientSetDomainName(otInstance *aInstance, const char *aName); /** - * This function converts a `otSrpClientItemState` to a string. + * Converts a `otSrpClientItemState` to a string. * * @param[in] aItemState An item state. * @@ -676,12 +676,12 @@ otError otSrpClientSetDomainName(otInstance *aInstance, const char *aName); const char *otSrpClientItemStateToString(otSrpClientItemState aItemState); /** - * This function enables/disables "service key record inclusion" mode. + * Enables/disables "service key record inclusion" mode. * * When enabled, SRP client will include KEY record in Service Description Instructions in the SRP update messages * that it sends. * - * This function is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled. + * Is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled. * * @note KEY record is optional in Service Description Instruction (it is required and always included in the Host * Description Instruction). The default behavior of SRP client is to not include it. This function is intended to @@ -694,9 +694,9 @@ const char *otSrpClientItemStateToString(otSrpClientItemState aItemState); void otSrpClientSetServiceKeyRecordEnabled(otInstance *aInstance, bool aEnabled); /** - * This method indicates whether the "service key record inclusion" mode is enabled or disabled. + * Indicates whether the "service key record inclusion" mode is enabled or disabled. * - * This function is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled. + * Is available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` configuration is enabled. * * @param[in] aInstance A pointer to the OpenThread instance. * diff --git a/include/openthread/srp_client_buffers.h b/include/openthread/srp_client_buffers.h index 1f8c457c871..974da0d565c 100644 --- a/include/openthread/srp_client_buffers.h +++ b/include/openthread/srp_client_buffers.h @@ -55,7 +55,7 @@ extern "C" { */ /** - * This struct represents a SRP client service pool entry. + * Represents a SRP client service pool entry. * */ typedef struct otSrpClientBuffersServiceEntry @@ -65,7 +65,7 @@ typedef struct otSrpClientBuffersServiceEntry } otSrpClientBuffersServiceEntry; /** - * This function gets the string buffer to use for SRP client host name. + * Gets the string buffer to use for SRP client host name. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[out] aSize Pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be @@ -77,7 +77,7 @@ typedef struct otSrpClientBuffersServiceEntry char *otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize); /** - * This function gets the array of IPv6 address entries to use as SRP client host address list. + * Gets the array of IPv6 address entries to use as SRP client host address list. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[out] aArrayLength Pointer to a variable to return the array length i.e., number of IPv6 address entries in @@ -89,7 +89,7 @@ char *otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize otIp6Address *otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength); /** - * This function allocates a new service entry from the pool. + * Allocates a new service entry from the pool. * * The returned service entry instance will be initialized as follows: * @@ -115,7 +115,7 @@ otIp6Address *otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uin otSrpClientBuffersServiceEntry *otSrpClientBuffersAllocateService(otInstance *aInstance); /** - * This function frees a previously allocated service entry. + * Frees a previously allocated service entry. * * The @p aService MUST be previously allocated using `otSrpClientBuffersAllocateService()` and not yet freed. Otherwise * the behavior of this function is undefined. @@ -127,7 +127,7 @@ otSrpClientBuffersServiceEntry *otSrpClientBuffersAllocateService(otInstance *aI void otSrpClientBuffersFreeService(otInstance *aInstance, otSrpClientBuffersServiceEntry *aService); /** - * This function frees all previously allocated service entries. + * Frees all previously allocated service entries. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -135,7 +135,7 @@ void otSrpClientBuffersFreeService(otInstance *aInstance, otSrpClientBuffersServ void otSrpClientBuffersFreeAllServices(otInstance *aInstance); /** - * This function gets the string buffer for service name from a service entry. + * Gets the string buffer for service name from a service entry. * * @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL). * @param[out] aSize A pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be @@ -147,7 +147,7 @@ void otSrpClientBuffersFreeAllServices(otInstance *aInstance); char *otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize); /** - * This function gets the string buffer for service instance name from a service entry. + * Gets the string buffer for service instance name from a service entry. * * @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL). * @param[out] aSize A pointer to a variable to return the size (number of bytes) of the string buffer (MUST NOT be @@ -159,7 +159,7 @@ char *otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServi char *otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize); /** - * This function gets the buffer for TXT record from a service entry. + * Gets the buffer for TXT record from a service entry. * * @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL). * @param[out] aSize A pointer to a variable to return the size (number of bytes) of the buffer (MUST NOT be NULL). @@ -170,7 +170,7 @@ char *otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServ uint8_t *otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize); /** - * This function gets the array for service subtype labels from the service entry. + * Gets the array for service subtype labels from the service entry. * * @param[in] aEntry A pointer to a previously allocated service entry (MUST NOT be NULL). * @param[out] aArrayLength A pointer to a variable to return the array length (MUST NOT be NULL). diff --git a/include/openthread/srp_server.h b/include/openthread/srp_server.h index c3dd36b2f76..4a37b46140e 100644 --- a/include/openthread/srp_server.h +++ b/include/openthread/srp_server.h @@ -132,7 +132,7 @@ enum }; /** - * This enumeration represents the state of the SRP server. + * Represents the state of the SRP server. * */ typedef enum @@ -143,7 +143,7 @@ typedef enum } otSrpServerState; /** - * This enumeration represents the address mode used by the SRP server. + * Represents the address mode used by the SRP server. * * Address mode specifies how the address and port number are determined by the SRP server and how this info is * published in the Thread Network Data. @@ -156,7 +156,7 @@ typedef enum otSrpServerAddressMode } otSrpServerAddressMode; /** - * This structure includes SRP server TTL configurations. + * Includes SRP server TTL configurations. * */ typedef struct otSrpServerTtlConfig @@ -166,7 +166,7 @@ typedef struct otSrpServerTtlConfig } otSrpServerTtlConfig; /** - * This structure includes SRP server LEASE and KEY-LEASE configurations. + * Includes SRP server LEASE and KEY-LEASE configurations. * */ typedef struct otSrpServerLeaseConfig @@ -178,7 +178,7 @@ typedef struct otSrpServerLeaseConfig } otSrpServerLeaseConfig; /** - * This structure includes SRP server lease information of a host/service. + * Includes SRP server lease information of a host/service. * */ typedef struct otSrpServerLeaseInfo @@ -190,7 +190,7 @@ typedef struct otSrpServerLeaseInfo } otSrpServerLeaseInfo; /** - * This structure includes the statistics of SRP server responses. + * Includes the statistics of SRP server responses. * */ typedef struct otSrpServerResponseCounters @@ -204,7 +204,7 @@ typedef struct otSrpServerResponseCounters } otSrpServerResponseCounters; /** - * This function returns the domain authorized to the SRP server. + * Returns the domain authorized to the SRP server. * * If the domain if not set by SetDomain, "default.service.arpa." will be returned. * A trailing dot is always appended even if the domain is set without it. @@ -217,10 +217,10 @@ typedef struct otSrpServerResponseCounters const char *otSrpServerGetDomain(otInstance *aInstance); /** - * This function sets the domain on the SRP server. + * Sets the domain on the SRP server. * * A trailing dot will be appended to @p aDomain if it is not already there. - * This function should only be called before the SRP server is enabled. + * Should only be called before the SRP server is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDomain The domain to be set. MUST NOT be NULL. @@ -234,7 +234,7 @@ const char *otSrpServerGetDomain(otInstance *aInstance); otError otSrpServerSetDomain(otInstance *aInstance, const char *aDomain); /** - * This function returns the state of the SRP server. + * Returns the state of the SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -244,7 +244,7 @@ otError otSrpServerSetDomain(otInstance *aInstance, const char *aDomain); otSrpServerState otSrpServerGetState(otInstance *aInstance); /** - * This function returns the port the SRP server is listening to. + * Returns the port the SRP server is listening to. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -254,7 +254,7 @@ otSrpServerState otSrpServerGetState(otInstance *aInstance); uint16_t otSrpServerGetPort(otInstance *aInstance); /** - * This function returns the address mode being used by the SRP server. + * Returns the address mode being used by the SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -264,7 +264,7 @@ uint16_t otSrpServerGetPort(otInstance *aInstance); otSrpServerAddressMode otSrpServerGetAddressMode(otInstance *aInstance); /** - * This function sets the address mode to be used by the SRP server. + * Sets the address mode to be used by the SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMode The address mode to use. @@ -276,7 +276,7 @@ otSrpServerAddressMode otSrpServerGetAddressMode(otInstance *aInstance); otError otSrpServerSetAddressMode(otInstance *aInstance, otSrpServerAddressMode aMode); /** - * This function returns the sequence number used with anycast address mode. + * Returns the sequence number used with anycast address mode. * * The sequence number is included in "DNS/SRP Service Anycast Address" entry published in the Network Data. * @@ -288,7 +288,7 @@ otError otSrpServerSetAddressMode(otInstance *aInstance, otSrpServerAddressMode uint8_t otSrpServerGetAnycastModeSequenceNumber(otInstance *aInstance); /** - * This function sets the sequence number used with anycast address mode. + * Sets the sequence number used with anycast address mode. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aSequenceNumber The sequence number to use. @@ -300,7 +300,7 @@ uint8_t otSrpServerGetAnycastModeSequenceNumber(otInstance *aInstance); otError otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t aSequenceNumber); /** - * This function enables/disables the SRP server. + * Enables/disables the SRP server. * * On a Border Router, it is recommended to use `otSrpServerSetAutoEnableMode()` instead. * @@ -311,9 +311,9 @@ otError otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t a void otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled); /** - * This function enables/disables the auto-enable mode on SRP server. + * Enables/disables the auto-enable mode on SRP server. * - * This function requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature. + * 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 @@ -333,9 +333,9 @@ void otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled); void otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled); /** - * This function indicates whether the auto-enable mode is enabled or disabled. + * Indicates whether the auto-enable mode is enabled or disabled. * - * This function requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature. + * Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -346,7 +346,7 @@ void otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled); bool otSrpServerIsAutoEnableMode(otInstance *aInstance); /** - * This function returns SRP server TTL configuration. + * Returns SRP server TTL configuration. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aTtlConfig A pointer to an `otSrpServerTtlConfig` instance. @@ -355,7 +355,7 @@ bool otSrpServerIsAutoEnableMode(otInstance *aInstance); void otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlConfig); /** - * This function sets SRP server TTL configuration. + * Sets SRP server TTL configuration. * * The granted TTL will always be no greater than the max lease interval configured via `otSrpServerSetLeaseConfig()`, * regardless of the minimum and maximum TTL configuration. @@ -370,7 +370,7 @@ void otSrpServerGetTtlConfig(otInstance *aInstance, otSrpServerTtlConfig *aTtlCo otError otSrpServerSetTtlConfig(otInstance *aInstance, const otSrpServerTtlConfig *aTtlConfig); /** - * This function returns SRP server LEASE and KEY-LEASE configurations. + * Returns SRP server LEASE and KEY-LEASE configurations. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aLeaseConfig A pointer to an `otSrpServerLeaseConfig` instance. @@ -379,7 +379,7 @@ otError otSrpServerSetTtlConfig(otInstance *aInstance, const otSrpServerTtlConfi void otSrpServerGetLeaseConfig(otInstance *aInstance, otSrpServerLeaseConfig *aLeaseConfig); /** - * This function sets SRP server LEASE and KEY-LEASE configurations. + * Sets SRP server LEASE and KEY-LEASE configurations. * * When a non-zero LEASE time is requested from a client, the granted value will be * limited in range [aMinLease, aMaxLease]; and a non-zero KEY-LEASE will be granted @@ -396,9 +396,9 @@ void otSrpServerGetLeaseConfig(otInstance *aInstance, otSrpServerLeaseConfig *aL otError otSrpServerSetLeaseConfig(otInstance *aInstance, const otSrpServerLeaseConfig *aLeaseConfig); /** - * This function handles SRP service updates. + * Handles SRP service updates. * - * This function is called by the SRP server to notify that a SRP host and possibly SRP services + * Is called by the SRP server to notify that a SRP host and possibly SRP services * are being updated. It is important that the SRP updates are not committed until the handler * returns the result by calling otSrpServerHandleServiceUpdateResult or times out after @p aTimeout. * @@ -434,7 +434,7 @@ typedef void (*otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId, void *aContext); /** - * This function sets the SRP service updates handler on SRP server. + * Sets the SRP service updates handler on SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aServiceHandler A pointer to a service handler. Use NULL to remove the handler. @@ -447,7 +447,7 @@ void otSrpServerSetServiceUpdateHandler(otInstance *aInstanc void *aContext); /** - * This function reports the result of processing a SRP update to the SRP server. + * Reports the result of processing a SRP update to the SRP server. * * The Service Update Handler should call this function to return the result of its * processing of a SRP update. @@ -462,7 +462,7 @@ void otSrpServerSetServiceUpdateHandler(otInstance *aInstanc void otSrpServerHandleServiceUpdateResult(otInstance *aInstance, otSrpServerServiceUpdateId aId, otError aError); /** - * This function returns the next registered host on the SRP server. + * Returns the next registered host on the SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aHost A pointer to current host; use NULL to get the first host. @@ -473,7 +473,7 @@ void otSrpServerHandleServiceUpdateResult(otInstance *aInstance, otSrpServerServ const otSrpServerHost *otSrpServerGetNextHost(otInstance *aInstance, const otSrpServerHost *aHost); /** - * This function returns the response counters of the SRP server. + * Returns the response counters of the SRP server. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -483,7 +483,7 @@ const otSrpServerHost *otSrpServerGetNextHost(otInstance *aInstance, const otSrp const otSrpServerResponseCounters *otSrpServerGetResponseCounters(otInstance *aInstance); /** - * This function tells if the SRP service host has been deleted. + * Tells if the SRP service host has been deleted. * * A SRP service host can be deleted but retains its name for future uses. * In this case, the host instance is not removed from the SRP server/registry. @@ -496,7 +496,7 @@ const otSrpServerResponseCounters *otSrpServerGetResponseCounters(otInstance *aI bool otSrpServerHostIsDeleted(const otSrpServerHost *aHost); /** - * This function returns the full name of the host. + * Returns the full name of the host. * * @param[in] aHost A pointer to the SRP service host. * @@ -506,7 +506,7 @@ bool otSrpServerHostIsDeleted(const otSrpServerHost *aHost); const char *otSrpServerHostGetFullName(const otSrpServerHost *aHost); /** - * This function returns the addresses of given host. + * Returns the addresses of given host. * * @param[in] aHost A pointer to the SRP service host. * @param[out] aAddressesNum A pointer to where we should output the number of the addresses to. @@ -517,7 +517,7 @@ const char *otSrpServerHostGetFullName(const otSrpServerHost *aHost); const otIp6Address *otSrpServerHostGetAddresses(const otSrpServerHost *aHost, uint8_t *aAddressesNum); /** - * This function returns the LEASE and KEY-LEASE information of a given host. + * Returns the LEASE and KEY-LEASE information of a given host. * * @param[in] aHost A pointer to the SRP server host. * @param[out] aLeaseInfo A pointer to where to output the LEASE and KEY-LEASE information. @@ -526,7 +526,7 @@ const otIp6Address *otSrpServerHostGetAddresses(const otSrpServerHost *aHost, ui void otSrpServerHostGetLeaseInfo(const otSrpServerHost *aHost, otSrpServerLeaseInfo *aLeaseInfo); /** - * This function returns the next service (excluding any sub-type services) of given host. + * Returns the next service (excluding any sub-type services) of given host. * * @note This function is being deprecated and will be removed. `otSrpServerHostFindNextService()` can be used * instead. @@ -541,7 +541,7 @@ const otSrpServerService *otSrpServerHostGetNextService(const otSrpServerHost const otSrpServerService *aService); /** - * This function finds the next matching service on the host. + * Finds the next matching service on the host. * * The combination of flags and service and instance names enables iterating over the full list of services and/or a * subset of them matching certain conditions, or finding a specific service. @@ -579,7 +579,7 @@ const otSrpServerService *otSrpServerHostFindNextService(const otSrpServerHost const char *aInstanceName); /** - * This function indicates whether or not the SRP service has been deleted. + * Indicates whether or not the SRP service has been deleted. * * A SRP service can be deleted but retains its name for future uses. * In this case, the service instance is not removed from the SRP server/registry. @@ -593,7 +593,7 @@ const otSrpServerService *otSrpServerHostFindNextService(const otSrpServerHost bool otSrpServerServiceIsDeleted(const otSrpServerService *aService); /** - * This function indicates whether or not the SRP service is sub-type. + * Indicates whether or not the SRP service is sub-type. * * @param[in] aService A pointer to the SRP service. * @@ -603,7 +603,7 @@ bool otSrpServerServiceIsDeleted(const otSrpServerService *aService); bool otSrpServerServiceIsSubType(const otSrpServerService *aService); /** - * This function returns the full service instance name of the service. + * Returns the full service instance name of the service. * * @note This function is being deprecated and will be removed. `otSrpServerServiceGetInstanceName()` can be used * instead. @@ -616,7 +616,7 @@ bool otSrpServerServiceIsSubType(const otSrpServerService *aService); const char *otSrpServerServiceGetFullName(const otSrpServerService *aService); /** - * This function returns the full service instance name of the service. + * Returns the full service instance name of the service. * * @param[in] aService A pointer to the SRP service. * @@ -626,7 +626,7 @@ const char *otSrpServerServiceGetFullName(const otSrpServerService *aService); const char *otSrpServerServiceGetInstanceName(const otSrpServerService *aService); /** - * This function returns the full service name of the service. + * Returns the full service name of the service. * * @param[in] aService A pointer to the SRP service. * @@ -636,9 +636,9 @@ const char *otSrpServerServiceGetInstanceName(const otSrpServerService *aService const char *otSrpServerServiceGetServiceName(const otSrpServerService *aService); /** - * This function gets the sub-type label from service name. + * Gets the sub-type label from service name. * - * This function is intended to be used when the @p aService is a sub-type, i.e., `otSrpServerServiceIsSubType()` for + * Is intended to be used when the @p aService is a sub-type, i.e., `otSrpServerServiceIsSubType()` for * the service returns TRUE. If it is not a sub-type this function returns `OT_ERROR_INVALID_ARGS`. * * The full service name for a sub-type service follows "._sub...". This function @@ -659,7 +659,7 @@ const char *otSrpServerServiceGetServiceName(const otSrpServerService *aService) otError otSrpServerServiceGetServiceSubTypeLabel(const otSrpServerService *aService, char *aLabel, uint8_t aMaxSize); /** - * This function returns the port of the service instance. + * Returns the port of the service instance. * * @param[in] aService A pointer to the SRP service. * @@ -669,7 +669,7 @@ otError otSrpServerServiceGetServiceSubTypeLabel(const otSrpServerService *aServ uint16_t otSrpServerServiceGetPort(const otSrpServerService *aService); /** - * This function returns the weight of the service instance. + * Returns the weight of the service instance. * * @param[in] aService A pointer to the SRP service. * @@ -679,7 +679,7 @@ uint16_t otSrpServerServiceGetPort(const otSrpServerService *aService); uint16_t otSrpServerServiceGetWeight(const otSrpServerService *aService); /** - * This function returns the priority of the service instance. + * Returns the priority of the service instance. * * @param[in] aService A pointer to the SRP service. * @@ -689,7 +689,7 @@ uint16_t otSrpServerServiceGetWeight(const otSrpServerService *aService); uint16_t otSrpServerServiceGetPriority(const otSrpServerService *aService); /** - * This function returns the TTL of the service instance. + * Returns the TTL of the service instance. * * @param[in] aService A pointer to the SRP service. * @@ -699,7 +699,7 @@ uint16_t otSrpServerServiceGetPriority(const otSrpServerService *aService); uint32_t otSrpServerServiceGetTtl(const otSrpServerService *aService); /** - * This function returns the TXT record data of the service instance. + * Returns the TXT record data of the service instance. * * @param[in] aService A pointer to the SRP service. * @param[out] aDataLength A pointer to return the TXT record data length. MUST NOT be NULL. @@ -710,7 +710,7 @@ uint32_t otSrpServerServiceGetTtl(const otSrpServerService *aService); const uint8_t *otSrpServerServiceGetTxtData(const otSrpServerService *aService, uint16_t *aDataLength); /** - * This function returns the host which the service instance reside on. + * Returns the host which the service instance reside on. * * @param[in] aService A pointer to the SRP service. * @@ -720,7 +720,7 @@ const uint8_t *otSrpServerServiceGetTxtData(const otSrpServerService *aService, const otSrpServerHost *otSrpServerServiceGetHost(const otSrpServerService *aService); /** - * This function returns the LEASE and KEY-LEASE information of a given service. + * Returns the LEASE and KEY-LEASE information of a given service. * * @param[in] aService A pointer to the SRP server service. * @param[out] aLeaseInfo A pointer to where to output the LEASE and KEY-LEASE information. diff --git a/include/openthread/tcp.h b/include/openthread/tcp.h index 3b63bc359c5..bbcd0ac070b 100644 --- a/include/openthread/tcp.h +++ b/include/openthread/tcp.h @@ -229,7 +229,7 @@ typedef void (*otTcpDisconnected)(otTcpEndpoint *aEndpoint, otTcpDisconnectedRea #define OT_TCP_ENDPOINT_TCB_NUM_PTR 36 /** - * This structure represents a TCP endpoint. + * Represents a TCP endpoint. * * An TCP endpoint acts an endpoint of TCP connection. It can be used to * initiate TCP connections, and, once a TCP connection is established, send @@ -266,7 +266,7 @@ struct otTcpEndpoint }; /** - * This structure contains arguments to the otTcpEndpointInitialize() function. + * Contains arguments to the otTcpEndpointInitialize() function. * */ typedef struct otTcpEndpointInitializeArgs @@ -390,7 +390,7 @@ const otSockAddr *otTcpGetPeerAddress(const otTcpEndpoint *aEndpoint); otError otTcpBind(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName); /** - * This enumeration defines flags passed to otTcpConnect(). + * Defines flags passed to otTcpConnect(). * */ enum @@ -418,7 +418,7 @@ enum otError otTcpConnect(otTcpEndpoint *aEndpoint, const otSockAddr *aSockName, uint32_t aFlags); /** - * This enumeration defines flags passed to @p otTcpSendByReference. + * Defines flags passed to @p otTcpSendByReference. * */ enum @@ -582,7 +582,7 @@ struct otTcpListener; typedef struct otTcpListener otTcpListener; /** - * This enumeration defines incoming connection actions. + * Defines incoming connection actions. * * This is used in otTcpAcceptReady() callback. * @@ -656,7 +656,7 @@ typedef void (*otTcpAcceptDone)(otTcpListener *aListener, otTcpEndpoint *aEndpoi #define OT_TCP_LISTENER_TCB_NUM_PTR 3 /** - * This structure represents a TCP listener. + * Represents a TCP listener. * * A TCP listener is used to listen for and accept incoming TCP connections. * @@ -681,7 +681,7 @@ struct otTcpListener }; /** - * This structure contains arguments to the otTcpListenerInitialize() function. + * Contains arguments to the otTcpListenerInitialize() function. * */ typedef struct otTcpListenerInitializeArgs diff --git a/include/openthread/tcp_ext.h b/include/openthread/tcp_ext.h index 0258ac28bf8..9ac705b9f18 100644 --- a/include/openthread/tcp_ext.h +++ b/include/openthread/tcp_ext.h @@ -53,7 +53,7 @@ extern "C" { */ /** - * This structure represents a circular send buffer for use with a TCP endpoint. + * Represents a circular send buffer for use with a TCP endpoint. * * Using a circular send buffer is optional. Applications can use a TCP * endpoint to send data by managing otLinkedBuffers directly. However, some @@ -108,7 +108,7 @@ typedef struct otTcpCircularSendBuffer void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, void *aDataBuffer, size_t aCapacity); /** - * This enumeration defines flags passed to @p otTcpCircularSendBufferWrite. + * Defines flags passed to @p otTcpCircularSendBufferWrite. * */ enum diff --git a/include/openthread/thread.h b/include/openthread/thread.h index 4bde02c140d..47cd7865b13 100644 --- a/include/openthread/thread.h +++ b/include/openthread/thread.h @@ -74,7 +74,7 @@ typedef enum } otDeviceRole; /** - * This structure represents an MLE Link Mode configuration. + * Represents an MLE Link Mode configuration. */ typedef struct otLinkModeConfig { @@ -84,7 +84,7 @@ typedef struct otLinkModeConfig } otLinkModeConfig; /** - * This structure holds diagnostic information for a neighboring Thread node + * Holds diagnostic information for a neighboring Thread node * */ typedef struct @@ -113,7 +113,7 @@ typedef struct typedef int16_t otNeighborInfoIterator; ///< Used to iterate through neighbor table. /** - * This structure represents the Thread Leader Data. + * Represents the Thread Leader Data. * */ typedef struct otLeaderData @@ -126,7 +126,7 @@ typedef struct otLeaderData } otLeaderData; /** - * This structure holds diagnostic information for a Thread Router + * Holds diagnostic information for a Thread Router * */ typedef struct @@ -152,7 +152,7 @@ typedef struct } otRouterInfo; /** - * This structure represents the IP level counters. + * Represents the IP level counters. * */ typedef struct otIpCounters @@ -164,7 +164,7 @@ typedef struct otIpCounters } otIpCounters; /** - * This structure represents the Thread MLE counters. + * Represents the Thread MLE counters. * */ typedef struct otMleCounters @@ -203,7 +203,7 @@ typedef struct otMleCounters } otMleCounters; /** - * This structure represents the MLE Parent Response data. + * Represents the MLE Parent Response data. * */ typedef struct otThreadParentResponseInfo @@ -227,7 +227,7 @@ typedef struct otThreadParentResponseInfo typedef void (*otDetachGracefullyCallback)(void *aContext); /** - * This function starts Thread protocol operation. + * Starts Thread protocol operation. * * The interface must be up when calling this function. * @@ -244,7 +244,7 @@ typedef void (*otDetachGracefullyCallback)(void *aContext); otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled); /** - * This function gets the Thread protocol version. + * Gets the Thread protocol version. * * @returns the Thread protocol version. * @@ -252,7 +252,7 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled); uint16_t otThreadGetVersion(void); /** - * This function indicates whether a node is the only router on the network. + * Indicates whether a node is the only router on the network. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -263,7 +263,7 @@ uint16_t otThreadGetVersion(void); bool otThreadIsSingleton(otInstance *aInstance); /** - * This function starts a Thread Discovery scan. + * Starts a Thread Discovery scan. * * @note A successful call to this function enables the rx-on-when-idle mode for the entire scan procedure. * @@ -291,7 +291,7 @@ otError otThreadDiscover(otInstance *aInstance, void *aCallbackContext); /** - * This function determines if an MLE Thread Discovery is currently in progress. + * Determines if an MLE Thread Discovery is currently in progress. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -299,7 +299,7 @@ otError otThreadDiscover(otInstance *aInstance, bool otThreadIsDiscoverInProgress(otInstance *aInstance); /** - * This method sets the Thread Joiner Advertisement when discovering Thread network. + * Sets the Thread Joiner Advertisement when discovering Thread network. * * Thread Joiner Advertisement is used to allow a Joiner to advertise its own application-specific information * (such as Vendor ID, Product ID, Discriminator, etc.) via a newly-proposed Joiner Advertisement TLV, @@ -376,7 +376,7 @@ const otExtendedPanId *otThreadGetExtendedPanId(otInstance *aInstance); otError otThreadSetExtendedPanId(otInstance *aInstance, const otExtendedPanId *aExtendedPanId); /** - * This function returns a pointer to the Leader's RLOC. + * Returns a pointer to the Leader's RLOC. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aLeaderRloc A pointer to the Leader's RLOC. @@ -427,7 +427,7 @@ void otThreadGetNetworkKey(otInstance *aInstance, otNetworkKey *aNetworkKey); /** * Get the `otNetworkKeyRef` for Thread Network Key. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + * Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -441,7 +441,7 @@ otNetworkKeyRef otThreadGetNetworkKeyRef(otInstance *aInstance); /** * Set the Thread Network Key. * - * This function succeeds only when Thread protocols are disabled. A successful + * Succeeds only when Thread protocols are disabled. A successful * call to this function invalidates the Active and Pending Operational Datasets in * non-volatile memory. * @@ -459,11 +459,11 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey); /** * Set the Thread Network Key as a `otNetworkKeyRef`. * - * This function succeeds only when Thread protocols are disabled. A successful + * Succeeds only when Thread protocols are disabled. A successful * call to this function invalidates the Active and Pending Operational Datasets in * non-volatile memory. * - * This function requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + * Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aKeyRef Reference to the Thread Network Key. @@ -497,7 +497,7 @@ const otIp6Address *otThreadGetRloc(otInstance *aInstance); const otIp6Address *otThreadGetMeshLocalEid(otInstance *aInstance); /** - * This function returns a pointer to the Mesh Local Prefix. + * Returns a pointer to the Mesh Local Prefix. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -507,9 +507,9 @@ const otIp6Address *otThreadGetMeshLocalEid(otInstance *aInstance); const otMeshLocalPrefix *otThreadGetMeshLocalPrefix(otInstance *aInstance); /** - * This function sets the Mesh Local Prefix. + * Sets the Mesh Local Prefix. * - * This function succeeds only when Thread protocols are disabled. A successful + * Succeeds only when Thread protocols are disabled. A successful * call to this function invalidates the Active and Pending Operational Datasets in * non-volatile memory. * @@ -569,7 +569,7 @@ const otIp6Address *otThreadGetLinkLocalAllThreadNodesMulticastAddress(otInstanc const otIp6Address *otThreadGetRealmLocalAllThreadNodesMulticastAddress(otInstance *aInstance); /** - * This function retrieves the Service ALOC for given Service ID. + * Retrieves the Service ALOC for given Service ID. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aServiceId Service ID to get ALOC for. @@ -595,7 +595,7 @@ const char *otThreadGetNetworkName(otInstance *aInstance); /** * Set the Thread Network Name. * - * This function succeeds only when Thread protocols are disabled. A successful + * Succeeds only when Thread protocols are disabled. A successful * call to this function invalidates the Active and Pending Operational Datasets in * non-volatile memory. * @@ -751,7 +751,7 @@ otError otThreadBecomeDetached(otInstance *aInstance); otError otThreadBecomeChild(otInstance *aInstance); /** - * This function gets the next neighbor information. It is used to go through the entries of + * Gets the next neighbor information. It is used to go through the entries of * the neighbor table. * * @param[in] aInstance A pointer to an OpenThread instance. @@ -791,7 +791,7 @@ otDeviceRole otThreadGetDeviceRole(otInstance *aInstance); const char *otThreadDeviceRoleToString(otDeviceRole aRole); /** - * This function get the Thread Leader Data. + * Get the Thread Leader Data. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aLeaderData A pointer to where the leader data is placed. @@ -921,7 +921,7 @@ const otMleCounters *otThreadGetMleCounters(otInstance *aInstance); void otThreadResetMleCounters(otInstance *aInstance); /** - * This function pointer is called every time an MLE Parent Response message is received. + * Pointer is called every time an MLE Parent Response message is received. * * This is used in `otThreadRegisterParentResponseCallback()`. * @@ -932,9 +932,9 @@ void otThreadResetMleCounters(otInstance *aInstance); typedef void (*otThreadParentResponseCallback)(otThreadParentResponseInfo *aInfo, void *aContext); /** - * This function registers a callback to receive MLE Parent Response data. + * Registers a callback to receive MLE Parent Response data. * - * This function requires `OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE`. + * 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. @@ -946,7 +946,7 @@ void otThreadRegisterParentResponseCallback(otInstance *aInst void *aContext); /** - * This structure represents the Thread Discovery Request data. + * Represents the Thread Discovery Request data. * */ typedef struct otThreadDiscoveryRequestInfo @@ -957,7 +957,7 @@ typedef struct otThreadDiscoveryRequestInfo } otThreadDiscoveryRequestInfo; /** - * This function pointer is called every time an MLE Discovery Request message is received. + * Pointer is called every time an MLE Discovery Request message is received. * * @param[in] aInfo A pointer to the Discovery Request info data. * @param[in] aContext A pointer to callback application-specific context. @@ -966,7 +966,7 @@ typedef struct otThreadDiscoveryRequestInfo typedef void (*otThreadDiscoveryRequestCallback)(const otThreadDiscoveryRequestInfo *aInfo, void *aContext); /** - * This function sets a callback to receive MLE Discovery Request data. + * Sets a callback to receive MLE Discovery Request data. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aCallback A pointer to a function that is called upon receiving an MLE Discovery Request message. @@ -978,7 +978,7 @@ void otThreadSetDiscoveryRequestCallback(otInstance *aInsta void *aContext); /** - * This function pointer type defines the callback to notify the outcome of a `otThreadLocateAnycastDestination()` + * Pointer type defines the callback to notify the outcome of a `otThreadLocateAnycastDestination()` * request. * * @param[in] aContext A pointer to an arbitrary context (provided when callback is registered). @@ -996,9 +996,9 @@ typedef void (*otThreadAnycastLocatorCallback)(void *aContext, uint16_t aRloc16); /** - * This function requests the closest destination of a given anycast address to be located. + * Requests the closest destination of a given anycast address to be located. * - * This function is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. + * Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. * * If a previous request is ongoing, a subsequent call to this function will cancel and replace the earlier request. * @@ -1018,9 +1018,9 @@ otError otThreadLocateAnycastDestination(otInstance *aInstanc void *aContext); /** - * This function indicates whether an anycast locate request is currently in progress. + * Indicates whether an anycast locate request is currently in progress. * - * This function is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. + * Is only available when `OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE` is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -1030,9 +1030,9 @@ otError otThreadLocateAnycastDestination(otInstance *aInstanc bool otThreadIsAnycastLocateInProgress(otInstance *aInstance); /** - * This function sends a Proactive Address Notification (ADDR_NTF.ntf) message. + * Sends a Proactive Address Notification (ADDR_NTF.ntf) message. * - * This function is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. + * Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDestination The destination to send the ADDR_NTF.ntf message. @@ -1046,9 +1046,9 @@ void otThreadSendAddressNotification(otInstance *aInstance, otIp6InterfaceIdentifier *aMlIid); /** - * This function sends a Proactive Backbone Notification (PRO_BB.ntf) message on the Backbone link. + * Sends a Proactive Backbone Notification (PRO_BB.ntf) message on the Backbone link. * - * This function is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. + * Is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aTarget The target address of the PRO_BB.ntf message. @@ -1065,7 +1065,7 @@ otError otThreadSendProactiveBackboneNotification(otInstance *aIns uint32_t aTimeSinceLastTransaction); /** - * This function notifies other nodes in the network (if any) and then stops Thread protocol operation. + * Notifies other nodes in the network (if any) and then stops Thread protocol operation. * * It sends an Address Release if it's a router, or sets its child timeout to 0 if it's a child. * @@ -1082,9 +1082,9 @@ otError otThreadDetachGracefully(otInstance *aInstance, otDetachGracefullyCallba #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. + * Converts an `uint32_t` duration (in seconds) to a human-readable string. * - * This function requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + * 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). @@ -1092,7 +1092,7 @@ otError otThreadDetachGracefully(otInstance *aInstance, otDetachGracefullyCallba * 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. + * 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. diff --git a/include/openthread/thread_ftd.h b/include/openthread/thread_ftd.h index f2b0db5d958..3776e1d7d7e 100644 --- a/include/openthread/thread_ftd.h +++ b/include/openthread/thread_ftd.h @@ -51,7 +51,7 @@ extern "C" { */ /** - * This structure holds diagnostic information for a Thread Child + * Holds diagnostic information for a Thread Child * */ typedef struct @@ -83,7 +83,7 @@ typedef struct typedef uint16_t otChildIp6AddressIterator; ///< Used to iterate through IPv6 addresses of a Thread Child entry. /** - * This enumeration defines the EID cache entry state. + * Defines the EID cache entry state. * */ typedef enum otCacheEntryState @@ -95,7 +95,7 @@ typedef enum otCacheEntryState } otCacheEntryState; /** - * This structure represents an EID cache entry. + * Represents an EID cache entry. * */ typedef struct otCacheEntryInfo @@ -112,7 +112,7 @@ typedef struct otCacheEntryInfo } otCacheEntryInfo; /** - * This type represents an iterator used for iterating through the EID cache table entries. + * Represents an iterator used for iterating through the EID cache table entries. * * To initialize the iterator and start from the first entry in the cache table, set all its fields in the structure to * zero (e.g., `memset` the iterator to zero). @@ -153,7 +153,7 @@ uint16_t otThreadGetMaxAllowedChildren(otInstance *aInstance); otError otThreadSetMaxAllowedChildren(otInstance *aInstance, uint16_t aMaxChildren); /** - * This method indicates whether or not the device is router-eligible. + * Indicates whether or not the device is router-eligible. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -164,7 +164,7 @@ otError otThreadSetMaxAllowedChildren(otInstance *aInstance, uint16_t aMaxChildr bool otThreadIsRouterEligible(otInstance *aInstance); /** - * This function sets whether or not the device is router-eligible. + * Sets whether or not the device is router-eligible. * * If @p aEligible is false and the device is currently operating as a router, this call will cause the device to * detach and attempt to reattach as a child. @@ -198,7 +198,7 @@ otError otThreadSetRouterEligible(otInstance *aInstance, bool aEligible); otError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId); /** - * This enumeration represents the power supply property on a device. + * Represents the power supply property on a device. * * This is used as a property in `otDeviceProperties` to calculate the leader weight. * @@ -212,7 +212,7 @@ typedef enum } otPowerSupply; /** - * This structure represents the device properties which are used for calculating the local leader weight on a + * 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. @@ -236,6 +236,8 @@ typedef struct otDeviceProperties /** * Get the current device properties. * + * Requires `OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1`. + * * @returns The device properties `otDeviceProperties`. * */ @@ -244,6 +246,8 @@ const otDeviceProperties *otThreadGetDeviceProperties(otInstance *aInstance); /** * Set the device properties which are then used to determine and set the Leader Weight. * + * Requires `OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1`. + * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aDeviceProperties The device properties. * @@ -266,7 +270,7 @@ uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance); /** * 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 + * 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. @@ -570,7 +574,7 @@ otError otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChi otError otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo); /** - * This function gets the next IPv6 address (using an iterator) for a given child. + * Gets the next IPv6 address (using an iterator) for a given child. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aChildIndex The child index. @@ -626,7 +630,7 @@ uint8_t otThreadGetMaxRouterId(otInstance *aInstance); otError otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo); /** - * This function gets the next EID cache entry (using an iterator). + * Gets the next EID cache entry (using an iterator). * * @param[in] aInstance A pointer to an OpenThread instance. * @param[out] aEntryInfo A pointer to where the EID cache entry information is placed. @@ -654,7 +658,7 @@ void otThreadGetPskc(otInstance *aInstance, otPskc *aPskc); /** * Get Key Reference to Thread PSKc stored * - * This function requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + * Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -668,7 +672,7 @@ otPskcRef otThreadGetPskcRef(otInstance *aInstance); /** * Set the Thread PSKc * - * This function will only succeed when Thread protocols are disabled. A successful + * Will only succeed when Thread protocols are disabled. A successful * call to this function will also invalidate the Active and Pending Operational Datasets in * non-volatile memory. * @@ -686,9 +690,9 @@ otError otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc); /** * Set the Thread PSKc * - * This function requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. + * Requires the build-time feature `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` to be enabled. * - * This function will only succeed when Thread protocols are disabled. A successful + * Will only succeed when Thread protocols are disabled. A successful * call to this function will also invalidate the Active and Pending Operational Datasets in * non-volatile memory. * @@ -768,7 +772,7 @@ uint8_t otThreadGetMaxChildIpAddresses(otInstance *aInstance); otError otThreadSetMaxChildIpAddresses(otInstance *aInstance, uint8_t aMaxIpAddresses); /** - * This enumeration defines the constants used in `otNeighborTableCallback` to indicate changes in neighbor table. + * Defines the constants used in `otNeighborTableCallback` to indicate changes in neighbor table. * */ typedef enum @@ -781,7 +785,7 @@ typedef enum } otNeighborTableEvent; /** - * This type represent a neighbor table entry info (child or router) and is used as a parameter in the neighbor table + * Represent a neighbor table entry info (child or router) and is used as a parameter in the neighbor table * callback `otNeighborTableCallback`. * */ @@ -796,7 +800,7 @@ typedef struct } otNeighborTableEntryInfo; /** - * This function pointer is called to notify that there is a change in the neighbor table. + * Pointer is called to notify that there is a change in the neighbor table. * * @param[in] aEvent A event flag. * @param[in] aEntryInfo A pointer to table entry info. @@ -805,7 +809,7 @@ typedef struct typedef void (*otNeighborTableCallback)(otNeighborTableEvent aEvent, const otNeighborTableEntryInfo *aEntryInfo); /** - * This function registers a neighbor table callback function. + * Registers a neighbor table callback function. * * The provided callback (if non-NULL) will be invoked when there is a change in the neighbor table (e.g., a child or a * router neighbor entry is being added/removed or an existing child's mode is changed). @@ -820,7 +824,7 @@ typedef void (*otNeighborTableCallback)(otNeighborTableEvent aEvent, const otNei void otThreadRegisterNeighborTableCallback(otInstance *aInstance, otNeighborTableCallback aCallback); /** - * This function sets whether the device was commissioned using CCM. + * Sets whether the device was commissioned using CCM. * * @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used by Thread Test Harness * to indicate whether this device was commissioned using CCM. @@ -832,7 +836,7 @@ void otThreadRegisterNeighborTableCallback(otInstance *aInstance, otNeighborTabl void otThreadSetCcmEnabled(otInstance *aInstance, bool aEnabled); /** - * This function sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled. + * Sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled. * * @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used by Thread Test Harness * to indicate that thread protocol version check VR should be skipped. @@ -844,7 +848,7 @@ void otThreadSetCcmEnabled(otInstance *aInstance, bool aEnabled); void otThreadSetThreadVersionCheckEnabled(otInstance *aInstance, bool aEnabled); /** - * This function gets the range of router IDs that are allowed to assign to nodes within the thread network. + * Gets the range of router IDs that are allowed to assign to nodes within the thread network. * * @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used for test purpose. All the * router IDs in the range [aMinRouterId, aMaxRouterId] are allowed. @@ -859,7 +863,7 @@ void otThreadSetThreadVersionCheckEnabled(otInstance *aInstance, bool aEnabled); void otThreadGetRouterIdRange(otInstance *aInstance, uint8_t *aMinRouterId, uint8_t *aMaxRouterId); /** - * This function sets the range of router IDs that are allowed to assign to nodes within the thread network. + * Sets the range of router IDs that are allowed to assign to nodes within the thread network. * * @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used for test purpose. All the * router IDs in the range [aMinRouterId, aMaxRouterId] are allowed. @@ -877,7 +881,7 @@ 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. + * 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. @@ -889,9 +893,9 @@ otError otThreadSetRouterIdRange(otInstance *aInstance, uint8_t aMinRouterId, ui bool otThreadIsRouterIdAllocated(otInstance *aInstance, uint8_t aRouterId); /** - * This function gets the next hop and path cost towards a given RLOC16 destination. + * 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 + * 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. diff --git a/include/openthread/trel.h b/include/openthread/trel.h index 26373501c42..2358ea26a11 100644 --- a/include/openthread/trel.h +++ b/include/openthread/trel.h @@ -57,7 +57,7 @@ extern "C" { */ /** - * This struct represents a TREL peer. + * Represents a TREL peer. * */ typedef struct otTrelPeer @@ -68,7 +68,7 @@ typedef struct otTrelPeer } otTrelPeer; /** - * This type represents an iterator for iterating over TREL peer table entries. + * Represents an iterator for iterating over TREL peer table entries. * */ typedef uint16_t otTrelPeerIterator; @@ -93,7 +93,7 @@ typedef uint16_t otTrelPeerIterator; void otTrelSetEnabled(otInstance *aInstance, bool aEnable); /** - * This function indicates whether the TREL operation is enabled. + * Indicates whether the TREL operation is enabled. * * @param[in] aInstance The OpenThread instance. * @@ -104,7 +104,7 @@ void otTrelSetEnabled(otInstance *aInstance, bool aEnable); bool otTrelIsEnabled(otInstance *aInstance); /** - * This function initializes a peer table iterator. + * Initializes a peer table iterator. * * @param[in] aInstance The OpenThread instance. * @param[in] aIterator The iterator to initialize. @@ -113,7 +113,7 @@ bool otTrelIsEnabled(otInstance *aInstance); void otTrelInitPeerIterator(otInstance *aInstance, otTrelPeerIterator *aIterator); /** - * This function iterates over the peer table entries and get the next entry from the table + * Iterates over the peer table entries and get the next entry from the table * * @param[in] aInstance The OpenThread instance. * @param[in] aIterator The iterator. MUST be initialized. @@ -124,7 +124,7 @@ void otTrelInitPeerIterator(otInstance *aInstance, otTrelPeerIterator *aIterator const otTrelPeer *otTrelGetNextPeer(otInstance *aInstance, otTrelPeerIterator *aIterator); /** - * This function sets the filter mode (enables/disables filtering). + * Sets the filter mode (enables/disables filtering). * * When filter mode is enabled, any rx and tx traffic through TREL interface is silently dropped. This is mainly * intended for use during testing. @@ -139,7 +139,7 @@ const otTrelPeer *otTrelGetNextPeer(otInstance *aInstance, otTrelPeerIterator *a void otTrelSetFilterEnabled(otInstance *aInstance, bool aEnable); /** - * This function indicates whether or not the filter mode is enabled. + * Indicates whether or not the filter mode is enabled. * * @param[in] aInstance The OpenThread instance. * diff --git a/include/openthread/udp.h b/include/openthread/udp.h index 5a2681320bd..6e577c4a134 100644 --- a/include/openthread/udp.h +++ b/include/openthread/udp.h @@ -63,7 +63,7 @@ extern "C" { typedef bool (*otUdpHandler)(void *aContext, const otMessage *aMessage, const otMessageInfo *aMessageInfo); /** - * This structure represents a UDP receiver. + * Represents a UDP receiver. * */ typedef struct otUdpReceiver @@ -74,7 +74,7 @@ typedef struct otUdpReceiver } otUdpReceiver; /** - * This function adds a UDP receiver. + * Adds a UDP receiver. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aUdpReceiver A pointer to the UDP receiver. @@ -86,7 +86,7 @@ typedef struct otUdpReceiver otError otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver); /** - * This function removes a UDP receiver. + * Removes a UDP receiver. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aUdpReceiver A pointer to the UDP receiver. @@ -98,7 +98,7 @@ otError otUdpAddReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver); otError otUdpRemoveReceiver(otInstance *aInstance, otUdpReceiver *aUdpReceiver); /** - * This function sends a UDP message without socket. + * Sends a UDP message without socket. * * @param[in] aInstance A pointer to an OpenThread instance. * @param[in] aMessage A pointer to a message without UDP header. @@ -117,7 +117,7 @@ otError otUdpSendDatagram(otInstance *aInstance, otMessage *aMessage, otMessageI typedef void (*otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo); /** - * This structure represents a UDP socket. + * Represents a UDP socket. * */ typedef struct otUdpSocket @@ -131,7 +131,7 @@ typedef struct otUdpSocket } otUdpSocket; /** - * This enumeration defines the OpenThread network interface identifiers. + * Defines the OpenThread network interface identifiers. * */ typedef enum otNetifIdentifier @@ -241,7 +241,7 @@ otError otUdpConnect(otInstance *aInstance, otUdpSocket *aSocket, const otSockAd otError otUdpSend(otInstance *aInstance, otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo); /** - * This function gets the head of linked list of UDP Sockets. + * Gets the head of linked list of UDP Sockets. * * @param[in] aInstance A pointer to an OpenThread instance. * @@ -269,7 +269,7 @@ otUdpSocket *otUdpGetSockets(otInstance *aInstance); */ /** - * This function pointer delivers the UDP packet to host and host should send the packet through its own network stack. + * Pointer delivers the UDP packet to host and host should send the packet through its own network stack. * * @param[in] aMessage A pointer to the UDP Message. * @param[in] aPeerPort The destination UDP port. diff --git a/script/check-ncp-rcp-migrate b/script/check-ncp-rcp-migrate deleted file mode 100755 index ce38eb527b9..00000000000 --- a/script/check-ncp-rcp-migrate +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2020, 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 -e -set -x - -at_exit() -{ - EXIT_CODE=$? - - killall expect || true - killall ot-cli-ftd || true - killall ot-cli || true - killall ot-rcp || true - - exit $EXIT_CODE -} - -build() -{ - make -f examples/Makefile-simulation - make -f src/posix/Makefile-posix -} - -check() -{ - trap at_exit INT TERM EXIT - - rm -rf tmp/ - - PANID="0xc001" - EXT_PANID="0123456789abcdef" - NETWORK_NAME="OT_NCP_TO_RCP" - CHANNEL="20" - NETWORK_KEY="0123456789abcdef0123456789abcdef" - - echo "Step 1. Start NCP platform and form a PAN..." - RADIO_NCP_CMD="$PWD/output/simulation/bin/ot-cli-ftd" - - expect <&2 "Unsupported option: $1. Supported: check" + # 128 for Invalid arguments + exit 128 + fi +} + +main "$@" diff --git a/script/make-pretty b/script/make-pretty index 28abdf01461..af73554ced1 100755 --- a/script/make-pretty +++ b/script/make-pretty @@ -93,6 +93,7 @@ OT_CLANG_TIDY_BUILD_OPTS=( '-DOT_BORDER_AGENT=ON' '-DOT_BORDER_ROUTER=ON' '-DOT_BORDER_ROUTING=ON' + '-DOT_BORDER_ROUTING_DHCP6_PD=ON' '-DOT_CHANNEL_MANAGER=ON' '-DOT_CHANNEL_MONITOR=ON' '-DOT_COAP=ON' diff --git a/script/test b/script/test index 7fc0c3ed214..8a237259881 100755 --- a/script/test +++ b/script/test @@ -446,7 +446,7 @@ do_expect() fi fi else - test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp') + test_patterns=(-name 'cli-*.exp' -o -name 'simulation-*.exp' -o -name 'cli_non_rcp-*.exp') fi if [[ $# != 0 ]]; then diff --git a/script/update-makefiles.py b/script/update-makefiles.py index bbaeca43ecc..3b16e4df158 100755 --- a/script/update-makefiles.py +++ b/script/update-makefiles.py @@ -28,7 +28,7 @@ # # This script updates different make/build files (CMakeLists.txt, BUILD.gn, -# Andriod.mk, Andriod.bp, auto-make) in OpenThread repo based on the +# Android.mk, Android.bp, auto-make) in OpenThread repo based on the # current files present in `./src/core/` & `./include/openthread/` # folders. This script MUST be called from openthread root folder. diff --git a/src/cli/BUILD.gn b/src/cli/BUILD.gn index 86e06af7666..fb68e8c8634 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_bbr.cpp", + "cli_bbr.hpp", "cli_br.cpp", "cli_br.hpp", "cli_coap.cpp", @@ -41,10 +43,14 @@ openthread_cli_sources = [ "cli_config.h", "cli_dataset.cpp", "cli_dataset.hpp", + "cli_dns.cpp", + "cli_dns.hpp", "cli_history.cpp", "cli_history.hpp", "cli_joiner.cpp", "cli_joiner.hpp", + "cli_mac_filter.cpp", + "cli_mac_filter.hpp", "cli_network_data.cpp", "cli_network_data.hpp", "cli_output.cpp", diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index d01dc893414..c203c266750 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -33,13 +33,16 @@ set(COMMON_INCLUDES set(COMMON_SOURCES cli.cpp + cli_bbr.cpp cli_br.cpp cli_coap.cpp cli_coap_secure.cpp cli_commissioner.cpp cli_dataset.cpp + cli_dns.cpp cli_history.cpp cli_joiner.cpp + cli_mac_filter.cpp cli_network_data.cpp cli_output.cpp cli_srp_client.cpp diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index 6df2c08e1be..4f8f9fb294b 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -153,13 +153,16 @@ libopenthread_cli_radio_a_CPPFLAGS = \ SOURCES_COMMON = \ cli.cpp \ + cli_bbr.cpp \ cli_br.cpp \ cli_coap.cpp \ cli_coap_secure.cpp \ cli_commissioner.cpp \ cli_dataset.cpp \ + cli_dns.cpp \ cli_history.cpp \ cli_joiner.cpp \ + cli_mac_filter.cpp \ cli_network_data.cpp \ cli_output.cpp \ cli_srp_client.cpp \ @@ -183,14 +186,17 @@ libopenthread_cli_radio_a_SOURCES = \ noinst_HEADERS = \ cli.hpp \ + cli_bbr.hpp \ cli_br.hpp \ cli_coap.hpp \ cli_coap_secure.hpp \ cli_commissioner.hpp \ cli_config.h \ cli_dataset.hpp \ + cli_dns.hpp \ cli_history.hpp \ cli_joiner.hpp \ + cli_mac_filter.hpp \ cli_network_data.hpp \ cli_output.hpp \ cli_srp_client.hpp \ diff --git a/src/cli/README.md b/src/cli/README.md index bdc405b437b..7778fc61988 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -56,6 +56,7 @@ Done - [fem](#fem) - [history](README_HISTORY.md) - [ifconfig](#ifconfig) +- [instanceid](#instanceid) - [ipaddr](#ipaddr) - [ipmaddr](#ipmaddr) - [joiner](README_JOINER.md) @@ -94,6 +95,7 @@ Done - [promiscuous](#promiscuous) - [pskc](#pskc) - [pskcref](#pskcref) +- [radio](#radio-enable) - [radiofilter](#radiofilter) - [rcp](#rcp) - [region](#region) @@ -1269,6 +1271,14 @@ The parameters after `service-name` are optional. Any unspecified (or zero) valu > 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 servicehost \ \ \[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 with a potential follow-up address resolution for the host name discovered for the service instance (if the server/resolver does not provide AAAA/A records for the host name in the response to SRV query). + +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`). + ### dns compression \[enable|disable\] Enable/Disable the "DNS name compression" mode. @@ -1317,7 +1327,7 @@ Done ### dua iid -Get the Interface Identifier mannually specified for Thread Domain Unicast Address on Thread 1.2 device. +Get the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device. ```bash > dua iid @@ -1327,7 +1337,7 @@ Done ### dua iid \ -Set the Interface Identifier mannually specified for Thread Domain Unicast Address on Thread 1.2 device. +Set the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device. ```bash > dua iid 0004000300020001 @@ -1336,7 +1346,7 @@ Done ### dua iid clear -Clear the Interface Identifier mannually specified for Thread Domain Unicast Address on Thread 1.2 device. +Clear the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device. ```bash > dua iid clear @@ -1483,6 +1493,16 @@ Bring down the IPv6 interface. Done ``` +### instanceid + +Show OpenThread instance identifier. + +```bash +> instanceid +468697314 +Done +``` + ### ipaddr List all IPv6 addresses assigned to the Thread interface. @@ -1495,7 +1515,7 @@ fe80:0:0:0:f3d9:2a82:c8d8:fe43 Done ``` -Use `-v` to get more verbose informations about the address. +Use `-v` to get more verbose information about the address. ```bash > ipaddr -v @@ -1671,7 +1691,7 @@ Done ### keysequence guardtime \ -Set Thread Key Switch Guard Time (in hours) 0 means Thread Key Switch imediately if key index match +Set Thread Key Switch Guard Time (in hours) 0 means Thread Key Switch immediately if key index match ```bash > keysequence guardtime 0 @@ -2194,14 +2214,14 @@ 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. +- `NotRunning`: NAT64 prefix manager is enabled, but is not running, probably because 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. +- `NotRunning`: NAT64 translator is enabled, but is not translating packets, probably because it is not configured 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. @@ -2677,7 +2697,7 @@ Done ### prefix -Get the prefix list in the local Network Data. Note: For the Thread 1.2 border router with backbone capability, the local Domain Prefix would be listed as well (with flag `D`), with preceeding `-` if backbone functionality is disabled. +Get the prefix list in the local Network Data. Note: For the Thread 1.2 border router with backbone capability, the local Domain Prefix would be listed as well (with flag `D`), with preceding `-` if backbone functionality is disabled. ```bash > prefix @@ -2767,6 +2787,52 @@ Disable radio promiscuous operation. Done ``` +### radio enable + +Enable radio. + +```bash +> radio enable +Done +``` + +### radio disable + +Disable radio. + +```bash +> radio disable +Done +``` + +### radio stats + +`OPENTHREAD_CONFIG_RADIO_STATS_ENABLE` is required. This feature is only available on FTD and MTD. + +The radio statistics shows the time when the radio is in sleep/tx/rx state. The command will show the time of these states since last reset in unit of microseconds. It will also show the percentage of the time. + +```bash +> radio stats +Radio Statistics: +Total Time: 67.756s +Tx Time: 0.022944s (0.03%) +Rx Time: 1.482353s (2.18%) +Sleep Time: 66.251128s (97.77%) +Disabled Time: 0.000080s (0.00%) +Done +``` + +### radio stats clear + +`OPENTHREAD_CONFIG_RADIO_STATS_ENABLE` is required. This feature is only available on FTD and MTD. + +This command resets the radio statistics. It sets all the time to 0. + +```bash +> radio stats clear +Done +``` + ### radiofilter `OPENTHREAD_CONFIG_MAC_FILTER_ENABLE` is required. @@ -3400,8 +3466,6 @@ Done ### vendor name -This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`. - Get the vendor name. ```bash @@ -3419,8 +3483,6 @@ Done ### vendor model -This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`. - Get the vendor model. ```bash @@ -3438,8 +3500,6 @@ Done ### vendor swversion -This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`. - Get the vendor SW version. ```bash @@ -3538,7 +3598,7 @@ Address Mode: Allowlist 0f6127e33af6b402 RssIn List: 0f6127e33af6b403 : rss -95 (lqi 1) -Default rss : -50 (lqi 3) +Default rss: -50 (lqi 3) Done ``` @@ -3583,7 +3643,7 @@ Done ### macfilter addr add \ \[rss\] -Add an IEEE 802.15.4 Extended Address to the address filter, and fixed the received singal strength for the messages from the address if rss is specified. +Add an IEEE 802.15.4 Extended Address to the address filter, and fixed the received signal strength for the messages from the address if rss is specified. ```bash > macfilter addr add 0f6127e33af6b403 -95 diff --git a/src/cli/README_DATASET.md b/src/cli/README_DATASET.md index df1b274c8a1..a1882af407f 100644 --- a/src/cli/README_DATASET.md +++ b/src/cli/README_DATASET.md @@ -392,7 +392,7 @@ Usage: `dataset networkname [name]` Get network name. ```bash -> datset networkname +> dataset networkname OpenThread Done ``` diff --git a/src/cli/README_HISTORY.md b/src/cli/README_HISTORY.md index 268cf7d242d..3fa681a276b 100644 --- a/src/cli/README_HISTORY.md +++ b/src/cli/README_HISTORY.md @@ -475,19 +475,19 @@ Print the latest 5 entries of the IPv6 message RX history as a list: ```bash > history rx list 4 00:00:13.368 - type:UDP len:50 cheksum:0xbd26 sec:no prio:net rss:-20 from:0x4800 radio:15.4 + type:UDP len:50 checksum:0xbd26 sec:no prio:net rss:-20 from:0x4800 radio:15.4 src:[fe80:0:0:0:d03d:d3e7:cc5e:7cd7]:19788 dst:[ff02:0:0:0:0:0:0:1]:19788 00:00:14.991 - type:HopOpts len:44 cheksum:0x0000 sec:yes prio:norm rss:-20 from:0x4800 radio:15.4 + type:HopOpts len:44 checksum:0x0000 sec:yes prio:norm rss:-20 from:0x4800 radio:15.4 src:[fdde:ad00:beef:0:0:ff:fe00:4800]:0 dst:[ff03:0:0:0:0:0:0:2]:0 00:00:15.030 - type:UDP len:12 cheksum:0x3f7d sec:yes prio:net rss:-20 from:0x4800 radio:15.4 + type:UDP len:12 checksum:0x3f7d sec:yes prio:net rss:-20 from:0x4800 radio:15.4 src:[fdde:ad00:beef:0:0:ff:fe00:4800]:61631 dst:[fdde:ad00:beef:0:0:ff:fe00:4801]:61631 00:00:15.032 - type:ICMP6(EchoReqst) len:16 cheksum:0x942c sec:yes prio:norm rss:-20 from:0x4800 radio:15.4 + type:ICMP6(EchoReqst) len:16 checksum:0x942c sec:yes prio:norm rss:-20 from:0x4800 radio:15.4 src:[fdde:ad00:beef:0:ac09:a16b:3204:dc09]:0 dst:[fdde:ad00:beef:0:dc0e:d6b3:f180:b75b]:0 Done @@ -577,23 +577,23 @@ Print the latest 5 entries of the IPv6 message RX history as a list: > history rxtx list 5 00:00:02.100 - type:UDP len:50 cheksum:0xd843 sec:no prio:net rss:-20 from:0x0800 radio:15.4 + type:UDP len:50 checksum:0xd843 sec:no prio:net rss:-20 from:0x0800 radio:15.4 src:[fe80:0:0:0:54d9:5153:ffc6:df26]:19788 dst:[ff02:0:0:0:0:0:0:1]:19788 00:00:15.331 - type:HopOpts len:44 cheksum:0x0000 sec:yes prio:norm rss:-20 from:0x0800 radio:15.4 + type:HopOpts len:44 checksum:0x0000 sec:yes prio:norm rss:-20 from:0x0800 radio:15.4 src:[fdde:ad00:beef:0:0:ff:fe00:800]:0 dst:[ff03:0:0:0:0:0:0:2]:0 00:00:15.354 - type:UDP len:12 cheksum:0x6c6b sec:yes prio:net rss:-20 from:0x0800 radio:15.4 + type:UDP len:12 checksum:0x6c6b sec:yes prio:net rss:-20 from:0x0800 radio:15.4 src:[fdde:ad00:beef:0:0:ff:fe00:800]:61631 dst:[fdde:ad00:beef:0:0:ff:fe00:801]:61631 00:00:15.356 - type:ICMP6(EchoReqst) len:16 cheksum:0xc6a2 sec:yes prio:norm rss:-20 from:0x0800 radio:15.4 + type:ICMP6(EchoReqst) len:16 checksum:0xc6a2 sec:yes prio:norm rss:-20 from:0x0800 radio:15.4 src:[fdde:ad00:beef:0:efe8:4910:cf95:dee9]:0 dst:[fdde:ad00:beef:0:af4c:3644:882a:3698]:0 00:00:15.356 - type:ICMP6(EchoReply) len:16 cheksum:0xc5a2 sec:yes prio:norm tx-success:yes to:0x0800 radio:15.4 + type:ICMP6(EchoReply) len:16 checksum:0xc5a2 sec:yes prio:norm tx-success:yes to:0x0800 radio:15.4 src:[fdde:ad00:beef:0:af4c:3644:882a:3698]:0 dst:[fdde:ad00:beef:0:efe8:4910:cf95:dee9]:0 ``` @@ -633,19 +633,19 @@ Print the IPv6 message TX history as a list: ```bash history tx list 00:00:23.957 - type:ICMP6(EchoReply) len:16 cheksum:0x932c sec:yes prio:norm tx-success:yes to:0x4800 radio:15.4 + type:ICMP6(EchoReply) len:16 checksum:0x932c sec:yes prio:norm tx-success:yes to:0x4800 radio:15.4 src:[fdde:ad00:beef:0:dc0e:d6b3:f180:b75b]:0 dst:[fdde:ad00:beef:0:ac09:a16b:3204:dc09]:0 00:00:23.959 - type:UDP len:50 cheksum:0xce87 sec:yes prio:net tx-success:yes to:0x4800 radio:15.4 + type:UDP len:50 checksum:0xce87 sec:yes prio:net tx-success:yes to:0x4800 radio:15.4 src:[fdde:ad00:beef:0:0:ff:fe00:4801]:61631 dst:[fdde:ad00:beef:0:0:ff:fe00:4800]:61631 00:00:44.658 - type:UDP len:64 cheksum:0xf7ba sec:no prio:net tx-success:yes to:0x4800 radio:15.4 + type:UDP len:64 checksum:0xf7ba sec:no prio:net tx-success:yes to:0x4800 radio:15.4 src:[fe80:0:0:0:a4a5:bbac:a8e:bd07]:19788 dst:[fe80:0:0:0:d03d:d3e7:cc5e:7cd7]:19788 00:00:45.415 - type:UDP len:44 cheksum:0x26d4 sec:no prio:net tx-success:yes to:0xffff radio:15.4 + type:UDP len:44 checksum:0x26d4 sec:no prio:net tx-success:yes to:0xffff radio:15.4 src:[fe80:0:0:0:a4a5:bbac:a8e:bd07]:19788 dst:[ff02:0:0:0:0:0:0:2]:19788 Done diff --git a/src/cli/README_NETDATA.md b/src/cli/README_NETDATA.md index 5fff19f09ea..f41f8998365 100644 --- a/src/cli/README_NETDATA.md +++ b/src/cli/README_NETDATA.md @@ -47,7 +47,7 @@ Border Router and service information may be stable or temporary. Stable Thread Done ``` -4. Observe IPv6 addresses assigned to the Thread inteface. +4. Observe IPv6 addresses assigned to the Thread interface. ```bash > ipaddr @@ -142,6 +142,7 @@ After the device successfully attaches to a Thread network, the device will retr ## Command List - [help](#help) +- [full](#full) - [length](#length) - [maxlength](#maxlength) - [publish](#publish) @@ -160,6 +161,7 @@ Print netdata help menu. ```bash > netdata help +full length maxlength publish @@ -170,6 +172,39 @@ unpublish Done ``` +### full + +Usage: `netdata full` + +Print "yes" or "no" flag tracking whether or not the "net data full" callback has been invoked since start of Thread operation or since the last time `netdata full reset` was used to reset the flag. + +This command requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. + +The "net data full" callback is invoked whenever: + +- The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it cannot add to Network Data (running out of space). +- The device is acting as a BR and new entries cannot be added to its local Network Data. +- The device is acting as a BR and tries to register its local Network Data entries with the leader, but determines that its local entries will not fit. + +``` +> netdata full +no +Done +``` + +### full reset + +Usage: `netdata full reset` + +Reset the flag tracking whether "net data full" callback was invoked. + +This command requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. + +``` +> netdata full reset +Done +``` + ### length Usage: `netdata length` diff --git a/src/cli/README_TCP.md b/src/cli/README_TCP.md index 3869570b814..6281fd88b99 100644 --- a/src/cli/README_TCP.md +++ b/src/cli/README_TCP.md @@ -60,7 +60,7 @@ For a more in-depth example, see [this video](https://youtu.be/ppZ784YUKlI). - [bind](#bind-ip-port) - [connect](#connect-ip-port) - [send](#send-message) -- [benchmark](#benchmark-size) +- [benchmark](#benchmark-run-size) - [sendend](#sendend) - [abort](#abort) - [listen](#listen-ip-port) @@ -78,19 +78,34 @@ TCP: Connection reset Done ``` -### benchmark [\] +### benchmark run [\] Transfers the specified number of bytes using the TCP connection currently associated with the example TCP endpoint (this TCP connection must be established before using this command). - size: the number of bytes to send for the benchmark. If it is left unspecified, the default size is used. ```bash -> tcp benchmark +> tcp benchmark run Done TCP Benchmark Complete: Transferred 73728 bytes in 7233 milliseconds TCP Goodput: 81.546 kb/s ``` +### benchmark result + +Get the last result of TCP benchmark. If the benchmark is ongoing, it will show that benchmark is ongoing. This command is used for test scripts which automate the tcp benchmark test. + +``` +> tcp benchmark result +TCP Benchmark Status: Ongoing +Done + +> tcp benchmark result +TCP Benchmark Status: Completed +TCP Benchmark Complete: Transferred 73728 bytes in 7056 milliseconds +TCP Goodput: 83.592 kb/s +``` + ### bind \ \ Associates a name (i.e. IPv6 address and port) to the example TCP endpoint. diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 8bb1d495092..6c0d6bab504 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -86,7 +86,9 @@ #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE || OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE #include #endif - +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) +#include +#endif #include "common/new.hpp" #include "common/string.hpp" #include "mac/channel_mask.hpp" @@ -109,6 +111,15 @@ Interpreter::Interpreter(Instance *aInstance, otCliOutputCallback aCallback, voi , mDataset(aInstance, *this) , mNetworkData(aInstance, *this) , mUdp(aInstance, *this) +#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE + , mMacFilter(aInstance, *this) +#endif +#if OPENTHREAD_CLI_DNS_ENABLE + , mDns(aInstance, *this) +#endif +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + , mBbr(aInstance, *this) +#endif #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE , mBr(aInstance, *this) #endif @@ -332,7 +343,6 @@ otError Interpreter::SetUserCommands(const otCliCommand *aCommands, uint8_t aLen return error; } -#if OPENTHREAD_FTD || OPENTHREAD_MTD otError Interpreter::ParseEnableOrDisable(const Arg &aArg, bool &aEnable) { otError error = OT_ERROR_NONE; @@ -353,6 +363,8 @@ otError Interpreter::ParseEnableOrDisable(const Arg &aArg, bool &aEnable) return error; } +#if OPENTHREAD_FTD || OPENTHREAD_MTD + otError Interpreter::ParseJoinerDiscerner(Arg &aArg, otJoinerDiscerner &aDiscerner) { otError error; @@ -545,11 +557,50 @@ template <> otError Interpreter::Process(Arg aArgs[]) OutputLine("%s", Stringify(otBorderAgentGetState(GetInstancePtr()), kStateStrings)); } +#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE + /** + * @cli ba id (get,set) + * @code + * ba id + * cb6da1e0c0448aaec39fa90f3d58f45c + * Done + * @endcode + * @code + * ba id 00112233445566778899aabbccddeeff + * Done + * @endcode + * @cparam ba id [@ca{border-agent-id}] + * Use the optional `border-agent-id` argument to set the Border Agent ID. + * @par + * Gets or sets the 16 bytes Border Router ID which can uniquely identifies the device among multiple BRs. + * @sa otBorderAgentGetId + * @sa otBorderAgentSetId + */ + else if (aArgs[0] == "id") + { + otBorderAgentId id; + + if (aArgs[1].IsEmpty()) + { + SuccessOrExit(error = otBorderAgentGetId(GetInstancePtr(), &id)); + OutputBytesLine(id.mId); + } + else + { + uint16_t idLength = sizeof(id); + + SuccessOrExit(error = aArgs[1].ParseAsHexString(idLength, id.mId)); + VerifyOrExit(idLength == sizeof(id), error = OT_ERROR_INVALID_ARGS); + error = otBorderAgentSetId(GetInstancePtr(), &id); + } + } +#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE else { - error = OT_ERROR_INVALID_COMMAND; + ExitNow(error = OT_ERROR_INVALID_COMMAND); } +exit: return error; } #endif // OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE @@ -562,12 +613,12 @@ template <> otError Interpreter::Process(Arg aArgs[]) { return mBr.Pr template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; - bool enable; if (aArgs[0].IsEmpty()) { ExitNow(error = OT_ERROR_INVALID_COMMAND); } + /** * @cli nat64 (enable,disable) * @code @@ -583,9 +634,8 @@ template <> otError Interpreter::Process(Arg aArgs[]) * #otNat64SetEnabled * */ - if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE) + if (ProcessEnableDisable(aArgs, otNat64SetEnabled) == OT_ERROR_NONE) { - otNat64SetEnabled(GetInstancePtr(), enable); } /** * @cli nat64 state @@ -636,25 +686,44 @@ template <> otError Interpreter::Process(Arg aArgs[]) #endif } #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE - /** - * @cli nat64 cidr - * @code - * nat64 cidr - * 192.168.255.0/24 - * Done - * @endcode - * @par api_copy - * #otNat64GetCidr - * - */ else if (aArgs[0] == "cidr") { otIp4Cidr cidr; - char cidrString[OT_IP4_CIDR_STRING_SIZE]; - SuccessOrExit(error = otNat64GetCidr(GetInstancePtr(), &cidr)); - otIp4CidrToString(&cidr, cidrString, sizeof(cidrString)); - OutputLine("%s", cidrString); + /** + * @cli nat64 cidr + * @code + * nat64 cidr + * 192.168.255.0/24 + * Done + * @endcode + * @par api_copy + * #otNat64GetCidr + * + */ + if (aArgs[1].IsEmpty()) + { + char cidrString[OT_IP4_CIDR_STRING_SIZE]; + + SuccessOrExit(error = otNat64GetCidr(GetInstancePtr(), &cidr)); + otIp4CidrToString(&cidr, cidrString, sizeof(cidrString)); + OutputLine("%s", cidrString); + } + /** + * @cli nat64 cidr + * @code + * nat64 cidr 192.168.255.0/24 + * Done + * @endcode + * @par api_copy + * #otPlatNat64SetIp4Cidr + * + */ + else + { + SuccessOrExit(error = otIp4CidrFromString(aArgs[1].GetCString(), &cidr)); + error = otNat64SetIp4Cidr(GetInstancePtr(), &cidr); + } } /** * @cli nat64 mappings @@ -698,9 +767,8 @@ template <> otError Interpreter::Process(Arg aArgs[]) 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; + char ip4AddressString[OT_IP4_ADDRESS_STRING_SIZE]; + char ip6AddressString[OT_IP6_PREFIX_STRING_SIZE]; otIp6AddressToString(&mapping.mIp6, ip6AddressString, sizeof(ip6AddressString)); otIp4AddressToString(&mapping.mIp4, ip4AddressString, sizeof(ip4AddressString)); @@ -710,36 +778,19 @@ template <> otError Interpreter::Process(Arg aArgs[]) 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("|"); + OutputNat64Counters(mapping.mCounters.mTotal); 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("|"); + OutputNat64Counters(mapping.mCounters.mTcp); 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("|"); + OutputNat64Counters(mapping.mCounters.mUdp); 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("|"); + OutputNat64Counters(mapping.mCounters.mIcmp); } } /** @@ -812,28 +863,16 @@ template <> otError Interpreter::Process(Arg aArgs[]) otNat64GetErrorCounters(GetInstancePtr(), &errorCounters); 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)); + OutputNat64Counters(counters.mTotal); 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)); + OutputNat64Counters(counters.mTcp); 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)); + OutputNat64Counters(counters.mUdp); 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)); + OutputNat64Counters(counters.mIcmp); OutputTableHeader(kNat64CounterTableErrorSubHeader, kNat64CounterTableErrorSubHeaderColumns); for (uint8_t i = 0; i < OT_NAT64_DROP_REASON_COUNT; i++) @@ -852,562 +891,178 @@ template <> otError Interpreter::Process(Arg aArgs[]) exit: return error; } + +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE +void Interpreter::OutputNat64Counters(const otNat64Counters &aCounters) +{ + Uint64StringBuffer u64StringBuffer; + + OutputFormat("| %8s ", Uint64ToString(aCounters.m4To6Packets, u64StringBuffer)); + OutputFormat("| %12s ", Uint64ToString(aCounters.m4To6Bytes, u64StringBuffer)); + OutputFormat("| %8s ", Uint64ToString(aCounters.m6To4Packets, u64StringBuffer)); + OutputLine("| %12s |", Uint64ToString(aCounters.m6To4Bytes, u64StringBuffer)); +} +#endif + #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[]) -{ - otError error = OT_ERROR_INVALID_COMMAND; - otBackboneRouterConfig config; +template <> otError Interpreter::Process(Arg aArgs[]) { return mBbr.Process(aArgs); } + +/** + * @cli domainname + * @code + * domainname + * Thread + * Done + * @endcode + * @par api_copy + * #otThreadGetDomainName + */ +template <> otError Interpreter::Process(Arg aArgs[]) +{ /** - * @cli bbr - * @code - * bbr - * BBR Primary: - * server16: 0xE400 - * seqno: 10 - * delay: 120 secs - * timeout: 300 secs - * Done - * @endcode + * @cli domainname (set) * @code - * bbr - * BBR Primary: None + * domainname Test\ Thread * Done * @endcode - * @par - * Returns the current Primary Backbone Router information for the Thread device. + * @cparam domainname @ca{name} + * Use a `backslash` to escape spaces. + * @par api_copy + * #otThreadSetDomainName */ - if (aArgs[0].IsEmpty()) - { - if (otBackboneRouterGetPrimary(GetInstancePtr(), &config) == OT_ERROR_NONE) - { - OutputLine("BBR Primary:"); - OutputLine("server16: 0x%04X", config.mServer16); - OutputLine("seqno: %u", config.mSequenceNumber); - OutputLine("delay: %u secs", config.mReregistrationDelay); - OutputLine("timeout: %lu secs", ToUlong(config.mMlrTimeout)); - } - else - { - OutputLine("BBR Primary: None"); - } - - error = OT_ERROR_NONE; - } -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE - else - { - if (aArgs[0] == "mgmt") - { - if (aArgs[1].IsEmpty()) - { - 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; - otIp6InterfaceIdentifier *mlIid = nullptr; - otIp6InterfaceIdentifier iid; - - SuccessOrExit(error = aArgs[2].ParseAsUint8(status)); - - if (!aArgs[3].IsEmpty()) - { - SuccessOrExit(error = aArgs[3].ParseAsHexString(iid.mFields.m8)); - mlIid = &iid; - VerifyOrExit(aArgs[4].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - } - - otBackboneRouterConfigNextDuaRegistrationResponse(GetInstancePtr(), mlIid, status); - ExitNow(); - } -#endif -#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE - else if (aArgs[1] == "mlr") - { - error = ProcessBackboneRouterMgmtMlr(aArgs + 2); - ExitNow(); - } -#endif - } - SuccessOrExit(error = ProcessBackboneRouterLocal(aArgs)); - } - -exit: -#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE - return error; + return ProcessGetSet(aArgs, otThreadGetDomainName, otThreadSetDomainName); } -#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE - -#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE -otError Interpreter::ProcessBackboneRouterMgmtMlr(Arg aArgs[]) +#if OPENTHREAD_CONFIG_DUA_ENABLE +template <> otError Interpreter::Process(Arg aArgs[]) { - otError error = OT_ERROR_INVALID_COMMAND; + otError error = OT_ERROR_NONE; /** - * @cli bbr mgmt mlr listener + * @cli dua iid * @code - * bbr mgmt mlr listener - * ff04:0:0:0:0:0:0:abcd 3534000 - * ff04:0:0:0:0:0:0:eeee 3537610 + * dua iid + * 0004000300020001 * 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 + * @par api_copy + * #otThreadGetFixedDuaInterfaceIdentifier */ - if (aArgs[0] == "listener") + if (aArgs[0] == "iid") { if (aArgs[1].IsEmpty()) { - PrintMulticastListenersTable(); - ExitNow(error = OT_ERROR_NONE); - } + const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(GetInstancePtr()); -#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; + if (iid != nullptr) + { + OutputBytesLine(iid->mFields.m8); + } } /** - * @cli bbr mgmt mlr listener add + * @cli dua iid (set,clear) * @code - * bbr mgmt mlr listener add ff04::1 + * dua iid 0004000300020001 * Done * @endcode * @code - * bbr mgmt mlr listener add ff04::2 300 + * dua iid clear * Done * @endcode - * @cparam bbr mgmt mlr listener add @ca{ipaddress} [@ca{timeout-seconds}] + * @cparam dua iid @ca{iid|clear} + * `dua iid clear` passes a `nullptr` to #otThreadSetFixedDuaInterfaceIdentifier. + * Otherwise, you can pass the `iid`. * @par api_copy - * #otBackboneRouterMulticastListenerAdd + * #otThreadSetFixedDuaInterfaceIdentifier */ - else if (aArgs[1] == "add") + else if (aArgs[1] == "clear") { - otIp6Address address; - uint32_t timeout = 0; - - SuccessOrExit(error = aArgs[2].ParseAsIp6Address(address)); - - if (!aArgs[3].IsEmpty()) - { - SuccessOrExit(error = aArgs[3].ParseAsUint32(timeout)); - VerifyOrExit(aArgs[4].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - } + error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), nullptr); + } + else + { + otIp6InterfaceIdentifier iid; - error = otBackboneRouterMulticastListenerAdd(GetInstancePtr(), &address, timeout); + SuccessOrExit(error = aArgs[1].ParseAsHexString(iid.mFields.m8)); + error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), &iid); } } - /** - * @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") + else { - error = ProcessSet(aArgs + 1, otBackboneRouterConfigNextMulticastListenerRegistrationResponse); -#endif + error = OT_ERROR_INVALID_COMMAND; } exit: return error; } +#endif // OPENTHREAD_CONFIG_DUA_ENABLE + +#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) -void Interpreter::PrintMulticastListenersTable(void) +/** + * @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[]) { - otBackboneRouterMulticastListenerIterator iter = OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ITERATOR_INIT; - otBackboneRouterMulticastListenerInfo listenerInfo; + struct BufferInfoName + { + const otMessageQueueInfo otBufferInfo::*mQueuePtr; + const char *mName; + }; + + static const BufferInfoName kBufferInfoNames[] = { + {&otBufferInfo::m6loSendQueue, "6lo send"}, + {&otBufferInfo::m6loReassemblyQueue, "6lo reas"}, + {&otBufferInfo::mIp6Queue, "ip6"}, + {&otBufferInfo::mMplQueue, "mpl"}, + {&otBufferInfo::mMleQueue, "mle"}, + {&otBufferInfo::mCoapQueue, "coap"}, + {&otBufferInfo::mCoapSecureQueue, "coap secure"}, + {&otBufferInfo::mApplicationCoapQueue, "application coap"}, + }; - while (otBackboneRouterMulticastListenerGetNext(GetInstancePtr(), &iter, &listenerInfo) == OT_ERROR_NONE) + otError error = OT_ERROR_NONE; + + if (aArgs[0].IsEmpty()) { - OutputIp6Address(listenerInfo.mAddress); - OutputLine(" %lu", ToUlong(listenerInfo.mTimeout)); - } -} + otBufferInfo bufferInfo; -#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE + otMessageGetBufferInfo(GetInstancePtr(), &bufferInfo); -otError Interpreter::ProcessBackboneRouterLocal(Arg aArgs[]) -{ - otError error = OT_ERROR_NONE; - 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[] = { - "Disabled", // (0) OT_BACKBONE_ROUTER_STATE_DISABLED - "Secondary", // (1) OT_BACKBONE_ROUTER_STATE_SECONDARY - "Primary", // (2) OT_BACKBONE_ROUTER_STATE_PRIMARY - }; - - static_assert(0 == OT_BACKBONE_ROUTER_STATE_DISABLED, "OT_BACKBONE_ROUTER_STATE_DISABLED value is incorrect"); - static_assert(1 == OT_BACKBONE_ROUTER_STATE_SECONDARY, "OT_BACKBONE_ROUTER_STATE_SECONDARY value is incorrect"); - static_assert(2 == OT_BACKBONE_ROUTER_STATE_PRIMARY, "OT_BACKBONE_ROUTER_STATE_PRIMARY value is incorrect"); - - 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: %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") - { - arg++; - SuccessOrExit(error = arg->ParseAsUint8(config.mSequenceNumber)); - } - else if (*arg == "delay") - { - arg++; - SuccessOrExit(error = arg->ParseAsUint16(config.mReregistrationDelay)); - } - else if (*arg == "timeout") - { - arg++; - SuccessOrExit(error = arg->ParseAsUint32(config.mMlrTimeout)); - } - else - { - ExitNow(error = OT_ERROR_INVALID_ARGS); - } - } - - SuccessOrExit(error = otBackboneRouterSetConfig(GetInstancePtr(), &config)); - } - } - else - { - error = OT_ERROR_INVALID_COMMAND; - } - -exit: - return error; -} -#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[]) -{ - /** - * @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 -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()) - { - const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(GetInstancePtr()); - - if (iid != nullptr) - { - 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); - } - else - { - otIp6InterfaceIdentifier iid; - - SuccessOrExit(error = aArgs[1].ParseAsHexString(iid.mFields.m8)); - error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), &iid); - } - } - else - { - error = OT_ERROR_INVALID_COMMAND; - } - -exit: - return error; -} -#endif // OPENTHREAD_CONFIG_DUA_ENABLE - -#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[]) -{ - struct BufferInfoName - { - const otMessageQueueInfo otBufferInfo::*mQueuePtr; - const char *mName; - }; - - static const BufferInfoName kBufferInfoNames[] = { - {&otBufferInfo::m6loSendQueue, "6lo send"}, - {&otBufferInfo::m6loReassemblyQueue, "6lo reas"}, - {&otBufferInfo::mIp6Queue, "ip6"}, - {&otBufferInfo::mMplQueue, "mpl"}, - {&otBufferInfo::mMleQueue, "mle"}, - {&otBufferInfo::mCoapQueue, "coap"}, - {&otBufferInfo::mCoapSecureQueue, "coap secure"}, - {&otBufferInfo::mApplicationCoapQueue, "application coap"}, - }; - - otError error = OT_ERROR_NONE; - - if (aArgs[0].IsEmpty()) - { - otBufferInfo bufferInfo; - - otMessageGetBufferInfo(GetInstancePtr(), &bufferInfo); - - OutputLine("total: %u", bufferInfo.mTotalBuffers); - OutputLine("free: %u", bufferInfo.mFreeBuffers); - OutputLine("max-used: %u", bufferInfo.mMaxUsedBuffers); + OutputLine("total: %u", bufferInfo.mTotalBuffers); + OutputLine("free: %u", bufferInfo.mFreeBuffers); + OutputLine("max-used: %u", bufferInfo.mMaxUsedBuffers); for (const BufferInfoName &info : kBufferInfoNames) { @@ -1478,32 +1133,13 @@ template <> otError Interpreter::Process(Arg aArgs[]) #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE template <> otError Interpreter::Process(Arg aArgs[]) { - otError error = OT_ERROR_NONE; - bool enable; - - VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_COMMAND); - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[0], enable)); - otThreadSetCcmEnabled(GetInstancePtr(), enable); - -exit: - return error; -} + return ProcessEnableDisable(aArgs, otThreadSetCcmEnabled); +} template <> otError Interpreter::Process(Arg aArgs[]) { - otError error = OT_ERROR_NONE; - bool enable; - - VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_COMMAND); - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[0], enable)); - otThreadSetThreadVersionCheckEnabled(GetInstancePtr(), enable); - -exit: - return error; + return ProcessEnableDisable(aArgs, otThreadSetThreadVersionCheckEnabled); } - #endif /** @@ -2205,15 +1841,9 @@ template <> otError Interpreter::Process(Arg aArgs[]) { return mCo template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; - bool enable; - if (aArgs[0].IsEmpty()) + if (ProcessEnableDisable(aArgs, otPlatRadioIsCoexEnabled, otPlatRadioSetCoexEnabled) == OT_ERROR_NONE) { - OutputEnabledDisabledStatus(otPlatRadioIsCoexEnabled(GetInstancePtr())); - } - else if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE) - { - error = otPlatRadioSetCoexEnabled(GetInstancePtr(), enable); } else if (aArgs[0] == "metrics") { @@ -2789,587 +2419,19 @@ template <> otError Interpreter::Process(Arg aArgs[]) /** * @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; - SuccessOrExit(error = aArgs[0].ParseAsUint32(delay)); - SuccessOrExit(error = otDatasetSetDelayTimerMinimal(GetInstancePtr(), static_cast(delay * 1000))); - } - else - { - error = OT_ERROR_INVALID_ARGS; - } - -exit: - return error; -} -#endif - -template <> otError Interpreter::Process(Arg aArgs[]) -{ - otError error = OT_ERROR_NONE; - - if (aArgs[0] == "async") - { - SuccessOrExit(error = otThreadDetachGracefully(GetInstancePtr(), nullptr, nullptr)); - } - else - { - SuccessOrExit(error = - otThreadDetachGracefully(GetInstancePtr(), &Interpreter::HandleDetachGracefullyResult, this)); - error = OT_ERROR_PENDING; - } - -exit: - 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; - - SuccessOrExit(error = aArgs[0].ParseAsUint8(channel)); - VerifyOrExit(channel < sizeof(scanChannels) * CHAR_BIT, error = OT_ERROR_INVALID_ARGS); - scanChannels = 1 << channel; - } - - SuccessOrExit(error = otThreadDiscover(GetInstancePtr(), scanChannels, OT_PANID_BROADCAST, false, false, - &Interpreter::HandleActiveScanResult, this)); - - static const char *const kScanTableTitles[] = { - "Network Name", "Extended PAN", "PAN", "MAC Address", "Ch", "dBm", "LQI", - }; - - static const uint8_t kScanTableColumnWidths[] = { - 18, 18, 6, 18, 4, 5, 5, - }; - - OutputTableHeader(kScanTableTitles, kScanTableColumnWidths); - - error = OT_ERROR_PENDING; - -exit: - return error; -} - -template <> otError Interpreter::Process(Arg aArgs[]) -{ - OT_UNUSED_VARIABLE(aArgs); - - otError error = OT_ERROR_NONE; -#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE - otDnsQueryConfig queryConfig; - otDnsQueryConfig *config = &queryConfig; -#endif - - if (aArgs[0].IsEmpty()) - { - 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()); - } - else - { - bool enable; - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[1], enable)); - otDnsSetNameCompressionEnabled(enable); - } - } -#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: %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); - SuccessOrExit(error = GetDnsConfig(aArgs + 2, config)); - SuccessOrExit(error = otDnsClientResolveAddress(GetInstancePtr(), aArgs[1].GetCString(), - &Interpreter::HandleDnsAddressResponse, this, config)); - error = OT_ERROR_PENDING; - } -#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE - else if (aArgs[0] == "resolve4") - { - VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - SuccessOrExit(error = GetDnsConfig(aArgs + 2, config)); - SuccessOrExit(error = otDnsClientResolveIp4Address(GetInstancePtr(), aArgs[1].GetCString(), - &Interpreter::HandleDnsAddressResponse, this, config)); - error = OT_ERROR_PENDING; - } -#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); - SuccessOrExit(error = GetDnsConfig(aArgs + 2, config)); - SuccessOrExit(error = otDnsClientBrowse(GetInstancePtr(), aArgs[1].GetCString(), - &Interpreter::HandleDnsBrowseResponse, this, config)); - error = OT_ERROR_PENDING; - } - /** - * @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); - } - -exit: - return error; -} - -#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 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 = 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)); - - VerifyOrExit(!aArgs[2].IsEmpty()); - SuccessOrExit(error = aArgs[2].ParseAsUint32(aConfig->mResponseTimeout)); - - VerifyOrExit(!aArgs[3].IsEmpty()); - SuccessOrExit(error = aArgs[3].ParseAsUint8(aConfig->mMaxTxAttempts)); - - VerifyOrExit(!aArgs[4].IsEmpty()); - 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") + * delaytimermin 60 + * Done + * @endcode + * @cparam delaytimermin @ca{delaytimermin} + * @par + * Sets the minimal delay timer (in seconds). + * @sa otDatasetSetDelayTimerMinimal + */ + else if (aArgs[1].IsEmpty()) { - aConfig->mTransportProto = OT_DNS_TRANSPORT_UDP; + uint32_t delay; + SuccessOrExit(error = aArgs[0].ParseAsUint32(delay)); + SuccessOrExit(error = otDatasetSetDelayTimerMinimal(GetInstancePtr(), static_cast(delay * 1000))); } else { @@ -3379,160 +2441,128 @@ otError Interpreter::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig) exit: return error; } +#endif -void Interpreter::HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse, void *aContext) -{ - static_cast(aContext)->HandleDnsAddressResponse(aError, aResponse); -} - -void Interpreter::HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse) -{ - char hostName[OT_DNS_MAX_NAME_SIZE]; - otIp6Address address; - uint32_t ttl; - - IgnoreError(otDnsAddressResponseGetHostName(aResponse, hostName, sizeof(hostName))); - - OutputFormat("DNS response for %s - ", hostName); - - if (aError == OT_ERROR_NONE) - { - uint16_t index = 0; - - while (otDnsAddressResponseGetAddress(aResponse, index, &address, &ttl) == OT_ERROR_NONE) - { - OutputIp6Address(address); - OutputFormat(" TTL:%lu ", ToUlong(ttl)); - index++; - } - } - - OutputNewLine(); - OutputResult(aError); -} - -#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE - -void Interpreter::OutputDnsServiceInfo(uint8_t aIndentSize, const otDnsServiceInfo &aServiceInfo) +template <> otError Interpreter::Process(Arg aArgs[]) { - 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:%lu", ToUlong(aServiceInfo.mHostAddressTtl)); - OutputFormat(aIndentSize, "TXT:"); + otError error = OT_ERROR_NONE; - if (!aServiceInfo.mTxtDataTruncated) + if (aArgs[0] == "async") { - OutputDnsTxtData(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize); + SuccessOrExit(error = otThreadDetachGracefully(GetInstancePtr(), nullptr, nullptr)); } else { - OutputFormat("["); - OutputBytes(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize); - OutputFormat("...]"); + SuccessOrExit(error = + otThreadDetachGracefully(GetInstancePtr(), &Interpreter::HandleDetachGracefullyResult, this)); + error = OT_ERROR_PENDING; } - OutputLine(" TTL:%lu", ToUlong(aServiceInfo.mTxtDataTtl)); -} - -void Interpreter::HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse, void *aContext) -{ - static_cast(aContext)->HandleDnsBrowseResponse(aError, aResponse); +exit: + return error; } -void Interpreter::HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse) +/** + * @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[]) { - char name[OT_DNS_MAX_NAME_SIZE]; - char label[OT_DNS_MAX_LABEL_SIZE]; - uint8_t txtBuffer[kMaxTxtDataSize]; - otDnsServiceInfo serviceInfo; - - IgnoreError(otDnsBrowseResponseGetServiceName(aResponse, name, sizeof(name))); - - OutputLine("DNS browse response for %s", name); + otError error = OT_ERROR_NONE; + uint32_t scanChannels = 0; - if (aError == OT_ERROR_NONE) +#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") { - uint16_t index = 0; - - while (otDnsBrowseResponseGetServiceInstance(aResponse, index, label, sizeof(label)) == OT_ERROR_NONE) - { - OutputLine("%s", label); - index++; - - serviceInfo.mHostNameBuffer = name; - serviceInfo.mHostNameBufferSize = sizeof(name); - serviceInfo.mTxtData = txtBuffer; - serviceInfo.mTxtDataSize = sizeof(txtBuffer); + bool enable; + otThreadDiscoveryRequestCallback callback = nullptr; + void *context = nullptr; - if (otDnsBrowseResponseGetServiceInfo(aResponse, label, &serviceInfo) == OT_ERROR_NONE) - { - OutputDnsServiceInfo(kIndentSize, serviceInfo); - } + SuccessOrExit(error = ParseEnableOrDisable(aArgs[1], enable)); - OutputNewLine(); + if (enable) + { + callback = &Interpreter::HandleDiscoveryRequest; + context = this; } + + otThreadSetDiscoveryRequestCallback(GetInstancePtr(), callback, context); + ExitNow(); } +#endif // OPENTHREAD_FTD - OutputResult(aError); -} + if (!aArgs[0].IsEmpty()) + { + uint8_t channel; -void Interpreter::HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse, void *aContext) -{ - static_cast(aContext)->HandleDnsServiceResponse(aError, aResponse); -} + SuccessOrExit(error = aArgs[0].ParseAsUint8(channel)); + VerifyOrExit(channel < sizeof(scanChannels) * CHAR_BIT, error = OT_ERROR_INVALID_ARGS); + scanChannels = 1 << channel; + } -void Interpreter::HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse) -{ - char name[OT_DNS_MAX_NAME_SIZE]; - char label[OT_DNS_MAX_LABEL_SIZE]; - uint8_t txtBuffer[kMaxTxtDataSize]; - otDnsServiceInfo serviceInfo; + SuccessOrExit(error = otThreadDiscover(GetInstancePtr(), scanChannels, OT_PANID_BROADCAST, false, false, + &Interpreter::HandleActiveScanResult, this)); - IgnoreError(otDnsServiceResponseGetServiceName(aResponse, label, sizeof(label), name, sizeof(name))); + static const char *const kScanTableTitles[] = { + "Network Name", "Extended PAN", "PAN", "MAC Address", "Ch", "dBm", "LQI", + }; - OutputLine("DNS service resolution response for %s for service %s", label, name); + static const uint8_t kScanTableColumnWidths[] = { + 18, 18, 6, 18, 4, 5, 5, + }; - if (aError == OT_ERROR_NONE) - { - serviceInfo.mHostNameBuffer = name; - serviceInfo.mHostNameBufferSize = sizeof(name); - serviceInfo.mTxtData = txtBuffer; - serviceInfo.mTxtDataSize = sizeof(txtBuffer); + OutputTableHeader(kScanTableTitles, kScanTableColumnWidths); - if (otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo) == OT_ERROR_NONE) - { - OutputDnsServiceInfo(/* aIndentSize */ 0, serviceInfo); - OutputNewLine(); - } - } + error = OT_ERROR_PENDING; - OutputResult(aError); +exit: + return error; } -#endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE -#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE +#if OPENTHREAD_CLI_DNS_ENABLE +template <> otError Interpreter::Process(Arg aArgs[]) { return mDns.Process(aArgs); } +#endif #if OPENTHREAD_FTD -const char *EidCacheStateToString(otCacheEntryState aState) +void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry) { - static const char *const kStateStrings[4] = { - "cache", - "snoop", - "query", - "retry", + static const char *const kStateStrings[] = { + "cache", // (0) OT_CACHE_ENTRY_STATE_CACHED + "snoop", // (1) OT_CACHE_ENTRY_STATE_SNOOPED + "query", // (2) OT_CACHE_ENTRY_STATE_QUERY + "retry", // (3) OT_CACHE_ENTRY_STATE_RETRY_QUERY }; - return Interpreter::Stringify(aState, kStateStrings); -} + static_assert(0 == OT_CACHE_ENTRY_STATE_CACHED, "OT_CACHE_ENTRY_STATE_CACHED value is incorrect"); + static_assert(1 == OT_CACHE_ENTRY_STATE_SNOOPED, "OT_CACHE_ENTRY_STATE_SNOOPED value is incorrect"); + static_assert(2 == OT_CACHE_ENTRY_STATE_QUERY, "OT_CACHE_ENTRY_STATE_QUERY value is incorrect"); + static_assert(3 == OT_CACHE_ENTRY_STATE_RETRY_QUERY, "OT_CACHE_ENTRY_STATE_RETRY_QUERY value is incorrect"); -void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry) -{ OutputIp6Address(aEntry.mTarget); OutputFormat(" %04x", aEntry.mRloc16); - OutputFormat(" %s", EidCacheStateToString(aEntry.mState)); + OutputFormat(" %s", Stringify(aEntry.mState, kStateStrings)); OutputFormat(" canEvict=%d", aEntry.mCanEvict); if (aEntry.mState == OT_CACHE_ENTRY_STATE_CACHED) @@ -3930,6 +2960,29 @@ template <> otError Interpreter::Process(Arg aArgs[]) return error; } +template <> otError Interpreter::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_INVALID_ARGS; + + /** + * @cli instanceid + * @code + * instanceid + * 468697314 + * Done + * @endcode + * @par api_copy + * #otInstanceGetId + */ + if (aArgs[0].IsEmpty()) + { + OutputLine("%lu", ToUlong(otInstanceGetId(GetInstancePtr()))); + error = OT_ERROR_NONE; + } + + return error; +} + const char *Interpreter::AddressOriginToString(uint8_t aOrigin) { static const char *const kOriginStrings[4] = { @@ -4165,10 +3218,6 @@ template <> otError Interpreter::Process(Arg aArgs[]) */ else if (aArgs[0] == "promiscuous") { - if (aArgs[1].IsEmpty()) - { - OutputEnabledDisabledStatus(otIp6IsMulticastPromiscuousEnabled(GetInstancePtr())); - } /** * @cli ipmaddr promiscuous (enable,disable) * @code @@ -4183,13 +3232,8 @@ template <> otError Interpreter::Process(Arg aArgs[]) * @par api_copy * #otIp6SetMulticastPromiscuousEnabled */ - else - { - bool enable; - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[1], enable)); - otIp6SetMulticastPromiscuousEnabled(GetInstancePtr(), enable); - } + error = + ProcessEnableDisable(aArgs + 1, otIp6IsMulticastPromiscuousEnabled, otIp6SetMulticastPromiscuousEnabled); } /** * @cli ipmaddr llatn @@ -4392,6 +3436,7 @@ template <> otError Interpreter::Process(Arg aArgs[]) return ProcessGetSet(aArgs, otThreadGetLocalLeaderWeight, otThreadSetLocalLeaderWeight); } +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) template <> otError Interpreter::Process(Arg aArgs[]) { static const char *const kPowerSupplyStrings[4] = { @@ -4490,6 +3535,7 @@ template <> otError Interpreter::Process(Arg aArgs[]) exit: return error; } +#endif // #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) #endif // OPENTHREAD_FTD @@ -5057,6 +4103,20 @@ template <> otError Interpreter::Process(Arg aArgs[]) #endif // OPENTHREAD_FTD #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE +/** + * @cli mliid + * @code + * mliid 1122334455667788 + * Done + * @endcode + * @par + * It must be used before Thread stack is enabled. + * @par + * Only for testing/reference device. + * @par api_copy + * #otIp6SetMeshLocalIid + * @cparam mliid @ca{iid} + */ template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; @@ -5073,7 +4133,37 @@ template <> otError Interpreter::Process(Arg aArgs[]) #endif #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE - +/** + * @cli mlr reg + * @code + * mlr reg ff04::1 + * status 0, 0 failed + * Done + * @endcode + * @code + * mlr reg ff04::1 ff04::2 ff02::1 + * status 2, 1 failed + * ff02:0:0:0:0:0:0:1 + * Done + * @endcode + * @code + * mlr reg ff04::1 ff04::2 1000 + * status 0, 0 failed + * Done + * @endcode + * @code + * mlr reg ff04::1 ff04::2 0 + * status 0, 0 failed + * Done + * @endcode + * @par + * Omit timeout to use the default MLR timeout on the Primary Backbone Router. + * @par + * Use timeout = 0 to deregister Multicast Listeners. + * @par api_copy + * #otIp6RegisterMulticastListeners + * @cparam mlr reg @ca{ipaddr} [@ca{timeout}] + */ template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_INVALID_COMMAND; @@ -5161,6 +4251,24 @@ template <> otError Interpreter::Process(Arg aArgs[]) ExitNow(); } + /** + * @cli mode (get,set) + * @code + * mode rdn + * Done + * @endcode + * @code + * mode - + * Done + * @endcode + * @par api_copy + * #otThreadSetLinkMode + * @cparam mode [@ca{rdn}] + * - `-`: -: no flags set (rx-off-when-idle, minimal Thread device, stable network data) + * - `r`: rx-on-when-idle + * - `d`: Full Thread Device + * - `n`: Full Network Data + */ if (aArgs[0] != "-") { for (const char *arg = aArgs[0].GetCString(); *arg != '\0'; arg++) @@ -5191,6 +4299,18 @@ template <> otError Interpreter::Process(Arg aArgs[]) return error; } +/** + * @cli multiradio + * @code + * multiradio + * [15.4, TREL] + * Done + * @endcode + * @par + * Get the list of supported radio links by the device. + * @par + * This command is always available, even when only a single radio is supported by the device. + */ template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; @@ -5218,6 +4338,17 @@ template <> otError Interpreter::Process(Arg aArgs[]) { otMultiRadioNeighborInfo multiRadioInfo; + /** + * @cli multiradio neighbor list + * @code + * multiradio neighbor list + * ExtAddr:3a65bc38dbe4a5be, RLOC16:0xcc00, Radios:[15.4(255), TREL(255)] + * ExtAddr:17df23452ee4a4be, RLOC16:0x1300, Radios:[15.4(255)] + * Done + * @endcode + * @par api_copy + * #otMultiRadioGetNeighborInfo + */ if (aArgs[1] == "list") { otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; @@ -5239,6 +4370,17 @@ template <> otError Interpreter::Process(Arg aArgs[]) } else { + /** + * @cli multiradio neighbor + * @code + * multiradio neighbor 3a65bc38dbe4a5be + * [15.4(255), TREL(255)] + * Done + * @endcode + * @par api_copy + * #otMultiRadioGetNeighborInfo + * @cparam multiradio neighbor @ca{ext-address} + */ otExtAddress extAddress; SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddress.m8)); @@ -6697,25 +5839,111 @@ template <> otError Interpreter::Process(Arg aArgs[]) #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE && OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE template <> otError Interpreter::Process(Arg aArgs[]) +{ + return ProcessEnableDisable(aArgs, otLinkIsRadioFilterEnabled, otLinkSetRadioFilterEnabled); +} +#endif + +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE +inline unsigned long UsToSInt(uint64_t aUs) { return ToUlong(static_cast(aUs / 1000000)); } +inline unsigned long UsToSDec(uint64_t aUs) { return ToUlong(static_cast(aUs % 1000000)); } + +void Interpreter::OutputRadioStatsTime(const char *aTimeName, uint64_t aTimeUs, uint64_t aTotalTimeUs) +{ + uint32_t timePercentInt = static_cast(aTimeUs * 100 / aTotalTimeUs); + uint32_t timePercentDec = static_cast((aTimeUs * 100 % aTotalTimeUs) * 100 / aTotalTimeUs); + + OutputLine("%s Time: %lu.%06lus (%lu.%02lu%%)", aTimeName, UsToSInt(aTimeUs), UsToSDec(aTimeUs), + ToUlong(timePercentInt), ToUlong(timePercentDec)); +} +#endif // OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + +template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; - if (aArgs[0].IsEmpty()) + /** + * @cli radio (enable,disable) + * @code + * radio enable + * Done + * @endcode + * @code + * radio disable + * Done + * @endcode + * @cparam radio [@ca{enable|disable}] + * @sa otLinkSetEnabled + * @par + * Enables or disables the radio. + */ + if (ProcessEnableDisable(aArgs, otLinkSetEnabled) == OT_ERROR_NONE) + { + } +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + /** + * @cli radio stats + * @code + * radio stats + * Radio Statistics: + * Total Time: 67.756s + * Tx Time: 0.022944s (0.03%) + * Rx Time: 1.482353s (2.18%) + * Sleep Time: 66.251128s (97.77%) + * Disabled Time: 0.000080s (0.00%) + * Done + * @endcode + * @par api_copy + * #otRadioTimeStatsGet + */ + else if (aArgs[0] == "stats") { - OutputEnabledDisabledStatus(otLinkIsRadioFilterEnabled(GetInstancePtr())); + if (aArgs[1].IsEmpty()) + { + const otRadioTimeStats *radioStats = nullptr; + uint64_t totalTimeUs; + + radioStats = otRadioTimeStatsGet(GetInstancePtr()); + + totalTimeUs = + radioStats->mSleepTime + radioStats->mTxTime + radioStats->mRxTime + radioStats->mDisabledTime; + if (totalTimeUs == 0) + { + OutputLine("Total Time is 0!"); + } + else + { + OutputLine("Radio Statistics:"); + OutputLine("Total Time: %lu.%03lus", ToUlong(static_cast(totalTimeUs / 1000000)), + ToUlong((totalTimeUs % 1000000) / 1000)); + OutputRadioStatsTime("Tx", radioStats->mTxTime, totalTimeUs); + OutputRadioStatsTime("Rx", radioStats->mRxTime, totalTimeUs); + OutputRadioStatsTime("Sleep", radioStats->mSleepTime, totalTimeUs); + OutputRadioStatsTime("Disabled", radioStats->mDisabledTime, totalTimeUs); + } + } + /** + * @cli radio stats clear + * @code + * radio stats clear + * Done + * @endcode + * @par api_copy + * #otRadioTimeStatsReset + */ + else if (aArgs[1] == "clear") + { + otRadioTimeStatsReset(GetInstancePtr()); + } } +#endif // OPENTHREAD_CONFIG_RADIO_STATS_ENABLE else { - bool enable; - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[0], enable)); - otLinkSetRadioFilterEnabled(GetInstancePtr(), enable); + error = OT_ERROR_INVALID_COMMAND; } -exit: return error; } -#endif template <> otError Interpreter::Process(Arg aArgs[]) { @@ -7113,24 +6341,19 @@ template <> otError Interpreter::Process(Arg aA return ProcessGetSet(aArgs, otThreadGetRouterDowngradeThreshold, otThreadSetRouterDowngradeThreshold); } +/** + * @cli routereligible + * @code + * routereligible + * Enabled + * Done + * @endcode + * @sa otThreadIsRouterEligible + * @par + * Indicates whether the router role is enabled or disabled. + */ template <> otError Interpreter::Process(Arg aArgs[]) { - otError error = OT_ERROR_NONE; - /** - * @cli routereligible - * @code - * routereligible - * Enabled - * Done - * @endcode - * @sa otThreadIsRouterEligible - * @par - * Indicates whether the router role is enabled or disabled. - */ - if (aArgs[0].IsEmpty()) - { - OutputEnabledDisabledStatus(otThreadIsRouterEligible(GetInstancePtr())); - } /** * @cli routereligible (enable,disable) * @code @@ -7146,17 +6369,9 @@ template <> otError Interpreter::Process(Arg aArgs[]) * @par * Enables or disables the router role. */ - else - { - bool enable; - - SuccessOrExit(error = ParseEnableOrDisable(aArgs[0], enable)); - error = otThreadSetRouterEligible(GetInstancePtr(), enable); - } - -exit: - return error; + return ProcessEnableDisable(aArgs, otThreadIsRouterEligible, otThreadSetRouterEligible); } + /** * @cli routerselectionjitter * @code @@ -7633,253 +6848,8 @@ template <> otError Interpreter::Process(Arg aArgs[]) #endif #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE -template <> otError Interpreter::Process(Arg aArgs[]) -{ - otError error = OT_ERROR_NONE; - - if (aArgs[0].IsEmpty()) - { - PrintMacFilter(); - } - else if (aArgs[0] == "addr") - { - error = ProcessMacFilterAddress(aArgs + 1); - } - else if (aArgs[0] == "rss") - { - error = ProcessMacFilterRss(aArgs + 1); - } - else - { - error = OT_ERROR_INVALID_COMMAND; - } - - return error; -} - -void Interpreter::PrintMacFilter(void) -{ - otMacFilterEntry entry; - otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; - - OutputLine("Address Mode: %s", MacFilterAddressModeToString(otLinkFilterGetAddressMode(GetInstancePtr()))); - - while (otLinkFilterGetNextAddress(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) - { - OutputMacFilterEntry(entry); - } - - iterator = OT_MAC_FILTER_ITERATOR_INIT; - OutputLine("RssIn List:"); - - while (otLinkFilterGetNextRssIn(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) - { - uint8_t i = 0; - - for (; i < OT_EXT_ADDRESS_SIZE; i++) - { - if (entry.mExtAddress.m8[i] != 0xff) - { - break; - } - } - - if (i == OT_EXT_ADDRESS_SIZE) - { - OutputLine("Default rss : %d (lqi %u)", entry.mRssIn, - otLinkConvertRssToLinkQuality(GetInstancePtr(), entry.mRssIn)); - } - else - { - OutputMacFilterEntry(entry); - } - } -} - -otError Interpreter::ProcessMacFilterAddress(Arg aArgs[]) -{ - otError error = OT_ERROR_NONE; - otExtAddress extAddr; - - if (aArgs[0].IsEmpty()) - { - otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; - otMacFilterEntry entry; - - OutputLine("%s", MacFilterAddressModeToString(otLinkFilterGetAddressMode(GetInstancePtr()))); - - while (otLinkFilterGetNextAddress(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) - { - OutputMacFilterEntry(entry); - } - } - else if (aArgs[0] == "disable") - { - VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - otLinkFilterSetAddressMode(GetInstancePtr(), OT_MAC_FILTER_ADDRESS_MODE_DISABLED); - } - else if (aArgs[0] == "allowlist") - { - VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - otLinkFilterSetAddressMode(GetInstancePtr(), OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST); - } - else if (aArgs[0] == "denylist") - { - VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - otLinkFilterSetAddressMode(GetInstancePtr(), OT_MAC_FILTER_ADDRESS_MODE_DENYLIST); - } - else if (aArgs[0] == "add") - { - SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); - error = otLinkFilterAddAddress(GetInstancePtr(), &extAddr); - - VerifyOrExit(error == OT_ERROR_NONE || error == OT_ERROR_ALREADY); - - if (!aArgs[2].IsEmpty()) - { - int8_t rss; - - SuccessOrExit(error = aArgs[2].ParseAsInt8(rss)); - SuccessOrExit(error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss)); - } - } - else if (aArgs[0] == "remove") - { - SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); - otLinkFilterRemoveAddress(GetInstancePtr(), &extAddr); - } - else if (aArgs[0] == "clear") - { - otLinkFilterClearAddresses(GetInstancePtr()); - } - else - { - error = OT_ERROR_INVALID_COMMAND; - } - -exit: - return error; -} - -otError Interpreter::ProcessMacFilterRss(Arg aArgs[]) -{ - otError error = OT_ERROR_NONE; - otMacFilterEntry entry; - otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; - otExtAddress extAddr; - int8_t rss; - - if (aArgs[0].IsEmpty()) - { - while (otLinkFilterGetNextRssIn(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) - { - uint8_t i = 0; - - for (; i < OT_EXT_ADDRESS_SIZE; i++) - { - if (entry.mExtAddress.m8[i] != 0xff) - { - break; - } - } - - if (i == OT_EXT_ADDRESS_SIZE) - { - OutputLine("Default rss: %d (lqi %u)", entry.mRssIn, - otLinkConvertRssToLinkQuality(GetInstancePtr(), entry.mRssIn)); - } - else - { - OutputMacFilterEntry(entry); - } - } - } - else if (aArgs[0] == "add-lqi") - { - uint8_t linkQuality; - - SuccessOrExit(error = aArgs[2].ParseAsUint8(linkQuality)); - VerifyOrExit(linkQuality <= 3, error = OT_ERROR_INVALID_ARGS); - rss = otLinkConvertLinkQualityToRss(GetInstancePtr(), linkQuality); - - if (aArgs[1] == "*") - { - otLinkFilterSetDefaultRssIn(GetInstancePtr(), rss); - } - else - { - SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); - error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss); - } - } - else if (aArgs[0] == "add") - { - SuccessOrExit(error = aArgs[2].ParseAsInt8(rss)); - - if (aArgs[1] == "*") - { - otLinkFilterSetDefaultRssIn(GetInstancePtr(), rss); - } - else - { - SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); - error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss); - } - } - else if (aArgs[0] == "remove") - { - if (aArgs[1] == "*") - { - otLinkFilterClearDefaultRssIn(GetInstancePtr()); - } - else - { - SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); - otLinkFilterRemoveRssIn(GetInstancePtr(), &extAddr); - } - } - else if (aArgs[0] == "clear") - { - otLinkFilterClearAllRssIn(GetInstancePtr()); - } - else - { - error = OT_ERROR_INVALID_COMMAND; - } - -exit: - return error; -} - -void Interpreter::OutputMacFilterEntry(const otMacFilterEntry &aEntry) -{ - OutputExtAddress(aEntry.mExtAddress); - - if (aEntry.mRssIn != OT_MAC_FILTER_FIXED_RSS_DISABLED) - { - OutputFormat(" : rss %d (lqi %d)", aEntry.mRssIn, - otLinkConvertRssToLinkQuality(GetInstancePtr(), aEntry.mRssIn)); - } - - OutputNewLine(); -} - -const char *Interpreter::MacFilterAddressModeToString(otMacFilterAddressMode aMode) -{ - static const char *const kModeStrings[] = { - "Disabled", // (0) OT_MAC_FILTER_ADDRESS_MODE_DISABLED - "Allowlist", // (1) OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST - "Denylist", // (2) OT_MAC_FILTER_ADDRESS_MODE_DENYLIST - }; - - static_assert(0 == OT_MAC_FILTER_ADDRESS_MODE_DISABLED, "OT_MAC_FILTER_ADDRESS_MODE_DISABLED value is incorrect"); - static_assert(1 == OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST, "OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST value is incorrect"); - static_assert(2 == OT_MAC_FILTER_ADDRESS_MODE_DENYLIST, "OT_MAC_FILTER_ADDRESS_MODE_DENYLIST value is incorrect"); - - return Stringify(aMode, kModeStrings); -} - -#endif // OPENTHREAD_CONFIG_MAC_FILTER_ENABLE +template <> otError Interpreter::Process(Arg aArgs[]) { return mMacFilter.Process(aArgs); } +#endif template <> otError Interpreter::Process(Arg aArgs[]) { @@ -7935,27 +6905,13 @@ template <> otError Interpreter::Process(Arg aArgs[]) template <> otError Interpreter::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; - bool enable; - if (aArgs[0].IsEmpty()) + if (ProcessEnableDisable(aArgs, otTrelIsEnabled, otTrelSetEnabled) == OT_ERROR_NONE) { - OutputEnabledDisabledStatus(otTrelIsEnabled(GetInstancePtr())); - } - else if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE) - { - otTrelSetEnabled(GetInstancePtr(), enable); } else if (aArgs[0] == "filter") { - if (aArgs[1].IsEmpty()) - { - OutputEnabledDisabledStatus(otTrelIsFilterEnabled(GetInstancePtr())); - } - else - { - SuccessOrExit(error = ParseEnableOrDisable(aArgs[1], enable)); - otTrelSetFilterEnabled(GetInstancePtr(), enable); - } + error = ProcessEnableDisable(aArgs + 1, otTrelIsFilterEnabled, otTrelSetFilterEnabled); } else if (aArgs[0] == "peers") { @@ -8402,6 +7358,76 @@ void Interpreter::Initialize(otInstance *aInstance, otCliOutputCallback aCallbac Interpreter::sInterpreter = new (&sInterpreterRaw) Interpreter(instance, aCallback, aContext); } +otError Interpreter::ProcessEnableDisable(Arg aArgs[], SetEnabledHandler aSetEnabledHandler) +{ + otError error = OT_ERROR_NONE; + bool enable; + + if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE) + { + aSetEnabledHandler(GetInstancePtr(), enable); + } + else + { + error = OT_ERROR_INVALID_COMMAND; + } + + return error; +} + +otError Interpreter::ProcessEnableDisable(Arg aArgs[], SetEnabledHandlerFailable aSetEnabledHandler) +{ + otError error = OT_ERROR_NONE; + bool enable; + + if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE) + { + error = aSetEnabledHandler(GetInstancePtr(), enable); + } + else + { + error = OT_ERROR_INVALID_COMMAND; + } + + return error; +} + +otError Interpreter::ProcessEnableDisable(Arg aArgs[], + IsEnabledHandler aIsEnabledHandler, + SetEnabledHandler aSetEnabledHandler) +{ + otError error = OT_ERROR_NONE; + + if (aArgs[0].IsEmpty()) + { + OutputEnabledDisabledStatus(aIsEnabledHandler(GetInstancePtr())); + } + else + { + error = ProcessEnableDisable(aArgs, aSetEnabledHandler); + } + + return error; +} + +otError Interpreter::ProcessEnableDisable(Arg aArgs[], + IsEnabledHandler aIsEnabledHandler, + SetEnabledHandlerFailable aSetEnabledHandler) +{ + otError error = OT_ERROR_NONE; + + if (aArgs[0].IsEmpty()) + { + OutputEnabledDisabledStatus(aIsEnabledHandler(GetInstancePtr())); + } + else + { + error = ProcessEnableDisable(aArgs, aSetEnabledHandler); + } + + return error; +} + void Interpreter::OutputPrompt(void) { #if OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE @@ -8501,7 +7527,7 @@ otError Interpreter::ProcessCommand(Arg aArgs[]) #endif CmdEntry("detach"), #endif // OPENTHREAD_FTD || OPENTHREAD_MTD -#if OPENTHREAD_FTD +#if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) CmdEntry("deviceprops"), #endif #if OPENTHREAD_CONFIG_DIAG_ENABLE @@ -8509,7 +7535,10 @@ otError Interpreter::ProcessCommand(Arg aArgs[]) #endif #if OPENTHREAD_FTD || OPENTHREAD_MTD CmdEntry("discover"), +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE || OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE || \ + OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE CmdEntry("dns"), +#endif #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) CmdEntry("domainname"), #endif @@ -8533,6 +7562,7 @@ otError Interpreter::ProcessCommand(Arg aArgs[]) CmdEntry("history"), #endif CmdEntry("ifconfig"), + CmdEntry("instanceid"), CmdEntry("ipaddr"), CmdEntry("ipmaddr"), #if OPENTHREAD_CONFIG_JOINER_ENABLE @@ -8617,6 +7647,9 @@ otError Interpreter::ProcessCommand(Arg aArgs[]) CmdEntry("pskcref"), #endif #endif +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + CmdEntry("radio"), +#endif #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE && OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE CmdEntry("radiofilter"), #endif @@ -8670,9 +7703,7 @@ otError Interpreter::ProcessCommand(Arg aArgs[]) #if OPENTHREAD_CONFIG_UPTIME_ENABLE CmdEntry("uptime"), #endif -#if OPENTHREAD_FTD || OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE CmdEntry("vendor"), -#endif #endif // OPENTHREAD_FTD || OPENTHREAD_MTD CmdEntry("version"), }; diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index 7e361a22a03..f303fa35049 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -58,11 +58,14 @@ #include #include +#include "cli/cli_bbr.hpp" #include "cli/cli_br.hpp" #include "cli/cli_commissioner.hpp" #include "cli/cli_dataset.hpp" +#include "cli/cli_dns.hpp" #include "cli/cli_history.hpp" #include "cli/cli_joiner.hpp" +#include "cli/cli_mac_filter.hpp" #include "cli/cli_network_data.hpp" #include "cli/cli_output.hpp" #include "cli/cli_srp_client.hpp" @@ -99,17 +102,20 @@ extern "C" void otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength); extern "C" void otCliOutputFormat(const char *aFmt, ...); /** - * This class implements the CLI interpreter. + * Implements the CLI interpreter. * */ class Interpreter : public OutputImplementer, public Output { #if OPENTHREAD_FTD || OPENTHREAD_MTD friend class Br; + friend class Bbr; friend class Commissioner; + friend class Dns; friend class Joiner; friend class NetworkData; friend class SrpClient; + friend class SrpServer; #endif friend void otCliPlatLogv(otLogLevel, otLogRegion, const char *, va_list); friend void otCliAppendResult(otError aError); @@ -129,7 +135,7 @@ class Interpreter : public OutputImplementer, public Output explicit Interpreter(Instance *aInstance, otCliOutputCallback aCallback, void *aContext); /** - * This method returns a reference to the interpreter object. + * Returns a reference to the interpreter object. * * @returns A reference to the interpreter object. * @@ -142,7 +148,7 @@ class Interpreter : public OutputImplementer, public Output } /** - * This method initializes the Console interpreter. + * Initializes the Console interpreter. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aCallback A pointer to a callback method. @@ -152,7 +158,7 @@ class Interpreter : public OutputImplementer, public Output static void Initialize(otInstance *aInstance, otCliOutputCallback aCallback, void *aContext); /** - * This method returns whether the interpreter is initialized. + * Returns whether the interpreter is initialized. * * @returns Whether the interpreter is initialized. * @@ -160,7 +166,7 @@ class Interpreter : public OutputImplementer, public Output static bool IsInitialized(void) { return sInterpreter != nullptr; } /** - * This method interprets a CLI command. + * Interprets a CLI command. * * @param[in] aBuf A pointer to a string. * @@ -168,7 +174,7 @@ class Interpreter : public OutputImplementer, public Output void ProcessLine(char *aBuf); /** - * This static method checks a given argument string against "enable" or "disable" commands. + * Checks a given argument string against "enable" or "disable" commands. * * @param[in] aArg The argument string to parse. * @param[out] aEnable Boolean variable to return outcome on success. @@ -181,7 +187,7 @@ class Interpreter : public OutputImplementer, public Output static otError ParseEnableOrDisable(const Arg &aArg, bool &aEnable); /** - * This method adds commands to the user command table. + * Adds commands to the user command table. * * @param[in] aCommands A pointer to an array with user commands. * @param[in] aLength @p aUserCommands length. @@ -195,7 +201,7 @@ class Interpreter : public OutputImplementer, public Output static constexpr uint8_t kLinkModeStringSize = sizeof("rdn"); ///< Size of string buffer for a MLE Link Mode. /** - * This method converts a given MLE Link Mode to flag string. + * Converts a given MLE Link Mode to flag string. * * The characters 'r', 'd', and 'n' are respectively used for `mRxOnWhenIdle`, `mDeviceType` and `mNetworkData` * flags. If all flags are `false`, then "-" is returned. @@ -209,7 +215,7 @@ class Interpreter : public OutputImplementer, public Output static const char *LinkModeToString(const otLinkModeConfig &aLinkMode, char (&aStringBuffer)[kLinkModeStringSize]); /** - * This method converts an IPv6 address origin `OT_ADDRESS_ORIGIN_*` value to human-readable string. + * Converts an IPv6 address origin `OT_ADDRESS_ORIGIN_*` value to human-readable string. * * @param[in] aOrigin The IPv6 address origin to convert. * @@ -219,7 +225,7 @@ class Interpreter : public OutputImplementer, public Output static const char *AddressOriginToString(uint8_t aOrigin); /** - * This static method parses a given argument string as a route preference comparing it against "high", "med", or + * Parses a given argument string as a route preference comparing it against "high", "med", or * "low". * * @param[in] aArg The argument string to parse. @@ -232,7 +238,7 @@ class Interpreter : public OutputImplementer, public Output static otError ParsePreference(const Arg &aArg, otRoutePreference &aPreference); /** - * This static method converts a route preference value to human-readable string. + * Converts a route preference value to human-readable string. * * @param[in] aPreference The preference value to convert (`OT_ROUTE_PREFERENCE_*` values). * @@ -242,7 +248,7 @@ class Interpreter : public OutputImplementer, public Output static const char *PreferenceToString(signed int aPreference); /** - * This method parses the argument as an IP address. + * Parses the argument as an IP address. * * If the argument string is an IPv4 address, this method will try to synthesize an IPv6 address using preferred * NAT64 prefix in the network data. @@ -285,6 +291,9 @@ class Interpreter : public OutputImplementer, public Output template using GetHandler = ValueType (&)(otInstance *); template using SetHandler = void (&)(otInstance *, ValueType); template using SetHandlerFailable = otError (&)(otInstance *, ValueType); + using IsEnabledHandler = bool (&)(otInstance *); + using SetEnabledHandler = void (&)(otInstance *, bool); + using SetEnabledHandlerFailable = otError (&)(otInstance *, bool); // Returns format string to output a `ValueType` (e.g., "%u" for `uint16_t`). template static constexpr const char *FormatStringFor(void); @@ -360,6 +369,13 @@ class Interpreter : public OutputImplementer, public Output return error; } + otError ProcessEnableDisable(Arg aArgs[], SetEnabledHandler aSetEnabledHandler); + otError ProcessEnableDisable(Arg aArgs[], SetEnabledHandlerFailable aSetEnabledHandler); + otError ProcessEnableDisable(Arg aArgs[], IsEnabledHandler aIsEnabledHandler, SetEnabledHandler aSetEnabledHandler); + otError ProcessEnableDisable(Arg aArgs[], + IsEnabledHandler aIsEnabledHandler, + SetEnabledHandlerFailable aSetEnabledHandler); + void OutputPrompt(void); void OutputResult(otError aError); @@ -427,14 +443,6 @@ class Interpreter : public OutputImplementer, public Output void OutputMultiRadioInfo(const otMultiRadioNeighborInfo &aMultiRadioInfo); #endif -#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE - void PrintMacFilter(void); - otError ProcessMacFilterAddress(Arg aArgs[]); - otError ProcessMacFilterRss(Arg aArgs[]); - void OutputMacFilterEntry(const otMacFilterEntry &aEntry); - static const char *MacFilterAddressModeToString(otMacFilterAddressMode aMode); -#endif - #if OPENTHREAD_CONFIG_PING_SENDER_ENABLE static void HandlePingReply(const otPingSenderReply *aReply, void *aContext); static void HandlePingStatistics(const otPingSenderStatistics *aStatistics, void *aContext); @@ -459,19 +467,11 @@ class Interpreter : public OutputImplementer, public Output void OutputChildTableEntry(uint8_t aIndentSize, const otNetworkDiagChildEntry &aChildEntry); #endif -#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE - otError GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig); - static void HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse, void *aContext); - void HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse); - const char *DnsConfigServiceModeToString(otDnsServiceMode aMode) const; - otError ParseDnsServiceMode(const Arg &aArg, otDnsServiceMode &aMode) const; -#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE - void OutputDnsServiceInfo(uint8_t aIndentSize, const otDnsServiceInfo &aServiceInfo); - static void HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse, void *aContext); - void HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse); - static void HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse, void *aContext); - void HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse); +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE + void OutputNat64Counters(const otNat64Counters &aCounters); #endif +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + void OutputRadioStatsTime(const char *aTimeName, uint64_t aTimeUs, uint64_t aTotalTime); #endif #if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE @@ -556,6 +556,18 @@ class Interpreter : public OutputImplementer, public Output NetworkData mNetworkData; UdpExample mUdp; +#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE + MacFilter mMacFilter; +#endif + +#if OPENTHREAD_CLI_DNS_ENABLE + Dns mDns; +#endif + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + Bbr mBbr; +#endif + #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE Br mBr; #endif diff --git a/src/cli/cli_bbr.cpp b/src/cli/cli_bbr.cpp new file mode 100644 index 00000000000..d37d3dfcc36 --- /dev/null +++ b/src/cli/cli_bbr.cpp @@ -0,0 +1,499 @@ +/* + * 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 + * This file implements CLI for Backbone Router. + */ + +#include "cli_bbr.hpp" + +#include "cli/cli.hpp" + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + +namespace ot { +namespace Cli { + +void Bbr::OutputConfig(const otBackboneRouterConfig &aConfig) +{ + OutputLine("seqno: %u", aConfig.mSequenceNumber); + OutputLine("delay: %u secs", aConfig.mReregistrationDelay); + OutputLine("timeout: %lu secs", ToUlong(aConfig.mMlrTimeout)); +} + +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + +#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE + +template <> otError Bbr::Process(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()) + { + otBackboneRouterMulticastListenerIterator iter = OT_BACKBONE_ROUTER_MULTICAST_LISTENER_ITERATOR_INIT; + otBackboneRouterMulticastListenerInfo listenerInfo; + + while (otBackboneRouterMulticastListenerGetNext(GetInstancePtr(), &iter, &listenerInfo) == OT_ERROR_NONE) + { + OutputIp6Address(listenerInfo.mAddress); + OutputLine(" %lu", ToUlong(listenerInfo.mTimeout)); + } + + ExitNow(error = OT_ERROR_NONE); + } + +#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; + uint32_t timeout = 0; + + SuccessOrExit(error = aArgs[2].ParseAsIp6Address(address)); + + if (!aArgs[3].IsEmpty()) + { + SuccessOrExit(error = aArgs[3].ParseAsUint32(timeout)); + } + + 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") + { + uint8_t status; + + SuccessOrExit(error = aArgs[1].ParseAsUint8(status)); + otBackboneRouterConfigNextMulticastListenerRegistrationResponse(GetInstancePtr(), status); + error = OT_ERROR_NONE; + +#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE + } + +exit: + return error; +} + +#endif // #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE + +template <> otError Bbr::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_INVALID_COMMAND; + + if (aArgs[0].IsEmpty()) + { + 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 + */ + if (aArgs[0] == "dua") + { + uint8_t status; + otIp6InterfaceIdentifier *mlIid = nullptr; + otIp6InterfaceIdentifier iid; + + SuccessOrExit(error = aArgs[1].ParseAsUint8(status)); + + if (!aArgs[2].IsEmpty()) + { + SuccessOrExit(error = aArgs[2].ParseAsHexString(iid.mFields.m8)); + mlIid = &iid; + VerifyOrExit(aArgs[3].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + } + + otBackboneRouterConfigNextDuaRegistrationResponse(GetInstancePtr(), mlIid, status); + ExitNow(); + } +#endif // OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE && OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE + +#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE + if (aArgs[0] == "mlr") + { + error = Process(aArgs + 1); + ExitNow(); + } +#endif + +exit: + return error; +} + +/** + * @cli bbr enable + * @code + * bbr enable + * Done + * @endcode + * @par api_copy + * #otBackboneRouterSetEnabled + */ +template <> otError Bbr::Process(Arg aArgs[]) +{ + OT_UNUSED_VARIABLE(aArgs); + otBackboneRouterSetEnabled(GetInstancePtr(), true); + + return OT_ERROR_NONE; +} + +/** + * @cli bbr disable + * @code + * bbr disable + * Done + * @endcode + * @par api_copy + * #otBackboneRouterSetEnabled + */ +template <> otError Bbr::Process(Arg aArgs[]) +{ + OT_UNUSED_VARIABLE(aArgs); + otBackboneRouterSetEnabled(GetInstancePtr(), false); + + return OT_ERROR_NONE; +} + +/** + * @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 + */ +template <> otError Bbr::Process(Arg aArgs[]) +{ + return Interpreter::GetInterpreter().ProcessGetSet(aArgs, otBackboneRouterGetRegistrationJitter, + otBackboneRouterSetRegistrationJitter); +} + +/** + * @cli bbr register + * @code + * bbr register + * Done + * @endcode + * @par api_copy + * #otBackboneRouterRegister + */ +template <> otError Bbr::Process(Arg aArgs[]) +{ + OT_UNUSED_VARIABLE(aArgs); + + return 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 + */ +template <> otError Bbr::Process(Arg aArgs[]) + +{ + static const char *const kStateStrings[] = { + "Disabled", // (0) OT_BACKBONE_ROUTER_STATE_DISABLED + "Secondary", // (1) OT_BACKBONE_ROUTER_STATE_SECONDARY + "Primary", // (2) OT_BACKBONE_ROUTER_STATE_PRIMARY + }; + + static_assert(0 == OT_BACKBONE_ROUTER_STATE_DISABLED, "OT_BACKBONE_ROUTER_STATE_DISABLED value is incorrect"); + static_assert(1 == OT_BACKBONE_ROUTER_STATE_SECONDARY, "OT_BACKBONE_ROUTER_STATE_SECONDARY value is incorrect"); + static_assert(2 == OT_BACKBONE_ROUTER_STATE_PRIMARY, "OT_BACKBONE_ROUTER_STATE_PRIMARY value is incorrect"); + + OT_UNUSED_VARIABLE(aArgs); + + OutputLine("%s", Stringify(otBackboneRouterGetState(GetInstancePtr()), kStateStrings)); + + return OT_ERROR_NONE; +} + +/** + * @cli bbr config + * @code + * bbr config + * seqno: 10 + * delay: 120 secs + * timeout: 300 secs + * Done + * @endcode + * @par api_copy + * #otBackboneRouterGetConfig + */ +template <> otError Bbr::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otBackboneRouterConfig config; + + otBackboneRouterGetConfig(GetInstancePtr(), &config); + + if (aArgs[0].IsEmpty()) + { + OutputConfig(config); + } + 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[0]; !arg->IsEmpty(); arg++) + { + if (*arg == "seqno") + { + arg++; + SuccessOrExit(error = arg->ParseAsUint8(config.mSequenceNumber)); + } + else if (*arg == "delay") + { + arg++; + SuccessOrExit(error = arg->ParseAsUint16(config.mReregistrationDelay)); + } + else if (*arg == "timeout") + { + arg++; + SuccessOrExit(error = arg->ParseAsUint32(config.mMlrTimeout)); + } + else + { + ExitNow(error = OT_ERROR_INVALID_ARGS); + } + } + + error = otBackboneRouterSetConfig(GetInstancePtr(), &config); + } + +exit: + return error; +} + +#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + +otError Bbr::Process(Arg aArgs[]) +{ +#define CmdEntry(aCommandString) {aCommandString, &Bbr::Process} + + otError error = OT_ERROR_INVALID_COMMAND; + + /** + * @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()) + { + otBackboneRouterConfig config; + + OutputFormat("BBR Primary:"); + + if (otBackboneRouterGetPrimary(GetInstancePtr(), &config) == OT_ERROR_NONE) + { + OutputNewLine(); + OutputLine("server16: 0x%04X", config.mServer16); + OutputConfig(config); + } + else + { + OutputLine(" None"); + } + + error = OT_ERROR_NONE; + ExitNow(); + } + +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + { + static constexpr Command kCommands[] = { + CmdEntry("config"), CmdEntry("disable"), CmdEntry("enable"), CmdEntry("jitter"), + CmdEntry("mgmt"), CmdEntry("register"), CmdEntry("state"), + }; + +#undef CmdEntry + + static_assert(BinarySearch::IsSorted(kCommands), "kCommands is not sorted"); + + const Command *command; + + command = BinarySearch::Find(aArgs[0].GetCString(), kCommands); + VerifyOrExit(command != nullptr); + + error = (this->*command->mHandler)(aArgs + 1); + } +#endif // #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE + +exit: + return error; +} + +} // namespace Cli +} // namespace ot + +#endif // #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) diff --git a/src/cli/cli_bbr.hpp b/src/cli/cli_bbr.hpp new file mode 100644 index 00000000000..40ed979f608 --- /dev/null +++ b/src/cli/cli_bbr.hpp @@ -0,0 +1,98 @@ +/* + * 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 + * This file contains definitions for CLI to backbone router. + */ + +#ifndef CLI_BBR_HPP_ +#define CLI_BBR_HPP_ + +#include "openthread-core-config.h" + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + +#include +#include + +#include "cli/cli_config.h" +#include "cli/cli_output.hpp" + +namespace ot { +namespace Cli { + +/** + * Implements the BBR CLI interpreter. + * + */ +class Bbr : private Output +{ +public: + typedef Utils::CmdLineParser::Arg Arg; + + /** + * Constructor. + * + * @param[in] aInstance The OpenThread Instance. + * @param[in] aOutputImplementer An `OutputImplementer`. + * + */ + Bbr(otInstance *aInstance, OutputImplementer &aOutputImplementer) + : Output(aInstance, aOutputImplementer) + { + } + + /** + * Processes a CLI sub-command. + * + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. + * + */ + otError Process(Arg aArgs[]); + +private: + using Command = CommandEntry; + + template otError Process(Arg aArgs[]); + + void OutputConfig(const otBackboneRouterConfig &aConfig); +}; + +} // namespace Cli +} // namespace ot + +#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) + +#endif // CLI_BBR_HPP_ diff --git a/src/cli/cli_br.hpp b/src/cli/cli_br.hpp index 794f8741f39..f953344e324 100644 --- a/src/cli/cli_br.hpp +++ b/src/cli/cli_br.hpp @@ -45,7 +45,7 @@ namespace ot { namespace Cli { /** - * This class implements the Border Router CLI interpreter. + * Implements the Border Router CLI interpreter. * */ class Br : private Output @@ -66,9 +66,15 @@ class Br : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs A pointer an array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_coap.hpp b/src/cli/cli_coap.hpp index 041e7ae9451..f3357fcc5ba 100644 --- a/src/cli/cli_coap.hpp +++ b/src/cli/cli_coap.hpp @@ -46,7 +46,7 @@ namespace ot { namespace Cli { /** - * This class implements the CLI CoAP server and client. + * Implements the CLI CoAP server and client. * */ class Coap : private Output @@ -64,9 +64,15 @@ class Coap : private Output Coap(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_coap_secure.hpp b/src/cli/cli_coap_secure.hpp index 9bdc63135ea..2165642bd25 100644 --- a/src/cli/cli_coap_secure.hpp +++ b/src/cli/cli_coap_secure.hpp @@ -52,7 +52,7 @@ namespace ot { namespace Cli { /** - * This class implements the CLI CoAP Secure server and client. + * Implements the CLI CoAP Secure server and client. * */ class CoapSecure : private Output @@ -70,9 +70,15 @@ class CoapSecure : private Output CoapSecure(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_commissioner.hpp b/src/cli/cli_commissioner.hpp index 7b63cb0d2b4..8969bd7620a 100644 --- a/src/cli/cli_commissioner.hpp +++ b/src/cli/cli_commissioner.hpp @@ -46,7 +46,7 @@ namespace ot { namespace Cli { /** - * This class implements the Commissioner CLI interpreter. + * Implements the Commissioner CLI interpreter. * */ class Commissioner : private Output @@ -67,9 +67,15 @@ class Commissioner : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_dataset.hpp b/src/cli/cli_dataset.hpp index 7f11ec3027a..4663650f2c2 100644 --- a/src/cli/cli_dataset.hpp +++ b/src/cli/cli_dataset.hpp @@ -46,7 +46,7 @@ namespace ot { namespace Cli { /** - * This class implements the Dataset CLI interpreter. + * Implements the Dataset CLI interpreter. * */ class Dataset : private Output @@ -60,9 +60,15 @@ class Dataset : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_dns.cpp b/src/cli/cli_dns.cpp new file mode 100644 index 00000000000..8d7e0a414b9 --- /dev/null +++ b/src/cli/cli_dns.cpp @@ -0,0 +1,753 @@ +/* + * 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 + * This file implements CLI for DNS (client and server/resolver). + */ + +#include "cli_dns.hpp" + +#include "cli/cli.hpp" + +#if OPENTHREAD_CLI_DNS_ENABLE + +namespace ot { +namespace Cli { + +#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE + +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + + /** + * @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 (aArgs[0].IsEmpty()) + { + OutputEnabledDisabledStatus(otDnsIsNameCompressionEnabled()); + } + /** + * @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 + */ + else + { + bool enable; + + SuccessOrExit(error = Interpreter::ParseEnableOrDisable(aArgs[0], enable)); + otDnsSetNameCompressionEnabled(enable); + } + +exit: + return error; +} + +#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE + +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + + /** + * @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[0].IsEmpty()) + { + const otDnsQueryConfig *defaultConfig = otDnsClientGetDefaultConfig(GetInstancePtr()); + + OutputFormat("Server: "); + OutputSockAddrLine(defaultConfig->mServerSockAddr); + 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 + { + otDnsQueryConfig queryConfig; + otDnsQueryConfig *config = &queryConfig; + + SuccessOrExit(error = GetDnsConfig(aArgs, config)); + otDnsClientSetDefaultConfig(GetInstancePtr(), config); + } + +exit: + return error; +} + +/** + * @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. + */ +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otDnsQueryConfig queryConfig; + otDnsQueryConfig *config = &queryConfig; + + VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + SuccessOrExit(error = GetDnsConfig(aArgs + 1, config)); + SuccessOrExit(error = otDnsClientResolveAddress(GetInstancePtr(), aArgs[0].GetCString(), &HandleDnsAddressResponse, + this, config)); + error = OT_ERROR_PENDING; + +exit: + return error; +} + +#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otDnsQueryConfig queryConfig; + otDnsQueryConfig *config = &queryConfig; + + VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + SuccessOrExit(error = GetDnsConfig(aArgs + 1, config)); + SuccessOrExit(error = otDnsClientResolveIp4Address(GetInstancePtr(), aArgs[0].GetCString(), + &HandleDnsAddressResponse, this, config)); + error = OT_ERROR_PENDING; + +exit: + return error; +} +#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. + */ +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otDnsQueryConfig queryConfig; + otDnsQueryConfig *config = &queryConfig; + + VerifyOrExit(!aArgs[0].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + SuccessOrExit(error = GetDnsConfig(aArgs + 1, config)); + SuccessOrExit( + error = otDnsClientBrowse(GetInstancePtr(), aArgs[0].GetCString(), &HandleDnsBrowseResponse, this, config)); + error = OT_ERROR_PENDING; + +exit: + return error; +} + +/** + * @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. + */ +template <> otError Dns::Process(Arg aArgs[]) +{ + return ProcessService(aArgs, otDnsClientResolveService); +} + +/** + * @cli dns servicehost + * @cparam dns servicehost @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 + * #otDnsClientResolveServiceAndHostAddress + * @par + * Send a service instance resolution DNS query for a given service instance + * with potential follow-up host name resolution. + * 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. + */ +template <> otError Dns::Process(Arg aArgs[]) +{ + return ProcessService(aArgs, otDnsClientResolveServiceAndHostAddress); +} + +otError Dns::ProcessService(Arg aArgs[], ResolveServiceFn aResolveServiceFn) +{ + otError error = OT_ERROR_NONE; + otDnsQueryConfig queryConfig; + otDnsQueryConfig *config = &queryConfig; + + VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + SuccessOrExit(error = GetDnsConfig(aArgs + 2, config)); + SuccessOrExit(error = aResolveServiceFn(GetInstancePtr(), aArgs[0].GetCString(), aArgs[1].GetCString(), + &HandleDnsServiceResponse, this, config)); + error = OT_ERROR_PENDING; + +exit: + return error; +} + +#endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + +//---------------------------------------------------------------------------------------------------------------------- + +void Dns::OutputResult(otError aError) { Interpreter::GetInterpreter().OutputResult(aError); } + +otError Dns::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig) +{ + // This method gets the optional DNS config from `aArgs[]`. + // 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 = 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)); + + VerifyOrExit(!aArgs[2].IsEmpty()); + SuccessOrExit(error = aArgs[2].ParseAsUint32(aConfig->mResponseTimeout)); + + VerifyOrExit(!aArgs[3].IsEmpty()); + SuccessOrExit(error = aArgs[3].ParseAsUint8(aConfig->mMaxTxAttempts)); + + VerifyOrExit(!aArgs[4].IsEmpty()); + 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; +} + +const char *const Dns::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"); + +const char *Dns::DnsConfigServiceModeToString(otDnsServiceMode aMode) const +{ + return Stringify(aMode, kServiceModeStrings); +} + +otError Dns::ParseDnsServiceMode(const Arg &aArg, otDnsServiceMode &aMode) const +{ + otError error = OT_ERROR_NONE; + + if (aArg == "def") + { + aMode = OT_DNS_SERVICE_MODE_UNSPECIFIED; + ExitNow(); + } + + for (uint8_t index = 0; index < OT_ARRAY_LENGTH(kServiceModeStrings); index++) + { + if (aArg == kServiceModeStrings[index]) + { + aMode = static_cast(index); + ExitNow(); + } + } + + error = OT_ERROR_INVALID_ARGS; + +exit: + return error; +} + +void Dns::HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse, void *aContext) +{ + static_cast(aContext)->HandleDnsAddressResponse(aError, aResponse); +} + +void Dns::HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse) +{ + char hostName[OT_DNS_MAX_NAME_SIZE]; + otIp6Address address; + uint32_t ttl; + + IgnoreError(otDnsAddressResponseGetHostName(aResponse, hostName, sizeof(hostName))); + + OutputFormat("DNS response for %s - ", hostName); + + if (aError == OT_ERROR_NONE) + { + uint16_t index = 0; + + while (otDnsAddressResponseGetAddress(aResponse, index, &address, &ttl) == OT_ERROR_NONE) + { + OutputIp6Address(address); + OutputFormat(" TTL:%lu ", ToUlong(ttl)); + index++; + } + } + + OutputNewLine(); + OutputResult(aError); +} + +#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + +void Dns::OutputDnsServiceInfo(uint8_t aIndentSize, const otDnsServiceInfo &aServiceInfo) +{ + 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:%lu", ToUlong(aServiceInfo.mHostAddressTtl)); + OutputFormat(aIndentSize, "TXT:"); + + if (!aServiceInfo.mTxtDataTruncated) + { + OutputDnsTxtData(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize); + } + else + { + OutputFormat("["); + OutputBytes(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize); + OutputFormat("...]"); + } + + OutputLine(" TTL:%lu", ToUlong(aServiceInfo.mTxtDataTtl)); +} + +void Dns::HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse, void *aContext) +{ + static_cast(aContext)->HandleDnsBrowseResponse(aError, aResponse); +} + +void Dns::HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse) +{ + char name[OT_DNS_MAX_NAME_SIZE]; + char label[OT_DNS_MAX_LABEL_SIZE]; + uint8_t txtBuffer[kMaxTxtDataSize]; + otDnsServiceInfo serviceInfo; + + IgnoreError(otDnsBrowseResponseGetServiceName(aResponse, name, sizeof(name))); + + OutputLine("DNS browse response for %s", name); + + if (aError == OT_ERROR_NONE) + { + uint16_t index = 0; + + while (otDnsBrowseResponseGetServiceInstance(aResponse, index, label, sizeof(label)) == OT_ERROR_NONE) + { + OutputLine("%s", label); + index++; + + serviceInfo.mHostNameBuffer = name; + serviceInfo.mHostNameBufferSize = sizeof(name); + serviceInfo.mTxtData = txtBuffer; + serviceInfo.mTxtDataSize = sizeof(txtBuffer); + + if (otDnsBrowseResponseGetServiceInfo(aResponse, label, &serviceInfo) == OT_ERROR_NONE) + { + OutputDnsServiceInfo(kIndentSize, serviceInfo); + } + + OutputNewLine(); + } + } + + OutputResult(aError); +} + +void Dns::HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse, void *aContext) +{ + static_cast(aContext)->HandleDnsServiceResponse(aError, aResponse); +} + +void Dns::HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse) +{ + char name[OT_DNS_MAX_NAME_SIZE]; + char label[OT_DNS_MAX_LABEL_SIZE]; + uint8_t txtBuffer[kMaxTxtDataSize]; + otDnsServiceInfo serviceInfo; + + IgnoreError(otDnsServiceResponseGetServiceName(aResponse, label, sizeof(label), name, sizeof(name))); + + OutputLine("DNS service resolution response for %s for service %s", label, name); + + if (aError == OT_ERROR_NONE) + { + serviceInfo.mHostNameBuffer = name; + serviceInfo.mHostNameBufferSize = sizeof(name); + serviceInfo.mTxtData = txtBuffer; + serviceInfo.mTxtDataSize = sizeof(txtBuffer); + + if (otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo) == OT_ERROR_NONE) + { + OutputDnsServiceInfo(/* aIndentSize */ 0, serviceInfo); + OutputNewLine(); + } + } + + OutputResult(aError); +} + +#endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE +#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + +#if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE + +template <> otError Dns::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + + if (aArgs[0].IsEmpty()) + { + error = OT_ERROR_INVALID_ARGS; + } +#if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE + /** + * @cli dns server upstream + * @code + * dns server upstream + * Enabled + * Done + * @endcode + * @par api_copy + * #otDnssdUpstreamQueryIsEnabled + */ + else if (aArgs[0] == "upstream") + { + /** + * @cli dns server upstream {enable|disable} + * @code + * dns server upstream enable + * Done + * @endcode + * @cparam dns server upstream @ca{enable|disable} + * @par api_copy + * #otDnssdUpstreamQuerySetEnabled + */ + error = Interpreter::GetInterpreter().ProcessEnableDisable(aArgs + 1, otDnssdUpstreamQueryIsEnabled, + otDnssdUpstreamQuerySetEnabled); + } +#endif // OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE + else + { + ExitNow(error = OT_ERROR_INVALID_COMMAND); + } + +exit: + return error; +} + +#endif // OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE + +otError Dns::Process(Arg aArgs[]) +{ +#define CmdEntry(aCommandString) \ + { \ + aCommandString, &Dns::Process \ + } + + static constexpr Command kCommands[] = { + +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE && OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + CmdEntry("browse"), +#endif +#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE + CmdEntry("compression"), +#endif +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + CmdEntry("config"), + CmdEntry("resolve"), +#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE + CmdEntry("resolve4"), +#endif +#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE +#if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE + CmdEntry("server"), +#endif +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE && OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + CmdEntry("service"), + CmdEntry("servicehost"), +#endif + }; + +#undef CmdEntry + + static_assert(BinarySearch::IsSorted(kCommands), "kCommands is not sorted"); + + otError error = OT_ERROR_INVALID_COMMAND; + const Command *command; + + if (aArgs[0].IsEmpty() || (aArgs[0] == "help")) + { + OutputCommandTable(kCommands); + ExitNow(error = aArgs[0].IsEmpty() ? error : OT_ERROR_NONE); + } + + command = BinarySearch::Find(aArgs[0].GetCString(), kCommands); + VerifyOrExit(command != nullptr); + + error = (this->*command->mHandler)(aArgs + 1); + +exit: + return error; +} + +} // namespace Cli +} // namespace ot + +#endif // OPENTHREAD_CLI_DNS_ENABLE diff --git a/src/cli/cli_dns.hpp b/src/cli/cli_dns.hpp new file mode 100644 index 00000000000..b9f16793973 --- /dev/null +++ b/src/cli/cli_dns.hpp @@ -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. + */ + +/** + * @file + * This file contains definitions for CLI to DNS (client and resolver). + */ + +#ifndef CLI_DNS_HPP_ +#define CLI_DNS_HPP_ + +#include "openthread-core-config.h" + +#ifdef OPENTHREAD_CLI_DNS_ENABLE +#error "OPENTHREAD_CLI_DNS_ENABLE MUST not be defined directly, it is derived from `OPENTHREAD_CONFIG_*` configs". +#endif + +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE || OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE || \ + OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE +#define OPENTHREAD_CLI_DNS_ENABLE 1 +#else +#define OPENTHREAD_CLI_DNS_ENABLE 0 +#endif + +#if OPENTHREAD_CLI_DNS_ENABLE + +#include +#include +#include + +#include "cli/cli_config.h" +#include "cli/cli_output.hpp" + +namespace ot { +namespace Cli { + +/** + * Implements the DNS CLI interpreter. + * + */ +class Dns : private Output +{ +public: + typedef Utils::CmdLineParser::Arg Arg; + + /** + * Constructor. + * + * @param[in] aInstance The OpenThread Instance. + * @param[in] aOutputImplementer An `OutputImplementer`. + * + */ + Dns(otInstance *aInstance, OutputImplementer &aOutputImplementer) + : Output(aInstance, aOutputImplementer) + { + } + + /** + * Processes a CLI sub-command. + * + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. + * + */ + otError Process(Arg aArgs[]); + +private: + static constexpr uint8_t kIndentSize = 4; + static constexpr uint16_t kMaxTxtDataSize = OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE; + + using Command = CommandEntry; + + template otError Process(Arg aArgs[]); + +#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE + void OutputResult(otError aError); + otError GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig); + const char *DnsConfigServiceModeToString(otDnsServiceMode aMode) const; + otError ParseDnsServiceMode(const Arg &aArg, otDnsServiceMode &aMode) const; + static void HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse, void *aContext); + void HandleDnsAddressResponse(otError aError, const otDnsAddressResponse *aResponse); +#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + static const char *const kServiceModeStrings[]; + + typedef otError (&ResolveServiceFn)(otInstance *, + const char *, + const char *, + otDnsServiceCallback, + void *, + const otDnsQueryConfig *); + + otError ProcessService(Arg aArgs[], ResolveServiceFn aResolveServiceFn); + void OutputDnsServiceInfo(uint8_t aIndentSize, const otDnsServiceInfo &aServiceInfo); + static void HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse, void *aContext); + void HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse); + static void HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse, void *aContext); + void HandleDnsServiceResponse(otError aError, const otDnsServiceResponse *aResponse); +#endif +#endif +}; + +} // namespace Cli +} // namespace ot + +#endif // OPENTHREAD_CLI_DNS_ENABLE + +#endif // CLI_DNS_HPP_ diff --git a/src/cli/cli_history.cpp b/src/cli/cli_history.cpp index 0ea5ebf694e..e2fa08753fb 100644 --- a/src/cli/cli_history.cpp +++ b/src/cli/cli_history.cpp @@ -572,7 +572,7 @@ void History::OutputRxTxEntryListFormat(const otHistoryTrackerMessageInfo &aInfo otHistoryTrackerEntryAgeToString(aEntryAge, ageString, sizeof(ageString)); OutputLine("%s", ageString); - OutputFormat(kIndentSize, "type:%s len:%u cheksum:0x%04x sec:%s prio:%s ", MessageTypeToString(aInfo), + OutputFormat(kIndentSize, "type:%s len:%u checksum:0x%04x sec:%s prio:%s ", MessageTypeToString(aInfo), aInfo.mPayloadLength, aInfo.mChecksum, aInfo.mLinkSecurity ? "yes" : "no", MessagePriorityToString(aInfo.mPriority)); if (aIsRx) diff --git a/src/cli/cli_history.hpp b/src/cli/cli_history.hpp index cab6d79eb4a..90f832fbf86 100644 --- a/src/cli/cli_history.hpp +++ b/src/cli/cli_history.hpp @@ -47,7 +47,7 @@ namespace ot { namespace Cli { /** - * This class implements the History Tracker CLI interpreter. + * Implements the History Tracker CLI interpreter. * */ class History : private Output @@ -68,9 +68,15 @@ class History : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs A pointer an array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_joiner.hpp b/src/cli/cli_joiner.hpp index cc3ddac2c55..e45dbf8dbfe 100644 --- a/src/cli/cli_joiner.hpp +++ b/src/cli/cli_joiner.hpp @@ -46,7 +46,7 @@ namespace ot { namespace Cli { /** - * This class implements the Joiner CLI interpreter. + * Implements the Joiner CLI interpreter. * */ class Joiner : private Output @@ -67,9 +67,15 @@ class Joiner : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs A pointer to an array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_mac_filter.cpp b/src/cli/cli_mac_filter.cpp new file mode 100644 index 00000000000..6525a20aafb --- /dev/null +++ b/src/cli/cli_mac_filter.cpp @@ -0,0 +1,297 @@ +/* + * 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 + * This file implements CLI for MAC Filter. + */ + +#include "cli_mac_filter.hpp" + +#include "cli/cli.hpp" + +#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE + +namespace ot { +namespace Cli { + +void MacFilter::OutputFilter(uint8_t aFilters) +{ + otMacFilterEntry entry; + otMacFilterIterator iterator; + + if (aFilters & kAddressFilter) + { + if ((aFilters & ~kAddressFilter) != 0) + { + OutputFormat("Address Mode: "); + } + + OutputLine("%s", AddressModeToString(otLinkFilterGetAddressMode(GetInstancePtr()))); + + iterator = OT_MAC_FILTER_ITERATOR_INIT; + + while (otLinkFilterGetNextAddress(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) + { + OutputEntry(entry); + } + } + + if (aFilters & kRssFilter) + { + if ((aFilters & ~kRssFilter) != 0) + { + OutputLine("RssIn List:"); + } + + iterator = OT_MAC_FILTER_ITERATOR_INIT; + + while (otLinkFilterGetNextRssIn(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE) + { + if (IsDefaultRss(entry.mExtAddress)) + { + OutputLine("Default rss: %d (lqi %u)", entry.mRssIn, + otLinkConvertRssToLinkQuality(GetInstancePtr(), entry.mRssIn)); + } + else + { + OutputEntry(entry); + } + } + } +} + +bool MacFilter::IsDefaultRss(const otExtAddress &aExtAddress) +{ + // In default RSS entry, the extended address will be all `0xff`. + + bool isDefault = true; + + for (uint8_t byte : aExtAddress.m8) + { + if (byte != 0xff) + { + isDefault = false; + break; + } + } + + return isDefault; +} + +const char *MacFilter::AddressModeToString(otMacFilterAddressMode aMode) +{ + static const char *const kModeStrings[] = { + "Disabled", // (0) OT_MAC_FILTER_ADDRESS_MODE_DISABLED + "Allowlist", // (1) OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST + "Denylist", // (2) OT_MAC_FILTER_ADDRESS_MODE_DENYLIST + }; + + static_assert(0 == OT_MAC_FILTER_ADDRESS_MODE_DISABLED, "OT_MAC_FILTER_ADDRESS_MODE_DISABLED value is incorrect"); + static_assert(1 == OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST, "OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST value is incorrect"); + static_assert(2 == OT_MAC_FILTER_ADDRESS_MODE_DENYLIST, "OT_MAC_FILTER_ADDRESS_MODE_DENYLIST value is incorrect"); + + return Stringify(aMode, kModeStrings); +} + +void MacFilter::OutputEntry(const otMacFilterEntry &aEntry) +{ + OutputExtAddress(aEntry.mExtAddress); + + if (aEntry.mRssIn != OT_MAC_FILTER_FIXED_RSS_DISABLED) + { + OutputFormat(" : rss %d (lqi %d)", aEntry.mRssIn, + otLinkConvertRssToLinkQuality(GetInstancePtr(), aEntry.mRssIn)); + } + + OutputNewLine(); +} + +template <> otError MacFilter::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otExtAddress extAddr; + + if (aArgs[0].IsEmpty()) + { + OutputFilter(kAddressFilter); + } + else if (aArgs[0] == "add") + { + SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); + error = otLinkFilterAddAddress(GetInstancePtr(), &extAddr); + + VerifyOrExit(error == OT_ERROR_NONE || error == OT_ERROR_ALREADY); + + if (!aArgs[2].IsEmpty()) + { + int8_t rss; + + SuccessOrExit(error = aArgs[2].ParseAsInt8(rss)); + SuccessOrExit(error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss)); + } + } + else if (aArgs[0] == "remove") + { + SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); + otLinkFilterRemoveAddress(GetInstancePtr(), &extAddr); + } + else if (aArgs[0] == "clear") + { + otLinkFilterClearAddresses(GetInstancePtr()); + } + else + { + static const char *const kModeCommands[] = { + "disable", // (0) OT_MAC_FILTER_ADDRESS_MODE_DISABLED + "allowlist", // (1) OT_MAC_FILTER_ADDRESS_MODE_ALLOWLIST + "denylist", // (2) OT_MAC_FILTER_ADDRESS_MODE_DENYLIST + }; + + for (uint8_t index = 0; index < OT_ARRAY_LENGTH(kModeCommands); index++) + { + if (aArgs[0] == kModeCommands[index]) + { + VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + otLinkFilterSetAddressMode(GetInstancePtr(), static_cast(index)); + ExitNow(); + } + } + + error = OT_ERROR_INVALID_COMMAND; + } + +exit: + return error; +} + +template <> otError MacFilter::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + otExtAddress extAddr; + int8_t rss; + + if (aArgs[0].IsEmpty()) + { + OutputFilter(kRssFilter); + } + else if (aArgs[0] == "add-lqi") + { + uint8_t linkQuality; + + SuccessOrExit(error = aArgs[2].ParseAsUint8(linkQuality)); + VerifyOrExit(linkQuality <= 3, error = OT_ERROR_INVALID_ARGS); + rss = otLinkConvertLinkQualityToRss(GetInstancePtr(), linkQuality); + + if (aArgs[1] == "*") + { + otLinkFilterSetDefaultRssIn(GetInstancePtr(), rss); + } + else + { + SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); + error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss); + } + } + else if (aArgs[0] == "add") + { + SuccessOrExit(error = aArgs[2].ParseAsInt8(rss)); + + if (aArgs[1] == "*") + { + otLinkFilterSetDefaultRssIn(GetInstancePtr(), rss); + } + else + { + SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); + error = otLinkFilterAddRssIn(GetInstancePtr(), &extAddr, rss); + } + } + else if (aArgs[0] == "remove") + { + if (aArgs[1] == "*") + { + otLinkFilterClearDefaultRssIn(GetInstancePtr()); + } + else + { + SuccessOrExit(error = aArgs[1].ParseAsHexString(extAddr.m8)); + otLinkFilterRemoveRssIn(GetInstancePtr(), &extAddr); + } + } + else if (aArgs[0] == "clear") + { + otLinkFilterClearAllRssIn(GetInstancePtr()); + } + else + { + error = OT_ERROR_INVALID_COMMAND; + } + +exit: + return error; +} + +otError MacFilter::Process(Arg aArgs[]) +{ +#define CmdEntry(aCommandString) \ + { \ + aCommandString, &MacFilter::Process \ + } + + static constexpr Command kCommands[] = { + CmdEntry("addr"), + CmdEntry("rss"), + }; + +#undef CmdEntry + + static_assert(BinarySearch::IsSorted(kCommands), "kCommands is not sorted"); + + otError error = OT_ERROR_INVALID_COMMAND; + const Command *command; + + if (aArgs[0].IsEmpty()) + { + OutputFilter(kAddressFilter | kRssFilter); + ExitNow(error = OT_ERROR_NONE); + } + + command = BinarySearch::Find(aArgs[0].GetCString(), kCommands); + VerifyOrExit(command != nullptr); + + error = (this->*command->mHandler)(aArgs + 1); + +exit: + return error; +} + +} // namespace Cli +} // namespace ot + +#endif // OPENTHREAD_CONFIG_MAC_FILTER_ENABLE diff --git a/src/cli/cli_mac_filter.hpp b/src/cli/cli_mac_filter.hpp new file mode 100644 index 00000000000..1394d4fa0ca --- /dev/null +++ b/src/cli/cli_mac_filter.hpp @@ -0,0 +1,106 @@ +/* + * 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 + * This file contains definitions for CLI to MAC Filter. + */ + +#ifndef CLI_MAC_FILTER_HPP_ +#define CLI_MAC_FILTER_HPP_ + +#include "openthread-core-config.h" + +#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE + +#include + +#include "cli/cli_config.h" +#include "cli/cli_output.hpp" + +namespace ot { +namespace Cli { + +/** + * Implements the MAC Filter CLI interpreter. + * + */ +class MacFilter : private Output +{ +public: + typedef Utils::CmdLineParser::Arg Arg; + + /** + * Constructor. + * + * @param[in] aInstance The OpenThread Instance. + * @param[in] aOutputImplementer An `OutputImplementer`. + * + */ + MacFilter(otInstance *aInstance, OutputImplementer &aOutputImplementer) + : Output(aInstance, aOutputImplementer) + { + } + + /** + * Processes a CLI sub-command. + * + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. + * + */ + otError Process(Arg aArgs[]); + +private: + static constexpr uint8_t kIndentSize = 4; + + using Command = CommandEntry; + + template otError Process(Arg aArgs[]); + + // For use as input to `OutputFilter()` + static constexpr uint8_t kAddressFilter = (1U << 0); + static constexpr uint8_t kRssFilter = (1U << 1); + + void OutputFilter(uint8_t aFilters); + void OutputEntry(const otMacFilterEntry &aEntry); + static bool IsDefaultRss(const otExtAddress &aExtAddress); + static const char *AddressModeToString(otMacFilterAddressMode aMode); +}; + +} // namespace Cli +} // namespace ot + +#endif // OPENTHREAD_CLI_DNS_ENABLE + +#endif // CLI_MAC_FILTER_HPP_ diff --git a/src/cli/cli_network_data.cpp b/src/cli/cli_network_data.cpp index 36fcf3de59b..8c492e38ac2 100644 --- a/src/cli/cli_network_data.cpp +++ b/src/cli/cli_network_data.cpp @@ -43,6 +43,15 @@ namespace ot { namespace Cli { +NetworkData::NetworkData(otInstance *aInstance, OutputImplementer &aOutputImplementer) + : Output(aInstance, aOutputImplementer) +{ +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + mFullCallbackWasCalled = false; + otBorderRouterSetNetDataFullCallback(aInstance, HandleNetdataFull, this); +#endif +} + void NetworkData::PrefixFlagsToString(const otBorderRouterConfig &aConfig, FlagsString &aString) { char *flagsPtr = &aString[0]; @@ -802,6 +811,58 @@ template <> otError NetworkData::Process(Arg aArgs[]) return error; } +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL +template <> otError NetworkData::Process(Arg aArgs[]) +{ + otError error = OT_ERROR_NONE; + + /** + * @cli netdata full + * @code + * netdata full + * no + * Done + * @endcode + * @par + * Print "yes" or "no" indicating whether or not the "net data full" callback has been invoked since start of + * Thread operation or since the last time `netdata full reset` was used to reset the flag. + * This command requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`. + * The "net data full" callback is invoked whenever: + * - The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it + * cannot add to Network Data (running out of space). + * - The device is acting as a BR and new entries cannot be added to its local Network Data. + * - The device is acting as a BR and tries to register its local Network Data entries with the leader, but + * determines that its local entries will not fit. + * @sa otBorderRouterSetNetDataFullCallback + */ + if (aArgs[0].IsEmpty()) + { + OutputLine(mFullCallbackWasCalled ? "yes" : "no"); + } + /** + * @cli netdata full reset + * @code + * netdata full reset + * Done + * @endcode + * @par + * Reset the flag tracking whether "net data full" callback was invoked. + */ + else if (aArgs[0] == "reset") + { + VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); + mFullCallbackWasCalled = false; + } + else + { + error = OT_ERROR_INVALID_ARGS; + } + +exit: + return error; +} +#endif // OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + otError NetworkData::Process(Arg aArgs[]) { #define CmdEntry(aCommandString) \ @@ -810,6 +871,9 @@ otError NetworkData::Process(Arg aArgs[]) } static constexpr Command kCommands[] = { +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + CmdEntry("full"), +#endif CmdEntry("length"), CmdEntry("maxlength"), #if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE diff --git a/src/cli/cli_network_data.hpp b/src/cli/cli_network_data.hpp index d751c458761..635ff383bdb 100644 --- a/src/cli/cli_network_data.hpp +++ b/src/cli/cli_network_data.hpp @@ -44,7 +44,7 @@ namespace ot { namespace Cli { /** - * This class implements the Network Data CLI. + * Implements the Network Data CLI. * */ class NetworkData : private Output @@ -71,21 +71,24 @@ class NetworkData : private Output * @param[in] aOutputImplementer An `OutputImplementer`. * */ - NetworkData(otInstance *aInstance, OutputImplementer &aOutputImplementer) - : Output(aInstance, aOutputImplementer) - { - } + NetworkData(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); /** - * This method outputs the prefix config. + * Outputs the prefix config. * * @param[in] aConfig The prefix config. * @@ -93,7 +96,7 @@ class NetworkData : private Output void OutputPrefix(const otBorderRouterConfig &aConfig); /** - * This method outputs the route config. + * Outputs the route config. * * @param[in] aConfig The route config. * @@ -101,7 +104,7 @@ class NetworkData : private Output void OutputRoute(const otExternalRouteConfig &aConfig); /** - * This method outputs the service config. + * Outputs the service config. * * @param[in] aConfig The service config. * @@ -109,7 +112,7 @@ class NetworkData : private Output void OutputService(const otServiceConfig &aConfig); /** - * This method converts the flags from a given prefix config to string. + * Converts the flags from a given prefix config to string. * * @param[in] aConfig The prefix config. * @param[out] aString The string to populate from @a Config flags. @@ -118,7 +121,7 @@ class NetworkData : private Output static void PrefixFlagsToString(const otBorderRouterConfig &aConfig, FlagsString &aString); /** - * This method converts the flags from a given route config to string. + * Converts the flags from a given route config to string. * * @param[in] aConfig The route config. * @param[out] aString The string to populate from @a Config flags. @@ -140,6 +143,13 @@ class NetworkData : private Output void OutputRoutes(bool aLocal); void OutputServices(bool aLocal); void OutputLowpanContexts(bool aLocal); + +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + static void HandleNetdataFull(void *aContext) { static_cast(aContext)->HandleNetdataFull(); } + void HandleNetdataFull(void) { mFullCallbackWasCalled = true; } + + bool mFullCallbackWasCalled; +#endif }; } // namespace Cli diff --git a/src/cli/cli_output.hpp b/src/cli/cli_output.hpp index 1c46935dca4..8941f7e5757 100644 --- a/src/cli/cli_output.hpp +++ b/src/cli/cli_output.hpp @@ -51,7 +51,7 @@ namespace ot { namespace Cli { /** - * This type represents a ID number value associated with a CLI command string. + * Represents a ID number value associated with a CLI command string. * */ typedef uint64_t CommandId; @@ -72,7 +72,7 @@ constexpr static CommandId Cmd(const char *aString) class Output; /** - * This class implements the basic output functions. + * Implements the basic output functions. * */ class OutputImplementer @@ -81,7 +81,7 @@ class OutputImplementer public: /** - * This constructor initializes the `OutputImplementer` object. + * Initializes the `OutputImplementer` object. * * @param[in] aCallback A pointer to an `otCliOutputCallback` to deliver strings to the CLI console. * @param[in] aCallbackContext An arbitrary context to pass in when invoking @p aCallback. @@ -110,7 +110,7 @@ class OutputImplementer }; /** - * This class provides CLI output helper methods. + * Provides CLI output helper methods. * */ class Output @@ -119,7 +119,7 @@ class Output typedef Utils::CmdLineParser::Arg Arg; ///< An argument /** - * This structure represent a CLI command table entry, mapping a command with `aName` to a handler method. + * Represent a CLI command table entry, mapping a command with `aName` to a handler method. * * @tparam Cli The CLI module type. * @@ -129,7 +129,7 @@ class Output typedef otError (Cli::*Handler)(Arg aArgs[]); ///< The handler method pointer type. /** - * This method compares the entry's name with a given name. + * Compares the entry's name with a given name. * * @param aName The name string to compare with. * @@ -183,7 +183,7 @@ class Output } /** - * This constructor initializes the `Output` object. + * Initializes the `Output` object. * * @param[in] aInstance A pointer to OpenThread instance. * @param[in] aImplementer An `OutputImplementer`. @@ -196,7 +196,7 @@ class Output } /** - * This method returns the pointer to OpenThread instance. + * Returns the pointer to OpenThread instance. * * @returns The pointer to the OpenThread instance. * @@ -204,7 +204,7 @@ class Output otInstance *GetInstancePtr(void) { return mInstance; } /** - * This structure represents a buffer which is used when converting a `uint64` value to string in decimal format. + * Represents a buffer which is used when converting a `uint64` value to string in decimal format. * */ struct Uint64StringBuffer @@ -215,7 +215,7 @@ class Output }; /** - * This static method converts a `uint64_t` value to a decimal format string. + * Converts a `uint64_t` value to a decimal format string. * * @param[in] aUint64 The `uint64_t` value to convert. * @param[in] aBuffer A buffer to allocate the string from. @@ -226,7 +226,7 @@ class Output static const char *Uint64ToString(uint64_t aUint64, Uint64StringBuffer &aBuffer); /** - * This method delivers a formatted output string to the CLI console. + * Delivers a formatted output string to the CLI console. * * @param[in] aFormat A pointer to the format string. * @param[in] ... A variable list of arguments to format. @@ -235,7 +235,7 @@ class Output void OutputFormat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3); /** - * This method delivers a formatted output string to the CLI console (to which it prepends a given number + * Delivers a formatted output string to the CLI console (to which it prepends a given number * indentation space chars). * * @param[in] aIndentSize Number of indentation space chars to prepend to the string. @@ -246,7 +246,7 @@ class Output void OutputFormat(uint8_t aIndentSize, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 4); /** - * This method delivers a formatted output string to the CLI console (to which it also appends newline "\r\n"). + * Delivers a formatted output string to the CLI console (to which it also appends newline "\r\n"). * * @param[in] aFormat A pointer to the format string. * @param[in] ... A variable list of arguments to format. @@ -255,7 +255,7 @@ class Output void OutputLine(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3); /** - * This method delivers a formatted output string to the CLI console (to which it prepends a given number + * Delivers a formatted output string to the CLI console (to which it prepends a given number * indentation space chars and appends newline "\r\n"). * * @param[in] aIndentSize Number of indentation space chars to prepend to the string. @@ -266,13 +266,13 @@ class Output void OutputLine(uint8_t aIndentSize, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 4); /** - * This method delivered newline "\r\n" to the CLI console. + * Delivered newline "\r\n" to the CLI console. * */ void OutputNewLine(void); /** - * This method outputs a given number of space chars to the CLI console. + * Outputs a given number of space chars to the CLI console. * * @param[in] aCount Number of space chars to output. * @@ -280,7 +280,7 @@ class Output void OutputSpaces(uint8_t aCount); /** - * This method outputs a number of bytes to the CLI console as a hex string. + * Outputs a number of bytes to the CLI console as a hex string. * * @param[in] aBytes A pointer to data which should be printed. * @param[in] aLength @p aBytes length. @@ -289,7 +289,7 @@ class Output void OutputBytes(const uint8_t *aBytes, uint16_t aLength); /** - * This method outputs a number of bytes to the CLI console as a hex string and at the end it also outputs newline + * Outputs a number of bytes to the CLI console as a hex string and at the end it also outputs newline * "\r\n". * * @param[in] aBytes A pointer to data which should be printed. @@ -299,7 +299,7 @@ class Output void OutputBytesLine(const uint8_t *aBytes, uint16_t aLength); /** - * This method outputs a number of bytes to the CLI console as a hex string. + * Outputs a number of bytes to the CLI console as a hex string. * * @tparam kBytesLength The length of @p aBytes array. * @@ -312,7 +312,7 @@ class Output } /** - * This method outputs a number of bytes to the CLI console as a hex string and at the end it also outputs newline + * Outputs a number of bytes to the CLI console as a hex string and at the end it also outputs newline * "\r\n". * * @tparam kBytesLength The length of @p aBytes array. @@ -326,7 +326,7 @@ class Output } /** - * This method outputs an Extended MAC Address to the CLI console. + * Outputs an Extended MAC Address to the CLI console. * * param[in] aExtAddress The Extended MAC Address to output. * @@ -334,7 +334,7 @@ class Output void OutputExtAddress(const otExtAddress &aExtAddress) { OutputBytes(aExtAddress.m8); } /** - * This method outputs an Extended MAC Address to the CLI console and at the end it also outputs newline "\r\n". + * Outputs an Extended MAC Address to the CLI console and at the end it also outputs newline "\r\n". * * param[in] aExtAddress The Extended MAC Address to output. * @@ -342,7 +342,7 @@ class Output void OutputExtAddressLine(const otExtAddress &aExtAddress) { OutputBytesLine(aExtAddress.m8); } /** - * This method outputs a `uint64_t` value in decimal format. + * Outputs a `uint64_t` value in decimal format. * * @param[in] aUint64 The `uint64_t` value to output. * @@ -350,7 +350,7 @@ class Output void OutputUint64(uint64_t aUint64); /** - * This method outputs a `uint64_t` value in decimal format and at the end it also outputs newline "\r\n". + * Outputs a `uint64_t` value in decimal format and at the end it also outputs newline "\r\n". * * @param[in] aUint64 The `uint64_t` value to output. * @@ -358,7 +358,7 @@ class Output void OutputUint64Line(uint64_t aUint64); /** - * This method outputs "Enabled" or "Disabled" status to the CLI console (it also appends newline "\r\n"). + * Outputs "Enabled" or "Disabled" status to the CLI console (it also appends newline "\r\n"). * * @param[in] aEnabled A boolean indicating the status. TRUE outputs "Enabled", FALSE outputs "Disabled". * @@ -368,7 +368,7 @@ class Output #if OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This method outputs an IPv6 address to the CLI console. + * Outputs an IPv6 address to the CLI console. * * @param[in] aAddress A reference to the IPv6 address. * @@ -376,7 +376,7 @@ class Output void OutputIp6Address(const otIp6Address &aAddress); /** - * This method outputs an IPv6 address to the CLI console and at the end it also outputs newline "\r\n". + * Outputs an IPv6 address to the CLI console and at the end it also outputs newline "\r\n". * * @param[in] aAddress A reference to the IPv6 address. * @@ -384,7 +384,7 @@ class Output void OutputIp6AddressLine(const otIp6Address &aAddress); /** - * This method outputs an IPv6 prefix to the CLI console. + * Outputs an IPv6 prefix to the CLI console. * * @param[in] aPrefix A reference to the IPv6 prefix. * @@ -392,7 +392,7 @@ class Output void OutputIp6Prefix(const otIp6Prefix &aPrefix); /** - * This method outputs an IPv6 prefix to the CLI console and at the end it also outputs newline "\r\n". + * Outputs an IPv6 prefix to the CLI console and at the end it also outputs newline "\r\n". * * @param[in] aPrefix A reference to the IPv6 prefix. * @@ -400,7 +400,7 @@ class Output void OutputIp6PrefixLine(const otIp6Prefix &aPrefix); /** - * This method outputs an IPv6 network prefix to the CLI console. + * Outputs an IPv6 network prefix to the CLI console. * * @param[in] aPrefix A reference to the IPv6 network prefix. * @@ -408,7 +408,7 @@ class Output void OutputIp6Prefix(const otIp6NetworkPrefix &aPrefix); /** - * This method outputs an IPv6 network prefix to the CLI console and at the end it also outputs newline "\r\n". + * Outputs an IPv6 network prefix to the CLI console and at the end it also outputs newline "\r\n". * * @param[in] aPrefix A reference to the IPv6 network prefix. * @@ -416,7 +416,7 @@ class Output void OutputIp6PrefixLine(const otIp6NetworkPrefix &aPrefix); /** - * This method outputs an IPv6 socket address to the CLI console. + * Outputs an IPv6 socket address to the CLI console. * * @param[in] aSockAddr A reference to the IPv6 socket address. * @@ -424,7 +424,7 @@ class Output void OutputSockAddr(const otSockAddr &aSockAddr); /** - * This method outputs an IPv6 socket address to the CLI console and at the end it also outputs newline "\r\n". + * Outputs an IPv6 socket address to the CLI console and at the end it also outputs newline "\r\n". * * @param[in] aSockAddr A reference to the IPv6 socket address. * @@ -432,7 +432,7 @@ class Output void OutputSockAddrLine(const otSockAddr &aSockAddr); /** - * This method outputs DNS TXT data to the CLI console. + * Outputs DNS TXT data to the CLI console. * * @param[in] aTxtData A pointer to a buffer containing the DNS TXT data. * @param[in] aTxtDataLength The length of @p aTxtData (in bytes). @@ -441,7 +441,7 @@ class Output void OutputDnsTxtData(const uint8_t *aTxtData, uint16_t aTxtDataLength); /** - * This structure represents a buffer which is used when converting an encoded rate value to percentage string. + * Represents a buffer which is used when converting an encoded rate value to percentage string. * */ struct PercentageStringBuffer @@ -452,7 +452,7 @@ class Output }; /** - * This static method converts an encoded value to a percentage representation. + * Converts an encoded value to a percentage representation. * * The encoded @p aValue is assumed to be linearly scaled such that `0` maps to 0% and `0xffff` maps to 100%. * @@ -469,7 +469,7 @@ class Output #endif // OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This method outputs a table header to the CLI console. + * Outputs a table header to the CLI console. * * An example of the table header format: * @@ -492,7 +492,7 @@ class Output } /** - * This method outputs a table separator to the CLI console. + * Outputs a table separator to the CLI console. * * An example of the table separator: * @@ -511,7 +511,7 @@ class Output } /** - * This method outputs the list of commands from a given command table. + * Outputs the list of commands from a given command table. * * @tparam Cli The CLI module type. * @tparam kLength The length of command table array. diff --git a/src/cli/cli_srp_client.cpp b/src/cli/cli_srp_client.cpp index 0294c5306d5..290dec52870 100644 --- a/src/cli/cli_srp_client.cpp +++ b/src/cli/cli_srp_client.cpp @@ -331,17 +331,8 @@ template <> otError SrpClient::Process(Arg aArgs[]) { // `key [enable/disable]` - bool enable; - - if (aArgs[1].IsEmpty()) - { - OutputEnabledDisabledStatus(otSrpClientIsServiceKeyRecordEnabled(GetInstancePtr())); - ExitNow(); - } - - SuccessOrExit(error = Interpreter::ParseEnableOrDisable(aArgs[1], enable)); - VerifyOrExit(aArgs[2].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - otSrpClientSetServiceKeyRecordEnabled(GetInstancePtr(), enable); + error = Interpreter::GetInterpreter().ProcessEnableDisable(aArgs + 1, otSrpClientIsServiceKeyRecordEnabled, + otSrpClientSetServiceKeyRecordEnabled); } #endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE else diff --git a/src/cli/cli_srp_client.hpp b/src/cli/cli_srp_client.hpp index 9b9ea4237ec..5d96a1366f1 100644 --- a/src/cli/cli_srp_client.hpp +++ b/src/cli/cli_srp_client.hpp @@ -48,7 +48,7 @@ namespace ot { namespace Cli { /** - * This class implements the SRP Client CLI interpreter. + * Implements the SRP Client CLI interpreter. * */ class SrpClient : private Output @@ -66,9 +66,15 @@ class SrpClient : private Output SrpClient(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs A pointer an array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_srp_server.cpp b/src/cli/cli_srp_server.cpp index 6a0a4027600..50281ade179 100644 --- a/src/cli/cli_srp_server.cpp +++ b/src/cli/cli_srp_server.cpp @@ -75,24 +75,18 @@ template <> otError SrpServer::Process(Arg aArgs[]) } #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE +/** + * @cli srp server auto + * @code + * srp server auto + * Disabled + * Done + * @endcode + * @par api_copy + * #otSrpServerIsAutoEnableMode + */ template <> otError SrpServer::Process(Arg aArgs[]) { - otError error = OT_ERROR_NONE; - - /** - * @cli srp server auto - * @code - * srp server auto - * Disabled - * Done - * @endcode - * @par api_copy - * #otSrpServerIsAutoEnableMode - */ - if (aArgs[0].IsEmpty()) - { - OutputEnabledDisabledStatus(otSrpServerIsAutoEnableMode(GetInstancePtr())); - } /** * @cli srp server auto enable * @code @@ -102,16 +96,8 @@ template <> otError SrpServer::Process(Arg aArgs[]) * @par api_copy * #otSrpServerSetAutoEnableMode */ - else - { - bool enable; - - SuccessOrExit(error = Interpreter::ParseEnableOrDisable(aArgs[0], enable)); - otSrpServerSetAutoEnableMode(GetInstancePtr(), enable); - } - -exit: - return error; + return Interpreter::GetInterpreter().ProcessEnableDisable(aArgs, otSrpServerIsAutoEnableMode, + otSrpServerSetAutoEnableMode); } #endif diff --git a/src/cli/cli_srp_server.hpp b/src/cli/cli_srp_server.hpp index 6d179d2a9af..344d3c2bb75 100644 --- a/src/cli/cli_srp_server.hpp +++ b/src/cli/cli_srp_server.hpp @@ -46,7 +46,7 @@ namespace ot { namespace Cli { /** - * This class implements the SRP Server CLI interpreter. + * Implements the SRP Server CLI interpreter. * */ class SrpServer : private Output @@ -67,12 +67,15 @@ class SrpServer : private Output } /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs A pointer to an array of command line arguments. + * @param[in] aArgs An array of command line arguments. * - * @retval OT_ERROR_NONE Successfully executed the CLI command. - * @retval ... Failed to execute the CLI command. + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/cli/cli_tcp.cpp b/src/cli/cli_tcp.cpp index 3e1cc82ff11..f74f4333123 100644 --- a/src/cli/cli_tcp.cpp +++ b/src/cli/cli_tcp.cpp @@ -70,6 +70,7 @@ TcpExample::TcpExample(otInstance *aInstance, OutputImplementer &aOutputImplemen , mTlsHandshakeComplete(false) , mBenchmarkBytesTotal(0) , mBenchmarkBytesUnsent(0) + , mBenchmarkTimeUsed(0) { mEndpointAndCircularSendBuffer.mEndpoint = &mEndpoint; mEndpointAndCircularSendBuffer.mSendBuffer = &mSendBuffer; @@ -377,49 +378,74 @@ template <> otError TcpExample::Process(Arg aArgs[]) { otError error = OT_ERROR_NONE; - VerifyOrExit(!mSendBusy, error = OT_ERROR_BUSY); - VerifyOrExit(mBenchmarkBytesTotal == 0, error = OT_ERROR_BUSY); - - if (aArgs[0].IsEmpty()) + if (aArgs[0] == "result") { - mBenchmarkBytesTotal = OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE; + OutputFormat("TCP Benchmark Status: "); + if (mBenchmarkBytesTotal != 0) + { + OutputLine("Ongoing"); + } + else if (mBenchmarkTimeUsed != 0) + { + OutputLine("Completed"); + OutputBenchmarkResult(); + } + else + { + OutputLine("Untested"); + } } - else + else if (aArgs[0] == "run") { - SuccessOrExit(error = aArgs[0].ParseAsUint32(mBenchmarkBytesTotal)); - VerifyOrExit(mBenchmarkBytesTotal != 0, error = OT_ERROR_INVALID_ARGS); - } - VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - - mBenchmarkStart = TimerMilli::GetNow(); - mBenchmarkBytesUnsent = mBenchmarkBytesTotal; + VerifyOrExit(!mSendBusy, error = OT_ERROR_BUSY); + VerifyOrExit(mBenchmarkBytesTotal == 0, error = OT_ERROR_BUSY); - if (mUseCircularSendBuffer) - { - SuccessOrExit(error = ContinueBenchmarkCircularSend()); - } - else - { - uint32_t benchmarkLinksLeft = (mBenchmarkBytesTotal + sizeof(mSendBufferBytes) - 1) / sizeof(mSendBufferBytes); - uint32_t toSendOut = OT_MIN(OT_ARRAY_LENGTH(mBenchmarkLinks), benchmarkLinksLeft); + if (aArgs[1].IsEmpty()) + { + mBenchmarkBytesTotal = OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE; + } + else + { + SuccessOrExit(error = aArgs[1].ParseAsUint32(mBenchmarkBytesTotal)); + VerifyOrExit(mBenchmarkBytesTotal != 0, error = OT_ERROR_INVALID_ARGS); + } + VerifyOrExit(aArgs[2].IsEmpty(), error = OT_ERROR_INVALID_ARGS); - /* We could also point the linked buffers directly to sBenchmarkData. */ - memset(mSendBufferBytes, 'a', sizeof(mSendBufferBytes)); + mBenchmarkStart = TimerMilli::GetNow(); + mBenchmarkBytesUnsent = mBenchmarkBytesTotal; - for (uint32_t i = 0; i != toSendOut; i++) + if (mUseCircularSendBuffer) { - mBenchmarkLinks[i].mNext = nullptr; - mBenchmarkLinks[i].mData = mSendBufferBytes; - mBenchmarkLinks[i].mLength = sizeof(mSendBufferBytes); - if (i == 0 && mBenchmarkBytesTotal % sizeof(mSendBufferBytes) != 0) + SuccessOrExit(error = ContinueBenchmarkCircularSend()); + } + else + { + uint32_t benchmarkLinksLeft = + (mBenchmarkBytesTotal + sizeof(mSendBufferBytes) - 1) / sizeof(mSendBufferBytes); + uint32_t toSendOut = OT_MIN(OT_ARRAY_LENGTH(mBenchmarkLinks), benchmarkLinksLeft); + + /* We could also point the linked buffers directly to sBenchmarkData. */ + memset(mSendBufferBytes, 'a', sizeof(mSendBufferBytes)); + + for (uint32_t i = 0; i != toSendOut; i++) { - mBenchmarkLinks[i].mLength = mBenchmarkBytesTotal % sizeof(mSendBufferBytes); + mBenchmarkLinks[i].mNext = nullptr; + mBenchmarkLinks[i].mData = mSendBufferBytes; + mBenchmarkLinks[i].mLength = sizeof(mSendBufferBytes); + if (i == 0 && mBenchmarkBytesTotal % sizeof(mSendBufferBytes) != 0) + { + mBenchmarkLinks[i].mLength = mBenchmarkBytesTotal % sizeof(mSendBufferBytes); + } + error = otTcpSendByReference(&mEndpoint, &mBenchmarkLinks[i], + i == toSendOut - 1 ? 0 : OT_TCP_SEND_MORE_TO_COME); + VerifyOrExit(error == OT_ERROR_NONE, mBenchmarkBytesTotal = 0); } - error = otTcpSendByReference(&mEndpoint, &mBenchmarkLinks[i], - i == toSendOut - 1 ? 0 : OT_TCP_SEND_MORE_TO_COME); - VerifyOrExit(error == OT_ERROR_NONE, mBenchmarkBytesTotal = 0); } } + else + { + error = OT_ERROR_INVALID_ARGS; + } exit: return error; @@ -860,15 +886,24 @@ otError TcpExample::ContinueBenchmarkCircularSend(void) return error; } -void TcpExample::CompleteBenchmark(void) +void TcpExample::OutputBenchmarkResult(void) { - uint32_t milliseconds = TimerMilli::GetNow() - mBenchmarkStart; - uint32_t thousandTimesGoodput = (1000 * (mBenchmarkBytesTotal << 3) + (milliseconds >> 1)) / milliseconds; + uint32_t thousandTimesGoodput = + (1000 * (mBenchmarkLastBytesTotal << 3) + (mBenchmarkTimeUsed >> 1)) / mBenchmarkTimeUsed; - OutputLine("TCP Benchmark Complete: Transferred %lu bytes in %lu milliseconds", ToUlong(mBenchmarkBytesTotal), - ToUlong(milliseconds)); + OutputLine("TCP Benchmark Complete: Transferred %lu bytes in %lu milliseconds", ToUlong(mBenchmarkLastBytesTotal), + ToUlong(mBenchmarkTimeUsed)); OutputLine("TCP Goodput: %lu.%03u kb/s", ToUlong(thousandTimesGoodput / 1000), static_cast(thousandTimesGoodput % 1000)); +} + +void TcpExample::CompleteBenchmark(void) +{ + mBenchmarkTimeUsed = TimerMilli::GetNow() - mBenchmarkStart; + mBenchmarkLastBytesTotal = mBenchmarkBytesTotal; + + OutputBenchmarkResult(); + mBenchmarkBytesTotal = 0; } diff --git a/src/cli/cli_tcp.hpp b/src/cli/cli_tcp.hpp index 9af459dbed3..24bb75fd1f7 100644 --- a/src/cli/cli_tcp.hpp +++ b/src/cli/cli_tcp.hpp @@ -56,7 +56,7 @@ namespace ot { namespace Cli { /** - * This class implements a CLI-based TCP example. + * Implements a CLI-based TCP example. * */ class TcpExample : private Output @@ -74,9 +74,15 @@ class TcpExample : private Output TcpExample(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); @@ -125,6 +131,8 @@ class TcpExample : private Output static void MbedTlsDebugOutput(void *ctx, int level, const char *file, int line, const char *str); #endif + void OutputBenchmarkResult(void); + otTcpEndpoint mEndpoint; otTcpListener mListener; @@ -145,7 +153,8 @@ class TcpExample : private Output uint32_t mBenchmarkBytesTotal; uint32_t mBenchmarkBytesUnsent; TimeMilli mBenchmarkStart; - + uint32_t mBenchmarkTimeUsed; + uint32_t mBenchmarkLastBytesTotal; otTcpEndpointAndCircularSendBuffer mEndpointAndCircularSendBuffer; #if OPENTHREAD_CONFIG_TLS_ENABLE diff --git a/src/cli/cli_udp.hpp b/src/cli/cli_udp.hpp index 55996c7ec82..0c15c807052 100644 --- a/src/cli/cli_udp.hpp +++ b/src/cli/cli_udp.hpp @@ -44,7 +44,7 @@ namespace ot { namespace Cli { /** - * This class implements a CLI-based UDP example. + * Implements a CLI-based UDP example. * */ class UdpExample : private Output @@ -62,9 +62,15 @@ class UdpExample : private Output UdpExample(otInstance *aInstance, OutputImplementer &aOutputImplementer); /** - * This method interprets a list of CLI arguments. + * Processes a CLI sub-command. * - * @param[in] aArgs An array of command line arguments. + * @param[in] aArgs An array of command line arguments. + * + * @retval OT_ERROR_NONE Successfully executed the CLI command. + * @retval OT_ERROR_PENDING The CLI command was successfully started but final result is pending. + * @retval OT_ERROR_INVALID_COMMAND Invalid or unknown CLI command. + * @retval OT_ERROR_INVALID_ARGS Invalid arguments. + * @retval ... Error during execution of the CLI command. * */ otError Process(Arg aArgs[]); diff --git a/src/core/BUILD.gn b/src/core/BUILD.gn index d7f9f63a54d..8c9aaa4e2f8 100644 --- a/src/core/BUILD.gn +++ b/src/core/BUILD.gn @@ -338,6 +338,7 @@ openthread_core_files = [ "api/netdiag_api.cpp", "api/network_time_api.cpp", "api/ping_sender_api.cpp", + "api/radio_stats_api.cpp", "api/random_crypto_api.cpp", "api/random_noncrypto_api.cpp", "api/server_api.cpp", @@ -791,6 +792,7 @@ source_set("libopenthread_core_config") { "config/logging.h", "config/mac.h", "config/mesh_diag.h", + "config/mesh_forwarder.h", "config/misc.h", "config/mle.h", "config/nat64.h", diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index eb1279f8ac1..acd33ffe666 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -70,6 +70,7 @@ set(COMMON_SOURCES api/netdiag_api.cpp api/network_time_api.cpp api/ping_sender_api.cpp + api/radio_stats_api.cpp api/random_crypto_api.cpp api/random_noncrypto_api.cpp api/server_api.cpp diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 92c2bf63470..feeb5221acd 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -160,6 +160,7 @@ SOURCES_COMMON = \ api/netdiag_api.cpp \ api/network_time_api.cpp \ api/ping_sender_api.cpp \ + api/radio_stats_api.cpp \ api/random_crypto_api.cpp \ api/random_noncrypto_api.cpp \ api/server_api.cpp \ @@ -516,6 +517,7 @@ HEADERS_COMMON = \ config/logging.h \ config/mac.h \ config/mesh_diag.h \ + config/mesh_forwarder.h \ config/misc.h \ config/mle.h \ config/nat64.h \ diff --git a/src/core/api/backbone_router_ftd_api.cpp b/src/core/api/backbone_router_ftd_api.cpp index 2f3e4b3d507..e24c642efe9 100644 --- a/src/core/api/backbone_router_ftd_api.cpp +++ b/src/core/api/backbone_router_ftd_api.cpp @@ -166,7 +166,7 @@ otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6A aTimeout = config.mMlrTimeout; } - aTimeout = Min(aTimeout, Mle::kMlrTimeoutMax); + aTimeout = Min(aTimeout, BackboneRouter::kMaxMlrTimeout); aTimeout = Time::SecToMsec(aTimeout); return AsCoreType(aInstance).Get().Add(AsCoreType(aAddress), diff --git a/src/core/api/border_agent_api.cpp b/src/core/api/border_agent_api.cpp index 70f39baef9d..35901162a59 100644 --- a/src/core/api/border_agent_api.cpp +++ b/src/core/api/border_agent_api.cpp @@ -43,9 +43,14 @@ using namespace ot; #if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE -otError otBorderAgentGetId(otInstance *aInstance, uint8_t *aId, uint16_t *aLength) +otError otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId) { - return AsCoreType(aInstance).Get().GetId(aId, *aLength); + return AsCoreType(aInstance).Get().GetId(AsCoreType(aId)); +} + +otError otBorderAgentSetId(otInstance *aInstance, const otBorderAgentId *aId) +{ + return AsCoreType(aInstance).Get().SetId(AsCoreType(aId)); } #endif diff --git a/src/core/api/border_router_api.cpp b/src/core/api/border_router_api.cpp index c3dd9ded27b..5694768e9bc 100644 --- a/src/core/api/border_router_api.cpp +++ b/src/core/api/border_router_api.cpp @@ -118,4 +118,13 @@ otError otBorderRouterRegister(otInstance *aInstance) return kErrorNone; } +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL +void otBorderRouterSetNetDataFullCallback(otInstance *aInstance, + otBorderRouterNetDataFullCallback aCallback, + void *aContext) +{ + AsCoreType(aInstance).Get().SetNetDataFullCallback(aCallback, aContext); +} +#endif + #endif // OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE diff --git a/src/core/api/border_routing_api.cpp b/src/core/api/border_routing_api.cpp index 2731e02c0cf..1e2c8de2855 100644 --- a/src/core/api/border_routing_api.cpp +++ b/src/core/api/border_routing_api.cpp @@ -36,6 +36,7 @@ #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE #include +#include #include "border_router/routing_manager.hpp" #include "common/instance.hpp" @@ -79,6 +80,15 @@ otError otBorderRoutingGetOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix) return AsCoreType(aInstance).Get().GetOmrPrefix(AsCoreType(aPrefix)); } +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +otError otBorderRoutingGetPdOmrPrefix(otInstance *aInstance, otBorderRoutingPrefixTableEntry *aPrefixInfo) +{ + AssertPointerIsNotNull(aPrefixInfo); + + return AsCoreType(aInstance).Get().GetPdOmrPrefix(*aPrefixInfo); +} +#endif + otError otBorderRoutingGetFavoredOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix, otRoutePreference *aPreference) { otError error; @@ -145,4 +155,17 @@ otError otBorderRoutingGetNextPrefixTableEntry(otInstance return AsCoreType(aInstance).Get().GetNextPrefixTableEntry(*aIterator, *aEntry); } +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +void otBorderRoutingDhcp6PdSetEnabled(otInstance *aInstance, bool aEnabled) +{ + AsCoreType(aInstance).Get().SetDhcp6PdEnabled(aEnabled); +} + +otBorderRoutingDhcp6PdState otBorderRoutingDhcp6PdGetState(otInstance *aInstance) +{ + return static_cast( + AsCoreType(aInstance).Get().GetDhcp6PdState()); +} +#endif + #endif // OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE diff --git a/src/core/api/dns_api.cpp b/src/core/api/dns_api.cpp index f1020ec5898..80246ca9394 100644 --- a/src/core/api/dns_api.cpp +++ b/src/core/api/dns_api.cpp @@ -188,6 +188,20 @@ otError otDnsClientResolveService(otInstance *aInstance, AsCoreTypePtr(aConfig)); } +otError otDnsClientResolveServiceAndHostAddress(otInstance *aInstance, + const char *aInstanceLabel, + const char *aServiceName, + otDnsServiceCallback aCallback, + void *aContext, + const otDnsQueryConfig *aConfig) +{ + AssertPointerIsNotNull(aInstanceLabel); + AssertPointerIsNotNull(aServiceName); + + return AsCoreType(aInstance).Get().ResolveServiceAndHostAddress( + aInstanceLabel, aServiceName, aCallback, aContext, AsCoreTypePtr(aConfig)); +} + otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse, char *aLabelBuffer, uint8_t aLabelBufferSize, diff --git a/src/core/api/instance_api.cpp b/src/core/api/instance_api.cpp index 06db73ce399..ad2a89e16ce 100644 --- a/src/core/api/instance_api.cpp +++ b/src/core/api/instance_api.cpp @@ -70,6 +70,8 @@ otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize) otInstance *otInstanceInitSingle(void) { return &Instance::InitSingle(); } #endif // #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE +uint32_t otInstanceGetId(otInstance *aInstance) { return AsCoreType(aInstance).GetId(); } + bool otInstanceIsInitialized(otInstance *aInstance) { #if OPENTHREAD_MTD || OPENTHREAD_FTD diff --git a/src/core/api/radio_stats_api.cpp b/src/core/api/radio_stats_api.cpp new file mode 100644 index 00000000000..7c4b6e77774 --- /dev/null +++ b/src/core/api/radio_stats_api.cpp @@ -0,0 +1,52 @@ +/* + * 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 + * This file implements the OpenThread APIs for radio statistics + */ + +#include "openthread-core-config.h" + +#include + +#include "common/as_core_type.hpp" +#include "common/locator_getters.hpp" + +using namespace ot; + +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + +const otRadioTimeStats *otRadioTimeStatsGet(otInstance *aInstance) +{ + return &AsCoreType(aInstance).Get().GetStats(); +} + +void otRadioTimeStatsReset(otInstance *aInstance) { AsCoreType(aInstance).Get().ResetTime(); } + +#endif // OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp index 96fb8903a2c..8b8504bb84d 100644 --- a/src/core/api/thread_ftd_api.cpp +++ b/src/core/api/thread_ftd_api.cpp @@ -79,6 +79,7 @@ otError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId) return AsCoreType(aInstance).Get().SetPreferredRouterId(aRouterId); } +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) const otDeviceProperties *otThreadGetDeviceProperties(otInstance *aInstance) { return &AsCoreType(aInstance).Get().GetDeviceProperties(); @@ -88,6 +89,7 @@ void otThreadSetDeviceProperties(otInstance *aInstance, const otDeviceProperties { AsCoreType(aInstance).Get().SetDeviceProperties(AsCoreType(aDeviceProperties)); } +#endif uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance) { diff --git a/src/core/backbone_router/backbone_tmf.hpp b/src/core/backbone_router/backbone_tmf.hpp index 73b92ad1bd8..286a9de9bae 100644 --- a/src/core/backbone_router/backbone_tmf.hpp +++ b/src/core/backbone_router/backbone_tmf.hpp @@ -47,14 +47,14 @@ namespace BackboneRouter { constexpr uint16_t kBackboneUdpPort = 61631; ///< Backbone TMF UDP Port /** - * This class implements functionality of the Backbone TMF agent. + * Implements functionality of the Backbone TMF agent. * */ class BackboneTmfAgent : public Coap::Coap { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -62,7 +62,7 @@ class BackboneTmfAgent : public Coap::Coap explicit BackboneTmfAgent(Instance &aInstance); /** - * This method starts the Backbone TMF agent. + * Starts the Backbone TMF agent. * * @retval kErrorNone Successfully started the CoAP service. * @retval kErrorFailed Failed to start the Backbone TMF agent. @@ -71,7 +71,7 @@ class BackboneTmfAgent : public Coap::Coap Error Start(void); /** - * This method returns whether @p aMessageInfo meets Backbone Thread Management Framework Addressing Rules. + * Returns whether @p aMessageInfo meets Backbone Thread Management Framework Addressing Rules. * * @retval true Thread Management Framework Addressing Rules are met. * @retval false Thread Management Framework Addressing Rules are not met. @@ -80,7 +80,7 @@ class BackboneTmfAgent : public Coap::Coap bool IsBackboneTmfMessage(const Ip6::MessageInfo &aMessageInfo) const; /** - * This method subscribes the Backbone TMF socket to a given IPv6 multicast group on the Backbone network. + * Subscribes the Backbone TMF socket to a given IPv6 multicast group on the Backbone network. * * @param[in] aAddress The IPv6 multicast group address. * @@ -88,7 +88,7 @@ class BackboneTmfAgent : public Coap::Coap void SubscribeMulticast(const Ip6::Address &aAddress); /** - * This method unsubscribes the Backbone TMF socket from a given IPv6 multicast group on the Backbone network. + * Unsubscribes the Backbone TMF socket from a given IPv6 multicast group on the Backbone network. * * @param[in] aAddress The IPv6 multicast group address. * diff --git a/src/core/backbone_router/bbr_leader.cpp b/src/core/backbone_router/bbr_leader.cpp index 30330dee714..efced1bb5c5 100644 --- a/src/core/backbone_router/bbr_leader.cpp +++ b/src/core/backbone_router/bbr_leader.cpp @@ -97,11 +97,6 @@ void Leader::LogBackboneRouterPrimary(State aState, const Config &aConfig) const } } -void Leader::LogDomainPrefix(DomainPrefixState aState, const Ip6::Prefix &aPrefix) const -{ - LogInfo("Domain Prefix: %s, state: %s", aPrefix.ToString().AsCString(), DomainPrefixStateToString(aState)); -} - const char *Leader::StateToString(State aState) { static const char *const kStateStrings[] = { @@ -123,23 +118,21 @@ const char *Leader::StateToString(State aState) return kStateStrings[aState]; } -const char *Leader::DomainPrefixStateToString(DomainPrefixState aState) +const char *Leader::DomainPrefixEventToString(DomainPrefixEvent aEvent) { - static const char *const kPrefixStateStrings[] = { - "None", // (0) kDomainPrefixNone - "Added", // (1) kDomainPrefixAdded - "Removed", // (2) kDomainPrefixRemoved - "Refreshed", // (3) kDomainPrefixRefreshed - "Unchanged", // (4) kDomainPrefixUnchanged + static const char *const kEventStrings[] = { + "Added", // (0) kDomainPrefixAdded + "Removed", // (1) kDomainPrefixRemoved + "Refreshed", // (2) kDomainPrefixRefreshed + "Unchanged", // (3) kDomainPrefixUnchanged }; - static_assert(0 == kDomainPrefixNone, "kDomainPrefixNone value is incorrect"); - static_assert(1 == kDomainPrefixAdded, "kDomainPrefixAdded value is incorrect"); - static_assert(2 == kDomainPrefixRemoved, "kDomainPrefixRemoved value is incorrect"); - static_assert(3 == kDomainPrefixRefreshed, "kDomainPrefixRefreshed value is incorrect"); - static_assert(4 == kDomainPrefixUnchanged, "kDomainPrefixUnchanged value is incorrect"); + static_assert(0 == kDomainPrefixAdded, "kDomainPrefixAdded value is incorrect"); + static_assert(1 == kDomainPrefixRemoved, "kDomainPrefixRemoved value is incorrect"); + static_assert(2 == kDomainPrefixRefreshed, "kDomainPrefixRefreshed value is incorrect"); + static_assert(3 == kDomainPrefixUnchanged, "kDomainPrefixUnchanged value is incorrect"); - return kPrefixStateStrings[aState]; + return kEventStrings[aEvent]; } #endif // OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) @@ -152,9 +145,8 @@ void Leader::Update(void) void Leader::UpdateBackboneRouterPrimary(void) { - Config config; - State state; - uint32_t origMlrTimeout; + Config config; + State state; Get().GetBackboneRouterPrimary(config); @@ -195,17 +187,13 @@ void Leader::UpdateBackboneRouterPrimary(void) // Restrain the range of MLR timeout to be always valid if (config.mServer16 != Mac::kShortAddrInvalid) { - origMlrTimeout = config.mMlrTimeout; - config.mMlrTimeout = config.mMlrTimeout < static_cast(Mle::kMlrTimeoutMin) - ? static_cast(Mle::kMlrTimeoutMin) - : config.mMlrTimeout; - config.mMlrTimeout = config.mMlrTimeout > static_cast(Mle::kMlrTimeoutMax) - ? static_cast(Mle::kMlrTimeoutMax) - : config.mMlrTimeout; - - if (config.mMlrTimeout != origMlrTimeout) + uint32_t origTimeout = config.mMlrTimeout; + + config.mMlrTimeout = Clamp(config.mMlrTimeout, kMinMlrTimeout, kMaxMlrTimeout); + + if (config.mMlrTimeout != origTimeout) { - LogNote("Leader MLR Timeout is normalized from %lu to %lu", ToUlong(origMlrTimeout), + LogNote("Leader MLR Timeout is normalized from %lu to %lu", ToUlong(origTimeout), ToUlong(config.mMlrTimeout)); } } @@ -230,7 +218,7 @@ void Leader::UpdateDomainPrefixConfig(void) { NetworkData::Iterator iterator = NetworkData::kIteratorInit; NetworkData::OnMeshPrefixConfig config; - DomainPrefixState state; + DomainPrefixEvent event; bool found = false; while (Get().GetNextOnMeshPrefix(iterator, config) == kErrorNone) @@ -244,47 +232,39 @@ void Leader::UpdateDomainPrefixConfig(void) if (!found) { - if (mDomainPrefix.GetLength() != 0) - { - // Domain Prefix does not exist any more. - mDomainPrefix.SetLength(0); - state = kDomainPrefixRemoved; - } - else - { - state = kDomainPrefixNone; - } + VerifyOrExit(HasDomainPrefix()); + + // Domain Prefix does not exist any more. + mDomainPrefix.Clear(); + event = kDomainPrefixRemoved; } else if (config.GetPrefix() == mDomainPrefix) { - state = kDomainPrefixUnchanged; + event = kDomainPrefixUnchanged; } else { - if (mDomainPrefix.mLength == 0) - { - state = kDomainPrefixAdded; - } - else - { - state = kDomainPrefixRefreshed; - } - + event = HasDomainPrefix() ? kDomainPrefixRefreshed : kDomainPrefixAdded; mDomainPrefix = config.GetPrefix(); } - LogDomainPrefix(state, mDomainPrefix); + LogInfo("%s domain Prefix: %s", DomainPrefixEventToString(event), mDomainPrefix.ToString().AsCString()); #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE - Get().HandleDomainPrefixUpdate(state); + Get().HandleDomainPrefixUpdate(event); #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE - Get().HandleDomainPrefixUpdate(state); + Get().HandleDomainPrefixUpdate(event); #endif #endif #if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE) - Get().HandleDomainPrefixUpdate(state); + Get().HandleDomainPrefixUpdate(event); +#else + OT_UNUSED_VARIABLE(event); #endif + +exit: + return; } bool Leader::IsDomainUnicast(const Ip6::Address &aAddress) const diff --git a/src/core/backbone_router/bbr_leader.hpp b/src/core/backbone_router/bbr_leader.hpp index 605283933c8..465765d45aa 100644 --- a/src/core/backbone_router/bbr_leader.hpp +++ b/src/core/backbone_router/bbr_leader.hpp @@ -54,8 +54,32 @@ namespace BackboneRouter { typedef otBackboneRouterConfig Config; +constexpr uint16_t kDefaultRegistrationDelay = 5; ///< Default registration delay (in sec). +constexpr uint32_t kDefaultMlrTimeout = 3600; ///< Default MLR Timeout (in sec). +constexpr uint32_t kMinMlrTimeout = 300; ///< Minimum MLR Timeout (in sec). +constexpr uint32_t kMaxMlrTimeout = 0x7fffffff / 1000; ///< Max MLR Timeout (in sec ~ about 24 days. +constexpr uint8_t kDefaultRegistrationJitter = 5; ///< Default registration jitter (in sec). +constexpr uint8_t kParentAggregateDelay = 5; ///< Parent Aggregate Delay (in sec). + +static_assert(kDefaultMlrTimeout >= kMinMlrTimeout && kDefaultMlrTimeout <= kMaxMlrTimeout, + "kDefaultMlrTimeout is not in valid range"); +static_assert(kMaxMlrTimeout * 1000 > kMaxMlrTimeout, "SecToMsec(kMaxMlrTimeout) will overflow"); +static_assert(kParentAggregateDelay > 1, "kParentAggregateDelay should be larger than 1 second"); + +/** + * Represents Domain Prefix changes. + * + */ +enum DomainPrefixEvent : uint8_t +{ + kDomainPrefixAdded, ///< Domain Prefix Added. + kDomainPrefixRemoved, ///< Domain Prefix Removed. + kDomainPrefixRefreshed, ///< Domain Prefix Changed. + kDomainPrefixUnchanged, ///< Domain Prefix did not change. +}; + /** - * This class implements the basic Primary Backbone Router service operations. + * Implements the basic Primary Backbone Router service operations. * */ class Leader : public InstanceLocator, private NonCopyable @@ -73,18 +97,8 @@ class Leader : public InstanceLocator, private NonCopyable kStateUnchanged, ///< No change on Primary Backbone Router information (only for logging). }; - // Domain Prefix state or state change. - enum DomainPrefixState : uint8_t - { - kDomainPrefixNone = 0, ///< Not available. - kDomainPrefixAdded, ///< Added. - kDomainPrefixRemoved, ///< Removed. - kDomainPrefixRefreshed, ///< Changed. - kDomainPrefixUnchanged, ///< Nothing changed. - }; - /** - * This constructor initializes the `Leader`. + * Initializes the `Leader`. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -92,19 +106,19 @@ class Leader : public InstanceLocator, private NonCopyable explicit Leader(Instance &aInstance); /** - * This method resets the cached Primary Backbone Router. + * Resets the cached Primary Backbone Router. * */ void Reset(void); /** - * This method updates the cached Primary Backbone Router if any when new network data is available. + * Updates the cached Primary Backbone Router if any when new network data is available. * */ void Update(void); /** - * This method gets the Primary Backbone Router in the Thread Network. + * Gets the Primary Backbone Router in the Thread Network. * * @param[out] aConfig The Primary Backbone Router information. * @@ -115,7 +129,7 @@ class Leader : public InstanceLocator, private NonCopyable Error GetConfig(Config &aConfig) const; /** - * This method gets the Backbone Router Service ID. + * Gets the Backbone Router Service ID. * * @param[out] aServiceId The reference whether to put the Backbone Router Service ID. * @@ -126,7 +140,7 @@ class Leader : public InstanceLocator, private NonCopyable Error GetServiceId(uint8_t &aServiceId) const; /** - * This method gets the short address of the Primary Backbone Router. + * Gets the short address of the Primary Backbone Router. * * @returns short address of Primary Backbone Router, or Mac::kShortAddrInvalid if no Primary Backbone Router. * @@ -134,7 +148,7 @@ class Leader : public InstanceLocator, private NonCopyable uint16_t GetServer16(void) const { return mConfig.mServer16; } /** - * This method indicates whether or not there is Primary Backbone Router. + * Indicates whether or not there is Primary Backbone Router. * * @retval TRUE If there is Primary Backbone Router. * @retval FALSE If there is no Primary Backbone Router. @@ -143,7 +157,7 @@ class Leader : public InstanceLocator, private NonCopyable bool HasPrimary(void) const { return mConfig.mServer16 != Mac::kShortAddrInvalid; } /** - * This method gets the Domain Prefix in the Thread Network. + * Gets the Domain Prefix in the Thread Network. * * @retval A pointer to the Domain Prefix or nullptr if there is no Domain Prefix. * @@ -154,7 +168,7 @@ class Leader : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the Domain Prefix is available in the Thread Network. + * Indicates whether or not the Domain Prefix is available in the Thread Network. * * @retval TRUE If there is Domain Prefix. * @retval FALSE If there is no Domain Prefix. @@ -163,7 +177,7 @@ class Leader : public InstanceLocator, private NonCopyable bool HasDomainPrefix(void) const { return (mDomainPrefix.GetLength() > 0); } /** - * This method indicates whether or not the address is a Domain Unicast Address. + * Indicates whether or not the address is a Domain Unicast Address. * * @param[in] aAddress A reference to the address. * @@ -178,12 +192,10 @@ class Leader : public InstanceLocator, private NonCopyable void UpdateDomainPrefixConfig(void); #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) void LogBackboneRouterPrimary(State aState, const Config &aConfig) const; - void LogDomainPrefix(DomainPrefixState aState, const Ip6::Prefix &aPrefix) const; static const char *StateToString(State aState); - static const char *DomainPrefixStateToString(DomainPrefixState aState); + static const char *DomainPrefixEventToString(DomainPrefixEvent aEvent); #else void LogBackboneRouterPrimary(State, const Config &) const {} - void LogDomainPrefix(DomainPrefixState, const Ip6::Prefix &) const {} #endif Config mConfig; ///< Primary Backbone Router information. diff --git a/src/core/backbone_router/bbr_local.cpp b/src/core/backbone_router/bbr_local.cpp index ee20b2b3f8d..430ac906ce6 100644 --- a/src/core/backbone_router/bbr_local.cpp +++ b/src/core/backbone_router/bbr_local.cpp @@ -52,10 +52,10 @@ RegisterLogModule("BbrLocal"); Local::Local(Instance &aInstance) : InstanceLocator(aInstance) , mState(kStateDisabled) - , mMlrTimeout(Mle::kMlrTimeoutDefault) - , mReregistrationDelay(Mle::kRegistrationDelayDefault) + , mMlrTimeout(kDefaultMlrTimeout) + , mReregistrationDelay(kDefaultRegistrationDelay) , mSequenceNumber(Random::NonCrypto::GetUint8() % 127) - , mRegistrationJitter(Mle::kBackboneRouterRegistrationJitter) + , mRegistrationJitter(kDefaultRegistrationJitter) , mIsServiceAdded(false) { mDomainPrefixConfig.GetPrefix().SetLength(0); @@ -131,7 +131,7 @@ Error Local::SetConfig(const Config &aConfig) bool update = false; #if !OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE - VerifyOrExit(aConfig.mMlrTimeout >= Mle::kMlrTimeoutMin && aConfig.mMlrTimeout <= Mle::kMlrTimeoutMax, + VerifyOrExit(aConfig.mMlrTimeout >= kMinMlrTimeout && aConfig.mMlrTimeout <= kMaxMlrTimeout, error = kErrorInvalidArgs); #endif // Validate configuration according to Thread 1.2.1 Specification 5.21.3.3: @@ -358,19 +358,19 @@ void Local::ApplyMeshLocalPrefix(void) return; } -void Local::HandleDomainPrefixUpdate(Leader::DomainPrefixState aState) +void Local::HandleDomainPrefixUpdate(DomainPrefixEvent aEvent) { if (!IsEnabled()) { ExitNow(); } - if (aState == Leader::kDomainPrefixRemoved || aState == Leader::kDomainPrefixRefreshed) + if (aEvent == kDomainPrefixRemoved || aEvent == kDomainPrefixRefreshed) { Get().UnsubscribeMulticast(mAllDomainBackboneRouters); } - if (aState == Leader::kDomainPrefixAdded || aState == Leader::kDomainPrefixRefreshed) + if (aEvent == kDomainPrefixAdded || aEvent == kDomainPrefixRefreshed) { mAllDomainBackboneRouters.SetMulticastNetworkPrefix(*Get().GetDomainPrefix()); Get().SubscribeMulticast(mAllDomainBackboneRouters); @@ -378,15 +378,15 @@ void Local::HandleDomainPrefixUpdate(Leader::DomainPrefixState aState) if (mDomainPrefixCallback.IsSet()) { - switch (aState) + switch (aEvent) { - case Leader::kDomainPrefixAdded: + case kDomainPrefixAdded: mDomainPrefixCallback.Invoke(OT_BACKBONE_ROUTER_DOMAIN_PREFIX_ADDED, Get().GetDomainPrefix()); break; - case Leader::kDomainPrefixRemoved: + case kDomainPrefixRemoved: mDomainPrefixCallback.Invoke(OT_BACKBONE_ROUTER_DOMAIN_PREFIX_REMOVED, Get().GetDomainPrefix()); break; - case Leader::kDomainPrefixRefreshed: + case kDomainPrefixRefreshed: mDomainPrefixCallback.Invoke(OT_BACKBONE_ROUTER_DOMAIN_PREFIX_CHANGED, Get().GetDomainPrefix()); break; default: diff --git a/src/core/backbone_router/bbr_local.hpp b/src/core/backbone_router/bbr_local.hpp index 42b1dd1047e..b2ba94e37ca 100644 --- a/src/core/backbone_router/bbr_local.hpp +++ b/src/core/backbone_router/bbr_local.hpp @@ -67,14 +67,14 @@ namespace ot { namespace BackboneRouter { /** - * This class implements the definitions for local Backbone Router service. + * Implements the definitions for local Backbone Router service. * */ class Local : public InstanceLocator, private NonCopyable { public: /** - * This enumeration represents Backbone Router state. + * Represents Backbone Router state. * */ enum State : uint8_t @@ -85,7 +85,7 @@ class Local : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the local Backbone Router. + * Initializes the local Backbone Router. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -93,7 +93,7 @@ class Local : public InstanceLocator, private NonCopyable explicit Local(Instance &aInstance); /** - * This method enables/disables Backbone function. + * Enables/disables Backbone function. * * @param[in] aEnable TRUE to enable the backbone function, FALSE otherwise. * @@ -101,7 +101,7 @@ class Local : public InstanceLocator, private NonCopyable void SetEnabled(bool aEnable); /** - * This method retrieves the Backbone Router state. + * Retrieves the Backbone Router state. * * * @returns The current state of Backbone Router. @@ -110,13 +110,13 @@ class Local : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method resets the local Thread Network Data. + * Resets the local Thread Network Data. * */ void Reset(void); /** - * This method gets local Backbone Router configuration. + * Gets local Backbone Router configuration. * * @param[out] aConfig The local Backbone Router configuration. * @@ -124,7 +124,7 @@ class Local : public InstanceLocator, private NonCopyable void GetConfig(Config &aConfig) const; /** - * This method sets local Backbone Router configuration. + * Sets local Backbone Router configuration. * * @param[in] aConfig The configuration to set. * @@ -135,7 +135,7 @@ class Local : public InstanceLocator, private NonCopyable Error SetConfig(const Config &aConfig); /** - * This method registers Backbone Router Dataset to Leader. + * Registers Backbone Router Dataset to Leader. * * @param[in] aForce True to force registration regardless of current state. * False to decide based on current state. @@ -149,7 +149,7 @@ class Local : public InstanceLocator, private NonCopyable Error AddService(bool aForce = false); /** - * This method indicates whether or not the Backbone Router is Primary. + * Indicates whether or not the Backbone Router is Primary. * * @retval True if the Backbone Router is Primary. * @retval False if the Backbone Router is not Primary. @@ -158,7 +158,7 @@ class Local : public InstanceLocator, private NonCopyable bool IsPrimary(void) const { return mState == kStatePrimary; } /** - * This method indicates whether or not the Backbone Router is enabled. + * Indicates whether or not the Backbone Router is enabled. * * @retval True if the Backbone Router is enabled. * @retval False if the Backbone Router is not enabled. @@ -167,7 +167,7 @@ class Local : public InstanceLocator, private NonCopyable bool IsEnabled(void) const { return mState != kStateDisabled; } /** - * This method sets the Backbone Router registration jitter value. + * Sets the Backbone Router registration jitter value. * * @param[in] aRegistrationJitter the Backbone Router registration jitter value to set. * @@ -175,7 +175,7 @@ class Local : public InstanceLocator, private NonCopyable void SetRegistrationJitter(uint8_t aRegistrationJitter) { mRegistrationJitter = aRegistrationJitter; } /** - * This method returns the Backbone Router registration jitter value. + * Returns the Backbone Router registration jitter value. * * @returns The Backbone Router registration jitter value. * @@ -183,7 +183,7 @@ class Local : public InstanceLocator, private NonCopyable uint8_t GetRegistrationJitter(void) const { return mRegistrationJitter; } /** - * This method notifies Primary Backbone Router status. + * Notifies Primary Backbone Router status. * * @param[in] aState The state or state change of Primary Backbone Router. * @param[in] aConfig The Primary Backbone Router service. @@ -192,7 +192,7 @@ class Local : public InstanceLocator, private NonCopyable void HandleBackboneRouterPrimaryUpdate(Leader::State aState, const Config &aConfig); /** - * This method gets the Domain Prefix configuration. + * Gets the Domain Prefix configuration. * * @param[out] aConfig A reference to the Domain Prefix configuration. * @@ -203,7 +203,7 @@ class Local : public InstanceLocator, private NonCopyable Error GetDomainPrefix(NetworkData::OnMeshPrefixConfig &aConfig); /** - * This method removes the local Domain Prefix configuration. + * Removes the local Domain Prefix configuration. * * @param[in] aPrefix A reference to the IPv6 Domain Prefix. * @@ -215,7 +215,7 @@ class Local : public InstanceLocator, private NonCopyable Error RemoveDomainPrefix(const Ip6::Prefix &aPrefix); /** - * This method sets the local Domain Prefix configuration. + * Sets the local Domain Prefix configuration. * * @param[in] aConfig A reference to the Domain Prefix configuration. * @@ -226,7 +226,7 @@ class Local : public InstanceLocator, private NonCopyable Error SetDomainPrefix(const NetworkData::OnMeshPrefixConfig &aConfig); /** - * This method returns a reference to the All Network Backbone Routers Multicast Address. + * Returns a reference to the All Network Backbone Routers Multicast Address. * * @returns A reference to the All Network Backbone Routers Multicast Address. * @@ -234,7 +234,7 @@ class Local : public InstanceLocator, private NonCopyable const Ip6::Address &GetAllNetworkBackboneRoutersAddress(void) const { return mAllNetworkBackboneRouters; } /** - * This method returns a reference to the All Domain Backbone Routers Multicast Address. + * Returns a reference to the All Domain Backbone Routers Multicast Address. * * @returns A reference to the All Domain Backbone Routers Multicast Address. * @@ -242,21 +242,21 @@ class Local : public InstanceLocator, private NonCopyable const Ip6::Address &GetAllDomainBackboneRoutersAddress(void) const { return mAllDomainBackboneRouters; } /** - * This method applies the Mesh Local Prefix. + * Applies the Mesh Local Prefix. * */ void ApplyMeshLocalPrefix(void); /** - * This method updates the subscription of All Domain Backbone Routers Multicast Address. + * Updates the subscription of All Domain Backbone Routers Multicast Address. * - * @param[in] aState The Domain Prefix state or state change. + * @param[in] aEvent The Domain Prefix event. * */ - void HandleDomainPrefixUpdate(Leader::DomainPrefixState aState); + void HandleDomainPrefixUpdate(DomainPrefixEvent aEvent); /** - * This method sets the Domain Prefix callback. + * Sets the Domain Prefix callback. * * @param[in] aCallback The callback function. * @param[in] aContext A user context pointer. diff --git a/src/core/backbone_router/bbr_manager.cpp b/src/core/backbone_router/bbr_manager.cpp index fd04b12a852..09c1c76561c 100644 --- a/src/core/backbone_router/bbr_manager.cpp +++ b/src/core/backbone_router/bbr_manager.cpp @@ -209,7 +209,7 @@ void Manager::HandleMulticastListenerRegistration(const Coap::Message &aMessage, { uint32_t origTimeout = timeout; - timeout = Min(timeout, Mle::kMlrTimeoutMax); + timeout = Min(timeout, kMaxMlrTimeout); if (timeout != origTimeout) { @@ -341,7 +341,7 @@ void Manager::SendBackboneMulticastListenerRegistration(const Ip6::Address *aAdd messageInfo.SetPeerAddr(Get().GetAllNetworkBackboneRoutersAddress()); messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort); // TODO: Provide API for configuring Backbone COAP port. - messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit); + messageInfo.SetHopLimit(kDefaultHoplimit); messageInfo.SetIsHostInterface(true); SuccessOrExit(error = backboneTmf.SendMessage(*message, messageInfo)); @@ -535,7 +535,7 @@ Error Manager::SendBackboneQuery(const Ip6::Address &aDua, uint16_t aRloc16) messageInfo.SetPeerAddr(Get().GetAllDomainBackboneRoutersAddress()); messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort); - messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit); + messageInfo.SetHopLimit(kDefaultHoplimit); messageInfo.SetIsHostInterface(true); error = mBackboneTmfAgent.SendMessage(*message, messageInfo); @@ -672,7 +672,7 @@ Error Manager::SendBackboneAnswer(const Ip6::Address &aDstAddr, messageInfo.SetPeerAddr(aDstAddr); messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort); - messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit); + messageInfo.SetHopLimit(kDefaultHoplimit); messageInfo.SetIsHostInterface(true); error = mBackboneTmfAgent.SendMessage(*message, messageInfo); diff --git a/src/core/backbone_router/bbr_manager.hpp b/src/core/backbone_router/bbr_manager.hpp index da5434d78f1..87d8021bc47 100644 --- a/src/core/backbone_router/bbr_manager.hpp +++ b/src/core/backbone_router/bbr_manager.hpp @@ -56,7 +56,7 @@ namespace ot { namespace BackboneRouter { /** - * This class implements the definitions for Backbone Router management. + * Implements the definitions for Backbone Router management. * */ class Manager : public InstanceLocator, private NonCopyable @@ -67,7 +67,7 @@ class Manager : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the Backbone Router manager. + * Initializes the Backbone Router manager. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -76,7 +76,7 @@ class Manager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE /** - * This method returns the NdProxy Table. + * Returns the NdProxy Table. * * @returns The NdProxy Table. * @@ -86,7 +86,7 @@ class Manager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method configures response status for next DUA registration. + * Configures response status for next DUA registration. * * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * Only used for test and certification. @@ -100,7 +100,7 @@ class Manager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE /** - * This method configures response status for next Multicast Listener Registration. + * Configures response status for next Multicast Listener Registration. * * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * Only used for test and certification. @@ -114,7 +114,7 @@ class Manager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE /** - * This method gets the Multicast Listeners Table. + * Gets the Multicast Listeners Table. * * @returns The Multicast Listeners Table. * @@ -123,7 +123,7 @@ class Manager : public InstanceLocator, private NonCopyable #endif /** - * This method returns if messages destined to a given Domain Unicast Address should be forwarded to the Backbone + * Returns if messages destined to a given Domain Unicast Address should be forwarded to the Backbone * link. * * @param aAddress The Domain Unicast Address. @@ -135,7 +135,7 @@ class Manager : public InstanceLocator, private NonCopyable bool ShouldForwardDuaToBackbone(const Ip6::Address &aAddress); /** - * This method returns a reference to the Backbone TMF agent. + * Returns a reference to the Backbone TMF agent. * * @returns A reference to the Backbone TMF agent. * @@ -143,7 +143,7 @@ class Manager : public InstanceLocator, private NonCopyable BackboneTmfAgent &GetBackboneTmfAgent(void) { return mBackboneTmfAgent; } /** - * This method sends BB.qry on the Backbone link. + * Sends BB.qry on the Backbone link. * * @param[in] aDua The Domain Unicast Address to query. * @param[in] aRloc16 The short address of the address resolution initiator or `Mac::kShortAddrInvalid` for @@ -157,7 +157,7 @@ class Manager : public InstanceLocator, private NonCopyable Error SendBackboneQuery(const Ip6::Address &aDua, uint16_t aRloc16 = Mac::kShortAddrInvalid); /** - * This method send a Proactive Backbone Notification (PRO_BB.ntf) on the Backbone link. + * Send a Proactive Backbone Notification (PRO_BB.ntf) on the Backbone link. * * @param[in] aDua The Domain Unicast Address to notify. * @param[in] aMeshLocalIid The Mesh-Local IID to notify. @@ -172,7 +172,8 @@ class Manager : public InstanceLocator, private NonCopyable uint32_t aTimeSinceLastTransaction); private: - static constexpr uint32_t kTimerInterval = 1000; + static constexpr uint8_t kDefaultHoplimit = 1; + static constexpr uint32_t kTimerInterval = 1000; template void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); diff --git a/src/core/backbone_router/multicast_listeners_table.hpp b/src/core/backbone_router/multicast_listeners_table.hpp index 7565f94d32c..392b8185fbd 100644 --- a/src/core/backbone_router/multicast_listeners_table.hpp +++ b/src/core/backbone_router/multicast_listeners_table.hpp @@ -52,7 +52,7 @@ namespace ot { namespace BackboneRouter { /** - * This class implements the definitions for Multicast Listeners Table. + * Implements the definitions for Multicast Listeners Table. * */ class MulticastListenersTable : public InstanceLocator, private NonCopyable @@ -61,7 +61,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable public: /** - * This class represents a Multicast Listener entry. + * Represents a Multicast Listener entry. * */ class Listener : public Clearable @@ -80,13 +80,13 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `Listener` object. + * Initializes the `Listener` object. * */ Listener(void) { Clear(); } /** - * This method returns the Multicast Listener address. + * Returns the Multicast Listener address. * * @returns The Multicast Listener address. * @@ -94,7 +94,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable const Ip6::Address &GetAddress(void) const { return mAddress; } /** - * This method returns the expire time of the Multicast Listener. + * Returns the expire time of the Multicast Listener. * * @returns The Multicast Listener expire time. * @@ -112,7 +112,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the Multicast Listeners Table. + * Initializes the Multicast Listeners Table. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -124,7 +124,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable } /** - * This method adds a Multicast Listener with given address and expire time. + * Adds a Multicast Listener with given address and expire time. * * @param[in] aAddress The Multicast Listener address. * @param[in] aExpireTime The Multicast Listener expire time. @@ -137,7 +137,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable Error Add(const Ip6::Address &aAddress, TimeMilli aExpireTime); /** - * This method removes a given Multicast Listener. + * Removes a given Multicast Listener. * * @param[in] aAddress The Multicast Listener address. * @@ -145,13 +145,13 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable void Remove(const Ip6::Address &aAddress); /** - * This method removes expired Multicast Listeners. + * Removes expired Multicast Listeners. * */ void Expire(void); /** - * This method counts the number of valid Multicast Listeners. + * Counts the number of valid Multicast Listeners. * * @returns The number of valid Multicast Listeners. * @@ -159,9 +159,9 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable uint16_t Count(void) const { return mNumValidListeners; } /** - * This method enables range-based `for` loop iteration over all Multicast Listeners. + * Enables range-based `for` loop iteration over all Multicast Listeners. * - * This method should be used as follows: + * Should be used as follows: * * for (MulticastListenersTable::Listener &listener : Get().Iterate()) * @@ -171,13 +171,13 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable IteratorBuilder Iterate(void) { return IteratorBuilder(GetInstance()); } /** - * This method removes all the Multicast Listeners. + * Removes all the Multicast Listeners. * */ void Clear(void); /** - * This method sets the Multicast Listener callback. + * Sets the Multicast Listener callback. * * @param[in] aCallback The callback function. * @param[in] aContext A user context pointer. @@ -186,7 +186,7 @@ class MulticastListenersTable : public InstanceLocator, private NonCopyable void SetCallback(Listener::Callback aCallback, void *aContext); /** - * This method gets the next Multicast Listener. + * Gets the next Multicast Listener. * * @param[in] aIterator A pointer to the Multicast Listener Iterator. * @param[out] aInfo A reference to output the Multicast Listener info. diff --git a/src/core/backbone_router/ndproxy_table.cpp b/src/core/backbone_router/ndproxy_table.cpp index 787a8a930ed..edb196cbceb 100644 --- a/src/core/backbone_router/ndproxy_table.cpp +++ b/src/core/backbone_router/ndproxy_table.cpp @@ -68,7 +68,7 @@ void NdProxyTable::NdProxy::Update(uint16_t aRloc16, uint32_t aTimeSinceLastTran OT_ASSERT(mValid); mRloc16 = aRloc16; - aTimeSinceLastTransaction = Min(aTimeSinceLastTransaction, Mle::kTimeSinceLastTransactionMax); + aTimeSinceLastTransaction = Min(aTimeSinceLastTransaction, kMaxTimeSinceLastTransaction); mLastRegistrationTime = TimerMilli::GetNow() - TimeMilli::SecToMsec(aTimeSinceLastTransaction); } @@ -125,10 +125,9 @@ void NdProxyTable::Iterator::Advance(void) void NdProxyTable::Erase(NdProxy &aNdProxy) { aNdProxy.mValid = false; } -void NdProxyTable::HandleDomainPrefixUpdate(Leader::DomainPrefixState aState) +void NdProxyTable::HandleDomainPrefixUpdate(DomainPrefixEvent aEvent) { - if (aState == Leader::kDomainPrefixAdded || aState == Leader::kDomainPrefixRemoved || - aState == Leader::kDomainPrefixRefreshed) + if (aEvent == kDomainPrefixAdded || aEvent == kDomainPrefixRemoved || aEvent == kDomainPrefixRefreshed) { Clear(); } @@ -291,7 +290,7 @@ void NdProxyTable::NotifyDadComplete(NdProxyTable::NdProxy &aNdProxy, bool aDupl } else { - aNdProxy.mDadAttempts = Mle::kDuaDadRepeats; + aNdProxy.mDadAttempts = kDuaDadRepeats; } } diff --git a/src/core/backbone_router/ndproxy_table.hpp b/src/core/backbone_router/ndproxy_table.hpp index 8c12db1a8ad..ae3c9c4e99e 100644 --- a/src/core/backbone_router/ndproxy_table.hpp +++ b/src/core/backbone_router/ndproxy_table.hpp @@ -54,14 +54,16 @@ namespace ot { namespace BackboneRouter { /** - * This class implements NdProxy Table maintenance on Primary Backbone Router. + * Implements NdProxy Table maintenance on Primary Backbone Router. * */ class NdProxyTable : public InstanceLocator, private NonCopyable { public: + static constexpr uint8_t kDuaDadRepeats = 3; ///< Number multicast DAD queries by BBR + /** - * This class represents a ND Proxy instance. + * Represents a ND Proxy instance. * */ class NdProxy : private Clearable @@ -73,7 +75,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable typedef otBackboneRouterNdProxyCallback Callback; ///< ND Proxy callback. /** - * This type represents the ND Proxy events. + * Represents the ND Proxy events. * */ enum Event @@ -85,7 +87,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable }; /** - * This method gets the Mesh-Local IID of the ND Proxy. + * Gets the Mesh-Local IID of the ND Proxy. * * @returns The Mesh-Local IID. * @@ -93,7 +95,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable const Ip6::InterfaceIdentifier &GetMeshLocalIid(void) const { return mMeshLocalIid; } /** - * This method gets the time since last transaction of the ND Proxy. + * Gets the time since last transaction of the ND Proxy. * * @returns The time since last transaction in seconds. * @@ -104,7 +106,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable } /** - * This method gets the short address of the device who sends the DUA registration. + * Gets the short address of the device who sends the DUA registration. * * @returns The RLOC16 value. * @@ -112,7 +114,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable uint16_t GetRloc16(void) const { return mRloc16; } /** - * This method gets the DAD flag of the ND Proxy. + * Gets the DAD flag of the ND Proxy. * * @returns The DAD flag. * @@ -120,6 +122,8 @@ class NdProxyTable : public InstanceLocator, private NonCopyable bool GetDadFlag(void) const { return mDadFlag; } private: + static constexpr uint32_t kMaxTimeSinceLastTransaction = 10 * 86400; // In seconds (10 days). + NdProxy(void) { Clear(); } void Init(const Ip6::InterfaceIdentifier &aAddressIid, @@ -129,7 +133,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable void Update(uint16_t aRloc16, uint32_t aTimeSinceLastTransaction); void IncreaseDadAttempts(void) { mDadAttempts++; } - bool IsDadAttemptsComplete() const { return mDadAttempts == Mle::kDuaDadRepeats; } + bool IsDadAttemptsComplete(void) const { return mDadAttempts == kDuaDadRepeats; } Ip6::InterfaceIdentifier mAddressIid; Ip6::InterfaceIdentifier mMeshLocalIid; @@ -139,11 +143,11 @@ class NdProxyTable : public InstanceLocator, private NonCopyable bool mDadFlag : 1; bool mValid : 1; - static_assert(Mle::kDuaDadRepeats < 4, "Mle::kDuaDadRepeats does not fit in mDadAttempts field as 2-bit value"); + static_assert(kDuaDadRepeats < 4, "kDuaDadRepeats does not fit in mDadAttempts field as 2-bit value"); }; /** - * This constructor initializes the `NdProxyTable` object. + * Initializes the `NdProxyTable` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -155,7 +159,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable } /** - * This method registers a given IPv6 address IID with related information to the NdProxy table. + * Registers a given IPv6 address IID with related information to the NdProxy table. * * @param[in] aAddressIid The IPv6 address IID. * @param[in] aMeshLocalIid The Mesh-Local IID. @@ -173,7 +177,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable const uint32_t *aTimeSinceLastTransaction); /** - * This method checks if a given IPv6 address IID was registered. + * Checks if a given IPv6 address IID was registered. * * @param[in] aAddressIid The IPv6 address IID. * @@ -184,21 +188,21 @@ class NdProxyTable : public InstanceLocator, private NonCopyable bool IsRegistered(const Ip6::InterfaceIdentifier &aAddressIid) { return FindByAddressIid(aAddressIid) != nullptr; } /** - * This method notifies Domain Prefix status. + * Notifies Domain Prefix event. * - * @param[in] aState The Domain Prefix state or state change. + * @param[in] aEvent The Domain Prefix event. * */ - void HandleDomainPrefixUpdate(Leader::DomainPrefixState aState); + void HandleDomainPrefixUpdate(DomainPrefixEvent aEvent); /** - * This method notifies ND Proxy table of the timer tick. + * Notifies ND Proxy table of the timer tick. * */ void HandleTimer(void); /** - * This method gets the ND Proxy info for a given Domain Unicast Address. + * Gets the ND Proxy info for a given Domain Unicast Address. * * @param[in] aDua The Domain Unicast Address. * @@ -208,7 +212,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable NdProxy *ResolveDua(const Ip6::Address &aDua); /** - * This method notifies DAD completed for a given ND Proxy. + * Notifies DAD completed for a given ND Proxy. * * @param[in] aNdProxy The ND Proxy to notify of. * @param[in] aDuplicated Whether duplicate was detected. @@ -217,7 +221,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable static void NotifyDadComplete(NdProxy &aNdProxy, bool aDuplicated); /** - * This method removes the ND Proxy. + * Removes the ND Proxy. * * @param[in] aNdProxy The ND Proxy to remove. * @@ -225,7 +229,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable static void Erase(NdProxy &aNdProxy); /* - * This method sets the ND Proxy callback. + * Sets the ND Proxy callback. * * @param[in] aCallback The callback function. * @param[in] aContext A user context pointer. @@ -234,7 +238,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable void SetCallback(NdProxy::Callback aCallback, void *aContext) { mCallback.Set(aCallback, aContext); } /** - * This method retrieves the ND Proxy info of the Domain Unicast Address. + * Retrieves the ND Proxy info of the Domain Unicast Address. * * @param[in] aDua The Domain Unicast Address to get info. * @param[in] aNdProxyInfo A pointer to the ND Proxy info. @@ -256,7 +260,7 @@ class NdProxyTable : public InstanceLocator, private NonCopyable }; /** - * This class represents an iterator for iterating through the NdProxy Table. + * Represents an iterator for iterating through the NdProxy Table. * */ class Iterator : public InstanceLocator, public ItemPtrIterator diff --git a/src/core/border_router/infra_if.hpp b/src/core/border_router/infra_if.hpp index ec4c5480d5e..b23bb26dfe3 100644 --- a/src/core/border_router/infra_if.hpp +++ b/src/core/border_router/infra_if.hpp @@ -51,7 +51,7 @@ namespace ot { namespace BorderRouter { /** - * This class represents the infrastructure network interface on a border router. + * Represents the infrastructure network interface on a border router. * */ class InfraIf : public InstanceLocator @@ -63,7 +63,7 @@ class InfraIf : public InstanceLocator typedef Data Icmp6Packet; ///< An IMCPv6 packet (data containing the IP payload) /** - * This constructor initializes the `InfraIf`. + * Initializes the `InfraIf`. * * @param[in] aInstance A OpenThread instance. * @@ -71,7 +71,7 @@ class InfraIf : public InstanceLocator explicit InfraIf(Instance &aInstance); /** - * This method initializes the `InfraIf`. + * Initializes the `InfraIf`. * * @param[in] aIfIndex The infrastructure interface index. * @@ -83,13 +83,13 @@ class InfraIf : public InstanceLocator Error Init(uint32_t aIfIndex); /** - * This method deinitilaizes the `InfraIf`. + * Deinitilaizes the `InfraIf`. * */ void Deinit(void); /** - * This method indicates whether or not the `InfraIf` is initialized. + * Indicates whether or not the `InfraIf` is initialized. * * @retval TRUE The `InfraIf` is initialized. * @retval FALSE The `InfraIf` is not initialized. @@ -98,7 +98,7 @@ class InfraIf : public InstanceLocator bool IsInitialized(void) const { return mInitialized; } /** - * This method indicates whether or not the infra interface is running. + * Indicates whether or not the infra interface is running. * * @retval TRUE The infrastructure interface is running. * @retval FALSE The infrastructure interface is not running. @@ -107,7 +107,7 @@ class InfraIf : public InstanceLocator bool IsRunning(void) const { return mIsRunning; } /** - * This method returns the infrastructure interface index. + * Returns the infrastructure interface index. * * @returns The interface index or zero if not initialized. * @@ -115,9 +115,9 @@ class InfraIf : public InstanceLocator uint32_t GetIfIndex(void) const { return mIfIndex; } /** - * This method indicates whether or not the infra interface has the given IPv6 address assigned. + * Indicates whether or not the infra interface has the given IPv6 address assigned. * - * This method MUST be used when interface is initialized. + * MUST be used when interface is initialized. * * @param[in] aAddress The IPv6 address. * @@ -128,9 +128,9 @@ class InfraIf : public InstanceLocator bool HasAddress(const Ip6::Address &aAddress) const; /** - * This method sends an ICMPv6 Neighbor Discovery packet on the infrastructure interface. + * Sends an ICMPv6 Neighbor Discovery packet on the infrastructure interface. * - * This method MUST be used when interface is initialized. + * MUST be used when interface is initialized. * * @param[in] aPacket The ICMPv6 packet to send. * @param[in] aDestination The destination address. @@ -142,7 +142,7 @@ class InfraIf : public InstanceLocator Error Send(const Icmp6Packet &aPacket, const Ip6::Address &aDestination) const; /** - * This method processes a received ICMPv6 Neighbor Discovery packet from an infrastructure interface. + * Processes a received ICMPv6 Neighbor Discovery packet from an infrastructure interface. * * @param[in] aIfIndex The infrastructure interface index on which the ICMPv6 message is received. * @param[in] aSource The IPv6 source address. @@ -152,7 +152,7 @@ class InfraIf : public InstanceLocator void HandledReceived(uint32_t aIfIndex, const Ip6::Address &aSource, const Icmp6Packet &aPacket); /** - * This method sends a request to discover the NAT64 prefix on the infrastructure interface. + * Sends a request to discover the NAT64 prefix on the infrastructure interface. * * @note This method MUST be used when interface is initialized. * @@ -163,7 +163,7 @@ class InfraIf : public InstanceLocator Error DiscoverNat64Prefix(void) const; /** - * This method processes the discovered NAT64 prefix. + * Processes the discovered NAT64 prefix. * * @param[in] aIfIndex The infrastructure interface index on which the host address is received. * @param[in] aPrefix The NAT64 prefix on the infrastructure link. @@ -172,7 +172,7 @@ class InfraIf : public InstanceLocator void DiscoverNat64PrefixDone(uint32_t aIfIndex, const Ip6::Prefix &aPrefix); /** - * This method handles infrastructure interface state changes. + * Handles infrastructure interface state changes. * * @param[in] aIfIndex The infrastructure interface index. * @param[in] aIsRunning A boolean that indicates whether the infrastructure interface is running. @@ -185,7 +185,7 @@ class InfraIf : public InstanceLocator Error HandleStateChanged(uint32_t aIfIndex, bool aIsRunning); /** - * This method converts the `InfraIf` to a human-readable string. + * Converts the `InfraIf` to a human-readable string. * * @returns The string representation of `InfraIf`. * diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 0c436c24208..58bae226ce8 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include "common/code_utils.hpp" @@ -47,11 +48,14 @@ #include "common/locator_getters.hpp" #include "common/log.hpp" #include "common/num_utils.hpp" +#include "common/numeric_limits.hpp" #include "common/random.hpp" #include "common/settings.hpp" #include "meshcop/extended_panid.hpp" #include "net/ip6.hpp" #include "net/nat64_translator.hpp" +#include "net/nd6.hpp" +#include "thread/mle_router.hpp" #include "thread/network_data_leader.hpp" #include "thread/network_data_local.hpp" #include "thread/network_data_notifier.hpp" @@ -60,14 +64,14 @@ namespace ot { namespace BorderRouter { -RegisterLogModule("BorderRouter"); +RegisterLogModule("RoutingManager"); RoutingManager::RoutingManager(Instance &aInstance) : InstanceLocator(aInstance) , mIsRunning(false) , mIsEnabled(false) , mInfraIf(aInstance) - , mLocalOmrPrefix(aInstance) + , mOmrPrefixManager(aInstance) , mRioPreference(NetworkData::kRoutePreferenceLow) , mUserSetRioPreference(false) , mOnLinkPrefixManager(aInstance) @@ -75,6 +79,9 @@ RoutingManager::RoutingManager(Instance &aInstance) , mRoutePublisher(aInstance) #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE , mNat64PrefixManager(aInstance) +#endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + , mPdPrefixManager(aInstance) #endif , mRsSender(aInstance) , mDiscoveredPrefixStaleTimer(aInstance) @@ -87,10 +94,12 @@ Error RoutingManager::Init(uint32_t aInfraIfIndex, bool aInfraIfIsRunning) { Error error; + LogInfo("Initializing - InfraIfIndex:%u", aInfraIfIndex); + SuccessOrExit(error = mInfraIf.Init(aInfraIfIndex)); SuccessOrExit(error = LoadOrGenerateRandomBrUlaPrefix()); - mLocalOmrPrefix.GenerateFrom(mBrUlaPrefix); + mOmrPrefixManager.Init(mBrUlaPrefix); #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE mNat64PrefixManager.GenerateLocalPrefix(mBrUlaPrefix); #endif @@ -116,6 +125,7 @@ Error RoutingManager::SetEnabled(bool aEnabled) VerifyOrExit(aEnabled != mIsEnabled); mIsEnabled = aEnabled; + LogInfo("%s", mIsEnabled ? "Enabling" : "Disabling"); EvaluateState(); exit: @@ -180,19 +190,32 @@ Error RoutingManager::GetOmrPrefix(Ip6::Prefix &aPrefix) const Error error = kErrorNone; VerifyOrExit(IsInitialized(), error = kErrorInvalidState); - aPrefix = mLocalOmrPrefix.GetPrefix(); + aPrefix = mOmrPrefixManager.GetGeneratedPrefix(); exit: return error; } +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +Error RoutingManager::GetPdOmrPrefix(PrefixTableEntry &aPrefixInfo) const +{ + Error error = kErrorNone; + + VerifyOrExit(IsInitialized(), error = kErrorInvalidState); + error = mPdPrefixManager.GetPrefixInfo(aPrefixInfo); + +exit: + return error; +} +#endif + Error RoutingManager::GetFavoredOmrPrefix(Ip6::Prefix &aPrefix, RoutePreference &aPreference) const { Error error = kErrorNone; VerifyOrExit(IsRunning(), error = kErrorInvalidState); - aPrefix = mFavoredOmrPrefix.GetPrefix(); - aPreference = mFavoredOmrPrefix.GetPreference(); + aPrefix = mOmrPrefixManager.GetFavoredPrefix().GetPrefix(); + aPreference = mOmrPrefixManager.GetFavoredPrefix().GetPreference(); exit: return error; @@ -304,12 +327,12 @@ void RoutingManager::Start(void) { if (!mIsRunning) { - LogInfo("Border Routing manager started"); + LogInfo("Starting"); mIsRunning = true; UpdateDiscoveredPrefixTableOnNetDataChange(); mOnLinkPrefixManager.Start(); - DetermineFavoredOmrPrefix(); + mOmrPrefixManager.Start(); mRoutePublisher.Start(); mRsSender.Start(); #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE @@ -322,9 +345,7 @@ void RoutingManager::Stop(void) { VerifyOrExit(mIsRunning); - mLocalOmrPrefix.RemoveFromNetData(); - mFavoredOmrPrefix.Clear(); - + mOmrPrefixManager.Stop(); mOnLinkPrefixManager.Stop(); #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE @@ -346,7 +367,7 @@ void RoutingManager::Stop(void) mRoutePublisher.Stop(); - LogInfo("Border Routing manager stopped"); + LogInfo("Stopped"); mIsRunning = false; @@ -458,63 +479,6 @@ void RoutingManager::UpdateDiscoveredPrefixTableOnNetDataChange(void) } } -void RoutingManager::DetermineFavoredOmrPrefix(void) -{ - // Determine the favored OMR prefix present in Network Data. - - NetworkData::Iterator iterator = NetworkData::kIteratorInit; - NetworkData::OnMeshPrefixConfig onMeshPrefixConfig; - - mFavoredOmrPrefix.Clear(); - - while (Get().GetNextOnMeshPrefix(iterator, onMeshPrefixConfig) == kErrorNone) - { - if (!IsValidOmrPrefix(onMeshPrefixConfig) || !onMeshPrefixConfig.mPreferred) - { - continue; - } - - if (mFavoredOmrPrefix.IsEmpty() || !mFavoredOmrPrefix.IsFavoredOver(onMeshPrefixConfig)) - { - mFavoredOmrPrefix.SetFrom(onMeshPrefixConfig); - } - } -} - -void RoutingManager::EvaluateOmrPrefix(void) -{ - OT_ASSERT(mIsRunning); - - DetermineFavoredOmrPrefix(); - - // Decide if we need to add or remove our local OMR prefix. - - if (mFavoredOmrPrefix.IsEmpty()) - { - LogInfo("EvaluateOmrPrefix: No preferred OMR prefix found in Thread network"); - - // The `mFavoredOmrPrefix` remains empty if we fail to publish - // the local OMR prefix. - SuccessOrExit(mLocalOmrPrefix.AddToNetData()); - - mFavoredOmrPrefix.SetFrom(mLocalOmrPrefix); - } - else if (mFavoredOmrPrefix.GetPrefix() == mLocalOmrPrefix.GetPrefix()) - { - IgnoreError(mLocalOmrPrefix.AddToNetData()); - } - else if (mLocalOmrPrefix.IsAddedInNetData()) - { - LogInfo("EvaluateOmrPrefix: There is already a preferred OMR prefix %s in the Thread network", - mFavoredOmrPrefix.GetPrefix().ToString().AsCString()); - - mLocalOmrPrefix.RemoveFromNetData(); - } - -exit: - return; -} - // This method evaluate the routing policy depends on prefix and route // information on Thread Network and infra link. As a result, this // method May send RA messages on infra link and publish/unpublish @@ -526,7 +490,7 @@ void RoutingManager::EvaluateRoutingPolicy(void) LogInfo("Evaluating routing policy"); mOnLinkPrefixManager.Evaluate(); - EvaluateOmrPrefix(); + mOmrPrefixManager.Evaluate(); mRoutePublisher.Evaluate(); #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE mNat64PrefixManager.Evaluate(); @@ -557,7 +521,8 @@ bool RoutingManager::IsInitalPolicyEvaluationDone(void) const // the emitted Router Advert message on infrastructure side // and published in the Thread Network Data. - return mIsRunning && !mFavoredOmrPrefix.IsEmpty() && mOnLinkPrefixManager.IsInitalEvaluationDone(); + return mIsRunning && !mOmrPrefixManager.GetFavoredPrefix().IsEmpty() && + mOnLinkPrefixManager.IsInitalEvaluationDone(); } void RoutingManager::ScheduleRoutingPolicyEvaluation(ScheduleMode aMode) @@ -593,9 +558,25 @@ void RoutingManager::ScheduleRoutingPolicyEvaluation(ScheduleMode aMode) // Ensure we wait a min delay after last RA tx evaluateTime = Max(now + delay, mRaInfo.mLastTxTime + kMinDelayBetweenRtrAdvs); - LogInfo("Start evaluating routing policy, scheduled in %lu milliseconds", ToUlong(evaluateTime - now)); - mRoutingPolicyTimer.FireAtIfEarlier(evaluateTime); + +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) + { + uint32_t duration = evaluateTime - now; + + if (duration == 0) + { + LogInfo("Will evaluate routing policy immediately"); + } + else + { + String string; + + Uptime::UptimeToString(duration, string, /* aIncludeMsec */ true); + LogInfo("Will evaluate routing policy in %s (%lu msec)", string.AsCString() + 3, ToUlong(duration)); + } + } +#endif } void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) @@ -619,6 +600,8 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) NetworkData::Iterator iterator; NetworkData::OnMeshPrefixConfig prefixConfig; + LogInfo("Preparing RA"); + // Append PIO for local on-link prefix if is either being // advertised or deprecated and for old prefix if is being // deprecated. @@ -641,7 +624,8 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) while (Get().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) { - if (!prefixConfig.mOnMesh || prefixConfig.mDp || (prefixConfig.GetPrefix() == mLocalOmrPrefix.GetPrefix())) + if (!prefixConfig.mOnMesh || prefixConfig.mDp || + (prefixConfig.GetPrefix() == mOmrPrefixManager.GetLocalPrefix().GetPrefix())) { continue; } @@ -649,9 +633,9 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) mAdvertisedPrefixes.MarkAsDeleted(prefixConfig.GetPrefix()); } - if (mLocalOmrPrefix.IsAddedInNetData()) + if (mOmrPrefixManager.IsLocalAddedInNetData()) { - mAdvertisedPrefixes.MarkAsDeleted(mLocalOmrPrefix.GetPrefix()); + mAdvertisedPrefixes.MarkAsDeleted(mOmrPrefixManager.GetLocalPrefix().GetPrefix()); } } @@ -660,7 +644,7 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) if (prefix.GetLength() != 0) { SuccessOrAssert(raMsg.AppendRouteInfoOption(prefix, /* aRouteLifetime */ 0, mRioPreference)); - LogInfo("RouterAdvert: Added RIO for %s (lifetime=0)", prefix.ToString().AsCString()); + LogRouteInfoOption(prefix, 0, mRioPreference); } } @@ -679,16 +663,16 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) // (1) Local OMR prefix. - if (mLocalOmrPrefix.IsAddedInNetData()) + if (mOmrPrefixManager.IsLocalAddedInNetData()) { - mAdvertisedPrefixes.Add(mLocalOmrPrefix.GetPrefix()); + mAdvertisedPrefixes.Add(mOmrPrefixManager.GetLocalPrefix().GetPrefix()); } // (2) Favored OMR prefix. - if (!mFavoredOmrPrefix.IsEmpty() && !mFavoredOmrPrefix.IsDomainPrefix()) + if (!mOmrPrefixManager.GetFavoredPrefix().IsEmpty() && !mOmrPrefixManager.GetFavoredPrefix().IsDomainPrefix()) { - mAdvertisedPrefixes.Add(mFavoredOmrPrefix.GetPrefix()); + mAdvertisedPrefixes.Add(mOmrPrefixManager.GetFavoredPrefix().GetPrefix()); } // (3) All other OMR prefixes. @@ -698,8 +682,8 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) while (Get().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) { // Local OMR prefix is added to the array depending on - // `mLocalOmrPrefix.IsAddedInNetData()` at step (1). As - // we iterate through the Network Data prefixes, we skip + // `mOmrPrefixManager.IsLocalAddedInNetData()` at step (1). + // As we iterate through the Network Data prefixes, we skip // over entries matching the local OMR prefix. This // ensures that we stop including it in emitted RA // message as soon as we decide to remove it from Network @@ -713,7 +697,8 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) continue; } - if (IsValidOmrPrefix(prefixConfig) && (prefixConfig.GetPrefix() != mLocalOmrPrefix.GetPrefix())) + if (IsValidOmrPrefix(prefixConfig) && + (prefixConfig.GetPrefix() != mOmrPrefixManager.GetLocalPrefix().GetPrefix())) { mAdvertisedPrefixes.Add(prefixConfig.GetPrefix()); } @@ -734,8 +719,7 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) for (const OnMeshPrefix &prefix : mAdvertisedPrefixes) { SuccessOrAssert(raMsg.AppendRouteInfoOption(prefix, kDefaultOmrPrefixLifetime, mRioPreference)); - LogInfo("RouterAdvert: Added RIO for %s (lifetime=%lu)", prefix.ToString().AsCString(), - ToUlong(kDefaultOmrPrefixLifetime)); + LogRouteInfoOption(prefix, kDefaultOmrPrefixLifetime, mRioPreference); } } @@ -754,15 +738,14 @@ void RoutingManager::SendRouterAdvertisement(RouterAdvTxMode aRaTxMode) { mRaInfo.mLastTxTime = TimerMilli::GetNow(); Get().GetBorderRoutingCounters().mRaTxSuccess++; - LogInfo("Sent Router Advertisement on %s", mInfraIf.ToString().AsCString()); + LogInfo("Sent RA on %s", mInfraIf.ToString().AsCString()); DumpDebg("[BR-CERT] direction=send | type=RA |", raMsg.GetAsPacket().GetBytes(), raMsg.GetAsPacket().GetLength()); } else { Get().GetBorderRoutingCounters().mRaTxFailure++; - LogWarn("Failed to send Router Advertisement on %s: %s", mInfraIf.ToString().AsCString(), - ErrorToString(error)); + LogWarn("Failed to send RA on %s: %s", mInfraIf.ToString().AsCString(), ErrorToString(error)); } } } @@ -862,7 +845,7 @@ bool RoutingManager::IsValidOnLinkPrefix(const Ip6::Nd::PrefixInfoOption &aPio) bool RoutingManager::IsValidOnLinkPrefix(const Ip6::Prefix &aOnLinkPrefix) { - return aOnLinkPrefix.IsValid() && (aOnLinkPrefix.GetLength() > 0) && !aOnLinkPrefix.IsLinkLocal() && + return (aOnLinkPrefix.GetLength() == kOnLinkPrefixLength) && !aOnLinkPrefix.IsLinkLocal() && !aOnLinkPrefix.IsMulticast(); } @@ -899,8 +882,7 @@ void RoutingManager::HandleRouterSolicit(const InfraIf::Icmp6Packet &aPacket, co OT_UNUSED_VARIABLE(aSrcAddress); Get().GetBorderRoutingCounters().mRsRx++; - LogInfo("Received Router Solicitation from %s on %s", aSrcAddress.ToString().AsCString(), - mInfraIf.ToString().AsCString()); + LogInfo("Received RS from %s on %s", aSrcAddress.ToString().AsCString(), mInfraIf.ToString().AsCString()); ScheduleRoutingPolicyEvaluation(kToReplyToRs); } @@ -927,8 +909,8 @@ void RoutingManager::HandleRouterAdvertisement(const InfraIf::Icmp6Packet &aPack VerifyOrExit(routerAdvMessage.IsValid()); Get().GetBorderRoutingCounters().mRaRx++; - LogInfo("Received Router Advertisement from %s on %s", aSrcAddress.ToString().AsCString(), - mInfraIf.ToString().AsCString()); + + LogInfo("Received RA from %s on %s", aSrcAddress.ToString().AsCString(), mInfraIf.ToString().AsCString()); DumpDebg("[BR-CERT] direction=recv | type=RA |", aPacket.GetBytes(), aPacket.GetLength()); mDiscoveredPrefixTable.ProcessRouterAdvertMessage(routerAdvMessage, aSrcAddress); @@ -955,7 +937,7 @@ bool RoutingManager::ShouldProcessPrefixInfoOption(const Ip6::Nd::PrefixInfoOpti if (!IsValidOnLinkPrefix(aPio)) { - LogInfo("Ignore invalid on-link prefix in PIO: %s", aPrefix.ToString().AsCString()); + LogInfo("- PIO %s - ignore since not a valid on-link prefix", aPrefix.ToString().AsCString()); ExitNow(); } @@ -989,11 +971,11 @@ bool RoutingManager::ShouldProcessRouteInfoOption(const Ip6::Nd::RouteInfoOption if (!IsValidOmrPrefix(aPrefix)) { - LogInfo("Ignore RIO prefix %s since not a valid OMR prefix", aPrefix.ToString().AsCString()); + LogInfo("- RIO %s - ignore since not a valid OMR prefix", aPrefix.ToString().AsCString()); ExitNow(); } - VerifyOrExit(mLocalOmrPrefix.GetPrefix() != aPrefix); + VerifyOrExit(mOmrPrefixManager.GetLocalPrefix().GetPrefix() != aPrefix); // Ignore OMR prefixes advertised by ourselves or in current Thread Network Data. // The `mAdvertisedPrefixes` and the OMR prefix set in Network Data should eventually @@ -1153,6 +1135,25 @@ void RoutingManager::ResetDiscoveredPrefixStaleTimer(void) } } +#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) +void RoutingManager::LogPrefixInfoOption(const Ip6::Prefix &aPrefix, + uint32_t aValidLifetime, + uint32_t aPreferredLifetime) +{ + LogInfo("- PIO %s (valid:%lu, preferred:%lu)", aPrefix.ToString().AsCString(), ToUlong(aValidLifetime), + ToUlong(aPreferredLifetime)); +} + +void RoutingManager::LogRouteInfoOption(const Ip6::Prefix &aPrefix, uint32_t aLifetime, RoutePreference aPreference) +{ + LogInfo("- RIO %s (lifetime:%lu, prf:%s)", aPrefix.ToString().AsCString(), ToUlong(aLifetime), + RoutePreferenceToString(aPreference)); +} +#else +void RoutingManager::LogPrefixInfoOption(const Ip6::Prefix &, uint32_t, uint32_t) {} +void RoutingManager::LogRouteInfoOption(const Ip6::Prefix &, uint32_t, RoutePreference) {} +#endif + //--------------------------------------------------------------------------------------------------------------------- // DiscoveredPrefixTable @@ -1227,6 +1228,8 @@ void RoutingManager::DiscoveredPrefixTable::ProcessDefaultRoute(const Ip6::Nd::R prefix.Clear(); entry = aRouter.mEntries.FindMatching(Entry::Matcher(prefix, Entry::kTypeRoute)); + LogInfo("- RA Header - default route - lifetime:%u", aRaHeader.GetRouterLifetime()); + if (entry == nullptr) { VerifyOrExit(aRaHeader.GetRouterLifetime() != 0); @@ -1266,7 +1269,7 @@ void RoutingManager::DiscoveredPrefixTable::ProcessPrefixInfoOption(const Ip6::N VerifyOrExit(Get().ShouldProcessPrefixInfoOption(aPio, prefix)); - LogInfo("Processing PIO (%s, %lu seconds)", prefix.ToString().AsCString(), ToUlong(aPio.GetValidLifetime())); + LogPrefixInfoOption(prefix, aPio.GetValidLifetime(), aPio.GetPreferredLifetime()); entry = aRouter.mEntries.FindMatching(Entry::Matcher(prefix, Entry::kTypeOnLink)); @@ -1312,7 +1315,7 @@ void RoutingManager::DiscoveredPrefixTable::ProcessRouteInfoOption(const Ip6::Nd VerifyOrExit(Get().ShouldProcessRouteInfoOption(aRio, prefix)); - LogInfo("Processing RIO (%s, %lu seconds)", prefix.ToString().AsCString(), ToUlong(aRio.GetRouteLifetime())); + LogRouteInfoOption(prefix, aRio.GetRouteLifetime(), aRio.GetPreference()); entry = aRouter.mEntries.FindMatching(Entry::Matcher(prefix, Entry::kTypeRoute)); @@ -1495,10 +1498,13 @@ void RoutingManager::DiscoveredPrefixTable::RemoveOrDeprecateEntriesFromInactive for (Entry &entry : router.mEntries) { - if (entry.IsOnLinkPrefix() && !entry.IsDeprecated()) + if (entry.IsOnLinkPrefix()) { - entry.ClearPreferredLifetime(); - SignalTableChanged(); + if (!entry.IsDeprecated()) + { + entry.ClearPreferredLifetime(); + SignalTableChanged(); + } } else { @@ -1897,9 +1903,9 @@ uint32_t RoutingManager::DiscoveredPrefixTable::Entry::CalculateExpireDelay(uint } //--------------------------------------------------------------------------------------------------------------------- -// OmrPrefix +// FavoredOmrPrefix -bool RoutingManager::OmrPrefix::IsInfrastructureDerived(void) const +bool RoutingManager::FavoredOmrPrefix::IsInfrastructureDerived(void) const { // Indicate whether the OMR prefix is infrastructure-derived which // can be identified as a valid OMR prefix with preference of @@ -1908,21 +1914,21 @@ bool RoutingManager::OmrPrefix::IsInfrastructureDerived(void) const return !IsEmpty() && (mPreference >= NetworkData::kRoutePreferenceMedium); } -void RoutingManager::OmrPrefix::SetFrom(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig) +void RoutingManager::FavoredOmrPrefix::SetFrom(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig) { mPrefix = aOnMeshPrefixConfig.GetPrefix(); mPreference = aOnMeshPrefixConfig.GetPreference(); mIsDomainPrefix = aOnMeshPrefixConfig.mDp; } -void RoutingManager::OmrPrefix::SetFrom(const LocalOmrPrefix &aLocalOmrPrefix) +void RoutingManager::FavoredOmrPrefix::SetFrom(const OmrPrefix &aOmrPrefix) { - mPrefix = aLocalOmrPrefix.GetPrefix(); - mPreference = aLocalOmrPrefix.GetPreference(); - mIsDomainPrefix = false; + mPrefix = aOmrPrefix.GetPrefix(); + mPreference = aOmrPrefix.GetPreference(); + mIsDomainPrefix = aOmrPrefix.IsDomainPrefix(); } -bool RoutingManager::OmrPrefix::IsFavoredOver(const NetworkData::OnMeshPrefixConfig &aOmrPrefixConfig) const +bool RoutingManager::FavoredOmrPrefix::IsFavoredOver(const NetworkData::OnMeshPrefixConfig &aOmrPrefixConfig) const { // This method determines whether this OMR prefix is favored // over another prefix. A prefix with higher preference is @@ -1942,37 +1948,133 @@ bool RoutingManager::OmrPrefix::IsFavoredOver(const NetworkData::OnMeshPrefixCon } //--------------------------------------------------------------------------------------------------------------------- -// LocalOmrPrefix +// OmrPrefixManager -RoutingManager::LocalOmrPrefix::LocalOmrPrefix(Instance &aInstance) +RoutingManager::OmrPrefixManager::OmrPrefixManager(Instance &aInstance) : InstanceLocator(aInstance) - , mIsAddedInNetData(false) + , mIsLocalAddedInNetData(false) , mDefaultRoute(false) { } -void RoutingManager::LocalOmrPrefix::GenerateFrom(const Ip6::Prefix &aBrUlaPrefix) +void RoutingManager::OmrPrefixManager::Init(const Ip6::Prefix &aBrUlaPrefix) { - mPrefix = aBrUlaPrefix; - mPrefix.SetSubnetId(kOmrPrefixSubnetId); - mPrefix.SetLength(kOmrPrefixLength); + mGeneratedPrefix = aBrUlaPrefix; + mGeneratedPrefix.SetSubnetId(kOmrPrefixSubnetId); + mGeneratedPrefix.SetLength(kOmrPrefixLength); + + LogInfo("Generated local OMR prefix: %s", mGeneratedPrefix.ToString().AsCString()); +} + +void RoutingManager::OmrPrefixManager::Start(void) { DetermineFavoredPrefix(); } + +void RoutingManager::OmrPrefixManager::Stop(void) +{ + RemoveLocalFromNetData(); + mFavoredPrefix.Clear(); +} + +void RoutingManager::OmrPrefixManager::DetermineFavoredPrefix(void) +{ + // Determine the favored OMR prefix present in Network Data. + + NetworkData::Iterator iterator = NetworkData::kIteratorInit; + NetworkData::OnMeshPrefixConfig prefixConfig; + + mFavoredPrefix.Clear(); + + while (Get().GetNextOnMeshPrefix(iterator, prefixConfig) == kErrorNone) + { + if (!IsValidOmrPrefix(prefixConfig) || !prefixConfig.mPreferred) + { + continue; + } + + if (mFavoredPrefix.IsEmpty() || !mFavoredPrefix.IsFavoredOver(prefixConfig)) + { + mFavoredPrefix.SetFrom(prefixConfig); + } + } +} + +void RoutingManager::OmrPrefixManager::Evaluate(void) +{ + OT_ASSERT(Get().IsRunning()); + + DetermineFavoredPrefix(); + + // Determine the local prefix and remove outdated prefix published by us. +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + if (Get().mPdPrefixManager.HasPrefix()) + { + if (mLocalPrefix.GetPrefix() != Get().mPdPrefixManager.GetPrefix()) + { + RemoveLocalFromNetData(); + mLocalPrefix.mPrefix = Get().mPdPrefixManager.GetPrefix(); + mLocalPrefix.mPreference = RoutePreference::kRoutePreferenceMedium; + mLocalPrefix.mIsDomainPrefix = false; + LogInfo("Setting local OMR prefix to PD prefix: %s", mLocalPrefix.GetPrefix().ToString().AsCString()); + } + } + else +#endif + if (mLocalPrefix.GetPrefix() != mGeneratedPrefix) + { + RemoveLocalFromNetData(); + mLocalPrefix.mPrefix = mGeneratedPrefix; + mLocalPrefix.mPreference = RoutePreference::kRoutePreferenceLow; + mLocalPrefix.mIsDomainPrefix = false; + LogInfo("Setting local OMR prefix to generated prefix: %s", mLocalPrefix.GetPrefix().ToString().AsCString()); + } - LogInfo("Generated OMR prefix: %s", mPrefix.ToString().AsCString()); + // Decide if we need to add or remove our local OMR prefix. + if (mFavoredPrefix.IsEmpty() || mFavoredPrefix.GetPreference() < mLocalPrefix.GetPreference()) + { + if (mFavoredPrefix.IsEmpty()) + { + LogInfo("No favored OMR prefix found in Thread network."); + } + else + { + LogInfo("Replacing favored OMR prefix %s with higher preference local prefix %s.", + mFavoredPrefix.GetPrefix().ToString().AsCString(), mLocalPrefix.GetPrefix().ToString().AsCString()); + } + + // The `mFavoredPrefix` remains empty if we fail to publish + // the local OMR prefix. + SuccessOrExit(AddLocalToNetData()); + + mFavoredPrefix.SetFrom(mLocalPrefix); + } + else if (mFavoredPrefix.GetPrefix() == mLocalPrefix.GetPrefix()) + { + IgnoreError(AddLocalToNetData()); + } + else if (mIsLocalAddedInNetData) + { + LogInfo("There is already a favored OMR prefix %s in the Thread network", + mFavoredPrefix.GetPrefix().ToString().AsCString()); + + RemoveLocalFromNetData(); + } + +exit: + return; } -Error RoutingManager::LocalOmrPrefix::AddToNetData(void) +Error RoutingManager::OmrPrefixManager::AddLocalToNetData(void) { Error error = kErrorNone; - VerifyOrExit(!mIsAddedInNetData); - SuccessOrExit(error = AddOrUpdate()); - mIsAddedInNetData = true; + VerifyOrExit(!mIsLocalAddedInNetData); + SuccessOrExit(error = AddOrUpdateLocalInNetData()); + mIsLocalAddedInNetData = true; exit: return error; } -Error RoutingManager::LocalOmrPrefix::AddOrUpdate(void) +Error RoutingManager::OmrPrefixManager::AddOrUpdateLocalInNetData(void) { // Add the local OMR prefix in Thread Network Data or update it // (e.g., change default route flag) if it is already added. @@ -1981,71 +2083,72 @@ Error RoutingManager::LocalOmrPrefix::AddOrUpdate(void) NetworkData::OnMeshPrefixConfig config; config.Clear(); - config.mPrefix = mPrefix; + config.mPrefix = mLocalPrefix.GetPrefix(); config.mStable = true; config.mSlaac = true; config.mPreferred = true; config.mOnMesh = true; config.mDefaultRoute = mDefaultRoute; - config.mPreference = GetPreference(); + config.mPreference = mLocalPrefix.GetPreference(); error = Get().AddOnMeshPrefix(config); if (error != kErrorNone) { - LogWarn("Failed to %s %s in Thread Network Data: %s", !mIsAddedInNetData ? "add" : "update", - ToString().AsCString(), ErrorToString(error)); + LogWarn("Failed to %s %s in Thread Network Data: %s", !mIsLocalAddedInNetData ? "add" : "update", + LocalToString().AsCString(), ErrorToString(error)); ExitNow(); } Get().HandleServerDataUpdated(); - LogInfo("%s %s in Thread Network Data", !mIsAddedInNetData ? "Added" : "Updated", ToString().AsCString()); + LogInfo("%s %s in Thread Network Data", !mIsLocalAddedInNetData ? "Added" : "Updated", LocalToString().AsCString()); exit: return error; } -void RoutingManager::LocalOmrPrefix::RemoveFromNetData(void) +void RoutingManager::OmrPrefixManager::RemoveLocalFromNetData(void) { Error error = kErrorNone; - VerifyOrExit(mIsAddedInNetData); + VerifyOrExit(mIsLocalAddedInNetData); - error = Get().RemoveOnMeshPrefix(mPrefix); + error = Get().RemoveOnMeshPrefix(mLocalPrefix.GetPrefix()); if (error != kErrorNone) { - LogWarn("Failed to remove %s from Thread Network Data: %s", ToString().AsCString(), ErrorToString(error)); + LogWarn("Failed to remove %s from Thread Network Data: %s", LocalToString().AsCString(), ErrorToString(error)); ExitNow(); } - mIsAddedInNetData = false; + mIsLocalAddedInNetData = false; Get().HandleServerDataUpdated(); - LogInfo("Removed %s from Thread Network Data", ToString().AsCString()); + LogInfo("Removed %s from Thread Network Data", LocalToString().AsCString()); exit: return; } -void RoutingManager::LocalOmrPrefix::UpdateDefaultRouteFlag(bool aDefaultRoute) +void RoutingManager::OmrPrefixManager::UpdateDefaultRouteFlag(bool aDefaultRoute) { VerifyOrExit(aDefaultRoute != mDefaultRoute); mDefaultRoute = aDefaultRoute; - VerifyOrExit(mIsAddedInNetData); - IgnoreError(AddOrUpdate()); + VerifyOrExit(mIsLocalAddedInNetData); + IgnoreError(AddOrUpdateLocalInNetData()); exit: return; } -RoutingManager::LocalOmrPrefix::InfoString RoutingManager::LocalOmrPrefix::ToString(void) const +RoutingManager::OmrPrefixManager::InfoString RoutingManager::OmrPrefixManager::LocalToString(void) const { InfoString string; - string.Append("local OMR prefix %s (def-route:%s)", mPrefix.ToString().AsCString(), ToYesNo(mDefaultRoute)); + string.Append("local OMR prefix %s (def-route:%s)", mLocalPrefix.GetPrefix().ToString().AsCString(), + ToYesNo(mDefaultRoute)); return string; } @@ -2226,8 +2329,7 @@ void RoutingManager::OnLinkPrefixManager::Evaluate(void) if (!(mLocalPrefix < mFavoredDiscoveredPrefix)) { - LogInfo("EvaluateOnLinkPrefix: There is already favored on-link prefix %s", - mFavoredDiscoveredPrefix.ToString().AsCString()); + LogInfo("Found a favored on-link prefix %s", mFavoredDiscoveredPrefix.ToString().AsCString()); Deprecate(); } } @@ -2283,6 +2385,8 @@ void RoutingManager::OnLinkPrefixManager::PublishAndAdvertise(void) mState = kPublishing; ResetExpireTime(TimerMilli::GetNow()); + LogInfo("Publishing route for local on-link prefix %s", mLocalPrefix.ToString().AsCString()); + // We wait for the ULA `fc00::/7` route or a sub-prefix of it (e.g., // default route) to be added in Network Data before // starting to advertise the local on-link prefix in RAs. @@ -2313,7 +2417,7 @@ void RoutingManager::OnLinkPrefixManager::Deprecate(void) case kPublishing: case kAdvertising: mState = kDeprecating; - LogInfo("Deprecate local on-link prefix %s", mLocalPrefix.ToString().AsCString()); + LogInfo("Deprecating local on-link prefix %s", mLocalPrefix.ToString().AsCString()); break; case kIdle: @@ -2342,7 +2446,7 @@ void RoutingManager::OnLinkPrefixManager::ResetExpireTime(TimeMilli aNow) void RoutingManager::OnLinkPrefixManager::EnterAdvertisingState(void) { mState = kAdvertising; - LogInfo("Start advertising local on-link prefix %s", mLocalPrefix.ToString().AsCString()); + LogInfo("Advertising local on-link prefix %s", mLocalPrefix.ToString().AsCString()); } bool RoutingManager::OnLinkPrefixManager::IsPublishingOrAdvertising(void) const @@ -2388,8 +2492,7 @@ void RoutingManager::OnLinkPrefixManager::AppendCurPrefix(Ip6::Nd::RouterAdvertM SuccessOrAssert(aRaMessage.AppendPrefixInfoOption(mLocalPrefix, validLifetime, preferredLifetime)); - LogInfo("RouterAdvert: Added PIO for %s (valid=%lu, preferred=%lu)", mLocalPrefix.ToString().AsCString(), - ToUlong(validLifetime), ToUlong(preferredLifetime)); + LogPrefixInfoOption(mLocalPrefix, validLifetime, preferredLifetime); exit: return; @@ -2410,8 +2513,7 @@ void RoutingManager::OnLinkPrefixManager::AppendOldPrefixes(Ip6::Nd::RouterAdver validLifetime = TimeMilli::MsecToSec(oldPrefix.mExpireTime - now); SuccessOrAssert(aRaMessage.AppendPrefixInfoOption(oldPrefix.mPrefix, validLifetime, 0)); - LogInfo("RouterAdvert: Added PIO for %s (valid=%lu, preferred=0)", oldPrefix.mPrefix.ToString().AsCString(), - ToUlong(validLifetime)); + LogPrefixInfoOption(oldPrefix.mPrefix, validLifetime, 0); } } @@ -2536,7 +2638,7 @@ void RoutingManager::OnLinkPrefixManager::HandleTimer(void) case kDeprecating: if (now >= mExpireTime) { - LogInfo("Local on-link prefix %s expired", mLocalPrefix.ToString().AsCString()); + LogInfo("Removing expired local on-link prefix %s", mLocalPrefix.ToString().AsCString()); IgnoreError(Get().RemoveBrOnLinkPrefix(mLocalPrefix)); mState = kIdle; } @@ -2632,7 +2734,7 @@ void RoutingManager::RoutePublisher::Evaluate(void) VerifyOrExit(Get().IsRunning()); - if (Get().mFavoredOmrPrefix.IsInfrastructureDerived() && + if (Get().mOmrPrefixManager.GetFavoredPrefix().IsInfrastructureDerived() && Get().mDiscoveredPrefixTable.ContainsDefaultOrNonUlaRoutePrefix()) { newState = kPublishDefault; @@ -2652,7 +2754,7 @@ void RoutingManager::RoutePublisher::Evaluate(void) { LogInfo("RoutePublisher state: %s -> %s", StateToString(mState), StateToString(newState)); UpdatePublishedRoute(newState); - Get().mLocalOmrPrefix.UpdateDefaultRouteFlag(newState == kPublishDefault); + Get().mOmrPrefixManager.UpdateDefaultRouteFlag(newState == kPublishDefault); } } @@ -2873,7 +2975,8 @@ const Ip6::Prefix &RoutingManager::Nat64PrefixManager::GetFavoredPrefix(RoutePre aPreference = NetworkData::kRoutePreferenceLow; - if (mInfraIfPrefix.IsValidNat64() && Get().mFavoredOmrPrefix.IsInfrastructureDerived()) + if (mInfraIfPrefix.IsValidNat64() && + Get().mOmrPrefixManager.GetFavoredPrefix().IsInfrastructureDerived()) { favoredPrefix = &mInfraIfPrefix; aPreference = NetworkData::kRoutePreferenceMedium; @@ -3028,7 +3131,8 @@ void RoutingManager::RsSender::Start(void) VerifyOrExit(!IsInProgress()); delay = Random::NonCrypto::GetUint32InRange(0, kMaxStartDelay); - LogInfo("Scheduled Router Solicitation in %lu milliseconds", ToUlong(delay)); + + LogInfo("RsSender: Starting - will send first RS in %lu msec", ToUlong(delay)); mTxCount = 0; mStartTime = TimerMilli::GetNow(); @@ -3070,6 +3174,7 @@ void RoutingManager::RsSender::HandleTimer(void) if (mTxCount >= kMaxTxCount) { + LogInfo("RsSender: Finished sending RS msgs and waiting for RAs"); Get().HandleRsSenderFinished(mStartTime); ExitNow(); } @@ -3079,12 +3184,12 @@ void RoutingManager::RsSender::HandleTimer(void) if (error == kErrorNone) { mTxCount++; - LogInfo("Successfully sent RS %u/%u", mTxCount, kMaxTxCount); delay = (mTxCount == kMaxTxCount) ? kWaitOnLastAttempt : kTxInterval; + LogInfo("RsSender: Sent RS %u/%u", mTxCount, kMaxTxCount); } else { - LogCrit("Failed to send RS %u, error:%s", mTxCount + 1, ErrorToString(error)); + LogCrit("RsSender: Failed to send RS %u/%u: %s", mTxCount + 1, kMaxTxCount, ErrorToString(error)); // Note that `mTxCount` is intentionally not incremented // if the tx fails. @@ -3097,6 +3202,161 @@ void RoutingManager::RsSender::HandleTimer(void) return; } +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +RoutingManager::PdPrefixManager::PdPrefixManager(Instance &aInstance) + : InstanceLocator(aInstance) + , mEnabled(false) + , mTimer(aInstance) +{ + mPrefix.Clear(); +} + +Error RoutingManager::PdPrefixManager::GetPrefixInfo(PrefixTableEntry &aInfo) const +{ + Error error = kErrorNone; + + VerifyOrExit(IsRunning() && HasPrefix(), error = kErrorNotFound); + + aInfo.mPrefix = mPrefix.GetPrefix(); + aInfo.mValidLifetime = mPrefix.GetValidLifetime(); + aInfo.mPreferredLifetime = mPrefix.GetPreferredLifetime(); + aInfo.mMsecSinceLastUpdate = TimerMilli::GetNow() - mPrefix.GetLastUpdateTime(); + +exit: + return error; +} + +void RoutingManager::PdPrefixManager::WithdrawPrefix(void) +{ + VerifyOrExit(HasPrefix()); + + LogInfo("Withdrew platform provided outdated prefix: %s", mPrefix.GetPrefix().ToString().AsCString()); + + mPrefix.Clear(); + mTimer.Stop(); + + Get().ScheduleRoutingPolicyEvaluation(kImmediately); + +exit: + return; +} + +void RoutingManager::PdPrefixManager::ProcessPlatformGeneratedRa(const uint8_t *aRouterAdvert, const uint16_t aLength) +{ + Error error = kErrorNone; + Ip6::Nd::RouterAdvertMessage::Icmp6Packet packet; + + VerifyOrExit(mEnabled, LogWarn("Ignore platform generated RA since PD is disabled.")); + packet.Init(aRouterAdvert, aLength); + error = Process(Ip6::Nd::RouterAdvertMessage(packet)); + +exit: + if (error != kErrorNone) + { + LogCrit("Failed to process platform generated ND OnMeshPrefix: %s", ErrorToString(error)); + } +} + +Error RoutingManager::PdPrefixManager::Process(const Ip6::Nd::RouterAdvertMessage &aMessage) +{ + Error error = kErrorNone; + DiscoveredPrefixTable::Entry favoredEntry; + bool currentPrefixUpdated = false; + + VerifyOrExit(aMessage.IsValid(), error = kErrorParse); + favoredEntry.Clear(); + + for (const Ip6::Nd::Option &option : aMessage) + { + DiscoveredPrefixTable::Entry entry; + + if (option.GetType() != Ip6::Nd::Option::Type::kTypePrefixInfo || + !static_cast(option).IsValid()) + { + continue; + } + + entry.SetFrom(static_cast(option)); + + if (!IsValidPdPrefix(entry.GetPrefix())) + { + LogWarn("PdPrefixManager: Ignore invalid PIO entry %s", entry.GetPrefix().ToString().AsCString()); + continue; + } + + entry.mPrefix.SetLength(kOmrPrefixLength); + entry.mPrefix.Tidy(); + + // The platform may send another RA message to announce that the current prefix we are using is no longer + // preferred or no longer valid. + if (entry.GetPrefix() == GetPrefix()) + { + currentPrefixUpdated = true; + mPrefix = entry; + } + + if (entry.IsDeprecated()) + { + continue; + } + + // Some platforms may delegate us more than one prefixes. We will pick the smallest one. This is a simple rule + // to pick the GUA prefix from the RA messages since GUA prefixes (2000::/3) are always smaller than ULA + // prefixes (fc00::/7). + if (favoredEntry.GetPrefix().GetLength() == 0 || entry.GetPrefix() < favoredEntry.GetPrefix()) + { + favoredEntry = entry; + } + } + + if (currentPrefixUpdated && mPrefix.IsDeprecated()) + { + LogInfo("PdPrefixManager: Prefix %s is deprecated", mPrefix.GetPrefix().ToString().AsCString()); + mPrefix.Clear(); + Get().ScheduleRoutingPolicyEvaluation(kImmediately); + } + + if (!HasPrefix() || (favoredEntry.GetPrefix().GetLength() != 0 && favoredEntry.GetPrefix() < mPrefix.GetPrefix())) + { + mPrefix = favoredEntry; + Get().ScheduleRoutingPolicyEvaluation(kImmediately); + } + +exit: + if (HasPrefix()) + { + mTimer.FireAt(mPrefix.GetStaleTime()); + } + else + { + mTimer.Stop(); + } + + return error; +} + +void RoutingManager::PdPrefixManager::SetEnabled(bool aEnabled) +{ + VerifyOrExit(mEnabled != aEnabled); + + mEnabled = aEnabled; + if (!aEnabled) + { + WithdrawPrefix(); + } + + LogInfo("PdPrefixManager is %s", aEnabled ? "enabled" : "disabled"); + +exit: + return; +} + +extern "C" void otPlatBorderRoutingProcessIcmp6Ra(otInstance *aInstance, const uint8_t *aMessage, uint16_t aLength) +{ + AsCoreType(aInstance).Get().ProcessPlatfromGeneratedRa(aMessage, aLength); +} +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + } // namespace BorderRouter } // namespace ot diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index 65a01fff30d..b1f554b46b2 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -55,6 +55,7 @@ #include "common/error.hpp" #include "common/linked_list.hpp" #include "common/locator.hpp" +#include "common/message.hpp" #include "common/notifier.hpp" #include "common/pool.hpp" #include "common/string.hpp" @@ -69,7 +70,7 @@ namespace ot { namespace BorderRouter { /** - * This class implements bi-directional routing between Thread and Infrastructure networks. + * Implements bi-directional routing between Thread and Infrastructure networks. * * The Border Routing manager works on both Thread interface and infrastructure interface. * All ICMPv6 messages are sent/received on the infrastructure interface. @@ -100,7 +101,7 @@ class RoutingManager : public InstanceLocator static constexpr uint16_t kMaxPublishedPrefixes = 3; /** - * This enumeration represents the states of `RoutingManager`. + * Represents the states of `RoutingManager`. * */ enum State : uint8_t @@ -112,7 +113,18 @@ class RoutingManager : public InstanceLocator }; /** - * This constructor initializes the routing manager. + * This enumeration represents the states of DHCPv6 PD in `RoutingManager`. + * + */ + enum Dhcp6PdState : uint8_t + { + kDhcp6PdStateDisabled = OT_BORDER_ROUTING_STATE_DISABLED, ///< Disabled. + kDhcp6PdStateStopped = OT_BORDER_ROUTING_STATE_STOPPED, ///< Enabled, but currently stopped. + kDhcp6PdStateRunning = OT_BORDER_ROUTING_STATE_RUNNING, ///< Enabled, and running. + }; + + /** + * Initializes the routing manager. * * @param[in] aInstance A OpenThread instance. * @@ -120,7 +132,7 @@ class RoutingManager : public InstanceLocator explicit RoutingManager(Instance &aInstance); /** - * This method initializes the routing manager on given infrastructure interface. + * Initializes the routing manager on given infrastructure interface. * * @param[in] aInfraIfIndex An infrastructure network interface index. * @param[in] aInfraIfIsRunning A boolean that indicates whether the infrastructure @@ -133,7 +145,7 @@ class RoutingManager : public InstanceLocator Error Init(uint32_t aInfraIfIndex, bool aInfraIfIsRunning); /** - * This method enables/disables the Border Routing Manager. + * Enables/disables the Border Routing Manager. * * @note The Border Routing Manager is enabled by default. * @@ -146,7 +158,7 @@ class RoutingManager : public InstanceLocator Error SetEnabled(bool aEnabled); /** - * This method indicates whether or not it is currently running. + * Indicates whether or not it is currently running. * * In order for the `RoutingManager` to be running it needs to be initialized and enabled, and device being * attached. @@ -158,7 +170,7 @@ class RoutingManager : public InstanceLocator bool IsRunning(void) const { return mIsRunning; } /** - * This method gets the state of `RoutingManager`. + * Gets the state of `RoutingManager`. * * @returns The current state of `RoutingManager`. * @@ -166,7 +178,7 @@ class RoutingManager : public InstanceLocator State GetState(void) const; /** - * This method requests the Border Routing Manager to stop. + * Requests the Border Routing Manager to stop. * * If Border Routing Manager is running, calling this method immediately stops it and triggers the preparation * and sending of a final Router Advertisement (RA) message on infrastructure interface which deprecates and/or @@ -181,7 +193,7 @@ class RoutingManager : public InstanceLocator void RequestStop(void) { Stop(); } /** - * This method gets the current preference used when advertising Route Info Options (RIO) in Router Advertisement + * 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: @@ -196,7 +208,7 @@ class RoutingManager : public InstanceLocator RoutePreference GetRouteInfoOptionPreference(void) const { return mRioPreference; } /** - * This method explicitly sets the preference to use when advertising Route Info Options (RIO) in Router + * Explicitly sets the preference to use when advertising Route Info Options (RIO) in Router * Advertisement messages sent over the infrastructure link. * * After a call to this method, BR will use the given preference for all its advertised RIOs. The preference can be @@ -208,7 +220,7 @@ class RoutingManager : public InstanceLocator void SetRouteInfoOptionPreference(RoutePreference aPreference); /** - * This method clears a previously set preference value for advertised Route Info Options. + * Clears a previously set preference value for advertised Route Info Options. * * After a call to this method, BR will use device role to determine the RIO preference: Medium preference when * in router/leader role and low preference when in child role. @@ -217,7 +229,7 @@ class RoutingManager : public InstanceLocator void ClearRouteInfoOptionPreference(void); /** - * This method returns the local off-mesh-routable (OMR) prefix. + * Returns the local generated off-mesh-routable (OMR) prefix. * * The randomly generated 64-bit prefix will be added to the Thread Network Data if there isn't already an OMR * prefix. @@ -230,8 +242,24 @@ class RoutingManager : public InstanceLocator */ Error GetOmrPrefix(Ip6::Prefix &aPrefix) const; +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE /** - * This method returns the currently favored off-mesh-routable (OMR) prefix. + * Returns the platform provided off-mesh-routable (OMR) prefix. + * + * The prefix is extracted from the platform generated RA messages handled by `ProcessPlatfromGeneratedNd()`. + * + * @param[out] aPrefixInfo A reference to where the prefix info will be output to. + * + * @retval kErrorNone Successfully retrieved the OMR prefix. + * @retval kErrorNotFound There are no valid PD prefix on this BR. + * @retval kErrorInvalidState The Border Routing Manager is not initialized yet. + * + */ + Error GetPdOmrPrefix(PrefixTableEntry &aPrefixInfo) const; +#endif + + /** + * Returns the currently favored off-mesh-routable (OMR) prefix. * * The favored OMR prefix can be discovered from Network Data or can be our local OMR prefix. * @@ -248,7 +276,7 @@ class RoutingManager : public InstanceLocator Error GetFavoredOmrPrefix(Ip6::Prefix &aPrefix, RoutePreference &aPreference) const; /** - * This method returns the on-link prefix for the adjacent infrastructure link. + * Returns the on-link prefix for the adjacent infrastructure link. * * The randomly generated 64-bit prefix will be advertised * on the infrastructure link if there isn't already a usable @@ -263,7 +291,7 @@ class RoutingManager : public InstanceLocator Error GetOnLinkPrefix(Ip6::Prefix &aPrefix) const; /** - * This method returns the favored on-link prefix for the adjacent infrastructure link. + * Returns the favored on-link prefix for the adjacent infrastructure link. * * The favored prefix is either a discovered prefix on the infrastructure link or the local on-link prefix. * @@ -298,7 +326,7 @@ class RoutingManager : public InstanceLocator void SetNat64PrefixManagerEnabled(bool aEnabled); /** - * This method returns the local NAT64 prefix. + * Returns the local NAT64 prefix. * * @param[out] aPrefix A reference to where the prefix will be output to. * @@ -309,7 +337,7 @@ class RoutingManager : public InstanceLocator Error GetNat64Prefix(Ip6::Prefix &aPrefix); /** - * This method returns the currently favored NAT64 prefix. + * Returns the currently favored NAT64 prefix. * * The favored NAT64 prefix can be discovered from infrastructure link or can be the local NAT64 prefix. * @@ -323,7 +351,7 @@ class RoutingManager : public InstanceLocator Error GetFavoredNat64Prefix(Ip6::Prefix &aPrefix, RoutePreference &aRoutePreference); /** - * This method informs `RoutingManager` of the result of the discovery request of NAT64 prefix on infrastructure + * Informs `RoutingManager` of the result of the discovery request of NAT64 prefix on infrastructure * interface (`InfraIf::DiscoverNat64Prefix()`). * * @param[in] aPrefix The discovered NAT64 prefix on `InfraIf`. @@ -334,7 +362,7 @@ class RoutingManager : public InstanceLocator #endif // OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE /** - * This method processes a received ICMPv6 message from the infrastructure interface. + * Processes a received ICMPv6 message from the infrastructure interface. * * Malformed or undesired messages are dropped silently. * @@ -345,13 +373,13 @@ class RoutingManager : public InstanceLocator void HandleReceived(const InfraIf::Icmp6Packet &aPacket, const Ip6::Address &aSrcAddress); /** - * This method handles infrastructure interface state changes. + * Handles infrastructure interface state changes. * */ void HandleInfraIfStateChanged(void) { EvaluateState(); } /** - * This method checks whether the on-mesh prefix configuration is a valid OMR prefix. + * Checks whether the on-mesh prefix configuration is a valid OMR prefix. * * @param[in] aOnMeshPrefixConfig The on-mesh prefix configuration to check. * @@ -362,7 +390,7 @@ class RoutingManager : public InstanceLocator static bool IsValidOmrPrefix(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig); /** - * This method checks whether a given prefix is a valid OMR prefix. + * Checks whether a given prefix is a valid OMR prefix. * * @param[in] aPrefix The prefix to check. * @@ -373,7 +401,7 @@ class RoutingManager : public InstanceLocator static bool IsValidOmrPrefix(const Ip6::Prefix &aPrefix); /** - * This method initializes a `PrefixTableIterator`. + * Initializes a `PrefixTableIterator`. * * An iterator can be initialized again to start from the beginning of the table. * @@ -389,7 +417,7 @@ class RoutingManager : public InstanceLocator } /** - * This method iterates over entries in the discovered prefix table. + * Iterates over entries in the discovered prefix table. * * @param[in,out] aIterator An iterator. * @param[out] aEntry A reference to the entry to populate. @@ -405,7 +433,7 @@ class RoutingManager : public InstanceLocator #if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE /** - * This method determines whether to enable/disable SRP server when the auto-enable mode is changed on SRP server. + * Determines whether to enable/disable SRP server when the auto-enable mode is changed on SRP server. * * This should be called from `Srp::Server` when auto-enable mode is changed. * @@ -413,6 +441,41 @@ class RoutingManager : public InstanceLocator void HandleSrpServerAutoEnableMode(void); #endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + /** + * Handles a router advertisement message received on platform's Thread interface. + * + * Note: This method is a part of DHCPv6 PD support on Thread border routers. The message should be generated by the + * software like dnamasq, radvd, systemd-networkd on the platform as a part of the DHCPv6 prefix delegation process + * for distributing the prefix to the interfaces (links). + * + * @param[in] aRouterAdvert A pointer to the buffer of the router advertisement message. + * @param[in] aLength The length of the router advertisement message. + * + */ + void ProcessPlatfromGeneratedRa(const uint8_t *aRouterAdvert, uint16_t aLength) + { + mPdPrefixManager.ProcessPlatformGeneratedRa(aRouterAdvert, aLength); + } + + /** + * Enables / Disables the functions for DHCPv6 PD. + * + * @param[in] aEnabled Whether to accept platform generated RA messages. + * + */ + void SetDhcp6PdEnabled(bool aEnabled) { return mPdPrefixManager.SetEnabled(aEnabled); } + + /** + * Returns the state of accpeting RouterAdvertisement messages on platform interface. + * + * @retval kDhcp6PdStateRunning DHCPv6 PD should be enabled and running on this border router. + * @retval kDhcp6PdStateDisabled DHCPv6 PD should be disabled on this border router.. + * + */ + Dhcp6PdState GetDhcp6PdState(void) const { return mPdPrefixManager.GetState(); } +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + private: static constexpr uint8_t kMaxOnMeshPrefixes = OPENTHREAD_CONFIG_BORDER_ROUTING_MAX_ON_MESH_PREFIXES; @@ -472,6 +535,10 @@ class RoutingManager : public InstanceLocator void HandleDiscoveredPrefixTableEntryTimer(void) { mDiscoveredPrefixTable.HandleEntryTimer(); } void HandleDiscoveredPrefixTableRouterTimer(void) { mDiscoveredPrefixTable.HandleRouterTimer(); } +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + class PdPrefixManager; // For DiscoveredPrefixTable::Entry +#endif + class DiscoveredPrefixTable : public InstanceLocator { // This class maintains the discovered on-link and route prefixes @@ -492,6 +559,10 @@ class RoutingManager : public InstanceLocator // changes within the same flow of execution, the callback is // invoked after all the changes are processed. +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + friend class PdPrefixManager; // For DiscoveredPrefixTable::Entry +#endif + public: explicit DiscoveredPrefixTable(Instance &aInstance); @@ -527,6 +598,9 @@ class RoutingManager : public InstanceLocator { friend class LinkedListEntry; friend class Clearable; +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + friend class PdPrefixManager; +#endif public: enum Type : uint8_t @@ -684,51 +758,70 @@ class RoutingManager : public InstanceLocator SignalTask mSignalTask; }; - class LocalOmrPrefix; + class OmrPrefixManager; class OmrPrefix : public Clearable { + friend class OmrPrefixManager; + public: OmrPrefix(void) { Clear(); } bool IsEmpty(void) const { return (mPrefix.GetLength() == 0); } - bool IsInfrastructureDerived(void) const; - void SetFrom(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig); - void SetFrom(const LocalOmrPrefix &aLocalOmrPrefix); const Ip6::Prefix &GetPrefix(void) const { return mPrefix; } RoutePreference GetPreference(void) const { return mPreference; } - bool IsFavoredOver(const NetworkData::OnMeshPrefixConfig &aOmrPrefixConfig) const; bool IsDomainPrefix(void) const { return mIsDomainPrefix; } - private: + protected: Ip6::Prefix mPrefix; RoutePreference mPreference; bool mIsDomainPrefix; }; - class LocalOmrPrefix : public InstanceLocator + class FavoredOmrPrefix : public OmrPrefix { + friend class OmrPrefixManager; + public: - explicit LocalOmrPrefix(Instance &aInstance); - void GenerateFrom(const Ip6::Prefix &aBrUlaPrefix); - const Ip6::Prefix &GetPrefix(void) const { return mPrefix; } - RoutePreference GetPreference(void) const { return NetworkData::kRoutePreferenceLow; } - Error AddToNetData(void); - void RemoveFromNetData(void); - bool IsAddedInNetData(void) const { return mIsAddedInNetData; } - void UpdateDefaultRouteFlag(bool aDefaultRoute); + bool IsInfrastructureDerived(void) const; + + private: + void SetFrom(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig); + void SetFrom(const OmrPrefix &aOmrPrefix); + bool IsFavoredOver(const NetworkData::OnMeshPrefixConfig &aOmrPrefixConfig) const; + }; + + class OmrPrefixManager : public InstanceLocator + { + public: + explicit OmrPrefixManager(Instance &aInstance); + + void Init(const Ip6::Prefix &aBrUlaPrefix); + void Start(void); + void Stop(void); + void Evaluate(void); + void UpdateDefaultRouteFlag(bool aDefaultRoute); + bool IsLocalAddedInNetData(void) const { return mIsLocalAddedInNetData; } + const Ip6::Prefix &GetGeneratedPrefix(void) const { return mGeneratedPrefix; } + const OmrPrefix &GetLocalPrefix(void) const { return mLocalPrefix; } + const FavoredOmrPrefix &GetFavoredPrefix(void) const { return mFavoredPrefix; } private: static constexpr uint16_t kInfoStringSize = 85; typedef String InfoString; - Error AddOrUpdate(void); - InfoString ToString(void) const; - - Ip6::Prefix mPrefix; - bool mIsAddedInNetData; - bool mDefaultRoute; + void DetermineFavoredPrefix(void); + Error AddLocalToNetData(void); + Error AddOrUpdateLocalInNetData(void); + void RemoveLocalFromNetData(void); + InfoString LocalToString(void) const; + + OmrPrefix mLocalPrefix; + Ip6::Prefix mGeneratedPrefix; + FavoredOmrPrefix mFavoredPrefix; + bool mIsLocalAddedInNetData; + bool mDefaultRoute; }; void HandleOnLinkPrefixManagerTimer(void) { mOnLinkPrefixManager.HandleTimer(); } @@ -948,6 +1041,53 @@ class RoutingManager : public InstanceLocator TimeMilli mStartTime; }; +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + void HandlePdPrefixManagerTimer(void) { mPdPrefixManager.HandleTimer(); } + + class PdPrefixManager : public InstanceLocator + { + public: + // This class implements handling (including management of the lifetime) of the prefix obtained from platform's + // DHCPv6 PD client. We expect the platform will send ICMP6 RA messages to the platform's interface for the + // information of the prefix. + // This class manages the state of the PD prefix in OmrPrefixManager + + explicit PdPrefixManager(Instance &aInstance); + + void SetEnabled(bool aEnabled); + bool IsRunning(void) const { return GetState() == Dhcp6PdState::kDhcp6PdStateRunning; } + bool HasPrefix(void) const { return IsValidOmrPrefix(mPrefix.GetPrefix()); } + const Ip6::Prefix &GetPrefix(void) const { return mPrefix.GetPrefix(); } + Dhcp6PdState GetState(void) const + { + // TODO: We need to stop and inform the platform when there is already a GUA prefix advertised in the + // network. + return mEnabled ? kDhcp6PdStateRunning : kDhcp6PdStateDisabled; + } + + void ProcessPlatformGeneratedRa(const uint8_t *aRouterAdvert, uint16_t aLength); + Error GetPrefixInfo(PrefixTableEntry &aInfo) const; + void HandleTimer(void) { WithdrawPrefix(); } + + static bool IsValidPdPrefix(const Ip6::Prefix &aPrefix) + { + // We should accept ULA prefix since it could be used by the internet infrastructure like NAT64. + return aPrefix.GetLength() != 0 && aPrefix.GetLength() <= kOmrPrefixLength && !aPrefix.IsLinkLocal() && + !aPrefix.IsMulticast(); + } + + private: + Error Process(const Ip6::Nd::RouterAdvertMessage &aMessage); + void WithdrawPrefix(void); + + using PlatformOmrPrefixTimer = TimerMilliIn; + + bool mEnabled; + PlatformOmrPrefixTimer mTimer; + DiscoveredPrefixTable::Entry mPrefix; + }; +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + void EvaluateState(void); void Start(void); void Stop(void); @@ -961,8 +1101,6 @@ class RoutingManager : public InstanceLocator void EvaluateRoutingPolicy(void); bool IsInitalPolicyEvaluationDone(void) const; void ScheduleRoutingPolicyEvaluation(ScheduleMode aMode); - void DetermineFavoredOmrPrefix(void); - void EvaluateOmrPrefix(void); void HandleRsSenderFinished(TimeMilli aStartTime); void SendRouterAdvertisement(RouterAdvTxMode aRaTxMode); @@ -984,6 +1122,9 @@ class RoutingManager : public InstanceLocator static bool IsValidOnLinkPrefix(const Ip6::Nd::PrefixInfoOption &aPio); static bool IsValidOnLinkPrefix(const Ip6::Prefix &aOnLinkPrefix); + static void LogPrefixInfoOption(const Ip6::Prefix &aPrefix, uint32_t aValidLifetime, uint32_t aPreferredLifetime); + static void LogRouteInfoOption(const Ip6::Prefix &aPrefix, uint32_t aLifetime, RoutePreference aPreference); + using RoutingPolicyTimer = TimerMilliIn; using DiscoveredPrefixStaleTimer = TimerMilliIn; @@ -1000,8 +1141,7 @@ class RoutingManager : public InstanceLocator // randomly generated if none is found in persistent storage. Ip6::Prefix mBrUlaPrefix; - LocalOmrPrefix mLocalOmrPrefix; - OmrPrefix mFavoredOmrPrefix; + OmrPrefixManager mOmrPrefixManager; // List of on-mesh prefixes (discovered from Network Data) which // were advertised as RIO in the last sent RA message. @@ -1020,6 +1160,10 @@ class RoutingManager : public InstanceLocator Nat64PrefixManager mNat64PrefixManager; #endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + PdPrefixManager mPdPrefixManager; +#endif + RaInfo mRaInfo; RsSender mRsSender; diff --git a/src/core/coap/coap.hpp b/src/core/coap/coap.hpp index b5d05a669fb..30a98ec47f6 100644 --- a/src/core/coap/coap.hpp +++ b/src/core/coap/coap.hpp @@ -64,7 +64,7 @@ namespace Coap { */ /** - * This type represents a function pointer which is called when a CoAP response is received or on the request timeout. + * Represents a function pointer which is called when a CoAP response is received or on the request timeout. * * Please see otCoapResponseHandler for details. * @@ -72,7 +72,7 @@ namespace Coap { typedef otCoapResponseHandler ResponseHandler; /** - * This type represents a function pointer which is called when a CoAP request associated with a given URI path is + * Represents a function pointer which is called when a CoAP request associated with a given URI path is * received. * * Please see otCoapRequestHandler for details. @@ -81,7 +81,7 @@ typedef otCoapResponseHandler ResponseHandler; typedef otCoapRequestHandler RequestHandler; /** - * This structure represents the CoAP transmission parameters. + * Represents the CoAP transmission parameters. * */ class TxParameters : public otCoapTxParameters @@ -91,7 +91,7 @@ class TxParameters : public otCoapTxParameters public: /** - * This static method coverts a pointer to `otCoapTxParameters` to `Coap::TxParamters` + * Coverts a pointer to `otCoapTxParameters` to `Coap::TxParamters` * * If the pointer is `nullptr`, the default parameters are used instead. * @@ -107,7 +107,7 @@ class TxParameters : public otCoapTxParameters } /** - * This method validates whether the CoAP transmission parameters are valid. + * Validates whether the CoAP transmission parameters are valid. * * @returns Whether the parameters are valid. * @@ -115,7 +115,7 @@ class TxParameters : public otCoapTxParameters bool IsValid(void) const; /** - * This static method returns default CoAP tx parameters. + * Returns default CoAP tx parameters. * * @returns The default tx parameters. * @@ -138,7 +138,7 @@ class TxParameters : public otCoapTxParameters }; /** - * This class implements CoAP resource handling. + * Implements CoAP resource handling. * */ class Resource : public otCoapResource, public LinkedListEntry @@ -147,7 +147,7 @@ class Resource : public otCoapResource, public LinkedListEntry public: /** - * This constructor initializes the resource. + * Initializes the resource. * * @param[in] aUriPath A pointer to a null-terminated string for the URI path. * @param[in] aHandler A function pointer that is called when receiving a CoAP message for @p aUriPath. @@ -157,7 +157,7 @@ class Resource : public otCoapResource, public LinkedListEntry Resource(const char *aUriPath, RequestHandler aHandler, void *aContext); /** - * This constructor initializes the resource. + * Initializes the resource. * * @param[in] aUri A Thread URI. * @param[in] aHandler A function pointer that is called when receiving a CoAP message for the URI. @@ -167,7 +167,7 @@ class Resource : public otCoapResource, public LinkedListEntry Resource(Uri aUri, RequestHandler aHandler, void *aContext); /** - * This method returns a pointer to the URI path. + * Returns a pointer to the URI path. * * @returns A pointer to the URI path. * @@ -183,7 +183,7 @@ class Resource : public otCoapResource, public LinkedListEntry #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This class implements CoAP block-wise resource handling. + * Implements CoAP block-wise resource handling. * */ class ResourceBlockWise : public otCoapBlockwiseResource @@ -192,7 +192,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource public: /** - * This constructor initializes the resource. + * Initializes the resource. * * @param[in] aUriPath A pointer to a NULL-terminated string for the Uri-Path. * @param[in] aHandler A function pointer that is called when receiving a CoAP message for @p aUriPath. @@ -231,7 +231,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource } /** - * This method gets the next entry in the linked list. + * Gets the next entry in the linked list. * * @returns A pointer to the next entry in the linked list or `nullptr` if at the end of the list. * @@ -242,7 +242,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource } /** - * This method gets the next entry in the linked list. + * Gets the next entry in the linked list. * * @returns A pointer to the next entry in the linked list or `nullptr` if at the end of the list. * @@ -253,7 +253,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource } /** - * This method sets the next pointer on the entry. + * Sets the next pointer on the entry. * * @param[in] aNext A pointer to the next entry. * @@ -261,7 +261,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource void SetNext(ResourceBlockWise *aNext) { static_cast(this)->mNext = aNext; } /** - * This method returns a pointer to the URI path. + * Returns a pointer to the URI path. * * @returns A pointer to the URI path. * @@ -277,7 +277,7 @@ class ResourceBlockWise : public otCoapBlockwiseResource #endif /** - * This class caches CoAP responses to implement message deduplication. + * Caches CoAP responses to implement message deduplication. * */ class ResponsesQueue @@ -292,7 +292,7 @@ class ResponsesQueue explicit ResponsesQueue(Instance &aInstance); /** - * This method adds a given response to the cache. + * Adds a given response to the cache. * * If matching response (the same Message ID, source endpoint address and port) exists in the cache given * response is not added. @@ -307,13 +307,13 @@ class ResponsesQueue void EnqueueResponse(Message &aMessage, const Ip6::MessageInfo &aMessageInfo, const TxParameters &aTxParameters); /** - * This method removes all responses from the cache. + * Removes all responses from the cache. * */ void DequeueAllResponses(void); /** - * This method gets a copy of CoAP response from the cache that matches a given Message ID and source endpoint. + * Gets a copy of CoAP response from the cache that matches a given Message ID and source endpoint. * * @param[in] aRequest The CoAP message containing Message ID. * @param[in] aMessageInfo The message info containing source endpoint address and port. @@ -327,7 +327,7 @@ class ResponsesQueue Error GetMatchedResponseCopy(const Message &aRequest, const Ip6::MessageInfo &aMessageInfo, Message **aResponse); /** - * This method gets a reference to the cached CoAP responses queue. + * Gets a reference to the cached CoAP responses queue. * * @returns A reference to the cached CoAP responses queue. * @@ -358,7 +358,7 @@ class ResponsesQueue }; /** - * This class implements the CoAP client and server. + * Implements the CoAP client and server. * */ class CoapBase : public InstanceLocator, private NonCopyable @@ -371,7 +371,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #endif /** - * This function pointer is called before CoAP server processing a CoAP message. + * Pointer is called before CoAP server processing a CoAP message. * * @param[in] aMessage A reference to the message. @ @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -385,13 +385,13 @@ class CoapBase : public InstanceLocator, private NonCopyable typedef Error (*Interceptor)(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo, void *aContext); /** - * This method clears requests and responses used by this CoAP agent. + * Clears requests and responses used by this CoAP agent. * */ void ClearRequestsAndResponses(void); /** - * This method clears requests with specified source address used by this CoAP agent. + * Clears requests with specified source address used by this CoAP agent. * * @param[in] aAddress A reference to the specified address. * @@ -401,7 +401,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method adds a block-wise resource to the CoAP server. + * Adds a block-wise resource to the CoAP server. * * @param[in] aResource A reference to the resource. * @@ -409,7 +409,7 @@ class CoapBase : public InstanceLocator, private NonCopyable void AddBlockWiseResource(ResourceBlockWise &aResource); /** - * This method removes a block-wise resource from the CoAP server. + * Removes a block-wise resource from the CoAP server. * * @param[in] aResource A reference to the resource. * @@ -418,7 +418,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #endif /** - * This method adds a resource to the CoAP server. + * Adds a resource to the CoAP server. * * @param[in] aResource A reference to the resource. * @@ -426,14 +426,14 @@ class CoapBase : public InstanceLocator, private NonCopyable void AddResource(Resource &aResource); /** - * This method removes a resource from the CoAP server. + * Removes a resource from the CoAP server. * * @param[in] aResource A reference to the resource. * */ void RemoveResource(Resource &aResource); - /* This method sets the default handler for unhandled CoAP requests. + /* Sets the default handler for unhandled CoAP requests. * * @param[in] aHandler A function pointer that shall be called when an unhandled request arrives. * @param[in] aContext A pointer to arbitrary context information. May be `nullptr` if not used. @@ -442,7 +442,7 @@ class CoapBase : public InstanceLocator, private NonCopyable void SetDefaultHandler(RequestHandler aHandler, void *aContext) { mDefaultHandler.Set(aHandler, aContext); } /** - * This method allocates a new message with a CoAP header. + * Allocates a new message with a CoAP header. * * @param[in] aSettings The message settings. * @@ -452,7 +452,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewMessage(const Message::Settings &aSettings); /** - * This method allocates a new message with a CoAP header with default settings. + * Allocates a new message with a CoAP header with default settings. * * @returns A pointer to the message or `nullptr` if failed to allocate message. * @@ -460,7 +460,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method allocates a new message with a CoAP header that has Network Control priority level. + * Allocates a new message with a CoAP header that has Network Control priority level. * * @returns A pointer to the message or `nullptr` if failed to allocate message. * @@ -468,7 +468,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewPriorityMessage(void); /** - * This method allocates and initializes a new CoAP Confirmable Post message with Network Control priority level. + * Allocates and initializes a new CoAP Confirmable Post message with Network Control priority level. * * The CoAP header is initialized as `kTypeConfirmable` and `kCodePost` with a given URI path and a randomly * generated token (of default length). This method also sets the payload marker (`SetPayloadMarker()` on message. @@ -483,7 +483,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewPriorityConfirmablePostMessage(Uri aUri); /** - * This method allocates and initializes a new CoAP Confirmable Post message with normal priority level. + * Allocates and initializes a new CoAP Confirmable Post message with normal priority level. * * The CoAP header is initialized as `kTypeConfirmable` and `kCodePost` with a given URI and a randomly * generated token (of default length). This method also sets the payload marker (calling `SetPayloadMarker()`). @@ -498,7 +498,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewConfirmablePostMessage(Uri aUri); /** - * This method allocates and initializes a new CoAP Non-confirmable Post message with Network Control priority + * Allocates and initializes a new CoAP Non-confirmable Post message with Network Control priority * level. * * The CoAP header is initialized as `kTypeNonConfirmable` and `kCodePost` with a given URI and a randomly @@ -514,7 +514,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewPriorityNonConfirmablePostMessage(Uri aUri); /** - * This method allocates and initializes a new CoAP Non-confirmable Post message with normal priority level. + * Allocates and initializes a new CoAP Non-confirmable Post message with normal priority level. * * The CoAP header is initialized as `kTypeNonConfirmable` and `kCodePost` with a given URI and a randomly * generated token (of default length). This method also sets the payload marker (calling `SetPayloadMarker()`). @@ -529,7 +529,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewNonConfirmablePostMessage(Uri aUri); /** - * This method allocates and initializes a new CoAP response message with Network Control priority level for a + * Allocates and initializes a new CoAP response message with Network Control priority level for a * given request message. * * The CoAP header is initialized as `kTypeAck` with `kCodeChanged`. The token and message ID is copied from @@ -543,7 +543,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Message *NewPriorityResponseMessage(const Message &aRequest); /** - * This method allocates and initializes a new CoAP response message with regular priority level for a given + * Allocates and initializes a new CoAP response message with regular priority level for a given * request message. * * The CoAP header is initialized as `kTypeAck` with `kCodeChanged`. The token and message ID is copied from @@ -558,7 +558,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a CoAP message block-wise with custom transmission parameters. + * Sends a CoAP message block-wise with custom transmission parameters. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -586,7 +586,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #else // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a CoAP message with custom transmission parameters. + * Sends a CoAP message with custom transmission parameters. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be `nullptr` pointers. @@ -610,7 +610,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a CoAP message with custom transmission parameters. + * Sends a CoAP message with custom transmission parameters. * * If Message ID was not set in the header (equal to 0), this method will assign unique Message ID to the message. * @@ -624,7 +624,7 @@ class CoapBase : public InstanceLocator, private NonCopyable */ Error SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageInfo, const TxParameters &aTxParameters); /** - * This method sends a CoAP message with default transmission parameters. + * Sends a CoAP message with default transmission parameters. * * If Message ID was not set in the header (equal to 0), this method will assign unique Message ID to the message. * @@ -643,7 +643,7 @@ class CoapBase : public InstanceLocator, private NonCopyable void *aContext); /** - * This method sends a CoAP message with default transmission parameters. + * Sends a CoAP message with default transmission parameters. * * If Message ID was not set in the header (equal to 0), this method will assign unique Message ID to the message. * @@ -657,7 +657,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This method sends a CoAP reset message. + * Sends a CoAP reset message. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. * @param[in] aMessageInfo The message info corresponding to the CoAP request. @@ -670,7 +670,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendReset(Message &aRequest, const Ip6::MessageInfo &aMessageInfo); /** - * This method sends header-only CoAP response message. + * Sends header-only CoAP response message. * * @param[in] aCode The CoAP code of this response. * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. @@ -684,7 +684,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendHeaderResponse(Message::Code aCode, const Message &aRequest, const Ip6::MessageInfo &aMessageInfo); /** - * This method sends a CoAP ACK empty message which is used in Separate Response for confirmable requests. + * Sends a CoAP ACK empty message which is used in Separate Response for confirmable requests. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. * @param[in] aMessageInfo The message info corresponding to the CoAP request. @@ -697,7 +697,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendAck(const Message &aRequest, const Ip6::MessageInfo &aMessageInfo); /** - * This method sends a CoAP ACK message on which a dummy CoAP response is piggybacked. + * Sends a CoAP ACK message on which a dummy CoAP response is piggybacked. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. * @param[in] aMessageInfo The message info corresponding to the CoAP request. @@ -711,7 +711,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendEmptyAck(const Message &aRequest, const Ip6::MessageInfo &aMessageInfo, Code aCode); /** - * This method sends a CoAP ACK message on which a dummy CoAP response is piggybacked. + * Sends a CoAP ACK message on which a dummy CoAP response is piggybacked. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. * @param[in] aMessageInfo The message info corresponding to the CoAP request. @@ -724,7 +724,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error SendEmptyAck(const Message &aRequest, const Ip6::MessageInfo &aMessageInfo); /** - * This method sends a header-only CoAP message to indicate no resource matched for the request. + * Sends a header-only CoAP message to indicate no resource matched for the request. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. * @param[in] aMessageInfo The message info corresponding to the CoAP request. @@ -737,7 +737,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a header-only CoAP message to indicate not all blocks have been sent or + * Sends a header-only CoAP message to indicate not all blocks have been sent or * were sent out of order. * * @param[in] aRequest A reference to the CoAP Message that was used in CoAP request. @@ -754,7 +754,7 @@ class CoapBase : public InstanceLocator, private NonCopyable #endif /** - * This method aborts CoAP transactions associated with given handler and context. + * Aborts CoAP transactions associated with given handler and context. * * The associated response handler will be called with kErrorAbort. * @@ -768,7 +768,7 @@ class CoapBase : public InstanceLocator, private NonCopyable Error AbortTransaction(ResponseHandler aHandler, void *aContext); /** - * This method sets interceptor to be called before processing a CoAP packet. + * Sets interceptor to be called before processing a CoAP packet. * * @param[in] aInterceptor A pointer to the interceptor. * @param[in] aContext A pointer to arbitrary context information. @@ -777,7 +777,7 @@ class CoapBase : public InstanceLocator, private NonCopyable void SetInterceptor(Interceptor aInterceptor, void *aContext) { mInterceptor.Set(aInterceptor, aContext); } /** - * This method returns a reference to the request message list. + * Returns a reference to the request message list. * * @returns A reference to the request message list. * @@ -785,7 +785,7 @@ class CoapBase : public InstanceLocator, private NonCopyable const MessageQueue &GetRequestMessages(void) const { return mPendingRequests; } /** - * This method returns a reference to the cached response list. + * Returns a reference to the cached response list. * * @returns A reference to the cached response list. * @@ -794,7 +794,7 @@ class CoapBase : public InstanceLocator, private NonCopyable protected: /** - * This type defines function pointer to handle a CoAP resource. + * Defines function pointer to handle a CoAP resource. * * When processing a received request, this handler is called first with the URI path before checking the list of * added `Resource` entries to match against the URI path. @@ -814,7 +814,7 @@ class CoapBase : public InstanceLocator, private NonCopyable const Ip6::MessageInfo &aMessageInfo); /** - * This function pointer is called to send a CoAP message. + * Pointer is called to send a CoAP message. * * @param[in] aCoapBase A reference to the CoAP agent. * @param[in] aMessage A reference to the message to send. @@ -827,7 +827,7 @@ class CoapBase : public InstanceLocator, private NonCopyable typedef Error (*Sender)(CoapBase &aCoapBase, ot::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aSender A function pointer to send CoAP message, which SHOULD be a static @@ -837,7 +837,7 @@ class CoapBase : public InstanceLocator, private NonCopyable CoapBase(Instance &aInstance, Sender aSender); /** - * This method receives a CoAP message. + * Receives a CoAP message. * * @param[in] aMessage A reference to the received message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -846,7 +846,7 @@ class CoapBase : public InstanceLocator, private NonCopyable void Receive(ot::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This method sets the resource handler function. + * Sets the resource handler function. * * @param[in] aResourceHandler The resource handler function pointer. * @@ -961,14 +961,14 @@ class CoapBase : public InstanceLocator, private NonCopyable }; /** - * This class implements the CoAP client and server. + * Implements the CoAP client and server. * */ class Coap : public CoapBase { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -976,7 +976,7 @@ class Coap : public CoapBase explicit Coap(Instance &aInstance); /** - * This method starts the CoAP service. + * Starts the CoAP service. * * @param[in] aPort The local UDP port to bind to. * @param[in] aNetifIdentifier The network interface identifier to bind. @@ -988,7 +988,7 @@ class Coap : public CoapBase Error Start(uint16_t aPort, Ip6::NetifIdentifier aNetifIdentifier = Ip6::kNetifUnspecified); /** - * This method stops the CoAP service. + * Stops the CoAP service. * * @retval kErrorNone Successfully stopped the CoAP service. * @retval kErrorFailed Failed to stop CoAP agent. diff --git a/src/core/coap/coap_message.cpp b/src/core/coap/coap_message.cpp index e4ef990880a..72fb6148e7d 100644 --- a/src/core/coap/coap_message.cpp +++ b/src/core/coap/coap_message.cpp @@ -106,7 +106,7 @@ void Message::Finish(void) uint8_t Message::WriteExtendedOptionField(uint16_t aValue, uint8_t *&aBuffer) { /* - * This method encodes a CoAP Option header field (Option Delta/Length) per + * Encodes a CoAP Option header field (Option Delta/Length) per * RFC 7252. The returned value is a 4-bit unsigned integer. Extended fields * (if needed) are written into the given buffer `aBuffer` and the pointer * would also be updated. diff --git a/src/core/coap/coap_message.hpp b/src/core/coap/coap_message.hpp index 40c9c97854e..f7910663ba2 100644 --- a/src/core/coap/coap_message.hpp +++ b/src/core/coap/coap_message.hpp @@ -161,7 +161,7 @@ enum OptionNumber : uint16_t }; /** - * This class implements CoAP message generation and parsing. + * Implements CoAP message generation and parsing. * */ class Message : public ot::Message @@ -190,13 +190,13 @@ class Message : public ot::Message static constexpr uint8_t kBlockSzxBase = 4; /** - * This method initializes the CoAP header. + * Initializes the CoAP header. * */ void Init(void); /** - * This method initializes the CoAP header with specific Type and Code. + * Initializes the CoAP header with specific Type and Code. * * @param[in] aType The Type value. * @param[in] aCode The Code value. @@ -205,7 +205,7 @@ class Message : public ot::Message void Init(Type aType, Code aCode); /** - * This method initializes the CoAP header with specific Type and Code. + * Initializes the CoAP header with specific Type and Code. * * @param[in] aType The Type value. * @param[in] aCode The Code value. @@ -218,7 +218,7 @@ class Message : public ot::Message Error Init(Type aType, Code aCode, Uri aUri); /** - * This method initializes the CoAP header as `kCodePost` with a given URI Path with its type determined from a + * Initializes the CoAP header as `kCodePost` with a given URI Path with its type determined from a * given destination IPv6 address. * * @param[in] aDestination The message destination IPv6 address used to determine the CoAP type, @@ -232,16 +232,16 @@ class Message : public ot::Message Error InitAsPost(const Ip6::Address &aDestination, Uri aUri); /** - * This method writes header to the message. This must be called before sending the message. + * Writes header to the message. This must be called before sending the message. * - * This method also checks whether the payload marker is set (`SetPayloadMarker()`) but the message contains no + * Also checks whether the payload marker is set (`SetPayloadMarker()`) but the message contains no * payload, and if so it removes the payload marker from the message. * */ void Finish(void); /** - * This method returns the Version value. + * Returns the Version value. * * @returns The Version value. * @@ -252,7 +252,7 @@ class Message : public ot::Message } /** - * This method sets the Version value. + * Sets the Version value. * * @param[in] aVersion The Version value. * @@ -264,7 +264,7 @@ class Message : public ot::Message } /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -272,7 +272,7 @@ class Message : public ot::Message uint8_t GetType(void) const { return (GetHelpData().mHeader.mVersionTypeToken & kTypeMask) >> kTypeOffset; } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -284,7 +284,7 @@ class Message : public ot::Message } /** - * This method returns the Code value. + * Returns the Code value. * * @returns The Code value. * @@ -292,7 +292,7 @@ class Message : public ot::Message uint8_t GetCode(void) const { return static_cast(GetHelpData().mHeader.mCode); } /** - * This method sets the Code value. + * Sets the Code value. * * @param[in] aCode The Code value. * @@ -301,7 +301,7 @@ class Message : public ot::Message #if OPENTHREAD_CONFIG_COAP_API_ENABLE /** - * This method returns the CoAP Code as human readable string. + * Returns the CoAP Code as human readable string. * * @ returns The CoAP Code as string. * @@ -310,7 +310,7 @@ class Message : public ot::Message #endif // OPENTHREAD_CONFIG_COAP_API_ENABLE /** - * This method returns the Message ID value. + * Returns the Message ID value. * * @returns The Message ID value. * @@ -318,7 +318,7 @@ class Message : public ot::Message uint16_t GetMessageId(void) const { return HostSwap16(GetHelpData().mHeader.mMessageId); } /** - * This method sets the Message ID value. + * Sets the Message ID value. * * @param[in] aMessageId The Message ID value. * @@ -326,7 +326,7 @@ class Message : public ot::Message void SetMessageId(uint16_t aMessageId) { GetHelpData().mHeader.mMessageId = HostSwap16(aMessageId); } /** - * This method returns the Token length. + * Returns the Token length. * * @returns The Token length. * @@ -337,7 +337,7 @@ class Message : public ot::Message } /** - * This method returns a pointer to the Token value. + * Returns a pointer to the Token value. * * @returns A pointer to the Token value. * @@ -345,7 +345,7 @@ class Message : public ot::Message const uint8_t *GetToken(void) const { return GetHelpData().mHeader.mToken; } /** - * This method sets the Token value and length. + * Sets the Token value and length. * * @param[in] aToken A pointer to the Token value. * @param[in] aTokenLength The Length of @p aToken. @@ -357,7 +357,7 @@ class Message : public ot::Message Error SetToken(const uint8_t *aToken, uint8_t aTokenLength); /** - * This method sets the Token value and length by copying it from another given message. + * Sets the Token value and length by copying it from another given message. * * @param[in] aMessage The message to copy the Token from. * @@ -368,7 +368,7 @@ class Message : public ot::Message Error SetTokenFromMessage(const Message &aMessage); /** - * This method sets the Token length and randomizes its value. + * Sets the Token length and randomizes its value. * * @param[in] aTokenLength The Length of a Token to set. * @@ -379,7 +379,7 @@ class Message : public ot::Message Error GenerateRandomToken(uint8_t aTokenLength); /** - * This method checks if Tokens in two CoAP headers are equal. + * Checks if Tokens in two CoAP headers are equal. * * @param[in] aMessage A header to compare. * @@ -390,7 +390,7 @@ class Message : public ot::Message bool IsTokenEqual(const Message &aMessage) const; /** - * This method appends a CoAP option. + * Appends a CoAP option. * * @param[in] aNumber The CoAP Option number. * @param[in] aLength The CoAP Option length. @@ -404,7 +404,7 @@ class Message : public ot::Message Error AppendOption(uint16_t aNumber, uint16_t aLength, const void *aValue); /** - * This method appends an unsigned integer CoAP option as specified in RFC-7252 section-3.2 + * Appends an unsigned integer CoAP option as specified in RFC-7252 section-3.2 * * @param[in] aNumber The CoAP Option number. * @param[in] aValue The CoAP Option unsigned integer value. @@ -417,7 +417,7 @@ class Message : public ot::Message Error AppendUintOption(uint16_t aNumber, uint32_t aValue); /** - * This method appends a string CoAP option. + * Appends a string CoAP option. * * @param[in] aNumber The CoAP Option number. * @param[in] aValue The CoAP Option string value. @@ -430,7 +430,7 @@ class Message : public ot::Message Error AppendStringOption(uint16_t aNumber, const char *aValue); /** - * This method appends an Observe option. + * Appends an Observe option. * * @param[in] aObserve Observe field value. * @@ -441,7 +441,7 @@ class Message : public ot::Message Error AppendObserveOption(uint32_t aObserve) { return AppendUintOption(kOptionObserve, aObserve & kObserveMask); } /** - * This method appends a Uri-Path option. + * Appends a Uri-Path option. * * @param[in] aUriPath A pointer to a null-terminated string. * @@ -453,7 +453,7 @@ class Message : public ot::Message Error AppendUriPathOptions(const char *aUriPath); /** - * This method reads the Uri-Path options and constructs the URI path in the buffer referenced by @p `aUriPath`. + * Reads the Uri-Path options and constructs the URI path in the buffer referenced by @p `aUriPath`. * * @param[in] aUriPath A reference to the buffer for storing URI path. * NOTE: The buffer size must be `kMaxReceivedUriPath + 1`. @@ -465,7 +465,7 @@ class Message : public ot::Message Error ReadUriPathOptions(char (&aUriPath)[kMaxReceivedUriPath + 1]) const; /** - * This method appends a Block option + * Appends a Block option * * @param[in] aType Type of block option, 1 or 2. * @param[in] aNum Current block number. @@ -480,7 +480,7 @@ class Message : public ot::Message Error AppendBlockOption(BlockType aType, uint32_t aNum, bool aMore, otCoapBlockSzx aSize); /** - * This method appends a Proxy-Uri option. + * Appends a Proxy-Uri option. * * @param[in] aProxyUri A pointer to a null-terminated string. * @@ -492,7 +492,7 @@ class Message : public ot::Message Error AppendProxyUriOption(const char *aProxyUri) { return AppendStringOption(kOptionProxyUri, aProxyUri); } /** - * This method appends a Content-Format option. + * Appends a Content-Format option. * * @param[in] aContentFormat The Content Format value. * @@ -507,7 +507,7 @@ class Message : public ot::Message } /** - * This method appends a Max-Age option. + * Appends a Max-Age option. * * @param[in] aMaxAge The Max-Age value. * @@ -518,7 +518,7 @@ class Message : public ot::Message Error AppendMaxAgeOption(uint32_t aMaxAge) { return AppendUintOption(kOptionMaxAge, aMaxAge); } /** - * This method appends a single Uri-Query option. + * Appends a single Uri-Query option. * * @param[in] aUriQuery A pointer to null-terminated string, which should contain a single key=value pair. * @@ -530,7 +530,7 @@ class Message : public ot::Message #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This function reads the information contained in a Block1 or Block2 option and set it in + * Reads the information contained in a Block1 or Block2 option and set it in * the HelpData of the message. * * @param[in] aBlockType Block1 or Block2 option value. @@ -542,7 +542,7 @@ class Message : public ot::Message Error ReadBlockOptionValues(uint16_t aBlockType); /** - * This method returns the current header length of a message. + * Returns the current header length of a message. * * @returns The length of the message header. * @@ -550,7 +550,7 @@ class Message : public ot::Message uint16_t GetHeaderLength(void) const { return GetHelpData().mHeaderLength; } /** - * This method returns the block number of a CoAP block-wise transfer message. + * Returns the block number of a CoAP block-wise transfer message. * * @returns The block number. * @@ -558,7 +558,7 @@ class Message : public ot::Message uint32_t GetBlockWiseBlockNumber(void) const { return GetHelpData().mBlockWiseData.mBlockNumber; } /** - * This method checks if the More Blocks flag is set. + * Checks if the More Blocks flag is set. * * @retval TRUE More Blocks flag is set. * @retval FALSE More Blocks flag is not set. @@ -567,7 +567,7 @@ class Message : public ot::Message bool IsMoreBlocksFlagSet(void) const { return GetHelpData().mBlockWiseData.mMoreBlocks; } /** - * This method returns the block size of a CoAP block-wise transfer message. + * Returns the block size of a CoAP block-wise transfer message. * * @returns The block size. * @@ -576,7 +576,7 @@ class Message : public ot::Message #endif // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This function reads and reassembles the URI path string and fills it into @p aUriPath. + * Reads and reassembles the URI path string and fills it into @p aUriPath. * * @retval kErrorNone URI path string has been reassembled. * @retval kErrorNoBufs URI path string is too long. @@ -585,7 +585,7 @@ class Message : public ot::Message Error GetUriPath(char *aUriPath) const; /** - * This method adds Payload Marker indicating beginning of the payload to the CoAP header. + * Adds Payload Marker indicating beginning of the payload to the CoAP header. * * It also set offset to the start of payload. * @@ -596,7 +596,7 @@ class Message : public ot::Message Error SetPayloadMarker(void); /** - * This method returns the offset of the first CoAP option. + * Returns the offset of the first CoAP option. * * @returns The offset of the first CoAP option. * @@ -604,7 +604,7 @@ class Message : public ot::Message uint16_t GetOptionStart(void) const { return kMinHeaderLength + GetTokenLength(); } /** - * This method parses CoAP header and moves offset end of CoAP header. + * Parses CoAP header and moves offset end of CoAP header. * * @retval kErrorNone Successfully parsed CoAP header from the message. * @retval kErrorParse Failed to parse the CoAP header. @@ -613,7 +613,7 @@ class Message : public ot::Message Error ParseHeader(void); /** - * This method sets a default response header based on request header. + * Sets a default response header based on request header. * * @param[in] aRequest The request message. * @@ -626,7 +626,7 @@ class Message : public ot::Message #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sets the block number value in the message HelpData. + * Sets the block number value in the message HelpData. * * @param[in] aBlockNumber Block number value to set. * @@ -634,7 +634,7 @@ class Message : public ot::Message void SetBlockWiseBlockNumber(uint32_t aBlockNumber) { GetHelpData().mBlockWiseData.mBlockNumber = aBlockNumber; } /** - * This method sets the More Blocks flag in the message HelpData. + * Sets the More Blocks flag in the message HelpData. * * @param[in] aMoreBlocks TRUE or FALSE. * @@ -642,7 +642,7 @@ class Message : public ot::Message void SetMoreBlocksFlag(bool aMoreBlocks) { GetHelpData().mBlockWiseData.mMoreBlocks = aMoreBlocks; } /** - * This method sets the block size value in the message HelpData. + * Sets the block size value in the message HelpData. * * @param[in] aBlockSize Block size value to set. * @@ -651,7 +651,7 @@ class Message : public ot::Message #endif // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method checks if a header is an empty message header. + * Checks if a header is an empty message header. * * @retval TRUE Message is an empty message header. * @retval FALSE Message is not an empty message header. @@ -660,7 +660,7 @@ class Message : public ot::Message bool IsEmpty(void) const { return (GetCode() == kCodeEmpty); } /** - * This method checks if a header is a request header. + * Checks if a header is a request header. * * @retval TRUE Message is a request header. * @retval FALSE Message is not a request header. @@ -669,7 +669,7 @@ class Message : public ot::Message bool IsRequest(void) const { return (GetCode() >= kCodeGet) && (GetCode() <= kCodeDelete); } /** - * This method indicates whether or not the CoAP code in header is "Get" request. + * Indicates whether or not the CoAP code in header is "Get" request. * * @retval TRUE Message is a Get request. * @retval FALSE Message is not a Get request. @@ -678,7 +678,7 @@ class Message : public ot::Message bool IsGetRequest(void) const { return GetCode() == kCodeGet; } /** - * This method indicates whether or not the CoAP code in header is "Post" request. + * Indicates whether or not the CoAP code in header is "Post" request. * * @retval TRUE Message is a Post request. * @retval FALSE Message is not a Post request. @@ -687,7 +687,7 @@ class Message : public ot::Message bool IsPostRequest(void) const { return GetCode() == kCodePost; } /** - * This method indicates whether or not the CoAP code in header is "Put" request. + * Indicates whether or not the CoAP code in header is "Put" request. * * @retval TRUE Message is a Put request. * @retval FALSE Message is not a Put request. @@ -696,7 +696,7 @@ class Message : public ot::Message bool IsPutRequest(void) const { return GetCode() == kCodePut; } /** - * This method indicates whether or not the CoAP code in header is "Delete" request. + * Indicates whether or not the CoAP code in header is "Delete" request. * * @retval TRUE Message is a Delete request. * @retval FALSE Message is not a Delete request. @@ -705,7 +705,7 @@ class Message : public ot::Message bool IsDeleteRequest(void) const { return GetCode() == kCodeDelete; } /** - * This method checks if a header is a response header. + * Checks if a header is a response header. * * @retval TRUE Message is a response header. * @retval FALSE Message is not a response header. @@ -714,7 +714,7 @@ class Message : public ot::Message bool IsResponse(void) const { return GetCode() >= OT_COAP_CODE_RESPONSE_MIN; } /** - * This method checks if a header is a CON message header. + * Checks if a header is a CON message header. * * @retval TRUE Message is a CON message header. * @retval FALSE Message is not is a CON message header. @@ -723,7 +723,7 @@ class Message : public ot::Message bool IsConfirmable(void) const { return (GetType() == kTypeConfirmable); } /** - * This method checks if a header is a NON message header. + * Checks if a header is a NON message header. * * @retval TRUE Message is a NON message header. * @retval FALSE Message is not is a NON message header. @@ -732,7 +732,7 @@ class Message : public ot::Message bool IsNonConfirmable(void) const { return (GetType() == kTypeNonConfirmable); } /** - * This method checks if a header is a ACK message header. + * Checks if a header is a ACK message header. * * @retval TRUE Message is a ACK message header. * @retval FALSE Message is not is a ACK message header. @@ -741,7 +741,7 @@ class Message : public ot::Message bool IsAck(void) const { return (GetType() == kTypeAck); } /** - * This method checks if a header is a RST message header. + * Checks if a header is a RST message header. * * @retval TRUE Message is a RST message header. * @retval FALSE Message is not is a RST message header. @@ -750,7 +750,7 @@ class Message : public ot::Message bool IsReset(void) const { return (GetType() == kTypeReset); } /** - * This method indicates whether or not the header is a confirmable Put request (i.e, `kTypeConfirmable` with + * Indicates whether or not the header is a confirmable Put request (i.e, `kTypeConfirmable` with * `kCodePost`). * * @retval TRUE Message is a confirmable Post request. @@ -760,7 +760,7 @@ class Message : public ot::Message bool IsConfirmablePostRequest(void) const; /** - * This method indicates whether or not the header is a non-confirmable Put request (i.e, `kTypeNonConfirmable` with + * Indicates whether or not the header is a non-confirmable Put request (i.e, `kTypeNonConfirmable` with * `kCodePost`). * * @retval TRUE Message is a non-confirmable Post request. @@ -770,7 +770,7 @@ class Message : public ot::Message bool IsNonConfirmablePostRequest(void) const; /** - * This method creates a copy of this CoAP message. + * Creates a copy of this CoAP message. * * It allocates the new message from the same message pool as the original one and copies @p aLength octets * of the payload. The `Type`, `SubType`, `LinkSecurity`, `Offset`, `InterfaceId`, and `Priority` fields on the @@ -784,7 +784,7 @@ class Message : public ot::Message Message *Clone(uint16_t aLength) const; /** - * This method creates a copy of the message. + * Creates a copy of the message. * * It allocates the new message from the same message pool as the original one and copies the entire payload. The * `Type`, `SubType`, `LinkSecurity`, `Offset`, `InterfaceId`, and `Priority` fields on the cloned message are also @@ -796,15 +796,15 @@ class Message : public ot::Message Message *Clone(void) const { return Clone(GetLength()); } /** - * This method returns the minimal reserved bytes required for CoAP message. + * Returns the minimal reserved bytes required for CoAP message. * */ static uint16_t GetHelpDataReserved(void) { return sizeof(HelpData) + kHelpDataAlignment; } /** - * This method returns a pointer to the next message after this as a `Coap::Message`. + * Returns a pointer to the next message after this as a `Coap::Message`. * - * This method should be used when the message is in a `Coap::MessageQueue` (i.e., a queue containing only CoAP + * Should be used when the message is in a `Coap::MessageQueue` (i.e., a queue containing only CoAP * messages). * * @returns A pointer to the next message in the queue or `nullptr` if at the end of the queue. @@ -813,9 +813,9 @@ class Message : public ot::Message Message *GetNextCoapMessage(void) { return static_cast(GetNext()); } /** - * This method returns a pointer to the next message after this as a `Coap::Message`. + * Returns a pointer to the next message after this as a `Coap::Message`. * - * This method should be used when the message is in a `Coap::MessageQueue` (i.e., a queue containing only CoAP + * Should be used when the message is in a `Coap::MessageQueue` (i.e., a queue containing only CoAP * messages). * * @returns A pointer to the next message in the queue or `nullptr` if at the end of the queue. @@ -896,7 +896,7 @@ class Message : public ot::Message #endif /** - * This structure represents a CoAP header excluding CoAP options. + * Represents a CoAP header excluding CoAP options. * */ OT_TOOL_PACKED_BEGIN @@ -909,7 +909,7 @@ class Message : public ot::Message } OT_TOOL_PACKED_END; /** - * This structure represents a HelpData used by this CoAP message. + * Represents a HelpData used by this CoAP message. * */ struct HelpData : public Clearable @@ -971,20 +971,20 @@ class Message : public ot::Message }; /** - * This class implements a CoAP message queue. + * Implements a CoAP message queue. * */ class MessageQueue : public ot::MessageQueue { public: /** - * This constructor initializes the message queue. + * Initializes the message queue. * */ MessageQueue(void) = default; /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -992,7 +992,7 @@ class MessageQueue : public ot::MessageQueue Message *GetHead(void) { return static_cast(ot::MessageQueue::GetHead()); } /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -1000,7 +1000,7 @@ class MessageQueue : public ot::MessageQueue const Message *GetHead(void) const { return static_cast(ot::MessageQueue::GetHead()); } /** - * This method adds a message to the end of the queue. + * Adds a message to the end of the queue. * * @param[in] aMessage The message to add. * @@ -1008,7 +1008,7 @@ class MessageQueue : public ot::MessageQueue void Enqueue(Message &aMessage) { Enqueue(aMessage, kQueuePositionTail); } /** - * This method adds a message at a given position (head/tail) of the queue. + * Adds a message at a given position (head/tail) of the queue. * * @param[in] aMessage The message to add. * @param[in] aPosition The position (head or tail) where to add the message. @@ -1017,7 +1017,7 @@ class MessageQueue : public ot::MessageQueue void Enqueue(Message &aMessage, QueuePosition aPosition) { ot::MessageQueue::Enqueue(aMessage, aPosition); } /** - * This method removes a message from the queue. + * Removes a message from the queue. * * @param[in] aMessage The message to remove. * @@ -1025,7 +1025,7 @@ class MessageQueue : public ot::MessageQueue void Dequeue(Message &aMessage) { ot::MessageQueue::Dequeue(aMessage); } /** - * This method removes a message from the queue and frees it. + * Removes a message from the queue and frees it. * * @param[in] aMessage The message to remove and free. * @@ -1045,21 +1045,21 @@ class MessageQueue : public ot::MessageQueue }; /** - * This class represents a CoAP option. + * Represents a CoAP option. * */ class Option : public otCoapOption { public: /** - * This class represents an iterator for CoAP options. + * Represents an iterator for CoAP options. * */ class Iterator : public otCoapOptionIterator { public: /** - * This method initializes the iterator to iterate over CoAP Options in a CoAP message. + * Initializes the iterator to iterate over CoAP Options in a CoAP message. * * The iterator MUST be initialized before any other methods are used, otherwise its behavior is undefined. * @@ -1075,7 +1075,7 @@ class Option : public otCoapOption Error Init(const Message &aMessage); /** - * This method initializes the iterator to iterate over CoAP Options in a CoAP message matching a given Option + * Initializes the iterator to iterate over CoAP Options in a CoAP message matching a given Option * Number value. * * The iterator MUST be initialized before any other methods are used, otherwise its behavior is undefined. @@ -1094,7 +1094,7 @@ class Option : public otCoapOption Error Init(const Message &aMessage, uint16_t aNumber) { return InitOrAdvance(&aMessage, aNumber); } /** - * This method indicates whether or not the iterator is done (i.e., has reached the end of CoAP Option Header). + * Indicates whether or not the iterator is done (i.e., has reached the end of CoAP Option Header). * * @retval TRUE Iterator is done (reached end of Option header). * @retval FALSE Iterator is not done and currently pointing to a CoAP Option. @@ -1103,7 +1103,7 @@ class Option : public otCoapOption bool IsDone(void) const { return mOption.mLength == kIteratorDoneLength; } /** - * This method indicates whether or not there was a earlier parse error (i.e., whether the iterator is valid). + * Indicates whether or not there was a earlier parse error (i.e., whether the iterator is valid). * * After a parse errors, iterator would also be marked as done. * @@ -1114,7 +1114,7 @@ class Option : public otCoapOption bool HasParseErrored(void) const { return mNextOptionOffset == kNextOptionOffsetParseError; } /** - * This method advances the iterator to the next CoAP Option in the header. + * Advances the iterator to the next CoAP Option in the header. * * The iterator is updated to point to the next option or marked as done when there are no more options. * @@ -1125,7 +1125,7 @@ class Option : public otCoapOption Error Advance(void); /** - * This method advances the iterator to the next CoAP Option in the header matching a given Option Number value. + * Advances the iterator to the next CoAP Option in the header matching a given Option Number value. * * The iterator is updated to point to the next matching option or marked as done when there are no more * matching options. @@ -1139,7 +1139,7 @@ class Option : public otCoapOption Error Advance(uint16_t aNumber) { return InitOrAdvance(nullptr, aNumber); } /** - * This method gets the CoAP message associated with the iterator. + * Gets the CoAP message associated with the iterator. * * @returns A reference to the CoAP message. * @@ -1147,7 +1147,7 @@ class Option : public otCoapOption const Message &GetMessage(void) const { return *static_cast(mMessage); } /** - * This methods gets a pointer to the current CoAP Option to which the iterator is currently pointing. + * Gets a pointer to the current CoAP Option to which the iterator is currently pointing. * * @returns A pointer to the current CoAP Option, or `nullptr` if iterator is done (or there was an earlier * parse error). @@ -1156,7 +1156,7 @@ class Option : public otCoapOption const Option *GetOption(void) const { return IsDone() ? nullptr : static_cast(&mOption); } /** - * This method reads the current Option Value into a given buffer. + * Reads the current Option Value into a given buffer. * * @param[out] aValue The pointer to a buffer to copy the Option Value. The buffer is assumed to be * sufficiently large (i.e. at least `GetOption()->GetLength()` bytes). @@ -1168,7 +1168,7 @@ class Option : public otCoapOption Error ReadOptionValue(void *aValue) const; /** - * This method read the current Option Value which is assumed to be an unsigned integer. + * Read the current Option Value which is assumed to be an unsigned integer. * * @param[out] aUintValue A reference to `uint64_t` to output the read Option Value. * @@ -1180,9 +1180,9 @@ class Option : public otCoapOption Error ReadOptionValue(uint64_t &aUintValue) const; /** - * This method gets the offset of beginning of the CoAP message payload (after the CoAP header). + * Gets the offset of beginning of the CoAP message payload (after the CoAP header). * - * This method MUST be used after the iterator is done (i.e. iterated through all options). + * MUST be used after the iterator is done (i.e. iterated through all options). * * @returns The offset of beginning of the CoAP message payload * @@ -1205,7 +1205,7 @@ class Option : public otCoapOption }; /** - * This method gets the CoAP Option Number. + * Gets the CoAP Option Number. * * @returns The CoAP Option Number. * @@ -1213,7 +1213,7 @@ class Option : public otCoapOption uint16_t GetNumber(void) const { return mNumber; } /** - * This method gets the CoAP Option Length (length of Option Value in bytes). + * Gets the CoAP Option Length (length of Option Value in bytes). * * @returns The CoAP Option Length (in bytes). * @@ -1234,7 +1234,7 @@ DefineMapEnum(otCoapType, Coap::Type); DefineMapEnum(otCoapCode, Coap::Code); /** - * This method casts an `otMessage` pointer to a `Coap::Message` reference. + * Casts an `otMessage` pointer to a `Coap::Message` reference. * * @param[in] aMessage A pointer to an `otMessage`. * @@ -1244,7 +1244,7 @@ DefineMapEnum(otCoapCode, Coap::Code); inline Coap::Message &AsCoapMessage(otMessage *aMessage) { return *static_cast(aMessage); } /** - * This method casts an `otMessage` pointer to a `Coap::Message` reference. + * Casts an `otMessage` pointer to a `Coap::Message` reference. * * @param[in] aMessage A pointer to an `otMessage`. * @@ -1254,7 +1254,7 @@ inline Coap::Message &AsCoapMessage(otMessage *aMessage) { return *static_cast(aMessage); } /** - * This method casts an `otMessage` pointer to a `Coap::Message` pointer. + * Casts an `otMessage` pointer to a `Coap::Message` pointer. * * @param[in] aMessage A pointer to an `otMessage`. * @@ -1267,7 +1267,7 @@ inline const Coap::Message &AsCoapMessage(const otMessage *aMessage) } /** - * This method casts an `otMessage` pointer to a `Coap::Message` reference. + * Casts an `otMessage` pointer to a `Coap::Message` reference. * * @param[in] aMessage A pointer to an `otMessage`. * diff --git a/src/core/coap/coap_secure.hpp b/src/core/coap/coap_secure.hpp index 43b2d02eef5..b24e7d0fb2e 100644 --- a/src/core/coap/coap_secure.hpp +++ b/src/core/coap/coap_secure.hpp @@ -53,7 +53,7 @@ class CoapSecure : public CoapBase { public: /** - * This function pointer is called once DTLS connection is established. + * Pointer is called once DTLS connection is established. * * @param[in] aConnected TRUE if a connection was established, FALSE otherwise. * @param[in] aContext A pointer to arbitrary context information. @@ -62,7 +62,7 @@ class CoapSecure : public CoapBase typedef void (*ConnectedCallback)(bool aConnected, void *aContext); /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aLayerTwoSecurity Specifies whether to use layer two security or not. @@ -71,7 +71,7 @@ class CoapSecure : public CoapBase explicit CoapSecure(Instance &aInstance, bool aLayerTwoSecurity = false); /** - * This method starts the secure CoAP agent. + * Starts the secure CoAP agent. * * @param[in] aPort The local UDP port to bind to. * @@ -82,7 +82,7 @@ class CoapSecure : public CoapBase Error Start(uint16_t aPort); /** - * This method starts the secure CoAP agent, but do not use socket to transmit/receive messages. + * Starts the secure CoAP agent, but do not use socket to transmit/receive messages. * * @param[in] aCallback A pointer to a function for sending messages. * @param[in] aContext A pointer to arbitrary context information. @@ -94,7 +94,7 @@ class CoapSecure : public CoapBase Error Start(MeshCoP::Dtls::TransportCallback aCallback, void *aContext); /** - * This method sets connected callback of this secure CoAP agent. + * Sets connected callback of this secure CoAP agent. * * @param[in] aCallback A pointer to a function to get called when connection state changes. * @param[in] aContext A pointer to arbitrary context information. @@ -106,13 +106,13 @@ class CoapSecure : public CoapBase } /** - * This method stops the secure CoAP agent. + * Stops the secure CoAP agent. * */ void Stop(void); /** - * This method initializes DTLS session with a peer. + * Initializes DTLS session with a peer. * * @param[in] aSockAddr A reference to the remote socket address, * @param[in] aCallback A pointer to a function that will be called once DTLS connection is @@ -124,7 +124,7 @@ class CoapSecure : public CoapBase Error Connect(const Ip6::SockAddr &aSockAddr, ConnectedCallback aCallback, void *aContext); /** - * This method indicates whether or not the DTLS session is active. + * Indicates whether or not the DTLS session is active. * * @retval TRUE If DTLS session is active. * @retval FALSE If DTLS session is not active. @@ -133,7 +133,7 @@ class CoapSecure : public CoapBase bool IsConnectionActive(void) const { return mDtls.IsConnectionActive(); } /** - * This method indicates whether or not the DTLS session is connected. + * Indicates whether or not the DTLS session is connected. * * @retval TRUE The DTLS session is connected. * @retval FALSE The DTLS session is not connected. @@ -142,13 +142,13 @@ class CoapSecure : public CoapBase bool IsConnected(void) const { return mDtls.IsConnected(); } /** - * This method stops the DTLS connection. + * Stops the DTLS connection. * */ void Disconnect(void) { mDtls.Disconnect(); } /** - * This method returns a reference to the DTLS object. + * Returns a reference to the DTLS object. * * @returns A reference to the DTLS object. * @@ -156,7 +156,7 @@ class CoapSecure : public CoapBase MeshCoP::Dtls &GetDtls(void) { return mDtls; } /** - * This method gets the UDP port of this agent. + * Gets the UDP port of this agent. * * @returns UDP port number. * @@ -164,7 +164,7 @@ class CoapSecure : public CoapBase uint16_t GetUdpPort(void) const { return mDtls.GetUdpPort(); } /** - * This method sets the PSK. + * Sets the PSK. * * @param[in] aPsk A pointer to the PSK. * @param[in] aPskLength The PSK length. @@ -176,7 +176,7 @@ class CoapSecure : public CoapBase Error SetPsk(const uint8_t *aPsk, uint8_t aPskLength) { return mDtls.SetPsk(aPsk, aPskLength); } /** - * This method sets the PSK. + * Sets the PSK. * * @param[in] aPskd A Joiner PSKd. * @@ -187,7 +187,7 @@ class CoapSecure : public CoapBase #ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED /** - * This method sets the Pre-Shared Key (PSK) for DTLS sessions identified by a PSK. + * Sets the Pre-Shared Key (PSK) for DTLS sessions identified by a PSK. * * DTLS mode "TLS with AES 128 CCM 8" for Application CoAPS. * @@ -205,7 +205,7 @@ class CoapSecure : public CoapBase #ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED /** - * This method sets a X509 certificate with corresponding private key for DTLS session. + * Sets a X509 certificate with corresponding private key for DTLS session. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. * @@ -224,7 +224,7 @@ class CoapSecure : public CoapBase } /** - * This method sets the trusted top level CAs. It is needed for validate the certificate of the peer. + * Sets the trusted top level CAs. It is needed for validate the certificate of the peer. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. * @@ -240,7 +240,7 @@ class CoapSecure : public CoapBase #if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) /** - * This method returns the peer x509 certificate base64 encoded. + * Returns the peer x509 certificate base64 encoded. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. * @@ -259,7 +259,7 @@ class CoapSecure : public CoapBase #endif // defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) /** - * This method sets the connected callback to indicate, when a Client connect to the CoAP Secure server. + * Sets the connected callback to indicate, when a Client connect to the CoAP Secure server. * * @param[in] aCallback A pointer to a function that will be called once DTLS connection is established. * @param[in] aContext A pointer to arbitrary context information. @@ -271,7 +271,7 @@ class CoapSecure : public CoapBase } /** - * This method sets the authentication mode for the CoAP secure connection. It disables or enables the verification + * Sets the authentication mode for the CoAP secure connection. It disables or enables the verification * of peer certificate. * * @param[in] aVerifyPeerCertificate true, if the peer certificate should be verified @@ -283,7 +283,7 @@ class CoapSecure : public CoapBase #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a CoAP message over secure DTLS connection. + * Sends a CoAP message over secure DTLS connection. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -307,7 +307,7 @@ class CoapSecure : public CoapBase otCoapBlockwiseReceiveHook aReceiveHook = nullptr); /** - * This method sends a CoAP message over secure DTLS connection. + * Sends a CoAP message over secure DTLS connection. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be NULL pointers. @@ -333,7 +333,7 @@ class CoapSecure : public CoapBase otCoapBlockwiseReceiveHook aReceiveHook = nullptr); #else // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method sends a CoAP message over secure DTLS connection. + * Sends a CoAP message over secure DTLS connection. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be nullptr pointers. @@ -351,7 +351,7 @@ class CoapSecure : public CoapBase Error SendMessage(Message &aMessage, ResponseHandler aHandler = nullptr, void *aContext = nullptr); /** - * This method sends a CoAP message over secure DTLS connection. + * Sends a CoAP message over secure DTLS connection. * * If a response for a request is expected, respective function and context information should be provided. * If no response is expected, these arguments should be nullptr pointers. @@ -374,7 +374,7 @@ class CoapSecure : public CoapBase #endif // OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE /** - * This method is used to pass UDP messages to the secure CoAP server. + * Is used to pass UDP messages to the secure CoAP server. * * @param[in] aMessage A reference to the received message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -386,7 +386,7 @@ class CoapSecure : public CoapBase } /** - * This method returns the DTLS session's peer address. + * Returns the DTLS session's peer address. * * @return DTLS session's message info. * diff --git a/src/core/common/appender.hpp b/src/core/common/appender.hpp index 5260ba83564..8cff1b5f49c 100644 --- a/src/core/common/appender.hpp +++ b/src/core/common/appender.hpp @@ -48,14 +48,14 @@ namespace ot { * The `Appender` class acts as a wrapper over either a `Message` or a data buffer and provides different flavors of * `Append()` method. * - * This class helps in construction of message content where the destination can be either a `Message` or a buffer. + * Helps in construction of message content where the destination can be either a `Message` or a buffer. * */ class Appender { public: /** - * This enumeration represent the `Appender` Type (whether appending to a `Message` or data buffer). + * Represent the `Appender` Type (whether appending to a `Message` or data buffer). * */ enum Type : uint8_t @@ -65,7 +65,7 @@ class Appender }; /** - * This constructor initializes the `Appender` to append to a `Message`. + * Initializes the `Appender` to append to a `Message`. * * New content is appended to the end of @p aMessage, growing its length. * @@ -75,7 +75,7 @@ class Appender explicit Appender(Message &aMessage); /** - * This constructor initializes the `Appender` to append in a given a buffer + * Initializes the `Appender` to append in a given a buffer * * New content is append in the buffer starting from @p aBuffer up to is size @p aSize. `Appender` does not allow * content to be appended beyond the size of the buffer. @@ -87,7 +87,7 @@ class Appender Appender(uint8_t *aBuffer, uint16_t aSize); /** - * This method indicates the `Appender` type (whether appending to a `Message` or data buffer). + * Indicates the `Appender` type (whether appending to a `Message` or data buffer). * * @returns The type of `Appender`. * @@ -95,7 +95,7 @@ class Appender Type GetType(void) const { return mType; } /** - * This method appends bytes to the `Appender` object + * Appends bytes to the `Appender` object * * @param[in] aBuffer A pointer to a data buffer (MUST NOT be `nullptr`) to append. * @param[in] aLength The number of bytes to append. @@ -107,7 +107,7 @@ class Appender Error AppendBytes(const void *aBuffer, uint16_t aLength); /** - * This method appends an object to the end of the `Appender` object. + * Appends an object to the end of the `Appender` object. * * @tparam ObjectType The object type to append to the message. * @@ -125,9 +125,9 @@ class Appender } /** - * This method returns the number of bytes appended so far using `Appender` methods. + * Returns the number of bytes appended so far using `Appender` methods. * - * This method can be used independent of the `Type` of `Appender`. + * Can be used independent of the `Type` of `Appender`. * * @returns The number of byes appended so far. * @@ -135,9 +135,9 @@ class Appender uint16_t GetAppendedLength(void) const; /** - * This method returns the `Message` associated with `Appender`. + * Returns the `Message` associated with `Appender`. * - * This method MUST be used when `GetType() == kMessage`. Otherwise its behavior is undefined. + * MUST be used when `GetType() == kMessage`. Otherwise its behavior is undefined. * * @returns The `Message` instance associated with `Appender`. * @@ -145,9 +145,9 @@ class Appender Message &GetMessage(void) const { return *mShared.mMessage.mMessage; } /** - * This method returns a pointer to the start of the data buffer associated with `Appender`. + * Returns a pointer to the start of the data buffer associated with `Appender`. * - * This method MUST be used when `GetType() == kBuffer`. Otherwise its behavior is undefined. + * MUST be used when `GetType() == kBuffer`. Otherwise its behavior is undefined. * * @returns A pointer to the start of the data buffer associated with `Appender`. * @@ -155,9 +155,9 @@ class Appender uint8_t *GetBufferStart(void) const { return AsNonConst(mShared.mFrameBuilder.GetBytes()); } /** - * This method gets the data buffer associated with `Appender` as a `Data`. + * Gets the data buffer associated with `Appender` as a `Data`. * - * This method MUST be used when `GetType() == kBuffer`. Otherwise its behavior is undefined. + * MUST be used when `GetType() == kBuffer`. Otherwise its behavior is undefined. * * @pram[out] aData A reference to a `Data` to output the data buffer. * diff --git a/src/core/common/arg_macros.hpp b/src/core/common/arg_macros.hpp index e832f2f3025..ee54e0f0cf8 100644 --- a/src/core/common/arg_macros.hpp +++ b/src/core/common/arg_macros.hpp @@ -35,7 +35,7 @@ #define OT_ARG_MACROS_HPP_ /** - * This macro returns the first argument in a list of input arguments. + * Returns the first argument in a list of input arguments. * * @param[in] ... A list of arguments (MUST contain at least one). * @@ -45,7 +45,7 @@ #define OT_FIRST_ARG(...) _OT_GET_FIRST_ARG(__VA_ARGS__, JUNK) /** - * This macro returns the second argument in a list of input arguments if any. + * Returns the second argument in a list of input arguments if any. * * @note: This macro works when the list contains either one or two arguments. * @@ -57,7 +57,7 @@ #define OT_SECOND_ARG(...) _OT_GET_SECOND_ARG(_OT_HAS_ONE_ARG_OR_TWO_ARGS(__VA_ARGS__), __VA_ARGS__) /** - * This macro expands to comma separated list of arguments excluding the first one. + * Expands to comma separated list of arguments excluding the first one. * * If there is only one argument, it expands to empty. If there is more than one argument, it expands to an initial * comma followed by all the rest of arguments excluding the first one. diff --git a/src/core/common/array.hpp b/src/core/common/array.hpp index 4a65073f108..c9873e1b4c5 100644 --- a/src/core/common/array.hpp +++ b/src/core/common/array.hpp @@ -46,7 +46,7 @@ namespace ot { /** - * This function returns the length of a given array (number of elements in the array). + * Returns the length of a given array (number of elements in the array). * * This template function is `constexpr`. The template arguments are expected to be deduced by the compiler allowing * callers to simply use `GetArrayLength(aArray)`. @@ -63,7 +63,7 @@ template constexpr inline uint16_t GetArr } /** - * This function returns a pointer to end of a given array (pointing to the past-the-end element). + * Returns a pointer to end of a given array (pointing to the past-the-end element). * * Note that the past-the-end element is a theoretical element that would follow the last element in the array. It does * not point to an actual element in array, and thus should not be dereferenced. @@ -82,7 +82,7 @@ template inline Type *GetArrayEnd(Type (& } /** - * This function returns a pointer to end of a given array (pointing to the past-the-end element). + * Returns a pointer to end of a given array (pointing to the past-the-end element). * * Note that the past-the-end element is a theoretical element that would follow the last element in the array. It does * not point to an actual element in array, and thus should not be dereferenced. @@ -101,7 +101,7 @@ template inline const Type *GetArrayEnd(c } /** - * This template class represents an array of elements with a fixed max size. + * Represents an array of elements with a fixed max size. * * @tparam Type The array element type. * @tparam kMaxSize Specifies the max array size (maximum number of elements in the array). @@ -120,7 +120,7 @@ class Array public: /** - * This type represents the length or index in array. + * Represents the length or index in array. * * It is typically either `uint8_t` or `uint16_t` (determined based on the maximum array size (`kMaxSize`)). * @@ -128,7 +128,7 @@ class Array typedef SizeType IndexType; /** - * This constructor initializes the array as empty. + * Initializes the array as empty. * */ Array(void) @@ -137,7 +137,7 @@ class Array } /** - * This constructor initializes the array by copying elements from another array. + * Initializes the array by copying elements from another array. * * The method uses assignment `=` operator on `Type` to copy each element from @p aOtherArray into the elements of * the array. @@ -148,10 +148,10 @@ class Array Array(const Array &aOtherArray) { *this = aOtherArray; } /** - * This constructor initializes the array as empty and initializes its elements by calling `Init(Instance &)` + * Initializes the array as empty and initializes its elements by calling `Init(Instance &)` * method on every element. * - * This constructor uses method `Init(Instance &aInstance)` on `Type`. + * Uses method `Init(Instance &aInstance)` on `Type`. * * @param[in] aInstance The OpenThread instance. * @@ -166,13 +166,13 @@ class Array } /** - * This method clears the array. + * Clears the array. * */ void Clear(void) { mLength = 0; } /** - * This method indicates whether or not the array is empty. + * Indicates whether or not the array is empty. * * @retval TRUE when array is empty. * @retval FALSE when array is not empty. @@ -181,7 +181,7 @@ class Array bool IsEmpty(void) const { return (mLength == 0); } /** - * This method indicates whether or not the array is full. + * Indicates whether or not the array is full. * * @retval TRUE when array is full. * @retval FALSE when array is not full. @@ -190,7 +190,7 @@ class Array bool IsFull(void) const { return (mLength == GetMaxSize()); } /** - * This method returns the maximum array size (max number of elements). + * Returns the maximum array size (max number of elements). * * @returns The maximum array size (max number of elements that can be added to the array). * @@ -198,7 +198,7 @@ class Array IndexType GetMaxSize(void) const { return static_cast(kMaxSize); } /** - * This method returns the current length of array (number of elements). + * Returns the current length of array (number of elements). * * @returns The current array length. * @@ -206,7 +206,7 @@ class Array IndexType GetLength(void) const { return mLength; } /** - * This methods sets the current length (number of elements) of the array. + * Sets the current length (number of elements) of the array. * * @param[in] aLength The array length. * @@ -214,7 +214,7 @@ class Array void SetLength(IndexType aLength) { mLength = aLength; } /** - * This method returns the pointer to the start of underlying C array buffer serving as `Array` storage. + * Returns the pointer to the start of underlying C array buffer serving as `Array` storage. * * @return The pointer to start of underlying C array buffer. * @@ -222,7 +222,7 @@ class Array Type *GetArrayBuffer(void) { return mElements; } /** - * This method returns the pointer to the start of underlying C array buffer serving as `Array` storage. + * Returns the pointer to the start of underlying C array buffer serving as `Array` storage. * * @return The pointer to start of underlying C array buffer. * @@ -230,9 +230,9 @@ class Array const Type *GetArrayBuffer(void) const { return mElements; } /** - * This method overloads the `[]` operator to get the element at a given index. + * Overloads the `[]` operator to get the element at a given index. * - * This method does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. + * Does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. * * @param[in] aIndex The index to get. * @@ -242,9 +242,9 @@ class Array Type &operator[](IndexType aIndex) { return mElements[aIndex]; } /** - * This method overloads the `[]` operator to get the element at a given index. + * Overloads the `[]` operator to get the element at a given index. * - * This method does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. + * Does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. * * @param[in] aIndex The index to get. * @@ -254,7 +254,7 @@ class Array const Type &operator[](IndexType aIndex) const { return mElements[aIndex]; } /** - * This method gets a pointer to the element at a given index. + * Gets a pointer to the element at a given index. * * Unlike `operator[]`, this method checks @p aIndex to be valid and within the current length. * @@ -266,7 +266,7 @@ class Array Type *At(IndexType aIndex) { return (aIndex < mLength) ? &mElements[aIndex] : nullptr; } /** - * This method gets a pointer to the element at a given index. + * Gets a pointer to the element at a given index. * * Unlike `operator[]`, this method checks @p aIndex to be valid and within the current length. * @@ -278,7 +278,7 @@ class Array const Type *At(IndexType aIndex) const { return (aIndex < mLength) ? &mElements[aIndex] : nullptr; } /** - * This method gets a pointer to the element at the front of the array (first element). + * Gets a pointer to the element at the front of the array (first element). * * @returns A pointer to the front element or `nullptr` if array is empty. * @@ -286,7 +286,7 @@ class Array Type *Front(void) { return At(0); } /** - * This method gets a pointer to the element at the front of the array (first element). + * Gets a pointer to the element at the front of the array (first element). * * @returns A pointer to the front element or `nullptr` if array is empty. * @@ -294,7 +294,7 @@ class Array const Type *Front(void) const { return At(0); } /** - * This method gets a pointer to the element at the back of the array (last element). + * Gets a pointer to the element at the back of the array (last element). * * @returns A pointer to the back element or `nullptr` if array is empty. * @@ -302,7 +302,7 @@ class Array Type *Back(void) { return At(mLength - 1); } /** - * This method gets a pointer to the element at the back of the array (last element). + * Gets a pointer to the element at the back of the array (last element). * * @returns A pointer to the back element or `nullptr` if array is empty. * @@ -310,7 +310,7 @@ class Array const Type *Back(void) const { return At(mLength - 1); } /** - * This method appends a new entry to the end of the array. + * Appends a new entry to the end of the array. * * The method uses assignment `=` operator on `Type` to copy @p aEntry into the added array element. * @@ -323,7 +323,7 @@ class Array Error PushBack(const Type &aEntry) { return IsFull() ? kErrorNoBufs : (mElements[mLength++] = aEntry, kErrorNone); } /** - * This method appends a new entry to the end of the array. + * Appends a new entry to the end of the array. * * On success, this method returns a pointer to the newly appended element in the array for the caller to * initialize and use. @@ -334,7 +334,7 @@ class Array Type *PushBack(void) { return IsFull() ? nullptr : &mElements[mLength++]; } /** - * This method removes the last element in the array. + * Removes the last element in the array. * * @returns A pointer to the removed element from the array, or `nullptr` if array is empty. * @@ -342,7 +342,7 @@ class Array Type *PopBack(void) { return IsEmpty() ? nullptr : &mElements[--mLength]; } /** - * This method returns the index of an element in the array. + * Returns the index of an element in the array. * * The @p aElement MUST be from the array, otherwise the behavior of this method is undefined. * @@ -354,7 +354,7 @@ class Array IndexType IndexOf(const Type &aElement) const { return static_cast(&aElement - &mElements[0]); } /** - * This method removes an element from the array. + * Removes an element from the array. * * The @p aElement MUST be from the array, otherwise the behavior of this method is undefined. * @@ -375,9 +375,9 @@ class Array } /** - * This method finds the first match of a given entry in the array. + * Finds the first match of a given entry in the array. * - * This method uses `==` operator on `Type` to compare the array element with @p aEntry. + * Uses `==` operator on `Type` to compare the array element with @p aEntry. * * @param[in] aEntry The entry to search for within the array. * @@ -387,9 +387,9 @@ class Array Type *Find(const Type &aEntry) { return AsNonConst(AsConst(this)->Find(aEntry)); } /** - * This method finds the first match of a given entry in the array. + * Finds the first match of a given entry in the array. * - * This method uses `==` operator to compare the array elements with @p aEntry. + * Uses `==` operator to compare the array elements with @p aEntry. * * @param[in] aEntry The entry to search for within the array. * @@ -413,9 +413,9 @@ class Array } /** - * This method indicates whether or not a match to given entry exists in the array. + * Indicates whether or not a match to given entry exists in the array. * - * This method uses `==` operator on `Type` to compare the array elements with @p aEntry. + * Uses `==` operator on `Type` to compare the array elements with @p aEntry. * * @param[in] aEntry The entry to search for within the array. * @@ -426,7 +426,7 @@ class Array bool Contains(const Type &aEntry) const { return Find(aEntry) != nullptr; } /** - * This template method finds the first element in the array matching a given indicator. + * Finds the first element in the array matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each @@ -445,7 +445,7 @@ class Array } /** - * This template method finds the first element in the array matching a given indicator. + * Finds the first element in the array matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each @@ -475,7 +475,7 @@ class Array } /** - * This template method indicates whether or not the array contains an element matching a given indicator. + * Indicates whether or not the array contains an element matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each @@ -495,9 +495,9 @@ class Array } /** - * This template method removes the first element in the array matching a given indicator. + * Removes the first element in the array matching a given indicator. * - * This method behaves similar to `Remove()`, i.e., the matched element (if found) is replaced with the last element + * Behaves similar to `Remove()`, i.e., the matched element (if found) is replaced with the last element * in the array (using `=` operator on `Type`). So the order of items in the array can change after a call to this * method. * @@ -521,9 +521,9 @@ class Array } /** - * This template method removes all elements in the array matching a given indicator. + * Removes all elements in the array matching a given indicator. * - * This method behaves similar to `Remove()`, i.e., a matched element is replaced with the last element in the + * Behaves similar to `Remove()`, i.e., a matched element is replaced with the last element in the * array (using `=` operator on `Type`). So the order of items in the array can change after a call to this method. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements @@ -557,7 +557,7 @@ class Array } /** - * This method overloads assignment `=` operator to copy elements from another array into the array. + * Overloads assignment `=` operator to copy elements from another array into the array. * * The method uses assignment `=` operator on `Type` to copy each element from @p aOtherArray into the elements of * the array. @@ -578,9 +578,9 @@ class Array } /** - * This method indicates whether a given entry pointer is from the array buffer. + * Indicates whether a given entry pointer is from the array buffer. * - * This method does not check the current length of array and only checks that @p aEntry is pointing to an address + * Does not check the current length of array and only checks that @p aEntry is pointing to an address * contained within underlying C array buffer. * * @param[in] aEntry A pointer to an entry to check. diff --git a/src/core/common/as_core_type.hpp b/src/core/common/as_core_type.hpp index 521cabbc4a0..ffe4e293164 100644 --- a/src/core/common/as_core_type.hpp +++ b/src/core/common/as_core_type.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This structure relates a given public OT type to its corresponding core C++ class/type. + * Relates a given public OT type to its corresponding core C++ class/type. * * @tparam FromType The public OT type. * @@ -54,7 +54,7 @@ namespace ot { template struct CoreType; /** - * This function converts a pointer to public OT type (C struct) to the corresponding core C++ type reference. + * Converts a pointer to public OT type (C struct) to the corresponding core C++ type reference. * * @tparam Type The public OT type to convert. * @@ -71,7 +71,7 @@ template typename CoreType::Type &AsCoreType(Type *aObject } /** - * This function converts a const pointer to public OT type (C struct) to the corresponding core C++ type reference. + * Converts a const pointer to public OT type (C struct) to the corresponding core C++ type reference. * * @tparam Type The public OT type to convert. * @@ -88,7 +88,7 @@ template const typename CoreType::Type &AsCoreType(const T } /** - * This function converts a pointer to public OT type (C struct) to the corresponding core C++ type pointer. + * Converts a pointer to public OT type (C struct) to the corresponding core C++ type pointer. * * @tparam Type The public OT type to convert. * @@ -103,7 +103,7 @@ template typename CoreType::Type *AsCoreTypePtr(Type *aObj } /** - * This function converts a const pointer to public OT type (C struct) to the corresponding core C++ type pointer. + * Converts a const pointer to public OT type (C struct) to the corresponding core C++ type pointer. * * @tparam Type The public OT type to convert. * @@ -118,7 +118,7 @@ template const typename CoreType::Type *AsCoreTypePtr(cons } /** - * This structure maps two enumeration types. + * Maps two enumeration types. * * @tparam FromEnumType The enum type. * @@ -131,7 +131,7 @@ template const typename CoreType::Type *AsCoreTypePtr(cons template struct MappedEnum; /** - * This function convert an enumeration type value to a related enumeration type value. + * Convert an enumeration type value to a related enumeration type value. * * @param[in] aValue The enumeration value to convert * diff --git a/src/core/common/binary_search.hpp b/src/core/common/binary_search.hpp index 0e05ab5406d..434c172c84f 100644 --- a/src/core/common/binary_search.hpp +++ b/src/core/common/binary_search.hpp @@ -44,7 +44,7 @@ class BinarySearch { public: /** - * This template method performs binary search in a given sorted table array to find an entry matching a given key. + * Performs binary search in a given sorted table array to find an entry matching a given key. * * @note This method requires the array to be sorted, otherwise its behavior is undefined. * @@ -77,9 +77,9 @@ class BinarySearch } /** - * This template method indicates whether a given table array is sorted based or not. + * Indicates whether a given table array is sorted based or not. * - * This method is `constexpr` and is intended for use in `static_assert`s to verify that a `constexpr` lookup table + * Is `constexpr` and is intended for use in `static_assert`s to verify that a `constexpr` lookup table * array is sorted. It is not recommended for use in other situations. * * @tparam Entry The table entry type. diff --git a/src/core/common/bit_vector.hpp b/src/core/common/bit_vector.hpp index 52b225a88aa..8c6962c133f 100644 --- a/src/core/common/bit_vector.hpp +++ b/src/core/common/bit_vector.hpp @@ -54,7 +54,7 @@ namespace ot { */ /** - * This class represents a bit-vector. + * Represents a bit-vector. * * @tparam N Specifies the number of bits. * @@ -63,7 +63,7 @@ template class BitVector : public Equatable>, public C { public: /** - * This method indicates whether a given index is included in the mask. + * Indicates whether a given index is included in the mask. * * @param[in] aIndex The index. * @@ -78,7 +78,7 @@ template class BitVector : public Equatable>, public C } /** - * This method sets the mask of a given index. + * Sets the mask of a given index. * * @param[in] aIndex The index. * @param[in] aValue TRUE to set the mask, or FALSE to clear the mask. @@ -99,7 +99,7 @@ template class BitVector : public Equatable>, public C } /** - * This method returns if any mask is set. + * Returns if any mask is set. * * @retval TRUE If any index is set. * @retval FALSE If all indexes are clear. diff --git a/src/core/common/callback.hpp b/src/core/common/callback.hpp index 02e4cf33f09..f4162203ee8 100644 --- a/src/core/common/callback.hpp +++ b/src/core/common/callback.hpp @@ -43,7 +43,7 @@ namespace ot { /** - * This enumeration specifies the context argument position in a callback function pointer. + * Specifies the context argument position in a callback function pointer. * */ enum CallbackContextPosition : uint8_t @@ -53,7 +53,7 @@ enum CallbackContextPosition : uint8_t }; /** - * This class is the base class for `Callback` (a function pointer handler and a `void *` context). + * Is the base class for `Callback` (a function pointer handler and a `void *` context). * * @tparam HandlerType The handler function pointer type. * @@ -62,13 +62,13 @@ template class CallbackBase { public: /** - * This method clears the `Callback` by setting the handler function pointer to `nullptr`. + * Clears the `Callback` by setting the handler function pointer to `nullptr`. * */ void Clear(void) { mHandler = nullptr; } /** - * This method sets the callback handler function pointer and its associated context. + * Sets the callback handler function pointer and its associated context. * * @param[in] aHandler The handler function pointer. * @param[in] aContext The context associated with handler. @@ -81,7 +81,7 @@ template class CallbackBase } /** - * This method indicates whether or not the callback is set (not `nullptr`). + * Indicates whether or not the callback is set (not `nullptr`). * * @retval TRUE The handler is set. * @retval FALSE The handler is not set. @@ -90,7 +90,7 @@ template class CallbackBase bool IsSet(void) const { return (mHandler != nullptr); } /** - * This method returns the handler function pointer. + * Returns the handler function pointer. * * @returns The handler function pointer. * @@ -98,7 +98,7 @@ template class CallbackBase HandlerType GetHandler(void) const { return mHandler; } /** - * This method returns the context associated with callback. + * Returns the context associated with callback. * * @returns The context. * @@ -106,7 +106,7 @@ template class CallbackBase void *GetContext(void) const { return mContext; } /** - * This method indicates whether the callback matches a given handler function pointer and context. + * Indicates whether the callback matches a given handler function pointer and context. * * @param[in] aHandler The handler function pointer to compare with. * @param[in] aContext The context associated with handler. @@ -132,7 +132,7 @@ template class CallbackBase }; /** - * This class represents a `Callback` (a function pointer handler and a `void *` context). + * Represents a `Callback` (a function pointer handler and a `void *` context). * * The context is passed as one of the arguments to the function pointer handler when invoked. * @@ -168,13 +168,13 @@ template class Callback : static constexpr CallbackContextPosition kContextPosition = kContextAsLastArg; ///< Context position. /** - * This constructor initializes `Callback` as empty (`nullptr` handler function pointer). + * Initializes `Callback` as empty (`nullptr` handler function pointer). * */ Callback(void) = default; /** - * This method invokes the callback handler. + * Invokes the callback handler. * * The caller MUST ensure that callback is set (`IsSet()` returns `true`) before calling this method. * @@ -189,7 +189,7 @@ template class Callback : } /** - * This method invokes the callback handler if it is set. + * Invokes the callback handler if it is set. * * The method MUST be used when the handler function returns `void`. * diff --git a/src/core/common/clearable.hpp b/src/core/common/clearable.hpp index b47bb196067..f91c15f41f3 100644 --- a/src/core/common/clearable.hpp +++ b/src/core/common/clearable.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This template class defines a `Clearable` object which provides `Clear()` method. + * Defines a `Clearable` object which provides `Clear()` method. * * The `Clear` implementation simply sets all the bytes of a `Type` instance to zero. * diff --git a/src/core/common/code_utils.hpp b/src/core/common/code_utils.hpp index 379c951cd5f..647042a9c89 100644 --- a/src/core/common/code_utils.hpp +++ b/src/core/common/code_utils.hpp @@ -41,7 +41,7 @@ #include "common/arg_macros.hpp" /** - * This macro calculates the number of elements in an array. + * Calculates the number of elements in an array. * * @param[in] aArray Name of the array variable. * @@ -51,7 +51,7 @@ #define OT_ARRAY_LENGTH(aArray) (sizeof(aArray) / sizeof(aArray[0])) /** - * This macro returns a pointer to end of a given array (pointing to the past-the-end element). + * Returns a pointer to end of a given array (pointing to the past-the-end element). * * Note that the past-the-end element is a theoretical element that would follow the last element in the array. It does * not point to an actual element in array, and thus should not be dereferenced. @@ -64,7 +64,7 @@ #define OT_ARRAY_END(aArray) (&aArray[OT_ARRAY_LENGTH(aArray)]) /** - * This macro returns a pointer aligned by @p aAlignment. + * Returns a pointer aligned by @p aAlignment. * * @param[in] aPointer A pointer to contiguous space. * @param[in] aAlignment The desired alignment. @@ -83,19 +83,19 @@ align_type name[(((size) + (sizeof(align_type) - 1)) / sizeof(align_type))] /** - * This macro returns the smaller of @p a and @p b. + * Returns the smaller of @p a and @p b. * */ #define OT_MIN(a, b) ((b) < (a) ? (b) : (a)) /** - * This macro returns the greater of @p a and @p b. + * Returns the greater of @p a and @p b. * */ #define OT_MAX(a, b) ((a) < (b) ? (b) : (a)) /** - * This macro checks for the specified status, which is expected to commonly be successful, and branches to the local + * Checks for the specified status, which is expected to commonly be successful, and branches to the local * label 'exit' if the status is unsuccessful. * * @param[in] aStatus A scalar status to be evaluated against zero (0). @@ -111,7 +111,7 @@ } while (false) /** - * This macro checks for the specified condition, which is expected to commonly be true, and both executes @a ... and + * Checks for the specified condition, which is expected to commonly be true, and both executes @a ... and * branches to the local label 'exit' if the condition is false. * * @param[in] aCondition A Boolean expression to be evaluated. @@ -129,7 +129,7 @@ } while (false) /** - * This macro unconditionally executes @a ... and branches to the local label 'exit'. + * Unconditionally executes @a ... and branches to the local label 'exit'. * * @note The use of this interface implies neither success nor failure for the overall exit status of the enclosing * function body. @@ -145,7 +145,7 @@ } while (false) /* - * This macro executes the `statement` and ignores the return value. + * Executes the `statement` and ignores the return value. * * This is primarily used to indicate the intention of developer that the return value of a function/method can be * safely ignored. @@ -162,7 +162,7 @@ } while (false) /** - * This function ignores an error explicitly. + * Ignores an error explicitly. * * This is primarily used to indicate the intention of developer that * the error can be safely ignored or there is guaranteed to be no error. diff --git a/src/core/common/const_cast.hpp b/src/core/common/const_cast.hpp index 2927df31a5b..e63fce812ad 100644 --- a/src/core/common/const_cast.hpp +++ b/src/core/common/const_cast.hpp @@ -39,7 +39,7 @@ namespace ot { /** - * This template method casts a given non-const reference to a const reference. + * Casts a given non-const reference to a const reference. * * @tparam Type The reference type. * @@ -51,7 +51,7 @@ namespace ot { template const Type &AsConst(Type &aObject) { return const_cast(aObject); } /** - * This template method casts a given non-const pointer to a const pointer. + * Casts a given non-const pointer to a const pointer. * * @tparam Type The pointer type. * @@ -63,7 +63,7 @@ template const Type &AsConst(Type &aObject) { return const_cast< template const Type *AsConst(Type *aPointer) { return const_cast(aPointer); } /** - * This template method casts a given const reference to a non-const reference. + * Casts a given const reference to a non-const reference. * * @tparam Type The reference type. * @@ -75,7 +75,7 @@ template const Type *AsConst(Type *aPointer) { return const_cast template Type &AsNonConst(const Type &aObject) { return const_cast(aObject); } /** - * This template method casts a given const pointer to a non-const pointer. + * Casts a given const pointer to a non-const pointer. * * @tparam Type The pointer type. * diff --git a/src/core/common/crc16.hpp b/src/core/common/crc16.hpp index 60f556ab3eb..e5a84194b87 100644 --- a/src/core/common/crc16.hpp +++ b/src/core/common/crc16.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This class implements CRC16 computations. + * Implements CRC16 computations. * */ class Crc16 @@ -54,7 +54,7 @@ class Crc16 }; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aPolynomial The polynomial value. * @@ -62,13 +62,13 @@ class Crc16 explicit Crc16(Polynomial aPolynomial); /** - * This method initializes the CRC16 computation. + * Initializes the CRC16 computation. * */ void Init(void) { mCrc = 0; } /*c* - * This method feeds a byte value into the CRC16 computation. + * Feeds a byte value into the CRC16 computation. * * @param[in] aByte The byte value. * @@ -76,7 +76,7 @@ class Crc16 void Update(uint8_t aByte); /** - * This method gets the current CRC16 value. + * Gets the current CRC16 value. * * @returns The current CRC16 value. * diff --git a/src/core/common/data.hpp b/src/core/common/data.hpp index 404e6a3f84c..aa865cc1458 100644 --- a/src/core/common/data.hpp +++ b/src/core/common/data.hpp @@ -50,7 +50,7 @@ namespace ot { /** - * This enumeration type is used as the template parameter in `Data` and `MutableData` to indicate the `uint` type to + * Type is used as the template parameter in `Data` and `MutableData` to indicate the `uint` type to * use for the data length. * */ @@ -61,7 +61,7 @@ enum DataLengthType : uint8_t }; /** - * This type specifies a function pointer which matches two given bytes. + * Specifies a function pointer which matches two given bytes. * * Such a function is used as a parameter in `Data::MatchesByteIn()` method. This can be used to relax the definition * of a match when comparing data bytes, e.g., can be used for case-insensitive string comparison. @@ -76,7 +76,7 @@ enum DataLengthType : uint8_t typedef bool (*ByteMatcher)(uint8_t aFirst, uint8_t aSecond); /** - * This class implements common utility methods used by `Data` and `MutableData`. + * Implements common utility methods used by `Data` and `MutableData`. * */ class DataUtils @@ -92,7 +92,7 @@ class DataUtils template class MutableData; /** - * This type represents a generic `Data` which is simply a wrapper over a pointer to a buffer with a given data length. + * Represents a generic `Data` which is simply a wrapper over a pointer to a buffer with a given data length. * * The data length can be either `uint8_t` or `uint16_t` (determined by the template parameter `kDataLengthType`). * @@ -112,13 +112,13 @@ class Data : public Clearable>, public Unequatable::Type; /** - * This method initializes the `Data` to point to a given buffer with a given length. + * Initializes the `Data` to point to a given buffer with a given length. * * @param[in] aBuffer A pointer to a buffer containing the data. * @param[in] aLength The data length (number of bytes in @p aBuffer) @@ -131,7 +131,7 @@ class Data : public Clearable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable>, public Unequatable class MutableData : public Data class MutableData : public Data class MutableData : public Data class MutableData : public Data class MutableData : public Data class MutableData : public Data class MutableData : public Data inline uint32_t HostSwap(uint32_t aValue) { return HostSwap32(aValue template <> inline uint64_t HostSwap(uint64_t aValue) { return HostSwap64(aValue); } /** - * This function reads a `uint16_t` value from a given buffer assuming big-endian encoding. + * Reads a `uint16_t` value from a given buffer assuming big-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -128,7 +128,7 @@ template <> inline uint64_t HostSwap(uint64_t aValue) { return HostSwap64(aValue inline uint16_t ReadUint16(const uint8_t *aBuffer) { return static_cast((aBuffer[0] << 8) | aBuffer[1]); } /** - * This function reads a `uint32_t` value from a given buffer assuming big-endian encoding. + * Reads a `uint32_t` value from a given buffer assuming big-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -142,7 +142,7 @@ inline uint32_t ReadUint32(const uint8_t *aBuffer) } /** - * This function reads a 24-bit integer value from a given buffer assuming big-endian encoding. + * Reads a 24-bit integer value from a given buffer assuming big-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -156,7 +156,7 @@ inline uint32_t ReadUint24(const uint8_t *aBuffer) } /** - * This function reads a `uint64_t` value from a given buffer assuming big-endian encoding. + * Reads a `uint64_t` value from a given buffer assuming big-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -172,7 +172,7 @@ inline uint64_t ReadUint64(const uint8_t *aBuffer) } /** - * This function writes a `uint16_t` value to a given buffer using big-endian encoding. + * Writes a `uint16_t` value to a given buffer using big-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -185,7 +185,7 @@ inline void WriteUint16(uint16_t aValue, uint8_t *aBuffer) } /** - * This function writes a 24-bit integer value to a given buffer using big-endian encoding. + * Writes a 24-bit integer value to a given buffer using big-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -199,7 +199,7 @@ inline void WriteUint24(uint32_t aValue, uint8_t *aBuffer) } /** - * This function writes a `uint32_t` value to a given buffer using big-endian encoding. + * Writes a `uint32_t` value to a given buffer using big-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -214,7 +214,7 @@ inline void WriteUint32(uint32_t aValue, uint8_t *aBuffer) } /** - * This function writes a `uint64_t` value to a given buffer using big-endian encoding. + * Writes a `uint64_t` value to a given buffer using big-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -268,7 +268,7 @@ template <> inline uint32_t HostSwap(uint32_t aValue) { return HostSwap32(aValue template <> inline uint64_t HostSwap(uint64_t aValue) { return HostSwap64(aValue); } /** - * This function reads a `uint16_t` value from a given buffer assuming little-endian encoding. + * Reads a `uint16_t` value from a given buffer assuming little-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -278,7 +278,7 @@ template <> inline uint64_t HostSwap(uint64_t aValue) { return HostSwap64(aValue inline uint16_t ReadUint16(const uint8_t *aBuffer) { return static_cast(aBuffer[0] | (aBuffer[1] << 8)); } /** - * This function reads a 24-bit integer value from a given buffer assuming little-endian encoding. + * Reads a 24-bit integer value from a given buffer assuming little-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -292,7 +292,7 @@ inline uint32_t ReadUint24(const uint8_t *aBuffer) } /** - * This function reads a `uint32_t` value from a given buffer assuming little-endian encoding. + * Reads a `uint32_t` value from a given buffer assuming little-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -306,7 +306,7 @@ inline uint32_t ReadUint32(const uint8_t *aBuffer) } /** - * This function reads a `uint64_t` value from a given buffer assuming little-endian encoding. + * Reads a `uint64_t` value from a given buffer assuming little-endian encoding. * * @param[in] aBuffer Pointer to buffer to read from. * @@ -322,7 +322,7 @@ inline uint64_t ReadUint64(const uint8_t *aBuffer) } /** - * This function writes a `uint16_t` value to a given buffer using little-endian encoding. + * Writes a `uint16_t` value to a given buffer using little-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -335,7 +335,7 @@ inline void WriteUint16(uint16_t aValue, uint8_t *aBuffer) } /** - * This function writes a 24-bit integer value to a given buffer using little-endian encoding. + * Writes a 24-bit integer value to a given buffer using little-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -349,7 +349,7 @@ inline void WriteUint24(uint32_t aValue, uint8_t *aBuffer) } /** - * This function writes a `uint32_t` value to a given buffer using little-endian encoding. + * Writes a `uint32_t` value to a given buffer using little-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. @@ -364,7 +364,7 @@ inline void WriteUint32(uint32_t aValue, uint8_t *aBuffer) } /** - * This function writes a `uint64_t` value to a given buffer using little-endian encoding. + * Writes a `uint64_t` value to a given buffer using little-endian encoding. * * @param[in] aValue The value to write to buffer. * @param[out] aBuffer Pointer to buffer where the value will be written. diff --git a/src/core/common/equatable.hpp b/src/core/common/equatable.hpp index d9130150fd0..8ece3bb27fe 100644 --- a/src/core/common/equatable.hpp +++ b/src/core/common/equatable.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This template class defines an overload of operator `!=`. + * Defines an overload of operator `!=`. * * The `!=` implementation uses an existing `==` overload provided by the `Type` class. * @@ -53,7 +53,7 @@ template class Unequatable { public: /** - * This method overloads operator `!=` to evaluate whether or not two instances of `Type` are equal. + * Overloads operator `!=` to evaluate whether or not two instances of `Type` are equal. * * This is implemented in terms of an existing `==` overload provided by `Type` class itself. * @@ -67,7 +67,7 @@ template class Unequatable }; /** - * This template class defines overloads of operators `==` and `!=`. + * Defines overloads of operators `==` and `!=`. * * The `==` implementation simply compares all the bytes of two `Type` instances to be equal (using `memcmp()`). * @@ -79,7 +79,7 @@ template class Equatable : public Unequatable { public: /** - * This method overloads operator `==` to evaluate whether or not two instances of `Type` are equal. + * Overloads operator `==` to evaluate whether or not two instances of `Type` are equal. * * @param[in] aOther The other `Type` instance to compare with. * diff --git a/src/core/common/error.hpp b/src/core/common/error.hpp index d89be292a57..27caac4240e 100644 --- a/src/core/common/error.hpp +++ b/src/core/common/error.hpp @@ -43,7 +43,7 @@ namespace ot { /** - * This type represents error codes used by OpenThread core modules. + * Represents error codes used by OpenThread core modules. * */ typedef otError Error; @@ -94,7 +94,7 @@ constexpr Error kErrorGeneric = OT_ERROR_GENERIC; constexpr uint8_t kNumErrors = OT_NUM_ERRORS; /** - * This function converts an `Error` into a string. + * Converts an `Error` into a string. * * @param[in] aError An error. * diff --git a/src/core/common/extension.hpp b/src/core/common/extension.hpp index d88d92177a9..ac93e016988 100644 --- a/src/core/common/extension.hpp +++ b/src/core/common/extension.hpp @@ -59,9 +59,9 @@ namespace Extension { */ /** - * This class defines the base class for an OpenThread vendor Extension object. + * Defines the base class for an OpenThread vendor Extension object. * - * This class is used by OpenThread core to interact with the extension module. Methods in this class are expected + * Is used by OpenThread core to interact with the extension module. Methods in this class are expected * to be implemented by the vendor extension module. * * Support for vendor extension can be enabled using `OPENTHREAD_ENABLE_VENDOR_EXTENSION` configuration option. @@ -71,7 +71,7 @@ class ExtensionBase : public InstanceLocator, private NonCopyable { public: /** - * This static method initializes and gets a vendor extension instance. + * Initializes and gets a vendor extension instance. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -84,13 +84,13 @@ class ExtensionBase : public InstanceLocator, private NonCopyable static ExtensionBase &Init(Instance &aInstance); /** - * This method notifies the extension object that OpenThread instance has been initialized. + * Notifies the extension object that OpenThread instance has been initialized. * */ void SignalInstanceInit(void); /** - * This method notifies the extension object that NCP instance has been initialized. + * Notifies the extension object that NCP instance has been initialized. * * @param[in] aNcpInstance A reference to the NCP object. * @@ -98,7 +98,7 @@ class ExtensionBase : public InstanceLocator, private NonCopyable void SignalNcpInit(Ncp::NcpBase &aNcpInstance); /** - * This method notifies the extension object of events from OpenThread `Notifier`. + * Notifies the extension object of events from OpenThread `Notifier`. * * @param[in] aEvents The list of events emitted by `Notifier`. * @@ -107,7 +107,7 @@ class ExtensionBase : public InstanceLocator, private NonCopyable protected: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * diff --git a/src/core/common/extension_example.cpp b/src/core/common/extension_example.cpp index 946032542d1..f392b31fb66 100644 --- a/src/core/common/extension_example.cpp +++ b/src/core/common/extension_example.cpp @@ -44,7 +44,7 @@ namespace ot { namespace Extension { /** - * This class defines the vendor extension object. + * Defines the vendor extension object. * */ class Extension : public ExtensionBase diff --git a/src/core/common/frame_builder.hpp b/src/core/common/frame_builder.hpp index bbbb73154e4..5d5a98d9e6c 100644 --- a/src/core/common/frame_builder.hpp +++ b/src/core/common/frame_builder.hpp @@ -51,7 +51,7 @@ class FrameBuilder { public: /** - * This method initializes the `FrameBuilder` to use a given buffer. + * Initializes the `FrameBuilder` to use a given buffer. * * `FrameBuilder` MUST be initialized before its other methods are used. * @@ -62,7 +62,7 @@ class FrameBuilder void Init(void *aBuffer, uint16_t aLength); /** - * This method returns a pointer to the start of `FrameBuilder` buffer. + * Returns a pointer to the start of `FrameBuilder` buffer. * * @returns A pointer to the frame buffer. * @@ -70,7 +70,7 @@ class FrameBuilder const uint8_t *GetBytes(void) const { return mBuffer; } /** - * This method returns the current length of frame (number of bytes appended so far). + * Returns the current length of frame (number of bytes appended so far). * * @returns The current frame length. * @@ -78,7 +78,7 @@ class FrameBuilder uint16_t GetLength(void) const { return mLength; } /** - * This method returns the maximum length of the frame. + * Returns the maximum length of the frame. * * @returns The maximum frame length (max number of bytes in the frame buffer). * @@ -86,9 +86,9 @@ class FrameBuilder uint16_t GetMaxLength(void) const { return mMaxLength; } /** - * This method sets the maximum length of the frame. + * Sets the maximum length of the frame. * - * This method does not perform any checks on the new given length. The caller MUST ensure that the specified max + * Does not perform any checks on the new given length. The caller MUST ensure that the specified max * length is valid for the frame buffer. * * @param[in] aLength The maximum frame length. @@ -97,7 +97,7 @@ class FrameBuilder void SetMaxLength(uint16_t aLength) { mMaxLength = aLength; } /** - * This method returns the remaining length (number of bytes that can be appended) in the frame. + * Returns the remaining length (number of bytes that can be appended) in the frame. * * @returns The remaining length. * @@ -105,7 +105,7 @@ class FrameBuilder uint16_t GetRemainingLength(void) const { return mMaxLength - mLength; } /** - * This method indicates whether or not there are enough bytes remaining in the `FrameBuilder` buffer to append a + * Indicates whether or not there are enough bytes remaining in the `FrameBuilder` buffer to append a * given number of bytes. * * @param[in] aLength The append length. @@ -117,7 +117,7 @@ class FrameBuilder bool CanAppend(uint16_t aLength) const { return (static_cast(mLength) + aLength) <= mMaxLength; } /** - * This method appends an `uint8_t` value to the `FrameBuilder`. + * Appends an `uint8_t` value to the `FrameBuilder`. * * @param[in] aUint8 The `uint8_t` value to append. * @@ -128,7 +128,7 @@ class FrameBuilder Error AppendUint8(uint8_t aUint8); /** - * This method appends an `uint16_t` value assuming big endian encoding to the `FrameBuilder`. + * Appends an `uint16_t` value assuming big endian encoding to the `FrameBuilder`. * * @param[in] aUint16 The `uint16_t` value to append. * @@ -139,7 +139,7 @@ class FrameBuilder Error AppendBigEndianUint16(uint16_t aUint16); /** - * This method appends an `uint32_t` value assuming big endian encoding to the `FrameBuilder`. + * Appends an `uint32_t` value assuming big endian encoding to the `FrameBuilder`. * * @param[in] aUint32 The `uint32_t` value to append. * @@ -150,7 +150,7 @@ class FrameBuilder Error AppendBigEndianUint32(uint32_t aUint32); /** - * This method appends an `uint16_t` value assuming little endian encoding to the `FrameBuilder`. + * Appends an `uint16_t` value assuming little endian encoding to the `FrameBuilder`. * * @param[in] aUint16 The `uint16_t` value to append. * @@ -161,7 +161,7 @@ class FrameBuilder Error AppendLittleEndianUint16(uint16_t aUint16); /** - * This method appends an `uint32_t` value assuming little endian encoding to the `FrameBuilder`. + * Appends an `uint32_t` value assuming little endian encoding to the `FrameBuilder`. * * @param[in] aUint32 The `uint32_t` value to append. * @@ -172,7 +172,7 @@ class FrameBuilder Error AppendLittleEndianUint32(uint32_t aUint32); /** - * This method appends bytes from a given buffer to the `FrameBuilder`. + * Appends bytes from a given buffer to the `FrameBuilder`. * * @param[in] aBuffer A pointer to a data bytes to append. * @param[in] aLength Number of bytes in @p aBuffer. @@ -184,7 +184,7 @@ class FrameBuilder Error AppendBytes(const void *aBuffer, uint16_t aLength); /** - * This method appends a given `Mac::Address` to the `FrameBuilder`. + * Appends a given `Mac::Address` to the `FrameBuilder`. * * @param[in] aMacAddress A `Mac::Address` to append. * @@ -196,7 +196,7 @@ class FrameBuilder #if OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This method appends bytes read from a given message to the `FrameBuilder`. + * Appends bytes read from a given message to the `FrameBuilder`. * * @param[in] aMessage The message to read the bytes from. * @param[in] aOffset The offset in @p aMessage to start reading the bytes from. @@ -211,7 +211,7 @@ class FrameBuilder #endif /** - * This method appends an object to the `FrameBuilder`. + * Appends an object to the `FrameBuilder`. * * @tparam ObjectType The object type to append. * @@ -229,9 +229,9 @@ class FrameBuilder } /** - * This method writes bytes in `FrameBuilder` at a given offset overwriting the previously appended content. + * Writes bytes in `FrameBuilder` at a given offset overwriting the previously appended content. * - * This method does not perform any bound checks. The caller MUST ensure that the given data length fits within the + * Does not perform any bound checks. The caller MUST ensure that the given data length fits within the * previously appended content. Otherwise the behavior of this method is undefined. * * @param[in] aOffset The offset to begin writing. @@ -242,9 +242,9 @@ class FrameBuilder void WriteBytes(uint16_t aOffset, const void *aBuffer, uint16_t aLength); /** - * This methods writes an object to the `FrameBuilder` at a given offset overwriting previously appended content. + * Writes an object to the `FrameBuilder` at a given offset overwriting previously appended content. * - * This method does not perform any bound checks. The caller MUST ensure the given data length fits within the + * Does not perform any bound checks. The caller MUST ensure the given data length fits within the * previously appended content. Otherwise the behavior of this method is undefined. * * @tparam ObjectType The object type to write. @@ -261,7 +261,7 @@ class FrameBuilder } /** - * This method inserts bytes in `FrameBuilder` at a given offset, moving previous content forward. + * Inserts bytes in `FrameBuilder` at a given offset, moving previous content forward. * * The caller MUST ensure that @p aOffset is within the current frame length (from 0 up to and including * `GetLength()`). Otherwise the behavior of this method is undefined. @@ -277,7 +277,7 @@ class FrameBuilder Error InsertBytes(uint16_t aOffset, const void *aBuffer, uint16_t aLength); /** - * This method inserts an object in `FrameBuilder` at a given offset, moving previous content forward. + * Inserts an object in `FrameBuilder` at a given offset, moving previous content forward. * * The caller MUST ensure that @p aOffset is within the current frame length (from 0 up to and including * `GetLength()`). Otherwise the behavior of this method is undefined. @@ -299,10 +299,10 @@ class FrameBuilder } /** - * This method removes a given number of bytes in `FrameBuilder` at a given offset, moving existing content + * Removes a given number of bytes in `FrameBuilder` at a given offset, moving existing content * after removed bytes backward. * - * This method does not perform any bound checks. The caller MUST ensure that the given length and offset fits + * Does not perform any bound checks. The caller MUST ensure that the given length and offset fits * within the previously appended content. Otherwise the behavior of this method is undefined. * * @param[in] aOffset The offset to remove bytes from. diff --git a/src/core/common/frame_data.hpp b/src/core/common/frame_data.hpp index 336a7827973..7aa8359334e 100644 --- a/src/core/common/frame_data.hpp +++ b/src/core/common/frame_data.hpp @@ -42,7 +42,7 @@ namespace ot { /** - * This class represents a frame `Data` which is simply a wrapper over a pointer to a buffer with a given frame length. + * Represents a frame `Data` which is simply a wrapper over a pointer to a buffer with a given frame length. * * It provide helper method to parse the content. As data is parsed and read, the `FrameData` is updated to skip over * the read content. @@ -52,7 +52,7 @@ class FrameData : public Data { public: /** - * This method indicates whether or not there are enough bytes remaining in the `FrameData` to read a given number + * Indicates whether or not there are enough bytes remaining in the `FrameData` to read a given number * of bytes. * * @param[in] aLength The read length to check. @@ -64,7 +64,7 @@ class FrameData : public Data bool CanRead(uint16_t aLength) const { return GetLength() >= aLength; } /** - * This method reads an `uint8_t` value from the `FrameData`. + * Reads an `uint8_t` value from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -77,7 +77,7 @@ class FrameData : public Data Error ReadUint8(uint8_t &aUint8); /** - * This method reads an `uint16_t` value assuming big endian encoding from the `FrameData`. + * Reads an `uint16_t` value assuming big endian encoding from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -90,7 +90,7 @@ class FrameData : public Data Error ReadBigEndianUint16(uint16_t &aUint16); /** - * This method reads an `uint32_t` value assuming big endian encoding from the `FrameData`. + * Reads an `uint32_t` value assuming big endian encoding from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -103,7 +103,7 @@ class FrameData : public Data Error ReadBigEndianUint32(uint32_t &aUint32); /** - * This method reads an `uint16_t` value assuming little endian encoding from the `FrameData`. + * Reads an `uint16_t` value assuming little endian encoding from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -116,7 +116,7 @@ class FrameData : public Data Error ReadLittleEndianUint16(uint16_t &aUint16); /** - * This method reads an `uint32_t` value assuming little endian encoding from the `FrameData`. + * Reads an `uint32_t` value assuming little endian encoding from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -129,7 +129,7 @@ class FrameData : public Data Error ReadLittleEndianUint32(uint32_t &aUint32); /** - * This method reads a given number of bytes from the `FrameData`. + * Reads a given number of bytes from the `FrameData`. * * If read successfully, the `FrameData` is updated to skip over the read content. * @@ -143,7 +143,7 @@ class FrameData : public Data Error ReadBytes(void *aBuffer, uint16_t aLength); /** - * This template method reads an object from the `FrameData`. + * Reads an object from the `FrameData`. * * @tparam ObjectType The object type to read from the message. * @@ -161,7 +161,7 @@ class FrameData : public Data } /** - * This method skips over a given number of bytes from `FrameData`. + * Skips over a given number of bytes from `FrameData`. * * The caller MUST make sure that the @p aLength is smaller than current data length. Otherwise the behavior of * this method is undefined. diff --git a/src/core/common/heap.hpp b/src/core/common/heap.hpp index 529f6f2b9fe..6dbe066cf9f 100644 --- a/src/core/common/heap.hpp +++ b/src/core/common/heap.hpp @@ -43,7 +43,7 @@ namespace ot { namespace Heap { /** - * This function allocates memory from heap for an array of given number of object of certain size. + * Allocates memory from heap for an array of given number of object of certain size. * * @param[in] aCount Number of objects. * @param[in] aSize Size of each object. @@ -54,7 +54,7 @@ namespace Heap { void *CAlloc(size_t aCount, size_t aSize); /** - * This function frees a previously heap allocated buffer. + * Frees a previously heap allocated buffer. * * A heap allocated buffer MUST be freed only once. * diff --git a/src/core/common/heap_allocatable.hpp b/src/core/common/heap_allocatable.hpp index e9073ed70a9..b51018d323e 100644 --- a/src/core/common/heap_allocatable.hpp +++ b/src/core/common/heap_allocatable.hpp @@ -45,7 +45,7 @@ namespace ot { namespace Heap { /** - * This template class defines a `Heap::Allocatable` object. + * Defines a `Heap::Allocatable` object. * * `Heap::Allocatable` provides methods to allocate and free instances of `Type` on heap. * @@ -60,7 +60,7 @@ template class Allocatable { public: /** - * This static method allocates a new instance of `Type` on heap and initializes it using `Type` constructor. + * Allocates a new instance of `Type` on heap and initializes it using `Type` constructor. * * The `Type` class MUST have a constructor `Type(Args...)` which is invoked upon allocation of new `Type` to * initialize it. @@ -78,7 +78,7 @@ template class Allocatable } /** - * This static method allocates a new instance of `Type` on heap and initializes it using `Type::Init()` method. + * Allocates a new instance of `Type` on heap and initializes it using `Type::Init()` method. * * The `Type` class MUST have a default constructor (with no arguments) which is invoked upon allocation of new * `Type` instance. It MUST also provide an `Error Init(Args...)` method to initialize the instance. If any `Error` @@ -109,7 +109,7 @@ template class Allocatable } /** - * This method frees the `Type` instance. + * Frees the `Type` instance. * * The instance MUST be heap allocated using either `Allocate()` or `AllocateAndInit()`. * diff --git a/src/core/common/heap_array.hpp b/src/core/common/heap_array.hpp index 29645f6fb7b..a4f549a74e4 100644 --- a/src/core/common/heap_array.hpp +++ b/src/core/common/heap_array.hpp @@ -49,7 +49,7 @@ namespace ot { namespace Heap { /** - * This class represents a heap allocated array. + * Represents a heap allocated array. * * The buffer to store the elements is allocated from heap and is managed by the `Heap::Array` class itself. The `Array` * implementation will automatically grow the buffer when new entries are added. The `Heap::Array` destructor will @@ -69,7 +69,7 @@ template class Array using IndexType = uint16_t; /** - * This constructor initializes the `Array` as empty. + * Initializes the `Array` as empty. * */ Array(void) @@ -86,7 +86,7 @@ template class Array ~Array(void) { Free(); } /** - * This method frees any buffer allocated by the `Array`. + * Frees any buffer allocated by the `Array`. * * The `Array` destructor will automatically call `Free()`. This method allows caller to free buffer explicitly. * @@ -100,12 +100,12 @@ template class Array } /** - * This method clears the array. + * Clears the array. * * Note that `Clear()` method (unlike `Free()`) does not free the allocated buffer and therefore does not change * the current capacity of the array. * - * This method invokes `Type` destructor on all cleared existing elements of array. + * Invokes `Type` destructor on all cleared existing elements of array. * */ void Clear(void) @@ -119,7 +119,7 @@ template class Array } /** - * This method returns the current array length (number of elements in the array). + * Returns the current array length (number of elements in the array). * * @returns The array length. * @@ -127,7 +127,7 @@ template class Array IndexType GetLength(void) const { return mLength; } /** - * This method returns a raw pointer to the array buffer. + * Returns a raw pointer to the array buffer. * * The returned raw pointer is valid only while the `Array` remains unchanged. * @@ -137,7 +137,7 @@ template class Array const Type *AsCArray(void) const { return (mLength != 0) ? mArray : nullptr; } /** - * This method returns the current capacity of array (number of elements that can fit in current allocated buffer). + * Returns the current capacity of array (number of elements that can fit in current allocated buffer). * * The allocated buffer and array capacity are automatically increased (by the `Array` itself) when new elements * are added to array. Removing elements does not change the buffer and the capacity. A desired capacity can be @@ -149,7 +149,7 @@ template class Array IndexType GetCapacity(void) const { return mCapacity; } /** - * This method allocates buffer to reserve a given capacity for array. + * Allocates buffer to reserve a given capacity for array. * * If the requested @p aCapacity is smaller than the current length of the array, capacity remains unchanged. * @@ -162,7 +162,7 @@ template class Array Error ReserveCapacity(IndexType aCapacity) { return Allocate(aCapacity); } /** - * This method sets the array by taking the buffer from another given array (using move semantics). + * Sets the array by taking the buffer from another given array (using move semantics). * * @param[in] aOther The other `Heap::Array` to take from (rvalue reference). * @@ -179,9 +179,9 @@ template class Array } /** - * This method overloads the `[]` operator to get the element at a given index. + * Overloads the `[]` operator to get the element at a given index. * - * This method does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. + * Does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. * * @param[in] aIndex The index to get. * @@ -191,9 +191,9 @@ template class Array Type &operator[](IndexType aIndex) { return mArray[aIndex]; } /** - * This method overloads the `[]` operator to get the element at a given index. + * Overloads the `[]` operator to get the element at a given index. * - * This method does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. + * Does not perform index bounds checking. Behavior is undefined if @p aIndex is not valid. * * @param[in] aIndex The index to get. * @@ -203,7 +203,7 @@ template class Array const Type &operator[](IndexType aIndex) const { return mArray[aIndex]; } /** - * This method gets a pointer to the element at a given index. + * Gets a pointer to the element at a given index. * * Unlike `operator[]`, this method checks @p aIndex to be valid and within the current length. The returned * pointer is valid only while the `Array` remains unchanged. @@ -216,7 +216,7 @@ template class Array Type *At(IndexType aIndex) { return (aIndex < mLength) ? &mArray[aIndex] : nullptr; } /** - * This method gets a pointer to the element at a given index. + * Gets a pointer to the element at a given index. * * Unlike `operator[]`, this method checks @p aIndex to be valid and within the current length. The returned * pointer is valid only while the `Array` remains unchanged. @@ -229,7 +229,7 @@ template class Array const Type *At(IndexType aIndex) const { return (aIndex < mLength) ? &mArray[aIndex] : nullptr; } /** - * This method gets a pointer to the element at the front of the array (first element). + * Gets a pointer to the element at the front of the array (first element). * * The returned pointer is valid only while the `Array` remains unchanged. * @@ -239,7 +239,7 @@ template class Array Type *Front(void) { return At(0); } /** - * This method gets a pointer to the element at the front of the array (first element). + * Gets a pointer to the element at the front of the array (first element). * * The returned pointer is valid only while the `Array` remains unchanged. * @@ -249,7 +249,7 @@ template class Array const Type *Front(void) const { return At(0); } /** - * This method gets a pointer to the element at the back of the array (last element). + * Gets a pointer to the element at the back of the array (last element). * * The returned pointer is valid only while the `Array` remains unchanged. * @@ -259,7 +259,7 @@ template class Array Type *Back(void) { return (mLength > 0) ? &mArray[mLength - 1] : nullptr; } /** - * This method gets a pointer to the element at the back of the array (last element). + * Gets a pointer to the element at the back of the array (last element). * * The returned pointer is valid only while the `Array` remains unchanged. * @@ -269,9 +269,9 @@ template class Array const Type *Back(void) const { return (mLength > 0) ? &mArray[mLength - 1] : nullptr; } /** - * This method appends a new entry to the end of the array. + * Appends a new entry to the end of the array. * - * This method requires the `Type` to provide a copy constructor of format `Type(const Type &aOther)` to init the + * Requires the `Type` to provide a copy constructor of format `Type(const Type &aOther)` to init the * new element in the array from @p aEntry. * * @param[in] aEntry The new entry to push back. @@ -296,9 +296,9 @@ template class Array } /** - * This method appends a new entry to the end of the array. + * Appends a new entry to the end of the array. * - * This method requires the `Type` to provide a copy constructor of format `Type(Type &&aOther)` to init the + * Requires the `Type` to provide a copy constructor of format `Type(Type &&aOther)` to init the * new element in the array from @p aEntry. * * @param[in] aEntry The new entry to push back (an rvalue reference) @@ -323,7 +323,7 @@ template class Array } /** - * This method appends a new entry to the end of the array. + * Appends a new entry to the end of the array. * * On success, this method returns a pointer to the newly appended element in the array for the caller to * initialize and use. This method uses the `Type(void)` default constructor on the newly appended element (if not @@ -350,9 +350,9 @@ template class Array } /** - * This method removes the last element in the array. + * Removes the last element in the array. * - * This method will invoke the `Type` destructor on the removed element. + * Will invoke the `Type` destructor on the removed element. * */ void PopBack(void) @@ -365,7 +365,7 @@ template class Array } /** - * This method returns the index of an element in the array. + * Returns the index of an element in the array. * * The @p aElement MUST be from the array, otherwise the behavior of this method is undefined. * @@ -377,9 +377,9 @@ template class Array IndexType IndexOf(const Type &aElement) const { return static_cast(&aElement - mArray); } /** - * This method finds the first match of a given entry in the array. + * Finds the first match of a given entry in the array. * - * This method uses `==` operator on `Type` to compare the array element with @p aEntry. The returned pointer is + * Uses `==` operator on `Type` to compare the array element with @p aEntry. The returned pointer is * valid only while the `Array` remains unchanged. * * @param[in] aEntry The entry to search for within the array. @@ -390,9 +390,9 @@ template class Array Type *Find(const Type &aEntry) { return AsNonConst(AsConst(this)->Find(aEntry)); } /** - * This method finds the first match of a given entry in the array. + * Finds the first match of a given entry in the array. * - * This method uses `==` operator to compare the array elements with @p aEntry. The returned pointer is valid only + * Uses `==` operator to compare the array elements with @p aEntry. The returned pointer is valid only * while the `Array` remains unchanged. * * @param[in] aEntry The entry to search for within the array. @@ -417,9 +417,9 @@ template class Array } /** - * This method indicates whether or not a match to given entry exists in the array. + * Indicates whether or not a match to given entry exists in the array. * - * This method uses `==` operator on `Type` to compare the array elements with @p aEntry. + * Uses `==` operator on `Type` to compare the array elements with @p aEntry. * * @param[in] aEntry The entry to search for within the array. * @@ -430,7 +430,7 @@ template class Array bool Contains(const Type &aEntry) const { return Find(aEntry) != nullptr; } /** - * This template method finds the first element in the array matching a given indicator. + * Finds the first element in the array matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each @@ -451,7 +451,7 @@ template class Array } /** - * This template method finds the first element in the array matching a given indicator. + * Finds the first element in the array matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each @@ -483,7 +483,7 @@ template class Array } /** - * This template method indicates whether or not the array contains an element matching a given indicator. + * Indicates whether or not the array contains an element matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against elements * in the array. To check that an element matches the given indicator, the `Matches()` method is invoked on each diff --git a/src/core/common/heap_data.hpp b/src/core/common/heap_data.hpp index 20545dae0ff..9fbbe3d4201 100644 --- a/src/core/common/heap_data.hpp +++ b/src/core/common/heap_data.hpp @@ -44,14 +44,14 @@ namespace ot { namespace Heap { /** - * This class represents a heap allocated data. + * Represents a heap allocated data. * */ class Data { public: /** - * This constructor initializes the `Heap::Data` as empty. + * Initializes the `Heap::Data` as empty. * */ Data(void) { mData.Init(nullptr, 0); } @@ -74,7 +74,7 @@ class Data ~Data(void) { Free(); } /** - * This method indicates whether or not the `Heap::Data` is null (i.e., it was never successfully set or it was + * Indicates whether or not the `Heap::Data` is null (i.e., it was never successfully set or it was * freed). * * @retval TRUE The `Heap::Data` is null. @@ -84,7 +84,7 @@ class Data bool IsNull(void) const { return (mData.GetBytes() == nullptr); } /** - * This method returns a pointer to the `Heap::Data` bytes buffer. + * Returns a pointer to the `Heap::Data` bytes buffer. * * @returns A pointer to data buffer or `nullptr` if the `Heap::Data` is null (never set or freed). * @@ -92,7 +92,7 @@ class Data const uint8_t *GetBytes(void) const { return mData.GetBytes(); } /** - * This method returns the `Heap::Data` length. + * Returns the `Heap::Data` length. * * @returns The data length (number of bytes) or zero if the `HeapData` is null. * @@ -100,7 +100,7 @@ class Data uint16_t GetLength(void) const { return mData.GetLength(); } /** - * This method sets the `Heap::Data` from the content of a given buffer. + * Sets the `Heap::Data` from the content of a given buffer. * * @param[in] aBuffer The buffer to copy bytes from. * @param[in] aLength The buffer length (number of bytes). @@ -112,7 +112,7 @@ class Data Error SetFrom(const uint8_t *aBuffer, uint16_t aLength); /** - * This method sets the `Heap::Data` from the content of a given message. + * Sets the `Heap::Data` from the content of a given message. * * The bytes are copied from current offset in @p aMessage till the end of the message. * @@ -125,7 +125,7 @@ class Data Error SetFrom(const Message &aMessage); /** - * This method sets the `Heap::Data` from the content of a given message read at a given offset up to a given + * Sets the `Heap::Data` from the content of a given message read at a given offset up to a given * length. * * @param[in] aMessage The message to read and copy bytes from. @@ -141,7 +141,7 @@ class Data Error SetFrom(const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method sets the `Heap::Data` from another one (move semantics). + * Sets the `Heap::Data` from another one (move semantics). * * @param[in] aData The other `Heap::Data` to set from (rvalue reference). * @@ -149,7 +149,7 @@ class Data void SetFrom(Data &&aData); /** - * This method appends the bytes from `Heap::Data` to a given message. + * Appends the bytes from `Heap::Data` to a given message. * * @param[in] aMessage The message to append the bytes into. * @@ -160,7 +160,7 @@ class Data Error CopyBytesTo(Message &aMessage) const { return aMessage.AppendBytes(mData.GetBytes(), mData.GetLength()); } /** - * This method copies the bytes from `Heap::Data` into a given buffer. + * Copies the bytes from `Heap::Data` into a given buffer. * * It is up to the caller to ensure that @p aBuffer has enough space for the current data length. * @@ -170,7 +170,7 @@ class Data void CopyBytesTo(uint8_t *aBuffer) const { return mData.CopyBytesTo(aBuffer); } /** - * This method frees any buffer allocated by the `Heap::Data`. + * Frees any buffer allocated by the `Heap::Data`. * * The `Heap::Data` destructor will automatically call `Free()`. This method allows caller to free the buffer * explicitly. diff --git a/src/core/common/heap_string.hpp b/src/core/common/heap_string.hpp index 2f737bb1599..d06c97bd59d 100644 --- a/src/core/common/heap_string.hpp +++ b/src/core/common/heap_string.hpp @@ -44,7 +44,7 @@ namespace ot { namespace Heap { /** - * This class represents a heap allocated string. + * Represents a heap allocated string. * * The buffer to store the string is allocated from heap and is manged by the `Heap::String` class itself, e.g., it may * be reused and/or freed and reallocated when the string is set. The `Heap::String` destructor will always free the @@ -55,7 +55,7 @@ class String : public Unequatable { public: /** - * This constructor initializes the `String` as null (or empty). + * Initializes the `String` as null (or empty). * */ String(void) @@ -83,7 +83,7 @@ class String : public Unequatable ~String(void) { Free(); } /** - * This method indicates whether or not the `String` is null (i.e., it was never successfully set or it was + * Indicates whether or not the `String` is null (i.e., it was never successfully set or it was * freed). * * @retval TRUE The `String` is null. @@ -93,7 +93,7 @@ class String : public Unequatable bool IsNull(void) const { return (mStringBuffer == nullptr); } /** - * This method returns the `String` as a C string. + * Returns the `String` as a C string. * * @returns A pointer to C string buffer or `nullptr` if the `String` is null (never set or freed). * @@ -101,7 +101,7 @@ class String : public Unequatable const char *AsCString(void) const { return mStringBuffer; } /** - * This method sets the string from a given C string. + * Sets the string from a given C string. * * @param[in] aCString A pointer to c string buffer. Can be `nullptr` which then frees the `String`. * @@ -112,7 +112,7 @@ class String : public Unequatable Error Set(const char *aCString); /** - * This method sets the string from another `String`. + * Sets the string from another `String`. * * @param[in] aString The other `String` to set from. * @@ -123,7 +123,7 @@ class String : public Unequatable Error Set(const String &aString) { return Set(aString.AsCString()); } /** - * This method sets the string from another `String`. + * Sets the string from another `String`. * * @param[in] aString The other `String` to set from (rvalue reference using move semantics). * @@ -134,7 +134,7 @@ class String : public Unequatable Error Set(String &&aString); /** - * This method frees any buffer allocated by the `String`. + * Frees any buffer allocated by the `String`. * * The `String` destructor will automatically call `Free()`. This method allows caller to free buffer * explicitly. @@ -143,7 +143,7 @@ class String : public Unequatable void Free(void); /** - * This method overloads operator `==` to evaluate whether or not the `String` is equal to a given C string. + * Overloads operator `==` to evaluate whether or not the `String` is equal to a given C string. * * @param[in] aCString A C string to compare with. Can be `nullptr` which then checks if `String` is null. * @@ -154,7 +154,7 @@ class String : public Unequatable bool operator==(const char *aCString) const; /** - * This method overloads operator `!=` to evaluate whether or not the `String` is unequal to a given C string. + * Overloads operator `!=` to evaluate whether or not the `String` is unequal to a given C string. * * @param[in] aCString A C string to compare with. Can be `nullptr` which then checks if `String` is not null. * @@ -165,7 +165,7 @@ class String : public Unequatable bool operator!=(const char *aCString) const { return !(*this == aCString); } /** - * This method overloads operator `==` to evaluate whether or not two `String` are equal. + * Overloads operator `==` to evaluate whether or not two `String` are equal. * * @param[in] aString The other string to compare with. * diff --git a/src/core/common/instance.cpp b/src/core/common/instance.cpp index d0aebecd378..10d545d669a 100644 --- a/src/core/common/instance.cpp +++ b/src/core/common/instance.cpp @@ -245,6 +245,7 @@ Instance::Instance(void) , mPowerCalibration(*this) #endif , mIsInitialized(false) + , mId(Random::NonCrypto::GetUint32()) { } diff --git a/src/core/common/instance.hpp b/src/core/common/instance.hpp index 8ce6eba09ef..0a262bab033 100644 --- a/src/core/common/instance.hpp +++ b/src/core/common/instance.hpp @@ -144,7 +144,7 @@ */ /** - * This struct represents an opaque (and empty) type corresponding to an OpenThread instance object. + * Represents an opaque (and empty) type corresponding to an OpenThread instance object. * */ typedef struct otInstance @@ -154,16 +154,16 @@ typedef struct otInstance namespace ot { /** - * This class represents an OpenThread instance. + * Represents an OpenThread instance. * - * This class contains all the components used by OpenThread. + * Contains all the components used by OpenThread. * */ class Instance : public otInstance, private NonCopyable { public: /** - * This type represents the message buffer information (number of messages/buffers in all OT stack message queues). + * Represents the message buffer information (number of messages/buffers in all OT stack message queues). * */ class BufferInfo : public otBufferInfo, public Clearable @@ -172,9 +172,9 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE /** - * This static method initializes the OpenThread instance. + * Initializes the OpenThread instance. * - * This function must be called before any other calls on OpenThread instance. + * Must be called before any other calls on OpenThread instance. * * @param[in] aBuffer The buffer for OpenThread to use for allocating the Instance. * @param[in,out] aBufferSize On input, the size of `aBuffer`. On output, if not enough space for `Instance`, the @@ -188,9 +188,9 @@ class Instance : public otInstance, private NonCopyable #else // OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE /** - * This static method initializes the single OpenThread instance. + * Initializes the single OpenThread instance. * - * This method initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be * called before any other calls to OpenThread. * * @returns A reference to the single OpenThread instance. @@ -199,7 +199,7 @@ class Instance : public otInstance, private NonCopyable static Instance &InitSingle(void); /** - * This static method returns a reference to the single OpenThread instance. + * Returns a reference to the single OpenThread instance. * * @returns A reference to the single OpenThread instance. * @@ -208,7 +208,18 @@ class Instance : public otInstance, private NonCopyable #endif /** - * This method indicates whether or not the instance is valid/initialized and not yet finalized. + * Gets the instance identifier. + * + * The instance identifier is set to a random value when the instance is constructed, and then its value will not + * change after initialization. + * + * @returns The instance identifier. + * + */ + uint32_t GetId(void) const { return mId; } + + /** + * Indicates whether or not the instance is valid/initialized and not yet finalized. * * @returns TRUE if the instance is valid/initialized, FALSE otherwise. * @@ -216,7 +227,7 @@ class Instance : public otInstance, private NonCopyable bool IsInitialized(void) const { return mIsInitialized; } /** - * This method triggers a platform reset. + * Triggers a platform reset. * * The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that * this method does not erase any persistent state/info saved in non-volatile memory. @@ -226,14 +237,14 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_RADIO /** - * This method resets the internal states of the radio. + * Resets the internal states of the radio. * */ void ResetRadioStack(void); #endif /** - * This method returns the active log level. + * Returns the active log level. * * @returns The log level. * @@ -251,7 +262,7 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE /** - * This method sets the log level. + * Sets the log level. * * @param[in] aLogLevel A log level. * @@ -260,22 +271,22 @@ class Instance : public otInstance, private NonCopyable #endif /** - * This method finalizes the OpenThread instance. + * Finalizes the OpenThread instance. * - * This method should be called when OpenThread instance is no longer in use. + * Should be called when OpenThread instance is no longer in use. * */ void Finalize(void); #if OPENTHREAD_MTD || OPENTHREAD_FTD /** - * This method deletes all the settings stored in non-volatile memory, and then triggers a platform reset. + * Deletes all the settings stored in non-volatile memory, and then triggers a platform reset. * */ void FactoryReset(void); /** - * This method erases all the OpenThread persistent info (network settings) stored in non-volatile memory. + * Erases all the OpenThread persistent info (network settings) stored in non-volatile memory. * * Erase is successful/allowed only if the device is in `disabled` state/role. * @@ -287,7 +298,7 @@ class Instance : public otInstance, private NonCopyable #if !OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE /** - * This method returns a reference to the Heap object. + * Returns a reference to the Heap object. * * @returns A reference to the Heap object. * @@ -297,7 +308,7 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_COAP_API_ENABLE /** - * This method returns a reference to application COAP object. + * Returns a reference to application COAP object. * * @returns A reference to the application COAP object. * @@ -307,7 +318,7 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE /** - * This method returns a reference to application COAP Secure object. + * Returns a reference to application COAP Secure object. * * @returns A reference to the application COAP Secure object. * @@ -317,7 +328,7 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method enables/disables the "DNS name compressions" mode. + * Enables/disables the "DNS name compressions" mode. * * 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. @@ -330,7 +341,7 @@ class Instance : public otInstance, private NonCopyable static void SetDnsNameCompressionEnabled(bool aEnabled) { sDnsNameCompressionEnabled = aEnabled; } /** - * This method indicates whether the "DNS name compression" mode is enabled or not. + * Indicates whether the "DNS name compression" mode is enabled or not. * * @returns TRUE if the "DNS name compressions" mode is enabled, FALSE otherwise. * @@ -339,7 +350,7 @@ class Instance : public otInstance, private NonCopyable #endif /** - * This method retrieves the the Message Buffer information. + * Retrieves the the Message Buffer information. * * @param[out] aInfo A `BufferInfo` where information is written. * @@ -347,10 +358,10 @@ class Instance : public otInstance, private NonCopyable void GetBufferInfo(BufferInfo &aInfo); /** - * This method resets the Message Buffer information counter tracking maximum number buffers in use at the same + * Resets the Message Buffer information counter tracking maximum number buffers in use at the same * time. * - * This method resets `mMaxUsedBuffers` in `BufferInfo`. + * Resets `mMaxUsedBuffers` in `BufferInfo`. * */ void ResetBufferInfo(void); @@ -358,7 +369,7 @@ class Instance : public otInstance, private NonCopyable #endif // OPENTHREAD_MTD || OPENTHREAD_FTD /** - * This template method returns a reference to a given `Type` object belonging to the OpenThread instance. + * Returns a reference to a given `Type` object belonging to the OpenThread instance. * * For example, `Get()` returns a reference to the `MeshForwarder` object of the instance. * @@ -645,6 +656,8 @@ class Instance : public otInstance, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) static bool sDnsNameCompressionEnabled; #endif + + uint32_t mId; }; DefineCoreType(otInstance, Instance); @@ -658,6 +671,10 @@ template <> inline Radio &Instance::Get(void) { return mRadio; } template <> inline Radio::Callbacks &Instance::Get(void) { return mRadio.mCallbacks; } +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) +template <> inline RadioStatistics &Instance::Get(void) { return mRadio.mRadioStatistics; } +#endif + #if OPENTHREAD_CONFIG_UPTIME_ENABLE template <> inline Uptime &Instance::Get(void) { return mUptime; } #endif diff --git a/src/core/common/iterator_utils.hpp b/src/core/common/iterator_utils.hpp index d6d45dedb6d..f0ae96ed1f0 100644 --- a/src/core/common/iterator_utils.hpp +++ b/src/core/common/iterator_utils.hpp @@ -47,7 +47,7 @@ namespace ot { */ /** - * This template class is used as a base class for those item-pointer iterators. + * Is used as a base class for those item-pointer iterators. * * These iterators have common methods and operators like `Advance()` and `++` and hold a pointer to the * object. @@ -65,7 +65,7 @@ template class ItemPtrIterator { public: /** - * This method indicates whether there are no more items to be accessed (iterator has reached the end). + * Indicates whether there are no more items to be accessed (iterator has reached the end). * * @retval TRUE There are no more items to be accessed (iterator has reached the end). * @retval FALSE The current item is valid. @@ -74,7 +74,7 @@ template class ItemPtrIterator bool IsDone(void) const { return mItem == nullptr; } /** - * This method overloads `++` operator (pre-increment) to advance the iterator. + * Overloads `++` operator (pre-increment) to advance the iterator. * * The iterator is moved to point to the next item using IteratorType's `Advance` method. * If there are no more items, the iterator becomes empty (i.e., `operator*` returns `nullptr` and `IsDone()` @@ -84,7 +84,7 @@ template class ItemPtrIterator void operator++(void) { static_cast(this)->Advance(); } /** - * This method overloads `++` operator (post-increment) to advance the iterator. + * Overloads `++` operator (post-increment) to advance the iterator. * * The iterator is moved to point to the next item using IteratorType's `Advance` method. * If there are no more items, the iterator becomes empty (i.e., `operator*` returns `nullptr` and `IsDone()` @@ -94,10 +94,10 @@ template class ItemPtrIterator void operator++(int) { static_cast(this)->Advance(); } /** - * This method overloads the `*` dereference operator and gets a reference to then item to which the iterator is + * Overloads the `*` dereference operator and gets a reference to then item to which the iterator is * currently pointing. * - * This method MUST be used when the iterator is not empty/finished (i.e., `IsDone()` returns `false`). + * MUST be used when the iterator is not empty/finished (i.e., `IsDone()` returns `false`). * * @returns A reference to the item currently pointed by the iterator. * @@ -105,7 +105,7 @@ template class ItemPtrIterator ItemType &operator*(void) { return *mItem; } /** - * This method overloads the `->` dereference operator and gets a pointer to the item to which the iterator is + * Overloads the `->` dereference operator and gets a pointer to the item to which the iterator is * currently pointing. * * @returns A pointer to the item associated with the iterator, or `nullptr` if iterator is empty/done. @@ -114,7 +114,7 @@ template class ItemPtrIterator ItemType *operator->(void) { return mItem; } /** - * This method overloads operator `==` to evaluate whether or not two `Iterator` instances point to the same + * Overloads operator `==` to evaluate whether or not two `Iterator` instances point to the same * item. * * @param[in] aOther The other `Iterator` to compare with. @@ -126,7 +126,7 @@ template class ItemPtrIterator bool operator==(const IteratorType &aOther) const { return mItem == aOther.mItem; } /** - * This method overloads operator `!=` to evaluate whether or not two `Iterator` instances point to the same + * Overloads operator `!=` to evaluate whether or not two `Iterator` instances point to the same * child entry. * * @param[in] aOther The other `Iterator` to compare with. diff --git a/src/core/common/linked_list.hpp b/src/core/common/linked_list.hpp index f79ac91d078..3f04aef1dad 100644 --- a/src/core/common/linked_list.hpp +++ b/src/core/common/linked_list.hpp @@ -55,9 +55,9 @@ namespace ot { */ /** - * This template class represents a linked list entry. + * Represents a linked list entry. * - * This class provides methods to `GetNext()` and `SetNext()` in the linked list entry. + * Provides methods to `GetNext()` and `SetNext()` in the linked list entry. * * Users of this class should follow CRTP-style inheritance, i.e., the `Type` class itself should publicly inherit * from `LinkedListEntry`. @@ -70,7 +70,7 @@ template class LinkedListEntry { public: /** - * This method gets the next entry in the linked list. + * Gets the next entry in the linked list. * * @returns A pointer to the next entry in the linked list or `nullptr` if at the end of the list. * @@ -78,7 +78,7 @@ template class LinkedListEntry const Type *GetNext(void) const { return static_cast(static_cast(this)->mNext); } /** - * This method gets the next entry in the linked list. + * Gets the next entry in the linked list. * * @returns A pointer to the next entry in the linked list or `nullptr` if at the end of the list. * @@ -86,7 +86,7 @@ template class LinkedListEntry Type *GetNext(void) { return static_cast(static_cast(this)->mNext); } /** - * This method sets the next pointer on the entry. + * Sets the next pointer on the entry. * * @param[in] aNext A pointer to the next entry. * @@ -95,7 +95,7 @@ template class LinkedListEntry }; /** - * This template class represents a singly linked list. + * Represents a singly linked list. * * The template type `Type` should provide `GetNext()` and `SetNext()` methods (which can be realized by `Type` * inheriting from `LinkedListEntry` class). @@ -108,7 +108,7 @@ template class LinkedList public: /** - * This constructor initializes the linked list. + * Initializes the linked list. * */ LinkedList(void) @@ -117,7 +117,7 @@ template class LinkedList } /** - * This method returns the entry at the head of the linked list + * Returns the entry at the head of the linked list * * @returns Pointer to the entry at the head of the linked list, or `nullptr` if the list is empty. * @@ -125,7 +125,7 @@ template class LinkedList Type *GetHead(void) { return mHead; } /** - * This method returns the entry at the head of the linked list. + * Returns the entry at the head of the linked list. * * @returns Pointer to the entry at the head of the linked list, or `nullptr` if the list is empty. * @@ -133,7 +133,7 @@ template class LinkedList const Type *GetHead(void) const { return mHead; } /** - * This method sets the head of the linked list to a given entry. + * Sets the head of the linked list to a given entry. * * @param[in] aHead A pointer to an entry to set as the head of the linked list. * @@ -141,13 +141,13 @@ template class LinkedList void SetHead(Type *aHead) { mHead = aHead; } /** - * This method clears the linked list. + * Clears the linked list. * */ void Clear(void) { mHead = nullptr; } /** - * This method indicates whether the linked list is empty or not. + * Indicates whether the linked list is empty or not. * * @retval TRUE If the linked list is empty. * @retval FALSE If the linked list is not empty. @@ -156,7 +156,7 @@ template class LinkedList bool IsEmpty(void) const { return (mHead == nullptr); } /** - * This method pushes an entry at the head of the linked list. + * Pushes an entry at the head of the linked list. * * @param[in] aEntry A reference to an entry to push at the head of linked list. * @@ -168,7 +168,7 @@ template class LinkedList } /** - * This method pushes an entry after a given previous existing entry in the linked list. + * Pushes an entry after a given previous existing entry in the linked list. * * @param[in] aEntry A reference to an entry to push into the list. * @param[in] aPrevEntry A reference to a previous entry (new entry @p aEntry will be pushed after this). @@ -181,7 +181,7 @@ template class LinkedList } /** - * This method pops an entry from head of the linked list. + * Pops an entry from head of the linked list. * * @note This method does not change the popped entry itself, i.e., the popped entry next pointer stays as before. * @@ -201,7 +201,7 @@ template class LinkedList } /** - * This method pops an entry after a given previous entry. + * Pops an entry after a given previous entry. * * @note This method does not change the popped entry itself, i.e., the popped entry next pointer stays as before. * @@ -233,7 +233,7 @@ template class LinkedList } /** - * This method indicates whether the linked list contains a given entry. + * Indicates whether the linked list contains a given entry. * * @param[in] aEntry A reference to an entry. * @@ -249,7 +249,7 @@ template class LinkedList } /** - * This template method indicates whether the linked list contains an entry matching a given entry indicator. + * Indicates whether the linked list contains an entry matching a given entry indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -269,7 +269,7 @@ template class LinkedList } /** - * This method adds an entry (at the head of the linked list) if it is not already in the list. + * Adds an entry (at the head of the linked list) if it is not already in the list. * * @param[in] aEntry A reference to an entry to add. * @@ -294,7 +294,7 @@ template class LinkedList } /** - * This method removes an entry from the linked list. + * Removes an entry from the linked list. * * @note This method does not change the removed entry @p aEntry itself (it is `const`), i.e., the entry next * pointer of @p aEntry stays as before. @@ -319,7 +319,7 @@ template class LinkedList } /** - * This template method removes an entry matching a given entry indicator from the linked list. + * Removes an entry matching a given entry indicator from the linked list. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -351,7 +351,7 @@ template class LinkedList } /** - * This template method removes all entries in the list matching a given entry indicator from the list and adds + * Removes all entries in the list matching a given entry indicator from the list and adds * them to a new list. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries @@ -390,7 +390,7 @@ template class LinkedList } /** - * This method searches within the linked list to find an entry and if found returns a pointer to previous entry. + * Searches within the linked list to find an entry and if found returns a pointer to previous entry. * * @param[in] aEntry A reference to an entry to find. * @param[out] aPrevEntry A pointer to output the previous entry on success (when @p aEntry is found in the list). @@ -420,7 +420,7 @@ template class LinkedList } /** - * This method searches within the linked list to find an entry and if found returns a pointer to previous entry. + * Searches within the linked list to find an entry and if found returns a pointer to previous entry. * * @param[in] aEntry A reference to an entry to find. * @param[out] aPrevEntry A pointer to output the previous entry on success (when @p aEntry is found in the list). @@ -437,7 +437,7 @@ template class LinkedList } /** - * This template method searches within a given range of the linked list to find an entry matching a given + * Searches within a given range of the linked list to find an entry matching a given * indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries @@ -479,7 +479,7 @@ template class LinkedList } /** - * This template method searches within a given range of the linked list to find an entry matching a given + * Searches within a given range of the linked list to find an entry matching a given * indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries @@ -506,7 +506,7 @@ template class LinkedList } /** - * This template method searches within the linked list to find an entry matching a given indicator. + * Searches within the linked list to find an entry matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -529,7 +529,7 @@ template class LinkedList } /** - * This template method searches within the linked list to find an entry matching a given indicator, and if found + * Searches within the linked list to find an entry matching a given indicator, and if found * returns a pointer to its previous entry in the list. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries @@ -553,7 +553,7 @@ template class LinkedList } /** - * This template method searches within the linked list to find an entry matching a given indicator. + * Searches within the linked list to find an entry matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -574,7 +574,7 @@ template class LinkedList } /** - * This template method searches within the linked list to find an entry matching a given indicator. + * Searches within the linked list to find an entry matching a given indicator. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -593,7 +593,7 @@ template class LinkedList } /** - * This method returns the tail of the linked list (i.e., the last entry in the list). + * Returns the tail of the linked list (i.e., the last entry in the list). * * @returns A pointer to the tail entry in the linked list or `nullptr` if the list is empty. * @@ -614,7 +614,7 @@ template class LinkedList } /** - * This method returns the tail of the linked list (i.e., the last entry in the list). + * Returns the tail of the linked list (i.e., the last entry in the list). * * @returns A pointer to the tail entry in the linked list or `nullptr` if the list is empty. * diff --git a/src/core/common/locator.hpp b/src/core/common/locator.hpp index 7ed3625ca8d..b621b4c7412 100644 --- a/src/core/common/locator.hpp +++ b/src/core/common/locator.hpp @@ -59,7 +59,7 @@ extern uint64_t gInstanceRaw[]; */ /** - * This template class implements `Get()` method for different `Type` objects belonging to the OpenThread + * Implements `Get()` method for different `Type` objects belonging to the OpenThread * instance. * * Users of this class MUST follow CRTP-style inheritance, i.e., the class `Class` itself should publicly inherit @@ -74,7 +74,7 @@ template class GetProvider { public: /** - * This template method returns a reference to a given `Type` object belonging to the OpenThread instance. + * Returns a reference to a given `Type` object belonging to the OpenThread instance. * * For example, `Get()` returns a reference to the `MeshForwarder` object of the instance. * @@ -91,7 +91,7 @@ template class GetProvider }; /** - * This class implements a locator for an OpenThread Instance object. + * Implements a locator for an OpenThread Instance object. * * The `InstanceLocator` is used as base class of almost all other OpenThread classes. It provides a way for an object * to get to its owning/parent OpenThread `Instance` and also any other `Type` within the `Instance` member variable @@ -107,7 +107,7 @@ class InstanceLocator : public GetProvider public: /** - * This method returns a reference to the parent OpenThread Instance. + * Returns a reference to the parent OpenThread Instance. * * @returns A reference to the parent otInstance. * @@ -120,7 +120,7 @@ class InstanceLocator : public GetProvider protected: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread Instance. * @@ -142,7 +142,7 @@ class InstanceLocator : public GetProvider }; /** - * This class implements a locator for an OpenThread Instance object. + * Implements a locator for an OpenThread Instance object. * * The `InstanceLocatorInit` is similar to `InstanceLocator` but provides a default constructor (instead of a * parameterized one) and allows an inheriting class to initialize the object (set the OpenThread Instance) post diff --git a/src/core/common/log.hpp b/src/core/common/log.hpp index 90fec6c2fd1..6d46030db71 100644 --- a/src/core/common/log.hpp +++ b/src/core/common/log.hpp @@ -51,7 +51,7 @@ namespace ot { #define OT_SHOULD_LOG (OPENTHREAD_CONFIG_LOG_OUTPUT != OPENTHREAD_CONFIG_LOG_OUTPUT_NONE) /** - * This macro indicates whether the OpenThread logging is enabled at a given log level. + * Indicates whether the OpenThread logging is enabled at a given log level. * * @param[in] aLevel The log level to check. * @@ -61,7 +61,7 @@ namespace ot { #define OT_SHOULD_LOG_AT(aLevel) (OT_SHOULD_LOG && (OPENTHREAD_CONFIG_LOG_LEVEL >= (aLevel))) /** - * This enumeration represents the log level. + * Represents the log level. * */ enum LogLevel : uint8_t @@ -78,9 +78,9 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG && (OPENTHREAD_CONFIG_LOG_LEVEL != OT_LOG_LEVEL_NONE) /** - * This macro registers log module name. + * Registers log module name. * - * This macro is used in a `cpp` file to register the log module name for that file before using any other logging + * Is used in a `cpp` file to register the log module name for that file before using any other logging * functions or macros (e.g., `LogInfo()` or `DumpInfo()`, ...) in the file. * * @param[in] aName The log module name string (MUST be shorter than `kMaxLogModuleNameLength`). @@ -102,7 +102,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_CRIT) /** - * This macro emits a log message at critical log level. + * Emits a log message at critical log level. * * @param[in] ... Arguments for the format specification. * @@ -114,7 +114,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) /** - * This macro emits a log message at warning log level. + * Emits a log message at warning log level. * * @param[in] ... Arguments for the format specification. * @@ -126,7 +126,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE) /** - * This macro emits a log message at note log level. + * Emits a log message at note log level. * * @param[in] ... Arguments for the format specification. * @@ -138,7 +138,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) /** - * This macro emits a log message at info log level. + * Emits a log message at info log level. * * @param[in] ... Arguments for the format specification. * @@ -150,7 +150,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_DEBG) /** - * This macro emits a log message at debug log level. + * Emits a log message at debug log level. * * @param[in] ... Arguments for the format specification. * @@ -162,7 +162,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG /** - * This macro emits a log message at a given log level. + * Emits a log message at a given log level. * * @param[in] aLogLevel The log level to use. * @param[in] ... Argument for the format specification. @@ -175,7 +175,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG /** - * This macro emits a log message independent of the configured log level. + * Emits a log message independent of the configured log level. * * @param[in] ... Arguments for the format specification. * @@ -187,7 +187,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG && OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This macro emit a log message for the certification test. + * Emit a log message for the certification test. * * @param[in] ... Arguments for the format specification. * @@ -199,7 +199,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_CRIT) && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump at log level critical. + * Generates a memory dump at log level critical. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -213,7 +213,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump at log level warning. + * Generates a memory dump at log level warning. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -227,7 +227,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE) && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump at log level note. + * Generates a memory dump at log level note. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -241,7 +241,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump at log level info. + * Generates a memory dump at log level info. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -255,7 +255,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_DEBG) && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump at log level debug. + * Generates a memory dump at log level debug. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -269,7 +269,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump independent of the configured log level. + * Generates a memory dump independent of the configured log level. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. @@ -281,7 +281,7 @@ constexpr uint8_t kMaxLogModuleNameLength = 14; ///< Maximum module name length #if OT_SHOULD_LOG && OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE && OPENTHREAD_CONFIG_LOG_PKT_DUMP /** - * This macro generates a memory dump for certification test. + * Generates a memory dump for certification test. * * @param[in] aText A string that is printed before the bytes. * @param[in] aData A pointer to the data buffer. diff --git a/src/core/common/message.hpp b/src/core/common/message.hpp index 307383724e7..a40cb050359 100644 --- a/src/core/common/message.hpp +++ b/src/core/common/message.hpp @@ -60,7 +60,7 @@ #include "thread/link_quality.hpp" /** - * This struct represents an opaque (and empty) type for an OpenThread message buffer. + * Represents an opaque (and empty) type for an OpenThread message buffer. * */ struct otMessage @@ -88,9 +88,9 @@ class HmacSha256; */ /** - * This macro frees a given message buffer if not `nullptr`. + * Frees a given message buffer if not `nullptr`. * - * This macro and the ones that follow contain small but common code patterns used in many of the core modules. They + * And the ones that follow contain small but common code patterns used in many of the core modules. They * are intentionally defined as macros instead of inline methods/functions to ensure that they are fully inlined. * Note that an `inline` method/function is not necessarily always inlined by the toolchain and not inlining such * small implementations can add a rather large code-size overhead. @@ -108,7 +108,7 @@ class HmacSha256; } while (false) /** - * This macro frees a given message buffer if a given `Error` indicates an error. + * Frees a given message buffer if a given `Error` indicates an error. * * The parameter @p aMessage can be `nullptr` in which case this macro does nothing. * @@ -126,7 +126,7 @@ class HmacSha256; } while (false) /** - * This macro frees a given message buffer if a given `Error` indicates an error and sets the `aMessage` to `nullptr`. + * Frees a given message buffer if a given `Error` indicates an error and sets the `aMessage` to `nullptr`. * * @param[in] aMessage A pointer to a `Message` to free (can be `nullptr`). * @param[in] aError The `Error` to check. @@ -152,7 +152,7 @@ class PriorityQueue; class ThreadLinkInfo; /** - * This class represents a Message buffer. + * Represents a Message buffer. * */ class Buffer : public otMessageBuffer, public LinkedListEntry @@ -161,7 +161,7 @@ class Buffer : public otMessageBuffer, public LinkedListEntry public: /** - * This method returns a pointer to the next message buffer. + * Returns a pointer to the next message buffer. * * @returns A pointer to the next message buffer. * @@ -169,7 +169,7 @@ class Buffer : public otMessageBuffer, public LinkedListEntry Buffer *GetNextBuffer(void) { return GetNext(); } /** - * This method returns a pointer to the next message buffer. + * Returns a pointer to the next message buffer. * * @returns A pointer to the next message buffer. * @@ -177,7 +177,7 @@ class Buffer : public otMessageBuffer, public LinkedListEntry const Buffer *GetNextBuffer(void) const { return GetNext(); } /** - * This method sets the pointer to the next message buffer. + * Sets the pointer to the next message buffer. * * @param[in] aNext A pointer to the next buffer. * @@ -257,7 +257,7 @@ static_assert(sizeof(Buffer) >= kBufferSize, "Buffer size is not valid. Increase OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE."); /** - * This class represents a message. + * Represents a message. * */ class Message : public otMessage, public Buffer, public GetProvider @@ -272,7 +272,7 @@ class Message : public otMessage, public Buffer, public GetProvider public: /** - * This enumeration represents the message type. + * Represents the message type. * */ enum Type : uint8_t @@ -286,7 +286,7 @@ class Message : public otMessage, public Buffer, public GetProvider }; /** - * This enumeration represents the message sub-type. + * Represents the message sub-type. * */ enum SubType : uint8_t @@ -316,7 +316,7 @@ class Message : public otMessage, public Buffer, public GetProvider static constexpr uint8_t kNumPriorities = 4; ///< Number of priority levels. /** - * This enumeration represents the link security mode (used by `Settings` constructor). + * Represents the link security mode (used by `Settings` constructor). * */ enum LinkSecurityMode : bool @@ -326,7 +326,7 @@ class Message : public otMessage, public Buffer, public GetProvider }; /** - * This enumeration represents the message ownership model when a `Message` instance is passed to a method/function. + * Represents the message ownership model when a `Message` instance is passed to a method/function. * */ enum Ownership : uint8_t @@ -348,14 +348,14 @@ class Message : public otMessage, public Buffer, public GetProvider }; /** - * This class represents settings used for creating a new message. + * Represents settings used for creating a new message. * */ class Settings : public otMessageSettings { public: /** - * This constructor initializes the `Settings` object. + * Initializes the `Settings` object. * * @param[in] aSecurityMode A link security mode. * @param[in] aPriority A message priority. @@ -364,7 +364,7 @@ class Message : public otMessage, public Buffer, public GetProvider Settings(LinkSecurityMode aSecurityMode, Priority aPriority); /** - * This constructor initializes the `Settings` with a given message priority and link security enabled. + * Initializes the `Settings` with a given message priority and link security enabled. * * @param[in] aPriority A message priority. * @@ -375,7 +375,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method gets the message priority. + * Gets the message priority. * * @returns The message priority. * @@ -383,7 +383,7 @@ class Message : public otMessage, public Buffer, public GetProvider Priority GetPriority(void) const { return static_cast(mPriority); } /** - * This method indicates whether the link security should be enabled. + * Indicates whether the link security should be enabled. * * @returns TRUE if link security should be enabled, FALSE otherwise. * @@ -391,9 +391,9 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsLinkSecurityEnabled(void) const { return mLinkSecurityEnabled; } /** - * This static method converts a pointer to an `otMessageSettings` to a `Settings`. + * Converts a pointer to an `otMessageSettings` to a `Settings`. * - * @param[in] aSettings A pointer to `otMessageSettings` to covert from. + * @param[in] aSettings A pointer to `otMessageSettings` to convert from. * If it is `nullptr`, then the default settings `GetDefault()` will be used. * * @returns A reference to the converted `Settings` or the default if @p aSettings is `nullptr`. @@ -402,7 +402,7 @@ class Message : public otMessage, public Buffer, public GetProvider static const Settings &From(const otMessageSettings *aSettings); /** - * This static method returns the default settings with link security enabled and `kPriorityNormal` priority. + * Returns the default settings with link security enabled and `kPriorityNormal` priority. * * @returns A reference to the default settings (link security enable and `kPriorityNormal` priority). * @@ -414,7 +414,7 @@ class Message : public otMessage, public Buffer, public GetProvider }; /** - * This method returns a reference to the OpenThread Instance which owns the `Message`. + * Returns a reference to the OpenThread Instance which owns the `Message`. * * @returns A reference to the `Instance`. * @@ -422,13 +422,13 @@ class Message : public otMessage, public Buffer, public GetProvider Instance &GetInstance(void) const; /** - * This method frees this message buffer. + * Frees this message buffer. * */ void Free(void); /** - * This method returns a pointer to the next message. + * Returns a pointer to the next message. * * @returns A pointer to the next message in the list or `nullptr` if at the end of the list. * @@ -436,7 +436,7 @@ class Message : public otMessage, public Buffer, public GetProvider Message *GetNext(void) const; /** - * This method returns the number of bytes in the message. + * Returns the number of bytes in the message. * * @returns The number of bytes in the message. * @@ -444,7 +444,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint16_t GetLength(void) const { return GetMetadata().mLength; } /** - * This method sets the number of bytes in the message. + * Sets the number of bytes in the message. * * @param[in] aLength Requested number of bytes in the message. * @@ -455,13 +455,13 @@ class Message : public otMessage, public Buffer, public GetProvider Error SetLength(uint16_t aLength); /** - * This method returns the number of buffers in the message. + * Returns the number of buffers in the message. * */ uint8_t GetBufferCount(void) const; /** - * This method returns the byte offset within the message. + * Returns the byte offset within the message. * * @returns A byte offset within the message. * @@ -469,7 +469,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint16_t GetOffset(void) const { return GetMetadata().mOffset; } /** - * This method moves the byte offset within the message. + * Moves the byte offset within the message. * * @param[in] aDelta The number of bytes to move the current offset, which may be positive or negative. * @@ -477,7 +477,7 @@ class Message : public otMessage, public Buffer, public GetProvider void MoveOffset(int aDelta); /** - * This method sets the byte offset within the message. + * Sets the byte offset within the message. * * @param[in] aOffset The byte offset within the message. * @@ -485,7 +485,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetOffset(uint16_t aOffset); /** - * This method returns the type of the message. + * Returns the type of the message. * * @returns The type of the message. * @@ -493,7 +493,7 @@ class Message : public otMessage, public Buffer, public GetProvider Type GetType(void) const { return static_cast(GetMetadata().mType); } /** - * This method sets the message type. + * Sets the message type. * * @param[in] aType The message type. * @@ -501,7 +501,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetType(Type aType) { GetMetadata().mType = aType; } /** - * This method returns the sub type of the message. + * Returns the sub type of the message. * * @returns The sub type of the message. * @@ -509,7 +509,7 @@ class Message : public otMessage, public Buffer, public GetProvider SubType GetSubType(void) const { return static_cast(GetMetadata().mSubType); } /** - * This method sets the message sub type. + * Sets the message sub type. * * @param[in] aSubType The message sub type. * @@ -517,7 +517,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetSubType(SubType aSubType) { GetMetadata().mSubType = aSubType; } /** - * This method returns whether or not the message is of MLE subtype. + * Returns whether or not the message is of MLE subtype. * * @retval TRUE If message is of MLE subtype. * @retval FALSE If message is not of MLE subtype. @@ -526,7 +526,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsSubTypeMle(void) const; /** - * This method checks whether this multicast message may be looped back. + * Checks whether this multicast message may be looped back. * * @retval TRUE If message may be looped back. * @retval FALSE If message must not be looped back. @@ -535,7 +535,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool GetMulticastLoop(void) const { return GetMetadata().mMulticastLoop; } /** - * This method sets whether multicast may be looped back. + * Sets whether multicast may be looped back. * * @param[in] aMulticastLoop Whether allow looping back multicast. * @@ -543,7 +543,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetMulticastLoop(bool aMulticastLoop) { GetMetadata().mMulticastLoop = aMulticastLoop; } /** - * This method returns the message priority level. + * Returns the message priority level. * * @returns The priority level associated with this message. * @@ -551,7 +551,7 @@ class Message : public otMessage, public Buffer, public GetProvider Priority GetPriority(void) const { return static_cast(GetMetadata().mPriority); } /** - * This method sets the messages priority. + * Sets the messages priority. * If the message is already queued in a priority queue, changing the priority ensures to * update the message in the associated queue. * @@ -564,7 +564,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error SetPriority(Priority aPriority); /** - * This static method convert a `Priority` to a string. + * Convert a `Priority` to a string. * * @param[in] aPriority The priority level. * @@ -574,7 +574,7 @@ class Message : public otMessage, public Buffer, public GetProvider static const char *PriorityToString(Priority aPriority); /** - * This method prepends bytes to the front of the message. + * Prepends bytes to the front of the message. * * On success, this method grows the message by @p aLength bytes. * @@ -588,7 +588,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error PrependBytes(const void *aBuf, uint16_t aLength); /** - * This method prepends an object to the front of the message. + * Prepends an object to the front of the message. * * On success, this method grows the message by the size of the object. * @@ -608,7 +608,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method removes header bytes from the message at start of message. + * Removes header bytes from the message at start of message. * * The caller MUST ensure that message contains the bytes to be removed, i.e. `aOffset` is smaller than the message * length. @@ -619,9 +619,9 @@ class Message : public otMessage, public Buffer, public GetProvider void RemoveHeader(uint16_t aLength); /** - * This method removes header bytes from the message at a given offset. + * Removes header bytes from the message at a given offset. * - * This method shrinks the message. The existing header bytes before @p aOffset are copied forward and replace the + * Shrinks the message. The existing header bytes before @p aOffset are copied forward and replace the * removed bytes. * * The caller MUST ensure that message contains the bytes to be removed, i.e. `aOffset + aLength` is smaller than @@ -634,9 +634,9 @@ class Message : public otMessage, public Buffer, public GetProvider void RemoveHeader(uint16_t aOffset, uint16_t aLength); /** - * This method grows the message to make space for new header bytes at a given offset. + * Grows the message to make space for new header bytes at a given offset. * - * This method grows the message header (similar to `PrependBytes()`). The existing header bytes from start to + * Grows the message header (similar to `PrependBytes()`). The existing header bytes from start to * `aOffset + aLength` are then copied backward to make room for the new header bytes. Note that this method does * not change the bytes from @p aOffset up @p aLength (the new inserted header range). Caller can write to this * range to update the bytes after successful return from this method. @@ -651,7 +651,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error InsertHeader(uint16_t aOffset, uint16_t aLength); /** - * This method appends bytes to the end of the message. + * Appends bytes to the end of the message. * * On success, this method grows the message by @p aLength bytes. * @@ -665,7 +665,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error AppendBytes(const void *aBuf, uint16_t aLength); /** - * This method appends bytes read from another or potentially the same message to the end of the current message. + * Appends bytes read from another or potentially the same message to the end of the current message. * * On success, this method grows the message by @p aLength bytes. * @@ -681,7 +681,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error AppendBytesFromMessage(const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method appends an object to the end of the message. + * Appends an object to the end of the message. * * On success, this method grows the message by the size of the appended object * @@ -701,7 +701,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method appends bytes from a given `Data` instance to the end of the message. + * Appends bytes from a given `Data` instance to the end of the message. * * On success, this method grows the message by the size of the appended data. * @@ -719,7 +719,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method reads bytes from the message. + * Reads bytes from the message. * * @param[in] aOffset Byte offset within the message to begin reading. * @param[out] aBuf A pointer to a data buffer to copy the read bytes into. @@ -731,7 +731,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint16_t ReadBytes(uint16_t aOffset, void *aBuf, uint16_t aLength) const; /** - * This method reads a given number of bytes from the message. + * Reads a given number of bytes from the message. * * If there are fewer bytes available in the message than the requested read length, the available bytes will be * read and copied into @p aBuf. In this case `kErrorParse` will be returned. @@ -747,7 +747,7 @@ class Message : public otMessage, public Buffer, public GetProvider Error Read(uint16_t aOffset, void *aBuf, uint16_t aLength) const; /** - * This method reads an object from the message. + * Reads an object from the message. * * If there are fewer bytes available in the message than the requested object size, the available bytes will be * read and copied into @p aObject (@p aObject will be read partially). In this case `kErrorParse` will @@ -770,7 +770,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method compares the bytes in the message at a given offset with a given byte array. + * Compares the bytes in the message at a given offset with a given byte array. * * If there are fewer bytes available in the message than the requested @p aLength, the comparison is treated as * failure (returns FALSE). @@ -788,7 +788,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool CompareBytes(uint16_t aOffset, const void *aBuf, uint16_t aLength, ByteMatcher aMatcher = nullptr) const; /** - * This method compares the bytes in the message at a given offset with bytes read from another message. + * Compares the bytes in the message at a given offset with bytes read from another message. * * If either message has fewer bytes available than the requested @p aLength, the comparison is treated as failure * (returns FALSE). @@ -810,7 +810,7 @@ class Message : public otMessage, public Buffer, public GetProvider ByteMatcher aMatcher = nullptr) const; /** - * This method compares the bytes in the message at a given offset with an object. + * Compares the bytes in the message at a given offset with an object. * * The bytes in the message are compared with the bytes in @p aObject. If there are fewer bytes available in the * message than the requested object size, it is treated as failed comparison (returns FALSE). @@ -832,9 +832,9 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method writes bytes to the message. + * Writes bytes to the message. * - * This method will not resize the message. The given data to write (with @p aLength bytes) MUST fit within the + * Will not resize the message. The given data to write (with @p aLength bytes) MUST fit within the * existing message buffer (from the given offset @p aOffset up to the message's length). * * @param[in] aOffset Byte offset within the message to begin writing. @@ -845,12 +845,12 @@ class Message : public otMessage, public Buffer, public GetProvider void WriteBytes(uint16_t aOffset, const void *aBuf, uint16_t aLength); /** - * This method writes bytes read from another or potentially the same message to the message at a given offset. + * Writes bytes read from another or potentially the same message to the message at a given offset. * - * This method will not resize the message. The bytes to write (with @p aLength) MUST fit within the existing + * Will not resize the message. The bytes to write (with @p aLength) MUST fit within the existing * message buffer (from the given @p aWriteOffset up to the message's length). * - * This method can be used to copy bytes within the same message in either direction, i.e., copy forward where + * Can be used to copy bytes within the same message in either direction, i.e., copy forward where * `aWriteOffset > aReadOffset` or copy backward where `aWriteOffset < aReadOffset`. * * @param[in] aWriteOffset Byte offset within this message to begin writing. @@ -862,9 +862,9 @@ class Message : public otMessage, public Buffer, public GetProvider void WriteBytesFromMessage(uint16_t aWriteOffset, const Message &aMessage, uint16_t aReadOffset, uint16_t aLength); /** - * This methods writes an object to the message. + * Writes an object to the message. * - * This method will not resize the message. The entire given object (all its bytes) MUST fit within the existing + * Will not resize the message. The entire given object (all its bytes) MUST fit within the existing * message buffer (from the given offset @p aOffset up to the message's length). * * @tparam ObjectType The object type to write to the message. @@ -881,9 +881,9 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method writes bytes from a given `Data` instance to the message. + * Writes bytes from a given `Data` instance to the message. * - * This method will not resize the message. The given data to write MUST fit within the existing message buffer + * Will not resize the message. The given data to write MUST fit within the existing message buffer * (from the given offset @p aOffset up to the message's length). * * @tparam kDataLengthType Determines the data length type (`uint8_t` or `uint16_t`). @@ -898,7 +898,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method creates a copy of the message. + * Creates a copy of the message. * * It allocates the new message from the same message pool as the original one and copies @p aLength octets * of the payload. The `Type`, `SubType`, `LinkSecurity`, `Offset`, `InterfaceId`, and `Priority` fields on the @@ -912,7 +912,7 @@ class Message : public otMessage, public Buffer, public GetProvider Message *Clone(uint16_t aLength) const; /** - * This method creates a copy of the message. + * Creates a copy of the message. * * It allocates the new message from the same message pool as the original one and copies the entire payload. The * `Type`, `SubType`, `LinkSecurity`, `Offset`, `InterfaceId`, and `Priority` fields on the cloned message are also @@ -924,7 +924,7 @@ class Message : public otMessage, public Buffer, public GetProvider Message *Clone(void) const { return Clone(GetLength()); } /** - * This method returns the datagram tag used for 6LoWPAN fragmentation or the identification used for IPv6 + * Returns the datagram tag used for 6LoWPAN fragmentation or the identification used for IPv6 * fragmentation. * * @returns The 6LoWPAN datagram tag or the IPv6 fragment identification. @@ -933,7 +933,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint32_t GetDatagramTag(void) const { return GetMetadata().mDatagramTag; } /** - * This method sets the datagram tag used for 6LoWPAN fragmentation. + * Sets the datagram tag used for 6LoWPAN fragmentation. * * @param[in] aTag The 6LoWPAN datagram tag. * @@ -941,7 +941,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetDatagramTag(uint32_t aTag) { GetMetadata().mDatagramTag = aTag; } /** - * This method returns whether or not the message forwarding is scheduled for the child. + * Returns whether or not the message forwarding is scheduled for the child. * * @param[in] aChildIndex The index into the child table. * @@ -952,7 +952,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool GetChildMask(uint16_t aChildIndex) const; /** - * This method unschedules forwarding of the message to the child. + * Unschedules forwarding of the message to the child. * * @param[in] aChildIndex The index into the child table. * @@ -960,7 +960,7 @@ class Message : public otMessage, public Buffer, public GetProvider void ClearChildMask(uint16_t aChildIndex); /** - * This method schedules forwarding of the message to the child. + * Schedules forwarding of the message to the child. * * @param[in] aChildIndex The index into the child table. * @@ -968,7 +968,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetChildMask(uint16_t aChildIndex); /** - * This method returns whether or not the message forwarding is scheduled for at least one child. + * Returns whether or not the message forwarding is scheduled for at least one child. * * @retval TRUE If message forwarding is scheduled for at least one child. * @retval FALSE If message forwarding is not scheduled for any child. @@ -977,7 +977,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsChildPending(void) const; /** - * This method returns the RLOC16 of the mesh destination. + * Returns the RLOC16 of the mesh destination. * * @note Only use this for non-link-local unicast messages. * @@ -987,7 +987,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint16_t GetMeshDest(void) const { return GetMetadata().mMeshDest; } /** - * This method sets the RLOC16 of the mesh destination. + * Sets the RLOC16 of the mesh destination. * * @note Only use this when sending non-link-local unicast messages. * @@ -997,7 +997,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetMeshDest(uint16_t aMeshDest) { GetMetadata().mMeshDest = aMeshDest; } /** - * This method returns the IEEE 802.15.4 Destination PAN ID. + * Returns the IEEE 802.15.4 Destination PAN ID. * * @note Only use this when sending MLE Discover Request or Response messages. * @@ -1007,7 +1007,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint16_t GetPanId(void) const { return GetMetadata().mPanId; } /** - * This method sets the IEEE 802.15.4 Destination PAN ID. + * Sets the IEEE 802.15.4 Destination PAN ID. * * @note Only use this when sending MLE Discover Request or Response messages. * @@ -1017,7 +1017,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetPanId(uint16_t aPanId) { GetMetadata().mPanId = aPanId; } /** - * This method returns the IEEE 802.15.4 Channel to use for transmission. + * Returns the IEEE 802.15.4 Channel to use for transmission. * * @note Only use this when sending MLE Announce messages. * @@ -1027,7 +1027,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint8_t GetChannel(void) const { return GetMetadata().mChannel; } /** - * This method sets the IEEE 802.15.4 Channel to use for transmission. + * Sets the IEEE 802.15.4 Channel to use for transmission. * * @note Only use this when sending MLE Announce messages. * @@ -1037,7 +1037,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetChannel(uint8_t aChannel) { GetMetadata().mChannel = aChannel; } /** - * This method returns the message timestamp. + * Returns the message timestamp. * * @returns The message timestamp. * @@ -1045,7 +1045,7 @@ class Message : public otMessage, public Buffer, public GetProvider TimeMilli GetTimestamp(void) const { return GetMetadata().mTimestamp; } /** - * This method sets the message timestamp to a given time. + * Sets the message timestamp to a given time. * * @param[in] aTimestamp The timestamp value. * @@ -1053,13 +1053,13 @@ class Message : public otMessage, public Buffer, public GetProvider void SetTimestamp(TimeMilli aTimestamp) { GetMetadata().mTimestamp = aTimestamp; } /** - * This method sets the message timestamp to the current time. + * Sets the message timestamp to the current time. * */ void SetTimestampToNow(void) { SetTimestamp(TimerMilli::GetNow()); } /** - * This method returns whether or not message forwarding is scheduled for direct transmission. + * Returns whether or not message forwarding is scheduled for direct transmission. * * @retval TRUE If message forwarding is scheduled for direct transmission. * @retval FALSE If message forwarding is not scheduled for direct transmission. @@ -1068,19 +1068,19 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsDirectTransmission(void) const { return GetMetadata().mDirectTx; } /** - * This method unschedules forwarding using direct transmission. + * Unschedules forwarding using direct transmission. * */ void ClearDirectTransmission(void) { GetMetadata().mDirectTx = false; } /** - * This method schedules forwarding using direct transmission. + * Schedules forwarding using direct transmission. * */ void SetDirectTransmission(void) { GetMetadata().mDirectTx = true; } /** - * This method indicates whether the direct transmission of message was successful. + * Indicates whether the direct transmission of message was successful. * * @retval TRUE If direct transmission of message was successful (all fragments were delivered and acked). * @retval FALSE If direct transmission of message failed (at least one fragment failed). @@ -1089,7 +1089,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool GetTxSuccess(void) const { return GetMetadata().mTxSuccess; } /** - * This method sets whether the direct transmission of message was successful. + * Sets whether the direct transmission of message was successful. * * @param[in] aTxSuccess TRUE if the direct transmission is successful, FALSE otherwise (i.e., at least one * fragment transmission failed). @@ -1098,7 +1098,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetTxSuccess(bool aTxSuccess) { GetMetadata().mTxSuccess = aTxSuccess; } /** - * This method indicates whether the message may be evicted. + * Indicates whether the message may be evicted. * * @retval TRUE If the message must not be evicted. * @retval FALSE If the message may be evicted. @@ -1107,7 +1107,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool GetDoNotEvict(void) const { return GetMetadata().mDoNotEvict; } /** - * This method sets whether the message may be evicted. + * Sets whether the message may be evicted. * * @param[in] aDoNotEvict TRUE if the message may not be evicted, FALSE otherwise. * @@ -1115,7 +1115,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetDoNotEvict(bool aDoNotEvict) { GetMetadata().mDoNotEvict = aDoNotEvict; } /** - * This method indicates whether the message is waiting for an address query resolution. + * Indicates whether the message is waiting for an address query resolution. * * @retval TRUE If the message is waiting for address query resolution. * @retval FALSE If the message is not waiting for address query resolution. @@ -1124,7 +1124,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsResolvingAddress(void) const { return GetMetadata().mResolvingAddress; } /** - * This method sets whether the message is waiting for an address query resolution. + * Sets whether the message is waiting for an address query resolution. * * @param[in] aResolvingAddress TRUE if message is waiting for address resolution, FALSE otherwise. * @@ -1132,7 +1132,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetResolvingAddress(bool aResolvingAddress) { GetMetadata().mResolvingAddress = aResolvingAddress; } /** - * This method indicates whether or not link security is enabled for the message. + * Indicates whether or not link security is enabled for the message. * * @retval TRUE If link security is enabled. * @retval FALSE If link security is not enabled. @@ -1141,7 +1141,7 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsLinkSecurityEnabled(void) const { return GetMetadata().mLinkSecurity; } /** - * This method sets whether or not link security is enabled for the message. + * Sets whether or not link security is enabled for the message. * * @param[in] aEnabled TRUE if link security is enabled, FALSE otherwise. * @@ -1149,7 +1149,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetLinkSecurityEnabled(bool aEnabled) { GetMetadata().mLinkSecurity = aEnabled; } /** - * This method updates the average RSS (Received Signal Strength) associated with the message by adding the given + * Updates the average RSS (Received Signal Strength) associated with the message by adding the given * RSS value to the average. Note that a message can be composed of multiple 802.15.4 data frame fragments each * received with a different signal strength. * @@ -1159,7 +1159,7 @@ class Message : public otMessage, public Buffer, public GetProvider void AddRss(int8_t aRss) { IgnoreError(GetMetadata().mRssAverager.Add(aRss)); } /** - * This method returns the average RSS (Received Signal Strength) associated with the message. + * Returns the average RSS (Received Signal Strength) associated with the message. * * @returns The current average RSS value (in dBm) or `Radio::kInvalidRssi` if no average is available. * @@ -1167,7 +1167,7 @@ class Message : public otMessage, public Buffer, public GetProvider int8_t GetAverageRss(void) const { return GetMetadata().mRssAverager.GetAverage(); } /** - * This method returns a const reference to RssAverager of the message. + * Returns a const reference to RssAverager of the message. * * @returns A const reference to the RssAverager of the message. * @@ -1176,7 +1176,7 @@ class Message : public otMessage, public Buffer, public GetProvider #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method updates the average LQI (Link Quality Indicator) associated with the message. + * Updates the average LQI (Link Quality Indicator) associated with the message. * * The given LQI value would be added to the average. Note that a message can be composed of multiple 802.15.4 * frame fragments each received with a different signal strength. @@ -1187,7 +1187,7 @@ class Message : public otMessage, public Buffer, public GetProvider void AddLqi(uint8_t aLqi) { GetMetadata().mLqiAverager.Add(aLqi); } /** - * This method returns the average LQI (Link Quality Indicator) associated with the message. + * Returns the average LQI (Link Quality Indicator) associated with the message. * * @returns The current average LQI value (in dBm) or OT_RADIO_LQI_NONE if no average is available. * @@ -1195,7 +1195,7 @@ class Message : public otMessage, public Buffer, public GetProvider uint8_t GetAverageLqi(void) const { return GetMetadata().mLqiAverager.GetAverage(); } /** - * This method returns the count of frames counted so far. + * Returns the count of frames counted so far. * * @returns The count of frames that have been counted. * @@ -1204,7 +1204,7 @@ class Message : public otMessage, public Buffer, public GetProvider #endif /** - * This method sets the message's link info properties (PAN ID, link security, RSS) from a given `ThreadLinkInfo`. + * Sets the message's link info properties (PAN ID, link security, RSS) from a given `ThreadLinkInfo`. * * @param[in] aLinkInfo The `ThreadLinkInfo` instance from which to set message's related properties. * @@ -1212,7 +1212,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetLinkInfo(const ThreadLinkInfo &aLinkInfo); /** - * This method returns a pointer to the message queue (if any) where this message is queued. + * Returns a pointer to the message queue (if any) where this message is queued. * * @returns A pointer to the message queue or `nullptr` if not in any message queue. * @@ -1223,7 +1223,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method returns a pointer to the priority message queue (if any) where this message is queued. + * Returns a pointer to the priority message queue (if any) where this message is queued. * * @returns A pointer to the priority queue or `nullptr` if not in any priority queue. * @@ -1234,7 +1234,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method indicates whether or not the message is also used for time sync purpose. + * Indicates whether or not the message is also used for time sync purpose. * * When OPENTHREAD_CONFIG_TIME_SYNC_ENABLE is 0, this method always return false. * @@ -1246,7 +1246,7 @@ class Message : public otMessage, public Buffer, public GetProvider #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method sets whether or not the message is also used for time sync purpose. + * Sets whether or not the message is also used for time sync purpose. * * @param[in] aEnabled TRUE if the message is also used for time sync purpose, FALSE otherwise. * @@ -1254,7 +1254,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetTimeSync(bool aEnabled) { GetMetadata().mTimeSync = aEnabled; } /** - * This method sets the offset to network time. + * Sets the offset to network time. * * @param[in] aNetworkTimeOffset The offset to network time. * @@ -1262,7 +1262,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetNetworkTimeOffset(int64_t aNetworkTimeOffset) { GetMetadata().mNetworkTimeOffset = aNetworkTimeOffset; } /** - * This method gets the offset to network time. + * Gets the offset to network time. * * @returns The offset to network time. * @@ -1270,7 +1270,7 @@ class Message : public otMessage, public Buffer, public GetProvider int64_t GetNetworkTimeOffset(void) const { return GetMetadata().mNetworkTimeOffset; } /** - * This method sets the time sync sequence. + * Sets the time sync sequence. * * @param[in] aTimeSyncSeq The time sync sequence. * @@ -1278,7 +1278,7 @@ class Message : public otMessage, public Buffer, public GetProvider void SetTimeSyncSeq(uint8_t aTimeSyncSeq) { GetMetadata().mTimeSyncSeq = aTimeSyncSeq; } /** - * This method gets the time sync sequence. + * Gets the time sync sequence. * * @returns The time sync sequence. * @@ -1288,7 +1288,7 @@ class Message : public otMessage, public Buffer, public GetProvider #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method indicates whether the radio type is set. + * Indicates whether the radio type is set. * * @retval TRUE If the radio type is set. * @retval FALSE If the radio type is not set. @@ -1297,9 +1297,9 @@ class Message : public otMessage, public Buffer, public GetProvider bool IsRadioTypeSet(void) const { return GetMetadata().mIsRadioTypeSet; } /** - * This method gets the radio link type the message was received on, or should be sent on. + * Gets the radio link type the message was received on, or should be sent on. * - * This method should be used only when `IsRadioTypeSet()` returns `true`. + * Should be used only when `IsRadioTypeSet()` returns `true`. * * @returns The radio link type of the message. * @@ -1307,7 +1307,7 @@ class Message : public otMessage, public Buffer, public GetProvider Mac::RadioType GetRadioType(void) const { return static_cast(GetMetadata().mRadioType); } /** - * This method sets the radio link type the message was received on, or should be sent on. + * Sets the radio link type the message was received on, or should be sent on. * * @param[in] aRadioType A radio link type of the message. * @@ -1319,7 +1319,7 @@ class Message : public otMessage, public Buffer, public GetProvider } /** - * This method clears any previously set radio type on the message. + * Clears any previously set radio type on the message. * * After calling this method, `IsRadioTypeSet()` returns false until radio type is set (`SetRadioType()`). * @@ -1419,7 +1419,7 @@ class Message : public otMessage, public Buffer, public GetProvider }; /** - * This class implements a message queue. + * Implements a message queue. * */ class MessageQueue : public otMessageQueue @@ -1431,7 +1431,7 @@ class MessageQueue : public otMessageQueue typedef otMessageQueueInfo Info; ///< This struct represents info (number of messages/buffers) about a queue. /** - * This enumeration represents a position (head or tail) in the queue. This is used to specify where a new message + * Represents a position (head or tail) in the queue. This is used to specify where a new message * should be added in the queue. * */ @@ -1442,13 +1442,13 @@ class MessageQueue : public otMessageQueue }; /** - * This constructor initializes the message queue. + * Initializes the message queue. * */ MessageQueue(void) { SetTail(nullptr); } /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -1456,7 +1456,7 @@ class MessageQueue : public otMessageQueue Message *GetHead(void) { return Message::NextOf(GetTail()); } /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -1464,7 +1464,7 @@ class MessageQueue : public otMessageQueue const Message *GetHead(void) const { return Message::NextOf(GetTail()); } /** - * This method adds a message to the end of the list. + * Adds a message to the end of the list. * * @param[in] aMessage The message to add. * @@ -1472,7 +1472,7 @@ class MessageQueue : public otMessageQueue void Enqueue(Message &aMessage) { Enqueue(aMessage, kQueuePositionTail); } /** - * This method adds a message at a given position (head/tail) of the list. + * Adds a message at a given position (head/tail) of the list. * * @param[in] aMessage The message to add. * @param[in] aPosition The position (head or tail) where to add the message. @@ -1481,7 +1481,7 @@ class MessageQueue : public otMessageQueue void Enqueue(Message &aMessage, QueuePosition aPosition); /** - * This method removes a message from the list. + * Removes a message from the list. * * @param[in] aMessage The message to remove. * @@ -1489,7 +1489,7 @@ class MessageQueue : public otMessageQueue void Dequeue(Message &aMessage); /** - * This method removes a message from the queue and frees it. + * Removes a message from the queue and frees it. * * @param[in] aMessage The message to remove and free. * @@ -1497,15 +1497,15 @@ class MessageQueue : public otMessageQueue void DequeueAndFree(Message &aMessage); /** - * This method removes and frees all messages from the queue. + * Removes and frees all messages from the queue. * */ void DequeueAndFreeAll(void); /** - * This method gets the information about number of messages and buffers in the queue. + * Gets the information about number of messages and buffers in the queue. * - * This method updates `aInfo` and adds number of message/buffers in the message queue to the corresponding member + * Updates `aInfo` and adds number of message/buffers in the message queue to the corresponding member * variable in `aInfo`. The caller needs to make sure `aInfo` is initialized before calling this method (e.g., * clearing `aInfo`). Same `aInfo` can be passed in multiple calls of `GetInfo(aInfo)` on different queues to add * up the number of messages/buffers on different queues. @@ -1533,7 +1533,7 @@ class MessageQueue : public otMessageQueue }; /** - * This class implements a priority queue. + * Implements a priority queue. * */ class PriorityQueue : private Clearable @@ -1547,13 +1547,13 @@ class PriorityQueue : private Clearable typedef otMessageQueueInfo Info; ///< This struct represents info (number of messages/buffers) about a queue. /** - * This constructor initializes the priority queue. + * Initializes the priority queue. * */ PriorityQueue(void) { Clear(); } /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -1561,7 +1561,7 @@ class PriorityQueue : private Clearable Message *GetHead(void) { return AsNonConst(AsConst(this)->GetHead()); } /** - * This method returns a pointer to the first message. + * Returns a pointer to the first message. * * @returns A pointer to the first message. * @@ -1569,7 +1569,7 @@ class PriorityQueue : private Clearable const Message *GetHead(void) const; /** - * This method returns a pointer to the first message for a given priority level. + * Returns a pointer to the first message for a given priority level. * * @param[in] aPriority Priority level. * @@ -1583,7 +1583,7 @@ class PriorityQueue : private Clearable } /** - * This method returns a pointer to the first message for a given priority level. + * Returns a pointer to the first message for a given priority level. * * @param[in] aPriority Priority level. * @@ -1594,7 +1594,7 @@ class PriorityQueue : private Clearable const Message *GetHeadForPriority(Message::Priority aPriority) const; /** - * This method adds a message to the queue. + * Adds a message to the queue. * * @param[in] aMessage The message to add. * @@ -1602,7 +1602,7 @@ class PriorityQueue : private Clearable void Enqueue(Message &aMessage); /** - * This method removes a message from the list. + * Removes a message from the list. * * @param[in] aMessage The message to remove. * @@ -1610,7 +1610,7 @@ class PriorityQueue : private Clearable void Dequeue(Message &aMessage); /** - * This method removes a message from the queue and frees it. + * Removes a message from the queue and frees it. * * @param[in] aMessage The message to remove and free. * @@ -1618,13 +1618,13 @@ class PriorityQueue : private Clearable void DequeueAndFree(Message &aMessage); /** - * This method removes and frees all messages from the queue. + * Removes and frees all messages from the queue. * */ void DequeueAndFreeAll(void); /** - * This method returns the tail of the list (last message in the list). + * Returns the tail of the list (last message in the list). * * @returns A pointer to the tail of the list. * @@ -1632,7 +1632,7 @@ class PriorityQueue : private Clearable Message *GetTail(void) { return AsNonConst(AsConst(this)->GetTail()); } /** - * This method returns the tail of the list (last message in the list). + * Returns the tail of the list (last message in the list). * * @returns A pointer to the tail of the list. * @@ -1640,9 +1640,9 @@ class PriorityQueue : private Clearable const Message *GetTail(void) const; /** - * This method gets the information about number of messages and buffers in the priority queue. + * Gets the information about number of messages and buffers in the priority queue. * - * This method updates `aInfo` array and adds number of message/buffers in the message queue to the corresponding + * Updates `aInfo` array and adds number of message/buffers in the message queue to the corresponding * member variable in `aInfo`. The caller needs to make sure `aInfo` is initialized before calling this method * (e.g., clearing `aInfo`). Same `aInfo` can be passed in multiple calls of `GetInfo(aInfo)` on different queues * to add up the number of messages/buffers on different queues. @@ -1680,7 +1680,7 @@ class PriorityQueue : private Clearable }; /** - * This class represents a message pool + * Represents a message pool * */ class MessagePool : public InstanceLocator, private NonCopyable @@ -1691,13 +1691,13 @@ class MessagePool : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit MessagePool(Instance &aInstance); /** - * This method allocates a new message with specified settings. + * Allocates a new message with specified settings. * * @param[in] aType The message type. * @param[in] aReserveHeader The number of header bytes to reserve. @@ -1709,7 +1709,7 @@ class MessagePool : public InstanceLocator, private NonCopyable Message *Allocate(Message::Type aType, uint16_t aReserveHeader, const Message::Settings &aSettings); /** - * This method allocates a new message of a given type using default settings. + * Allocates a new message of a given type using default settings. * * @param[in] aType The message type. * @@ -1719,7 +1719,7 @@ class MessagePool : public InstanceLocator, private NonCopyable Message *Allocate(Message::Type aType); /** - * This method allocates a new message with a given type and reserved length using default settings. + * Allocates a new message with a given type and reserved length using default settings. * * @param[in] aType The message type. * @param[in] aReserveHeader The number of header bytes to reserve. @@ -1730,7 +1730,7 @@ class MessagePool : public InstanceLocator, private NonCopyable Message *Allocate(Message::Type aType, uint16_t aReserveHeader); /** - * This method is used to free a message and return all message buffers to the buffer pool. + * Is used to free a message and return all message buffers to the buffer pool. * * @param[in] aMessage The message to free. * @@ -1738,7 +1738,7 @@ class MessagePool : public InstanceLocator, private NonCopyable void Free(Message *aMessage); /** - * This method returns the number of free buffers. + * Returns the number of free buffers. * * @returns The number of free buffers, or 0xffff (UINT16_MAX) if number is unknown. * @@ -1746,7 +1746,7 @@ class MessagePool : public InstanceLocator, private NonCopyable uint16_t GetFreeBufferCount(void) const; /** - * This method returns the total number of buffers. + * Returns the total number of buffers. * * @returns The total number of buffers, or 0xffff (UINT16_MAX) if number is unknown. * @@ -1754,7 +1754,7 @@ class MessagePool : public InstanceLocator, private NonCopyable uint16_t GetTotalBufferCount(void) const; /** - * This method returns the maximum number of buffers in use at the same time since OT stack initialization or + * Returns the maximum number of buffers in use at the same time since OT stack initialization or * since last call to `ResetMaxUsedBufferCount()`. * * @returns The maximum number of buffers in use at the same time so far (buffer allocation watermark). @@ -1763,7 +1763,7 @@ class MessagePool : public InstanceLocator, private NonCopyable uint16_t GetMaxUsedBufferCount(void) const { return mMaxAllocated; } /** - * This method resets the tracked maximum number of buffers in use. + * Resets the tracked maximum number of buffers in use. * * @sa GetMaxUsedBufferCount * diff --git a/src/core/common/non_copyable.hpp b/src/core/common/non_copyable.hpp index b6e44feada1..bc6fb42f8de 100644 --- a/src/core/common/non_copyable.hpp +++ b/src/core/common/non_copyable.hpp @@ -37,7 +37,7 @@ namespace ot { /** - * This class makes any class that derives from it non-copyable. It is intended to be used as a private base class. + * Makes any class that derives from it non-copyable. It is intended to be used as a private base class. * */ class NonCopyable diff --git a/src/core/common/notifier.cpp b/src/core/common/notifier.cpp index 4cc5a9634cb..706350bba18 100644 --- a/src/core/common/notifier.cpp +++ b/src/core/common/notifier.cpp @@ -271,6 +271,7 @@ const char *Notifier::EventToString(Event aEvent) const "JoinerState", // kEventJoinerStateChanged (1 << 27) "ActDset", // kEventActiveDatasetChanged (1 << 28) "PndDset", // kEventPendingDatasetChanged (1 << 29) + "Nat64", // kEventNat64TranslatorStateChanged (1 << 30) }; for (uint8_t index = 0; index < GetArrayLength(kEventStrings); index++) diff --git a/src/core/common/notifier.hpp b/src/core/common/notifier.hpp index cd05f2dc538..02efc21d3c9 100644 --- a/src/core/common/notifier.hpp +++ b/src/core/common/notifier.hpp @@ -61,7 +61,7 @@ namespace ot { */ /** - * This enumeration type represents events emitted from OpenThread Notifier. + * Type represents events emitted from OpenThread Notifier. * */ enum Event : uint32_t @@ -100,20 +100,20 @@ enum Event : uint32_t }; /** - * This type represents a list of events. + * Represents a list of events. * */ class Events { public: /** - * This type represents a bit-field indicating a list of events (with values from `Event`) + * Represents a bit-field indicating a list of events (with values from `Event`) * */ typedef otChangedFlags Flags; /** - * This constructor initializes the `Events` list (as empty). + * Initializes the `Events` list (as empty). * */ Events(void) @@ -122,13 +122,13 @@ class Events } /** - * This method clears the `Events` list. + * Clears the `Events` list. * */ void Clear(void) { mEventFlags = 0; } /** - * This method indicates whether the `Events` list contains a given event. + * Indicates whether the `Events` list contains a given event. * * @param[in] aEvent The event to check. * @@ -138,7 +138,7 @@ class Events bool Contains(Event aEvent) const { return (mEventFlags & aEvent) != 0; } /** - * This method indicates whether the `Events` list contains any of a given set of events. + * Indicates whether the `Events` list contains any of a given set of events. * * @param[in] aEvents The events set to check (must be a collection of `Event` constants combined using `|`). * @@ -148,7 +148,7 @@ class Events bool ContainsAny(Flags aEvents) const { return (mEventFlags & aEvents) != 0; } /** - * This method indicates whether the `Events` list contains all of a given set of events. + * Indicates whether the `Events` list contains all of a given set of events. * * @param[in] aEvents The events set to check (must be collection of `Event` constants combined using `|`). * @@ -158,7 +158,7 @@ class Events bool ContainsAll(Flags aEvents) const { return (mEventFlags & aEvents) == aEvents; } /** - * This method adds a given event to the `Events` list. + * Adds a given event to the `Events` list. * * @param[in] aEvent The event to add. * @@ -166,7 +166,7 @@ class Events void Add(Event aEvent) { mEventFlags |= aEvent; } /** - * This method indicates whether the `Events` list is empty. + * Indicates whether the `Events` list is empty. * * @returns TRUE if the list is empty, FALSE otherwise. * @@ -174,7 +174,7 @@ class Events bool IsEmpty(void) const { return (mEventFlags == 0); } /** - * This method gets the `Events` list as bit-field `Flags` value. + * Gets the `Events` list as bit-field `Flags` value. * * @returns The list as bit-field `Flags` value. * @@ -186,7 +186,7 @@ class Events }; /** - * This class implements the OpenThread Notifier. + * Implements the OpenThread Notifier. * * For core internal modules, `Notifier` class emits events directly to them by invoking method `HandleNotifierEvents()` * on the module instance. @@ -200,7 +200,7 @@ class Notifier : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes a `Notifier` instance. + * Initializes a `Notifier` instance. * * @param[in] aInstance A reference to OpenThread instance. * @@ -208,7 +208,7 @@ class Notifier : public InstanceLocator, private NonCopyable explicit Notifier(Instance &aInstance); /** - * This method registers an `otStateChangedCallback` handler. + * Registers an `otStateChangedCallback` handler. * * @param[in] aCallback A pointer to the handler function that is called to notify of the changes. * @param[in] aContext A pointer to arbitrary context information. @@ -221,7 +221,7 @@ class Notifier : public InstanceLocator, private NonCopyable Error RegisterCallback(otStateChangedCallback aCallback, void *aContext); /** - * This method removes/unregisters a previously registered `otStateChangedCallback` handler. + * Removes/unregisters a previously registered `otStateChangedCallback` handler. * * @param[in] aCallback A pointer to the callback function pointer. * @param[in] aContext A pointer to arbitrary context information. @@ -230,7 +230,7 @@ class Notifier : public InstanceLocator, private NonCopyable void RemoveCallback(otStateChangedCallback aCallback, void *aContext); /** - * This method schedules signaling of an event. + * Schedules signaling of an event. * * @param[in] aEvent The event to signal. * @@ -238,7 +238,7 @@ class Notifier : public InstanceLocator, private NonCopyable void Signal(Event aEvent); /** - * This method schedules signaling of am event only if the event has not been signaled before (first time signal). + * Schedules signaling of am event only if the event has not been signaled before (first time signal). * * @param[in] aEvent The event to signal. * @@ -246,7 +246,7 @@ class Notifier : public InstanceLocator, private NonCopyable void SignalIfFirst(Event aEvent); /** - * This method indicates whether or not an event signal callback is pending/scheduled. + * Indicates whether or not an event signal callback is pending/scheduled. * * @returns TRUE if a callback is pending, FALSE otherwise. * @@ -254,7 +254,7 @@ class Notifier : public InstanceLocator, private NonCopyable bool IsPending(void) const { return !mEventsToSignal.IsEmpty(); } /** - * This method indicates whether or not an event has been signaled before. + * Indicates whether or not an event has been signaled before. * * @param[in] aEvent The event to check. * @@ -265,7 +265,7 @@ class Notifier : public InstanceLocator, private NonCopyable bool HasSignaled(Event aEvent) const { return mSignaledEvents.Contains(aEvent); } /** - * This template method updates a variable of a type `Type` with a new value and signals the given event. + * Updates a variable of a type `Type` with a new value and signals the given event. * * If the variable is already set to the same value, this method returns `kErrorAlready` and the event is * signaled using `SignalIfFirst()` (i.e., signal is scheduled only if event has not been signaled before). diff --git a/src/core/common/num_utils.hpp b/src/core/common/num_utils.hpp index dff0ce11355..598324098ba 100644 --- a/src/core/common/num_utils.hpp +++ b/src/core/common/num_utils.hpp @@ -131,6 +131,29 @@ template uint16_t ClampToUint16(UintType aValue) return static_cast(Min(aValue, static_cast(NumericLimits::kMax))); } +/** + * Returns a clamped version of given integer to a `int8_t`. + * + * If @p aValue is smaller than min value of a `int8_t`, the min value of `int8_t` is returned. + * If @p aValue is larger than max value of a `int8_t`, the max value of `int8_t` is returned. + * + * @tparam IntType The value type (MUST be `int16_t`, `int32_t`, or `int64_t`). + * + * @param[in] aValue The value to clamp. + * + * @returns The clamped version of @p aValue to `int8_t`. + * + */ +template int8_t ClampToInt8(IntType aValue) +{ + static_assert(TypeTraits::IsSame::kValue || TypeTraits::IsSame::kValue || + TypeTraits::IsSame::kValue, + "IntType must be `int16_t, `int32_t`, or `int64_t`"); + + return static_cast(Clamp(aValue, static_cast(NumericLimits::kMin), + static_cast(NumericLimits::kMax))); +} + /** * This template function performs a three-way comparison between two values. * @@ -182,7 +205,7 @@ template inline IntType DivideAndRoundToClosest(IntType aDivi } /** - * This function casts a given `uint32_t` to `unsigned long`. + * Casts a given `uint32_t` to `unsigned long`. * * @param[in] aUint32 A `uint32_t` value. * @@ -192,7 +215,7 @@ template inline IntType DivideAndRoundToClosest(IntType aDivi inline unsigned long ToUlong(uint32_t aUint32) { return static_cast(aUint32); } /** - * This function counts the number of `1` bits in the binary representation of a given unsigned int bit-mask value. + * Counts the number of `1` bits in the binary representation of a given unsigned int bit-mask value. * * @tparam UintType The unsigned int type (MUST be `uint8_t`, uint16_t`, uint32_t`, or `uint64_t`). * diff --git a/src/core/common/numeric_limits.hpp b/src/core/common/numeric_limits.hpp index de3fa137f38..35e984394cb 100644 --- a/src/core/common/numeric_limits.hpp +++ b/src/core/common/numeric_limits.hpp @@ -39,7 +39,7 @@ namespace ot { /** - * This class template provides a way to query properties of arithmetic types. + * Provides a way to query properties of arithmetic types. * * There are no members if `Type` is not a supported arithmetic type. * diff --git a/src/core/common/owned_ptr.hpp b/src/core/common/owned_ptr.hpp index c1dde762bb4..b46c17a9d22 100644 --- a/src/core/common/owned_ptr.hpp +++ b/src/core/common/owned_ptr.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This template class represents an owned smart pointer. + * Represents an owned smart pointer. * * `OwnedPtr` acts as sole owner of the object it manages. An `OwnedPtr` is non-copyable (copy constructor is deleted) * but the ownership can be transferred from one `OwnedPtr` to another using move semantics. @@ -63,7 +63,7 @@ template class OwnedPtr : public Ptr OwnedPtr(void) = default; /** - * This constructor initializes the `OwnedPtr` with a given pointer. + * Initializes the `OwnedPtr` with a given pointer. * * The `OwnedPtr` takes the ownership of the object at @p aPointer. * @@ -76,7 +76,7 @@ template class OwnedPtr : public Ptr } /** - * This constructor initializes the `OwnedPtr` from another `OwnedPtr` using move semantics. + * Initializes the `OwnedPtr` from another `OwnedPtr` using move semantics. * * The `OwnedPtr` takes over the ownership of the object from @p aOther. After this call, @p aOther will be null. * @@ -98,9 +98,9 @@ template class OwnedPtr : public Ptr ~OwnedPtr(void) { Delete(); } /** - * This method frees the owned object (if any). + * Frees the owned object (if any). * - * This method invokes `Free()` method on the `Type` object owned by `OwnedPtr` (if any). It will also set the + * Invokes `Free()` method on the `Type` object owned by `OwnedPtr` (if any). It will also set the * `OwnedPtr` to null. * */ @@ -111,7 +111,7 @@ template class OwnedPtr : public Ptr } /** - * This method frees the current object owned by `OwnedPtr` (if any) and replaces it with a new one. + * Frees the current object owned by `OwnedPtr` (if any) and replaces it with a new one. * * The method will `Free()` the current object managed by `OwnedPtr` (if different from @p aPointer) before taking * the ownership of the object at @p aPointer. The method correctly handles a self `Reset()` (i.e., @p aPointer @@ -130,7 +130,7 @@ template class OwnedPtr : public Ptr } /** - * This method releases the ownership of the current object in `OwnedPtr` (if any). + * Releases the ownership of the current object in `OwnedPtr` (if any). * * After this call, the `OwnedPtr` will be null. * @@ -145,7 +145,7 @@ template class OwnedPtr : public Ptr } /** - * This method allows passing of the ownership to another `OwnedPtr` using move semantics. + * Allows passing of the ownership to another `OwnedPtr` using move semantics. * * @returns An rvalue reference of the pointer to move from. * @@ -153,7 +153,7 @@ template class OwnedPtr : public Ptr OwnedPtr &&PassOwnership(void) { return static_cast(*this); } /** - * This method overload the assignment operator `=` to replace the object owned by the `OwnedPtr` with another one + * Overload the assignment operator `=` to replace the object owned by the `OwnedPtr` with another one * using move semantics. * * The `OwnedPtr` first frees its current owned object (if there is any and it is different from @p aOther) before diff --git a/src/core/common/owning_list.hpp b/src/core/common/owning_list.hpp index 3b73fe6ebf0..583bc685996 100644 --- a/src/core/common/owning_list.hpp +++ b/src/core/common/owning_list.hpp @@ -43,7 +43,7 @@ namespace ot { /** - * This template class represents a singly linked list which owns its entries and frees them upon destruction of the + * Represents a singly linked list which owns its entries and frees them upon destruction of the * list. * */ @@ -68,7 +68,7 @@ template class OwningList : public LinkedList ~OwningList(void) { Free(); } /** - * This method clears the list and frees all existing entries in it. + * Clears the list and frees all existing entries in it. * */ void Free(void) @@ -79,13 +79,13 @@ template class OwningList : public LinkedList } /** - * This method clears the list and frees all existing entries in it. + * Clears the list and frees all existing entries in it. * */ void Clear(void) { Free(); } /** - * This method pops an entry from head of the linked list and return an `OwnedPtr` to it. + * Pops an entry from head of the linked list and return an `OwnedPtr` to it. * * @note This method does not change the popped entry itself, i.e., the popped entry next pointer stays as before. * @@ -95,7 +95,7 @@ template class OwningList : public LinkedList OwnedPtr Pop(void) { return OwnedPtr(LinkedList::Pop()); } /** - * This method pops an entry after a given previous entry. + * Pops an entry after a given previous entry. * * @note This method does not change the popped entry itself, i.e., the popped entry next pointer stays as before. * @@ -108,7 +108,7 @@ template class OwningList : public LinkedList OwnedPtr PopAfter(Type *aPrevEntry) { return OwnedPtr(LinkedList::PopAfter(aPrevEntry)); } /** - * This template method removes an entry matching a given entry indicator from the linked list. + * Removes an entry matching a given entry indicator from the linked list. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries * in the list. To check that an entry matches the given indicator, the `Matches()` method is invoked on each @@ -130,7 +130,7 @@ template class OwningList : public LinkedList } /** - * This template method removes all entries in the list matching a given entry indicator from the list and adds + * Removes all entries in the list matching a given entry indicator from the list and adds * them to a new list. * * The template type `Indicator` specifies the type of @p aIndicator object which is used to match against entries diff --git a/src/core/common/pool.hpp b/src/core/common/pool.hpp index 4a0f0e54289..926c56a1576 100644 --- a/src/core/common/pool.hpp +++ b/src/core/common/pool.hpp @@ -55,7 +55,7 @@ class Instance; */ /** - * This template class represents an object pool. + * Represents an object pool. * * @tparam Type The object type. Type should provide `GetNext() and `SetNext()` so that it can be added to a * linked list. @@ -66,7 +66,7 @@ template class Pool : private NonCopyable { public: /** - * This constructor initializes the pool. + * Initializes the pool. * */ Pool(void) @@ -79,9 +79,9 @@ template class Pool : private NonCopyable } /** - * This constructor initializes the pool. + * Initializes the pool. * - * This constructor version requires the `Type` class to provide method `void Init(Instance &)` to initialize + * Version requires the `Type` class to provide method `void Init(Instance &)` to initialize * each `Type` entry object. This can be realized by the `Type` class inheriting from `InstanceLocatorInit()`. * * @param[in] aInstance A reference to the OpenThread instance. @@ -98,7 +98,7 @@ template class Pool : private NonCopyable } /** - * This method allocates a new object from the pool. + * Allocates a new object from the pool. * * @returns A pointer to the newly allocated object, or `nullptr` if all entries from the pool are already * allocated. @@ -107,7 +107,7 @@ template class Pool : private NonCopyable Type *Allocate(void) { return mFreeList.Pop(); } /** - * This method frees a previously allocated object. + * Frees a previously allocated object. * * The @p aEntry MUST be an entry from the pool previously allocated using `Allocate()` method and not yet freed. * An already freed entry MUST not be freed again. @@ -118,7 +118,7 @@ template class Pool : private NonCopyable void Free(Type &aEntry) { mFreeList.Push(aEntry); } /** - * This method frees all previously allocated objects. + * Frees all previously allocated objects. * */ void FreeAll(void) @@ -132,7 +132,7 @@ template class Pool : private NonCopyable } /** - * This method returns the pool size. + * Returns the pool size. * * @returns The pool size (maximum number of objects in the pool). * @@ -140,7 +140,7 @@ template class Pool : private NonCopyable uint16_t GetSize(void) const { return kPoolSize; } /** - * This method indicates whether or not a given `Type` object is from the pool. + * Indicates whether or not a given `Type` object is from the pool. * * @param[in] aObject A reference to a `Type` object. * @@ -151,7 +151,7 @@ template class Pool : private NonCopyable bool IsPoolEntry(const Type &aObject) const { return (&mPool[0] <= &aObject) && (&aObject < GetArrayEnd(mPool)); } /** - * This method returns the associated index of a given entry from the pool. + * Returns the associated index of a given entry from the pool. * * The @p aEntry MUST be from the pool, otherwise the behavior of this method is undefined. * @@ -163,7 +163,7 @@ template class Pool : private NonCopyable uint16_t GetIndexOf(const Type &aEntry) const { return static_cast(&aEntry - mPool); } /** - * This method retrieves a pool entry at a given index. + * Retrieves a pool entry at a given index. * * The @p aIndex MUST be from an earlier call to `GetIndexOf()`. * @@ -175,7 +175,7 @@ template class Pool : private NonCopyable Type &GetEntryAt(uint16_t aIndex) { return mPool[aIndex]; } /** - * This method retrieves a pool entry at a given index. + * Retrieves a pool entry at a given index. * * The @p aIndex MUST be from an earlier call to `GetIndexOf()`. * diff --git a/src/core/common/preference.hpp b/src/core/common/preference.hpp index cf0657dd76c..5919a8f47a4 100644 --- a/src/core/common/preference.hpp +++ b/src/core/common/preference.hpp @@ -42,7 +42,7 @@ namespace ot { /** - * This class provides constants and static methods to convert between `int8_t` preference and its 2-bit unsigned + * Provides constants and static methods to convert between `int8_t` preference and its 2-bit unsigned * representation. * */ @@ -54,7 +54,7 @@ class Preference static constexpr int8_t kLow = -1; ///< Low preference. /** - * This static method converts a signed preference value to its corresponding 2-bit `uint8_t` value. + * Converts a signed preference value to its corresponding 2-bit `uint8_t` value. * * A positive @p aPrf is mapped to "High Preference", a negative @p aPrf is mapped to "Low Preference", and * zero @p aPrf is mapped to "Medium Preference". @@ -67,7 +67,7 @@ class Preference static uint8_t To2BitUint(int8_t aPrf); /** - * This static method converts a 2-bit `uint8_t` value to a signed preference value `kHigh`, `kMedium`, and `kLow`. + * Converts a 2-bit `uint8_t` value to a signed preference value `kHigh`, `kMedium`, and `kLow`. * * Only the first two bits (LSB) of @p a2BitUint are used and the rest of the bits are ignored. * @@ -86,7 +86,7 @@ class Preference static int8_t From2BitUint(uint8_t a2BitUint); /** - * This static method indicates whether a given `int8_t` preference value is valid, i.e., whether it has of the + * Indicates whether a given `int8_t` preference value is valid, i.e., whether it has of the * three values `kHigh`, `kMedium`, or `kLow`. * * @param[in] aPrf The signed preference value to check. @@ -98,7 +98,7 @@ class Preference static bool IsValid(int8_t aPrf); /** - * This static method indicates whether a given 2-bit `uint8_t` preference value is valid. + * Indicates whether a given 2-bit `uint8_t` preference value is valid. * * @param[in] a2BitUint The 2-bit unsigned value to convert from. Only two LSB bits are used and the reset are * ignored. @@ -110,7 +110,7 @@ class Preference static bool Is2BitUintValid(uint8_t a2BitUint) { return ((a2BitUint & k2BitMask) != k2BitReserved); } /** - * This static method converts a given preference to a human-readable string. + * Converts a given preference to a human-readable string. * * @param[in] aPrf The preference to convert. * diff --git a/src/core/common/ptr_wrapper.hpp b/src/core/common/ptr_wrapper.hpp index 3704d76ceb0..eea318120f4 100644 --- a/src/core/common/ptr_wrapper.hpp +++ b/src/core/common/ptr_wrapper.hpp @@ -42,7 +42,7 @@ namespace ot { /** - * This template class represents a wrapper over a pointer. + * Represents a wrapper over a pointer. * * This is intended as base class of `OwnedPtr` or `RetainPtr` providing common simple methods. * @@ -62,7 +62,7 @@ template class Ptr } /** - * This constructor initializes the `Ptr` with a given pointer. + * Initializes the `Ptr` with a given pointer. * * @param[in] aPointer A pointer to initialize with. * @@ -73,7 +73,7 @@ template class Ptr } /** - * This method indicates whether the `Ptr` is null or not. + * Indicates whether the `Ptr` is null or not. * * @retval TRUE The `Ptr` is null. * @retval FALSE The `Ptr` is not null. @@ -82,7 +82,7 @@ template class Ptr bool IsNull(void) const { return (mPointer == nullptr); } /** - * This method gets the wrapped pointer. + * Gets the wrapped pointer. * * @returns The wrapped pointer. * @@ -90,7 +90,7 @@ template class Ptr Type *Get(void) { return mPointer; } /** - * This method gets the wrapped pointer. + * Gets the wrapped pointer. * * @returns The wrapped pointer. * @@ -98,7 +98,7 @@ template class Ptr const Type *Get(void) const { return mPointer; } /** - * This method overloads the `->` dereference operator and returns the pointer. + * Overloads the `->` dereference operator and returns the pointer. * * @returns The wrapped pointer. * @@ -106,7 +106,7 @@ template class Ptr Type *operator->(void) { return mPointer; } /** - * This method overloads the `->` dereference operator and returns the pointer. + * Overloads the `->` dereference operator and returns the pointer. * * @returns The wrapped pointer. * @@ -114,7 +114,7 @@ template class Ptr const Type *operator->(void) const { return mPointer; } /** - * This method overloads the `*` dereference operator and returns a reference to the pointed object. + * Overloads the `*` dereference operator and returns a reference to the pointed object. * * The behavior is undefined if `IsNull() == true`. * @@ -124,7 +124,7 @@ template class Ptr Type &operator*(void) { return *mPointer; } /** - * This method overloads the `*` dereference operator and returns a reference to the pointed object. + * Overloads the `*` dereference operator and returns a reference to the pointed object. * * The behavior is undefined if `IsNull() == true`. * @@ -134,7 +134,7 @@ template class Ptr const Type &operator*(void) const { return *mPointer; } /** - * This method overloads the operator `==` to compare the `Ptr` with a given pointer. + * Overloads the operator `==` to compare the `Ptr` with a given pointer. * * @param[in] aPointer The pointer to compare with. * @@ -145,7 +145,7 @@ template class Ptr bool operator==(const Type *aPointer) const { return (mPointer == aPointer); } /** - * This method overloads the operator `!=` to compare the `Ptr` with a given pointer. + * Overloads the operator `!=` to compare the `Ptr` with a given pointer. * * @param[in] aPointer The pointer to compare with. * @@ -156,7 +156,7 @@ template class Ptr bool operator!=(const Type *aPointer) const { return (mPointer != aPointer); } /** - * This method overloads the operator `==` to compare the `Ptr` with another `Ptr`. + * Overloads the operator `==` to compare the `Ptr` with another `Ptr`. * * @param[in] aOther The other `Ptr` to compare with. * @@ -167,7 +167,7 @@ template class Ptr bool operator==(const Ptr &aOther) const { return (mPointer == aOther.mPointer); } /** - * This method overloads the operator `!=` to compare the `Ptr` with another `Ptr`. + * Overloads the operator `!=` to compare the `Ptr` with another `Ptr`. * * @param[in] aOther The other `Ptr` to compare with. * diff --git a/src/core/common/random.cpp b/src/core/common/random.cpp index 482d68d75d6..18efcef8a26 100644 --- a/src/core/common/random.cpp +++ b/src/core/common/random.cpp @@ -54,7 +54,7 @@ Manager::Manager(void) #if !OPENTHREAD_RADIO otPlatCryptoRandomInit(); - SuccessOrAssert(Random::Crypto::FillBuffer(reinterpret_cast(&seed), sizeof(seed))); + SuccessOrAssert(Random::Crypto::Fill(seed)); #else SuccessOrAssert(otPlatEntropyGet(reinterpret_cast(&seed), sizeof(seed))); #endif diff --git a/src/core/common/random.hpp b/src/core/common/random.hpp index 01fb982bfc4..fb01e22c86a 100644 --- a/src/core/common/random.hpp +++ b/src/core/common/random.hpp @@ -43,19 +43,20 @@ #include "common/debug.hpp" #include "common/error.hpp" #include "common/non_copyable.hpp" +#include "common/type_traits.hpp" namespace ot { namespace Random { /** - * This class manages random number generator initialization/deinitialization. + * Manages random number generator initialization/deinitialization. * */ class Manager : private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * */ Manager(void); @@ -67,7 +68,7 @@ class Manager : private NonCopyable ~Manager(void); /** - * This static method generates and returns a random value using a non-crypto Pseudo Random Number Generator. + * Generates and returns a random value using a non-crypto Pseudo Random Number Generator. * * @returns A random `uint32_t` value. * @@ -76,7 +77,7 @@ class Manager : private NonCopyable #if !OPENTHREAD_RADIO /** - * This static method fills a given buffer with cryptographically secure random bytes. + * 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). @@ -105,7 +106,7 @@ class Manager : private NonCopyable namespace NonCrypto { /** - * This function generates and returns a random `uint32_t` value. + * Generates and returns a random `uint32_t` value. * * @returns A random `uint32_t` value. * @@ -113,7 +114,7 @@ namespace NonCrypto { inline uint32_t GetUint32(void) { return Manager::NonCryptoGetUint32(); } /** - * This function generates and returns a random byte. + * Generates and returns a random byte. * * @returns A random `uint8_t` value. * @@ -121,7 +122,7 @@ inline uint32_t GetUint32(void) { return Manager::NonCryptoGetUint32(); } inline uint8_t GetUint8(void) { return static_cast(GetUint32() & 0xff); } /** - * This function generates and returns a random `uint16_t` value. + * Generates and returns a random `uint16_t` value. * * @returns A random `uint16_t` value. * @@ -129,7 +130,7 @@ inline uint8_t GetUint8(void) { return static_cast(GetUint32() & 0xff); inline uint16_t GetUint16(void) { return static_cast(GetUint32() & 0xffff); } /** - * This function generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`. * * @param[in] aMin A minimum value (this value can be included in returned random result). * @param[in] aMax A maximum value (this value is excluded from returned random result). @@ -140,7 +141,7 @@ inline uint16_t GetUint16(void) { return static_cast(GetUint32() & 0xf uint8_t GetUint8InRange(uint8_t aMin, uint8_t aMax); /** - * This function generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`. * * @note The returned random value can include the @p aMin value but excludes the @p aMax. * @@ -153,7 +154,7 @@ uint8_t GetUint8InRange(uint8_t aMin, uint8_t aMax); uint16_t GetUint16InRange(uint16_t aMin, uint16_t aMax); /** - * This function generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`. + * Generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`. * * @note The returned random value can include the @p aMin value but excludes the @p aMax. * @@ -166,7 +167,7 @@ uint16_t GetUint16InRange(uint16_t aMin, uint16_t aMax); uint32_t GetUint32InRange(uint32_t aMin, uint32_t aMax); /** - * This function fills a given buffer with random bytes. + * Fills a given buffer with 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). @@ -175,7 +176,22 @@ uint32_t GetUint32InRange(uint32_t aMin, uint32_t aMax); void FillBuffer(uint8_t *aBuffer, uint16_t aSize); /** - * This function adds a random jitter within a given range to a given value. + * Fills a given object with random bytes. + * + * @tparam ObjectType The object type to fill. + * + * @param[in] aObject A reference to the object to fill. + * + */ +template void Fill(ObjectType &aObject) +{ + static_assert(!TypeTraits::IsPointer::kValue, "ObjectType must not be a pointer"); + + FillBuffer(reinterpret_cast(&aObject), sizeof(ObjectType)); +} + +/** + * Adds a random jitter within a given range to a given value. * * @param[in] aValue A value to which the random jitter is added. * @param[in] aJitter Maximum jitter. Random jitter is selected from the range `[-aJitter, aJitter]`. @@ -192,7 +208,7 @@ uint32_t AddJitter(uint32_t aValue, uint16_t aJitter); namespace Crypto { /** - * This function fills a given buffer with cryptographically secure random bytes. + * 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). @@ -202,6 +218,24 @@ namespace Crypto { */ inline Error FillBuffer(uint8_t *aBuffer, uint16_t aSize) { return Manager::CryptoFillBuffer(aBuffer, aSize); } +/** + * Fills a given object with cryptographically secure random bytes. + * + * @tparam ObjectType The object type to fill. + * + * @param[in] aObject A reference to the object to fill. + * + * @retval kErrorNone Successfully filled @p aObject with random values. + * @retval kErrorFailed Failed to generate secure random bytes to fill the object. + * + */ +template Error Fill(ObjectType &aObject) +{ + static_assert(!TypeTraits::IsPointer::kValue, "ObjectType must not be a pointer"); + + return FillBuffer(reinterpret_cast(&aObject), sizeof(ObjectType)); +} + } // namespace Crypto #endif // !OPENTHREAD_RADIO diff --git a/src/core/common/retain_ptr.hpp b/src/core/common/retain_ptr.hpp index 5605ced588b..207f4963eb8 100644 --- a/src/core/common/retain_ptr.hpp +++ b/src/core/common/retain_ptr.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This template class represents a retain (reference counted) smart pointer. + * Represents a retain (reference counted) smart pointer. * * The `Type` class MUST provide mechanism to track its current retain count. It MUST provide the following three * methods: @@ -67,7 +67,7 @@ template class RetainPtr : public Ptr RetainPtr(void) = default; /** - * This constructor initializes the `RetainPtr` with a given pointer. + * Initializes the `RetainPtr` with a given pointer. * * Upon construction the `RetainPtr` will increment the retain count on @p aPointer (if not null). * @@ -81,7 +81,7 @@ template class RetainPtr : public Ptr } /** - * This constructor initializes the `RetainPtr` from another `RetainPtr`. + * Initializes the `RetainPtr` from another `RetainPtr`. * * @param[in] aOther Another `RetainPtr`. * @@ -102,7 +102,7 @@ template class RetainPtr : public Ptr ~RetainPtr(void) { DecrementRetainCount(); } /** - * This method replaces the managed object by `RetainPtr` with a new one. + * Replaces the managed object by `RetainPtr` with a new one. * * The method correctly handles a self `Reset()` (i.e., @p aPointer being the same pointer as the one currently * managed by `RetainPtr`). @@ -121,7 +121,7 @@ template class RetainPtr : public Ptr } /** - * This method releases the ownership of the current pointer in `RetainPtr` (if any) without changing its retain + * Releases the ownership of the current pointer in `RetainPtr` (if any) without changing its retain * count. * * After this call, the `RetainPtr` will be null. @@ -137,7 +137,7 @@ template class RetainPtr : public Ptr } /** - * This method overloads the assignment operator `=`. + * Overloads the assignment operator `=`. * * The `RetainPtr` first frees its current managed object (if there is any and it is different from @p aOther) * before taking over the ownership of the object from @p aOther. This method correctly handles a self assignment @@ -173,7 +173,7 @@ template class RetainPtr : public Ptr }; /** - * This class provides mechanism to track retain count. + * Provides mechanism to track retain count. * */ class RetainCountable @@ -191,7 +191,7 @@ class RetainCountable } /** - * This method returns the current retain count. + * Returns the current retain count. * * @returns The current retain count. * @@ -199,13 +199,13 @@ class RetainCountable uint16_t GetRetainCount(void) const { return mRetainCount; } /** - * This method increments the retain count. + * Increments the retain count. * */ void IncrementRetainCount(void) { ++mRetainCount; } /** - * This method decrements the retain count. + * Decrements the retain count. * * @returns The retain count value after decrementing it. * diff --git a/src/core/common/serial_number.hpp b/src/core/common/serial_number.hpp index 39f116643fb..07e536c3b3c 100644 --- a/src/core/common/serial_number.hpp +++ b/src/core/common/serial_number.hpp @@ -47,7 +47,7 @@ class SerialNumber { public: /** - * This static method indicates whether or not a first serial number is strictly less than a second serial number. + * Indicates whether or not a first serial number is strictly less than a second serial number. * * The comparison takes into account the wrapping of serial number values (similar to RFC-1982). It is semantically * equivalent to `aFirst < aSecond`. @@ -74,7 +74,7 @@ class SerialNumber } /** - * This static method indicates whether or not a first serial number is strictly greater than a second serial + * Indicates whether or not a first serial number is strictly greater than a second serial * number. * * The comparison takes into account the wrapping of serial number values (similar to RFC-1982). It is semantically diff --git a/src/core/common/settings.cpp b/src/core/common/settings.cpp index 18f17d8872e..c9b6f3ad7fd 100644 --- a/src/core/common/settings.cpp +++ b/src/core/common/settings.cpp @@ -107,23 +107,12 @@ void SettingsBase::SrpServerInfo::Log(Action aAction) const #endif #if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE -Error SettingsBase::BorderAgentId::SetId(const uint8_t *aId, uint16_t aLength) -{ - Error error = kErrorNone; - - VerifyOrExit(aLength == sizeof(mId), error = kErrorInvalidArgs); - memcpy(mId, aId, aLength); - -exit: - return error; -} - void SettingsBase::BorderAgentId::Log(Action aAction) const { char buffer[sizeof(BorderAgentId) * 2 + 1]; StringWriter sw(buffer, sizeof(buffer)); - sw.AppendHexBytes(GetId(), sizeof(BorderAgentId)); + sw.AppendHexBytes(GetId().mId, sizeof(BorderAgentId)); LogInfo("%s BorderAgentId {id:%s}", ActionToString(aAction), buffer); } #endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE diff --git a/src/core/common/settings.hpp b/src/core/common/settings.hpp index 4b307d01c2b..f7f538136e1 100644 --- a/src/core/common/settings.hpp +++ b/src/core/common/settings.hpp @@ -36,7 +36,6 @@ #include "openthread-core-config.h" -#include #include #include "common/clearable.hpp" @@ -48,6 +47,7 @@ #include "common/settings_driver.hpp" #include "crypto/ecdsa.hpp" #include "mac/mac_types.hpp" +#include "meshcop/border_agent.hpp" #include "meshcop/dataset.hpp" #include "net/ip6_address.hpp" #include "thread/version.hpp" @@ -59,9 +59,9 @@ namespace ot { class Settings; /** - * This class defines the base class used by `Settings` and `Settings::ChildInfoIterator`. + * Defines the base class used by `Settings` and `Settings::ChildInfoIterator`. * - * This class provides structure definitions for different settings keys. + * Provides structure definitions for different settings keys. * */ class SettingsBase : public InstanceLocator @@ -104,7 +104,7 @@ class SettingsBase : public InstanceLocator */ /** - * This enumeration defines the keys of settings. + * Defines the keys of settings. * */ enum Key : uint16_t @@ -130,7 +130,7 @@ class SettingsBase : public InstanceLocator "Core settings keys overlap with vendor reserved keys"); /** - * This structure represents the device's own network information for settings storage. + * Represents the device's own network information for settings storage. * */ OT_TOOL_PACKED_BEGIN @@ -143,7 +143,7 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeyNetworkInfo; ///< The associated key. /** - * This method initializes the `NetworkInfo` object. + * Initializes the `NetworkInfo` object. * */ void Init(void) @@ -153,7 +153,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the Thread role. + * Returns the Thread role. * * @returns The Thread role. * @@ -161,7 +161,7 @@ class SettingsBase : public InstanceLocator uint8_t GetRole(void) const { return mRole; } /** - * This method sets the Thread role. + * Sets the Thread role. * * @param[in] aRole The Thread Role. * @@ -169,7 +169,7 @@ class SettingsBase : public InstanceLocator void SetRole(uint8_t aRole) { mRole = aRole; } /** - * This method returns the Thread device mode. + * Returns the Thread device mode. * * @returns the Thread device mode. * @@ -177,7 +177,7 @@ class SettingsBase : public InstanceLocator uint8_t GetDeviceMode(void) const { return mDeviceMode; } /** - * This method sets the Thread device mode. + * Sets the Thread device mode. * * @param[in] aDeviceMode The Thread device mode. * @@ -185,7 +185,7 @@ class SettingsBase : public InstanceLocator void SetDeviceMode(uint8_t aDeviceMode) { mDeviceMode = aDeviceMode; } /** - * This method returns the RLOC16. + * Returns the RLOC16. * * @returns The RLOC16. * @@ -193,7 +193,7 @@ class SettingsBase : public InstanceLocator uint16_t GetRloc16(void) const { return Encoding::LittleEndian::HostSwap16(mRloc16); } /** - * This method sets the RLOC16. + * Sets the RLOC16. * * @param[in] aRloc16 The RLOC16. * @@ -201,7 +201,7 @@ class SettingsBase : public InstanceLocator void SetRloc16(uint16_t aRloc16) { mRloc16 = Encoding::LittleEndian::HostSwap16(aRloc16); } /** - * This method returns the key sequence. + * Returns the key sequence. * * @returns The key sequence. * @@ -209,7 +209,7 @@ class SettingsBase : public InstanceLocator uint32_t GetKeySequence(void) const { return Encoding::LittleEndian::HostSwap32(mKeySequence); } /** - * This method sets the key sequence. + * Sets the key sequence. * * @param[in] aKeySequence The key sequence. * @@ -217,7 +217,7 @@ class SettingsBase : public InstanceLocator void SetKeySequence(uint32_t aKeySequence) { mKeySequence = Encoding::LittleEndian::HostSwap32(aKeySequence); } /** - * This method returns the MLE frame counter. + * Returns the MLE frame counter. * * @returns The MLE frame counter. * @@ -225,7 +225,7 @@ class SettingsBase : public InstanceLocator uint32_t GetMleFrameCounter(void) const { return Encoding::LittleEndian::HostSwap32(mMleFrameCounter); } /** - * This method sets the MLE frame counter. + * Sets the MLE frame counter. * * @param[in] aMleFrameCounter The MLE frame counter. * @@ -236,7 +236,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the MAC frame counter. + * Returns the MAC frame counter. * * @returns The MAC frame counter. * @@ -244,7 +244,7 @@ class SettingsBase : public InstanceLocator uint32_t GetMacFrameCounter(void) const { return Encoding::LittleEndian::HostSwap32(mMacFrameCounter); } /** - * This method sets the MAC frame counter. + * Sets the MAC frame counter. * * @param[in] aMacFrameCounter The MAC frame counter. * @@ -255,7 +255,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the previous partition ID. + * Returns the previous partition ID. * * @returns The previous partition ID. * @@ -263,7 +263,7 @@ class SettingsBase : public InstanceLocator uint32_t GetPreviousPartitionId(void) const { return Encoding::LittleEndian::HostSwap32(mPreviousPartitionId); } /** - * This method sets the previous partition id. + * Sets the previous partition id. * * @param[in] aPreviousPartitionId The previous partition ID. * @@ -274,7 +274,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the extended address. + * Returns the extended address. * * @returns The extended address. * @@ -282,7 +282,7 @@ class SettingsBase : public InstanceLocator const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; } /** - * This method sets the extended address. + * Sets the extended address. * * @param[in] aExtAddress The extended address. * @@ -290,7 +290,7 @@ class SettingsBase : public InstanceLocator void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; } /** - * This method returns the Mesh Local Interface Identifier. + * Returns the Mesh Local Interface Identifier. * * @returns The Mesh Local Interface Identifier. * @@ -298,7 +298,7 @@ class SettingsBase : public InstanceLocator const Ip6::InterfaceIdentifier &GetMeshLocalIid(void) const { return mMlIid; } /** - * This method sets the Mesh Local Interface Identifier. + * Sets the Mesh Local Interface Identifier. * * @param[in] aMeshLocalIid The Mesh Local Interface Identifier. * @@ -306,7 +306,7 @@ class SettingsBase : public InstanceLocator void SetMeshLocalIid(const Ip6::InterfaceIdentifier &aMeshLocalIid) { mMlIid = aMeshLocalIid; } /** - * This method returns the Thread version. + * Returns the Thread version. * * @returns The Thread version. * @@ -314,7 +314,7 @@ class SettingsBase : public InstanceLocator uint16_t GetVersion(void) const { return Encoding::LittleEndian::HostSwap16(mVersion); } /** - * This method sets the Thread version. + * Sets the Thread version. * * @param[in] aVersion The Thread version. * @@ -337,7 +337,7 @@ class SettingsBase : public InstanceLocator } OT_TOOL_PACKED_END; /** - * This structure represents the parent information for settings storage. + * Represents the parent information for settings storage. * */ OT_TOOL_PACKED_BEGIN @@ -350,7 +350,7 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeyParentInfo; ///< The associated key. /** - * This method initializes the `ParentInfo` object. + * Initializes the `ParentInfo` object. * */ void Init(void) @@ -360,7 +360,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the extended address. + * Returns the extended address. * * @returns The extended address. * @@ -368,7 +368,7 @@ class SettingsBase : public InstanceLocator const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; } /** - * This method sets the extended address. + * Sets the extended address. * * @param[in] aExtAddress The extended address. * @@ -376,7 +376,7 @@ class SettingsBase : public InstanceLocator void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; } /** - * This method returns the Thread version. + * Returns the Thread version. * * @returns The Thread version. * @@ -384,7 +384,7 @@ class SettingsBase : public InstanceLocator uint16_t GetVersion(void) const { return Encoding::LittleEndian::HostSwap16(mVersion); } /** - * This method sets the Thread version. + * Sets the Thread version. * * @param[in] aVersion The Thread version. * @@ -400,7 +400,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_FTD /** - * This structure represents the child information for settings storage. + * Represents the child information for settings storage. * */ OT_TOOL_PACKED_BEGIN @@ -412,7 +412,7 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeyChildInfo; ///< The associated key. /** - * This method clears the struct object (setting all the fields to zero). + * Clears the struct object (setting all the fields to zero). * */ void Init(void) @@ -422,7 +422,7 @@ class SettingsBase : public InstanceLocator } /** - * This method returns the extended address. + * Returns the extended address. * * @returns The extended address. * @@ -430,7 +430,7 @@ class SettingsBase : public InstanceLocator const Mac::ExtAddress &GetExtAddress(void) const { return mExtAddress; } /** - * This method sets the extended address. + * Sets the extended address. * * @param[in] aExtAddress The extended address. * @@ -438,7 +438,7 @@ class SettingsBase : public InstanceLocator void SetExtAddress(const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; } /** - * This method returns the child timeout. + * Returns the child timeout. * * @returns The child timeout. * @@ -446,7 +446,7 @@ class SettingsBase : public InstanceLocator uint32_t GetTimeout(void) const { return Encoding::LittleEndian::HostSwap32(mTimeout); } /** - * This method sets the child timeout. + * Sets the child timeout. * * @param[in] aTimeout The child timeout. * @@ -454,7 +454,7 @@ class SettingsBase : public InstanceLocator void SetTimeout(uint32_t aTimeout) { mTimeout = Encoding::LittleEndian::HostSwap32(aTimeout); } /** - * This method returns the RLOC16. + * Returns the RLOC16. * * @returns The RLOC16. * @@ -462,7 +462,7 @@ class SettingsBase : public InstanceLocator uint16_t GetRloc16(void) const { return Encoding::LittleEndian::HostSwap16(mRloc16); } /** - * This method sets the RLOC16. + * Sets the RLOC16. * * @param[in] aRloc16 The RLOC16. * @@ -470,7 +470,7 @@ class SettingsBase : public InstanceLocator void SetRloc16(uint16_t aRloc16) { mRloc16 = Encoding::LittleEndian::HostSwap16(aRloc16); } /** - * This method returns the Thread device mode. + * Returns the Thread device mode. * * @returns The Thread device mode. * @@ -478,7 +478,7 @@ class SettingsBase : public InstanceLocator uint8_t GetMode(void) const { return mMode; } /** - * This method sets the Thread device mode. + * Sets the Thread device mode. * * @param[in] aMode The Thread device mode. * @@ -486,7 +486,7 @@ class SettingsBase : public InstanceLocator void SetMode(uint8_t aMode) { mMode = aMode; } /** - * This method returns the Thread version. + * Returns the Thread version. * * @returns The Thread version. * @@ -494,7 +494,7 @@ class SettingsBase : public InstanceLocator uint16_t GetVersion(void) const { return Encoding::LittleEndian::HostSwap16(mVersion); } /** - * This method sets the Thread version. + * Sets the Thread version. * * @param[in] aVersion The Thread version. * @@ -514,7 +514,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE /** - * This class defines constants and types for SLAAC IID Secret key settings. + * Defines constants and types for SLAAC IID Secret key settings. * */ class SlaacIidSecretKey @@ -531,7 +531,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_DUA_ENABLE /** - * This structure represents the duplicate address detection information for settings storage. + * Represents the duplicate address detection information for settings storage. * */ OT_TOOL_PACKED_BEGIN @@ -544,13 +544,13 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeyDadInfo; ///< The associated key. /** - * This method initializes the `DadInfo` object. + * Initializes the `DadInfo` object. * */ void Init(void) { Clear(); } /** - * This method returns the Dad Counter. + * Returns the Dad Counter. * * @returns The Dad Counter value. * @@ -558,7 +558,7 @@ class SettingsBase : public InstanceLocator uint8_t GetDadCounter(void) const { return mDadCounter; } /** - * This method sets the Dad Counter. + * Sets the Dad Counter. * * @param[in] aDadCounter The Dad Counter value. * @@ -574,7 +574,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE /** - * This class defines constants and types for BR ULA prefix settings. + * Defines constants and types for BR ULA prefix settings. * */ class BrUlaPrefix @@ -589,7 +589,7 @@ class SettingsBase : public InstanceLocator }; /** - * This class represents a BR on-link prefix entry for settings storage. + * Represents a BR on-link prefix entry for settings storage. * */ OT_TOOL_PACKED_BEGIN @@ -601,13 +601,13 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeyBrOnLinkPrefixes; ///< The associated key. /** - * This method initializes the `BrOnLinkPrefix` object. + * Initializes the `BrOnLinkPrefix` object. * */ void Init(void) { Clear(); } /** - * This method gets the prefix. + * Gets the prefix. * * @returns The prefix. * @@ -615,7 +615,7 @@ class SettingsBase : public InstanceLocator const Ip6::Prefix &GetPrefix(void) const { return mPrefix; } /** - * This method set the prefix. + * Set the prefix. * * @param[in] aPrefix The prefix. * @@ -623,7 +623,7 @@ class SettingsBase : public InstanceLocator void SetPrefix(const Ip6::Prefix &aPrefix) { mPrefix = aPrefix; } /** - * This method gets the remaining prefix lifetime in seconds. + * Gets the remaining prefix lifetime in seconds. * * @returns The prefix lifetime in seconds. * @@ -631,7 +631,7 @@ class SettingsBase : public InstanceLocator uint32_t GetLifetime(void) const { return mLifetime; } /** - * This method sets the the prefix lifetime. + * Sets the the prefix lifetime. * * @param[in] aLifetime The prefix lifetime in seconds. * @@ -649,7 +649,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE /** - * This class defines constants and types for SRP ECDSA key settings. + * Defines constants and types for SRP ECDSA key settings. * */ class SrpEcdsaKey @@ -665,7 +665,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_SRP_CLIENT_SAVE_SELECTED_SERVER_ENABLE /** - * This structure represents the SRP client info (selected server address). + * Represents the SRP client info (selected server address). * */ OT_TOOL_PACKED_BEGIN @@ -678,13 +678,13 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeySrpClientInfo; ///< The associated key. /** - * This method initializes the `SrpClientInfo` object. + * Initializes the `SrpClientInfo` object. * */ void Init(void) { Clear(); } /** - * This method returns the server IPv6 address. + * Returns the server IPv6 address. * * @returns The server IPv6 address. * @@ -692,7 +692,7 @@ class SettingsBase : public InstanceLocator const Ip6::Address &GetServerAddress(void) const { return mServerAddress; } /** - * This method sets the server IPv6 address. + * Sets the server IPv6 address. * * @param[in] aAddress The server IPv6 address. * @@ -700,7 +700,7 @@ class SettingsBase : public InstanceLocator void SetServerAddress(const Ip6::Address &aAddress) { mServerAddress = aAddress; } /** - * This method returns the server port number. + * Returns the server port number. * * @returns The server port number. * @@ -708,7 +708,7 @@ class SettingsBase : public InstanceLocator uint16_t GetServerPort(void) const { return Encoding::LittleEndian::HostSwap16(mServerPort); } /** - * This method sets the server port number. + * Sets the server port number. * * @param[in] aPort The server port number. * @@ -726,7 +726,7 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_SERVER_PORT_SWITCH_ENABLE /** - * This structure represents the SRP server info. + * Represents the SRP server info. * */ OT_TOOL_PACKED_BEGIN @@ -739,13 +739,13 @@ class SettingsBase : public InstanceLocator static constexpr Key kKey = kKeySrpServerInfo; ///< The associated key. /** - * This method initializes the `SrpServerInfo` object. + * Initializes the `SrpServerInfo` object. * */ void Init(void) { Clear(); } /** - * This method returns the server port number. + * Returns the server port number. * * @returns The server port number. * @@ -753,7 +753,7 @@ class SettingsBase : public InstanceLocator uint16_t GetPort(void) const { return Encoding::LittleEndian::HostSwap16(mPort); } /** - * This method sets the server port number. + * Sets the server port number. * * @param[in] aPort The server port number. * @@ -769,54 +769,49 @@ class SettingsBase : public InstanceLocator #if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE /** - * This structure represents the Border Agent ID. + * Represents the Border Agent ID. * */ OT_TOOL_PACKED_BEGIN - class BorderAgentId : private Clearable + class BorderAgentId { friend class Settings; - friend class Clearable; public: - static constexpr Key kKey = kKeyBorderAgentId; ///< The associated key. - static constexpr uint8_t kLength = OT_BORDER_AGENT_ID_LENGTH; + static constexpr Key kKey = kKeyBorderAgentId; ///< The associated key. /** - * This method initializes the `BorderAgentId` object. + * Initializes the `BorderAgentId` object. * */ - void Init(void) { Clear(); } + void Init(void) { mId = {}; } /** - * This method returns the Border Agent ID. + * Returns the Border Agent ID. * * @returns The Border Agent ID. * */ - const uint8_t *GetId(void) const { return mId; } + const MeshCoP::BorderAgent::Id &GetId(void) const { return mId; } /** - * This method returns the Border Agent ID. + * Returns the Border Agent ID. * * @returns The Border Agent ID. * */ - uint8_t *GetId(void) { return mId; } + MeshCoP::BorderAgent::Id &GetId(void) { return mId; } /** - * This method sets the Border Agent ID. - * - * @retval kErrorInvalidArgs If `aLength` doesn't equal to `OT_BORDER_AGENT_ID_LENGTH`. - * @retval kErrorNone If success. + * Sets the Border Agent ID. * */ - Error SetId(const uint8_t *aId, uint16_t aLength); + void SetId(const MeshCoP::BorderAgent::Id &aId) { mId = aId; } private: void Log(Action aAction) const; - uint8_t mId[kLength]; + MeshCoP::BorderAgent::Id mId; } OT_TOOL_PACKED_END; #endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE @@ -839,7 +834,7 @@ class SettingsBase : public InstanceLocator }; /** - * This class defines methods related to non-volatile storage of settings. + * Defines methods related to non-volatile storage of settings. * */ class Settings : public SettingsBase, private NonCopyable @@ -848,7 +843,7 @@ class Settings : public SettingsBase, private NonCopyable public: /** - * This constructor initializes a `Settings` object. + * Initializes a `Settings` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -859,7 +854,7 @@ class Settings : public SettingsBase, private NonCopyable } /** - * This method initializes the platform settings (non-volatile) module. + * Initializes the platform settings (non-volatile) module. * * This should be called before any other method from this class. * @@ -867,21 +862,21 @@ class Settings : public SettingsBase, private NonCopyable void Init(void); /** - * This method de-initializes the platform settings (non-volatile) module. + * De-initializes the platform settings (non-volatile) module. * - * This method should be called when OpenThread instance is no longer in use. + * Should be called when OpenThread instance is no longer in use. * */ void Deinit(void); /** - * This method removes all settings from the non-volatile store. + * Removes all settings from the non-volatile store. * */ void Wipe(void); /** - * This method saves the Operational Dataset (active or pending). + * Saves the Operational Dataset (active or pending). * * @param[in] aType The Dataset type (active or pending) to save. * @param[in] aDataset A reference to a `Dataset` object to be saved. @@ -893,7 +888,7 @@ class Settings : public SettingsBase, private NonCopyable Error SaveOperationalDataset(MeshCoP::Dataset::Type aType, const MeshCoP::Dataset &aDataset); /** - * This method reads the Operational Dataset (active or pending). + * Reads the Operational Dataset (active or pending). * * @param[in] aType The Dataset type (active or pending) to read. * @param[out] aDataset A reference to a `Dataset` object to output the read content. @@ -906,7 +901,7 @@ class Settings : public SettingsBase, private NonCopyable Error ReadOperationalDataset(MeshCoP::Dataset::Type aType, MeshCoP::Dataset &aDataset) const; /** - * This method deletes the Operational Dataset (active/pending) from settings. + * Deletes the Operational Dataset (active/pending) from settings. * * @param[in] aType The Dataset type (active or pending) to delete. * @@ -917,7 +912,7 @@ class Settings : public SettingsBase, private NonCopyable Error DeleteOperationalDataset(MeshCoP::Dataset::Type aType); /** - * This template method reads a specified settings entry. + * Reads a specified settings entry. * * The template type `EntryType` specifies the entry's value data structure. It must provide the following: * @@ -944,7 +939,7 @@ class Settings : public SettingsBase, private NonCopyable } /** - * This template method reads a specified settings entry. + * Reads a specified settings entry. * * The template type `EntryType` provides information about the entry's value type. It must provide the following: * @@ -969,7 +964,7 @@ class Settings : public SettingsBase, private NonCopyable } /** - * This template method saves a specified settings entry. + * Saves a specified settings entry. * * The template type `EntryType` specifies the entry's value data structure. It must provide the following: * @@ -994,7 +989,7 @@ class Settings : public SettingsBase, private NonCopyable } /** - * This template method saves a specified settings entry. + * Saves a specified settings entry. * * The template type `EntryType` provides information about the entry's value type. It must provide the following: * @@ -1020,7 +1015,7 @@ class Settings : public SettingsBase, private NonCopyable } /** - * This template method deletes a specified setting entry. + * Deletes a specified setting entry. * * The template type `EntryType` provides information about the entry's key. * @@ -1036,7 +1031,7 @@ class Settings : public SettingsBase, private NonCopyable #if OPENTHREAD_FTD /** - * This method adds a Child Info entry to settings. + * Adds a Child Info entry to settings. * * @note Child Info is a list-based settings property and can contain multiple entries. * @@ -1049,7 +1044,7 @@ class Settings : public SettingsBase, private NonCopyable Error AddChildInfo(const ChildInfo &aChildInfo); /** - * This method deletes all Child Info entries from the settings. + * Deletes all Child Info entries from the settings. * * @note Child Info is a list-based settings property and can contain multiple entries. * @@ -1060,9 +1055,9 @@ class Settings : public SettingsBase, private NonCopyable Error DeleteAllChildInfo(void); /** - * This method enables range-based `for` loop iteration over all child info entries in the `Settings`. + * Enables range-based `for` loop iteration over all child info entries in the `Settings`. * - * This method should be used as follows: + * Should be used as follows: * * for (const ChildInfo &childInfo : Get().IterateChildInfo()) { ... } * @@ -1073,7 +1068,7 @@ class Settings : public SettingsBase, private NonCopyable ChildInfoIteratorBuilder IterateChildInfo(void) { return ChildInfoIteratorBuilder(GetInstance()); } /** - * This class defines an iterator to access all Child Info entries in the settings. + * Defines an iterator to access all Child Info entries in the settings. * */ class ChildInfoIterator : public SettingsBase, public Unequatable @@ -1082,7 +1077,7 @@ class Settings : public SettingsBase, private NonCopyable public: /** - * This constructor initializes a `ChildInfoInterator` object. + * Initializes a `ChildInfoInterator` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -1090,7 +1085,7 @@ class Settings : public SettingsBase, private NonCopyable explicit ChildInfoIterator(Instance &aInstance); /** - * This method indicates whether there are no more Child Info entries in the list (iterator has reached end of + * Indicates whether there are no more Child Info entries in the list (iterator has reached end of * the list), or the current entry is valid. * * @retval TRUE There are no more entries in the list (reached end of the list). @@ -1100,21 +1095,21 @@ class Settings : public SettingsBase, private NonCopyable bool IsDone(void) const { return mIsDone; } /** - * This method overloads operator `++` (pre-increment) to advance the iterator to move to the next Child Info + * Overloads operator `++` (pre-increment) to advance the iterator to move to the next Child Info * entry in the list (if any). * */ void operator++(void) { Advance(); } /** - * This method overloads operator `++` (post-increment) to advance the iterator to move to the next Child Info + * Overloads operator `++` (post-increment) to advance the iterator to move to the next Child Info * entry in the list (if any). * */ void operator++(int) { Advance(); } /** - * This method gets the Child Info corresponding to the current iterator entry in the list. + * Gets the Child Info corresponding to the current iterator entry in the list. * * @note This method should be used only if `IsDone()` is returning FALSE indicating that the iterator is * pointing to a valid entry. @@ -1125,7 +1120,7 @@ class Settings : public SettingsBase, private NonCopyable const ChildInfo &GetChildInfo(void) const { return mChildInfo; } /** - * This method deletes the current Child Info entry. + * Deletes the current Child Info entry. * * @retval kErrorNone The entry was deleted successfully. * @retval kErrorInvalidState The entry is not valid (iterator has reached end of list). @@ -1135,7 +1130,7 @@ class Settings : public SettingsBase, private NonCopyable Error Delete(void); /** - * This method overloads the `*` dereference operator and gets a reference to `ChildInfo` entry to which the + * Overloads the `*` dereference operator and gets a reference to `ChildInfo` entry to which the * iterator is currently pointing. * * @note This method should be used only if `IsDone()` is returning FALSE indicating that the iterator is @@ -1148,7 +1143,7 @@ class Settings : public SettingsBase, private NonCopyable const ChildInfo &operator*(void) const { return mChildInfo; } /** - * This method overloads operator `==` to evaluate whether or not two iterator instances are equal. + * Overloads operator `==` to evaluate whether or not two iterator instances are equal. * * @param[in] aOther The other iterator to compare with. * @@ -1185,7 +1180,7 @@ class Settings : public SettingsBase, private NonCopyable #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE /** - * This method adds or updates an on-link prefix. + * Adds or updates an on-link prefix. * * If there is no matching entry (matching the same `GetPrefix()`) saved in `Settings`, the new entry will be added. * If there is matching entry, it will be updated to the new @p aPrefix. @@ -1199,7 +1194,7 @@ class Settings : public SettingsBase, private NonCopyable Error AddOrUpdateBrOnLinkPrefix(const BrOnLinkPrefix &aBrOnLinkPrefix); /** - * This method removes an on-link prefix entry matching a given prefix. + * Removes an on-link prefix entry matching a given prefix. * * @param[in] aPrefix The prefix to remove * @@ -1210,7 +1205,7 @@ class Settings : public SettingsBase, private NonCopyable Error RemoveBrOnLinkPrefix(const Ip6::Prefix &aPrefix); /** - * This method deletes all on-link prefix entries from the settings. + * Deletes all on-link prefix entries from the settings. * * @retval kErrorNone Successfully deleted the entries. * @retval kErrorNotImplemented The platform does not implement settings functionality. @@ -1219,7 +1214,7 @@ class Settings : public SettingsBase, private NonCopyable Error DeleteAllBrOnLinkPrefixes(void); /** - * This method retrieves an entry from on-link prefixes list at a given index. + * Retrieves an entry from on-link prefixes list at a given index. * * @param[in] aIndex The index to read. * @param[out] aBrOnLinkPrefix A reference to `BrOnLinkPrefix` to output the read value. diff --git a/src/core/common/settings_driver.hpp b/src/core/common/settings_driver.hpp index f7851a22864..c4670897ba5 100644 --- a/src/core/common/settings_driver.hpp +++ b/src/core/common/settings_driver.hpp @@ -50,7 +50,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the `SettingsDriver`. + * Initializes the `SettingsDriver`. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -64,7 +64,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method initializes the settings storage driver. + * Initializes the settings storage driver. * * @param[in] aSensitiveKeys A pointer to an array containing the list of sensitive keys. * @param[in] aSensitiveKeysLength The number of entries in the @p aSensitiveKeys array. @@ -83,7 +83,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method deinitializes the settings driver. + * Deinitializes the settings driver. * */ void Deinit(void) @@ -94,7 +94,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method adds a value to @p aKey. + * Adds a value to @p aKey. * * @param[in] aKey The key associated with the value. * @param[in] aValue A pointer to where the new value of the setting should be read from. @@ -119,7 +119,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method removes a value from @p aKey. + * Removes a value from @p aKey. * * @param[in] aKey The key associated with the value. * @param[in] aIndex The index of the value to be removed. @@ -142,7 +142,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method fetches the value identified by @p aKey at a given @p aIndex. + * Fetches the value identified by @p aKey at a given @p aIndex. * * @param[in] aKey The key associated with the requested value. * @param[in] aIndex The index of the specific item to get. @@ -172,7 +172,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method fetches the value identified by @p aKey. + * Fetches the value identified by @p aKey. * * @param[in] aKey The key associated with the requested value. * @param[out] aValue A pointer to where the value of the setting should be written. @@ -190,7 +190,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable Error Get(uint16_t aKey, void *aValue, uint16_t *aValueLength) const { return Get(aKey, 0, aValue, aValueLength); } /** - * This method sets or replaces the value identified by @p aKey. + * Sets or replaces the value identified by @p aKey. * * If there was more than one value previously associated with @p aKey, then they are all deleted and replaced with * this single entry. @@ -218,7 +218,7 @@ class SettingsDriver : public InstanceLocator, private NonCopyable } /** - * This method removes all values. + * Removes all values. * */ void Wipe(void) diff --git a/src/core/common/string.hpp b/src/core/common/string.hpp index fbbaca7ee21..035bc3f3218 100644 --- a/src/core/common/string.hpp +++ b/src/core/common/string.hpp @@ -58,7 +58,7 @@ namespace ot { */ /** - * This enumeration represents comparison mode when matching strings. + * Represents comparison mode when matching strings. * */ enum StringMatchMode : uint8_t @@ -70,7 +70,7 @@ enum StringMatchMode : uint8_t static constexpr char kNullChar = '\0'; ///< null character. /** - * This function returns the number of characters that precede the terminating null character. + * Returns the number of characters that precede the terminating null character. * * @param[in] aString A pointer to the string. * @param[in] aMaxLength The maximum length in bytes. @@ -82,7 +82,7 @@ static constexpr char kNullChar = '\0'; ///< null character. uint16_t StringLength(const char *aString, uint16_t aMaxLength); /** - * This function finds the first occurrence of a given character in a null-terminated string. + * Finds the first occurrence of a given character in a null-terminated string. * * @param[in] aString A pointer to the string. * @param[in] aChar A char to search for in the string. @@ -93,7 +93,7 @@ uint16_t StringLength(const char *aString, uint16_t aMaxLength); const char *StringFind(const char *aString, char aChar); /** - * This function finds the first occurrence of a given sub-string in a null-terminated string. + * Finds the first occurrence of a given sub-string in a null-terminated string. * * @param[in] aString A pointer to the string. * @param[in] aSubString A sub-string to search for. @@ -106,7 +106,7 @@ const char *StringFind(const char *aString, char aChar); const char *StringFind(const char *aString, const char *aSubString, StringMatchMode aMode = kStringExactMatch); /** - * This function checks whether a null-terminated string starts with a given prefix string. + * Checks whether a null-terminated string starts with a given prefix string. * * @param[in] aString A pointer to the string. * @param[in] aPrefixString A prefix string. @@ -119,7 +119,7 @@ const char *StringFind(const char *aString, const char *aSubString, StringMatchM bool StringStartsWith(const char *aString, const char *aPrefixString, StringMatchMode aMode = kStringExactMatch); /** - * This function checks whether a null-terminated string ends with a given character. + * Checks whether a null-terminated string ends with a given character. * * @param[in] aString A pointer to the string. * @param[in] aChar A char to check. @@ -131,7 +131,7 @@ bool StringStartsWith(const char *aString, const char *aPrefixString, StringMatc bool StringEndsWith(const char *aString, char aChar); /** - * This function checks whether a null-terminated string ends with a given sub-string. + * Checks whether a null-terminated string ends with a given sub-string. * * @param[in] aString A pointer to the string. * @param[in] aSubString A sub-string to check against. @@ -144,7 +144,7 @@ bool StringEndsWith(const char *aString, char aChar); bool StringEndsWith(const char *aString, const char *aSubString, StringMatchMode aMode = kStringExactMatch); /** - * This function checks whether or not two null-terminated strings match. + * Checks whether or not two null-terminated strings match. * * @param[in] aFirstString A pointer to the first string. * @param[in] aSecondString A pointer to the second string. @@ -157,7 +157,7 @@ bool StringEndsWith(const char *aString, const char *aSubString, StringMatchMode bool StringMatch(const char *aFirstString, const char *aSecondString, StringMatchMode aMode = kStringExactMatch); /** - * This function parses a decimal number from a string as `uint8_t` and skips over the parsed characters. + * Parses a decimal number from a string as `uint8_t` and skips over the parsed characters. * * If the string does not start with a digit, `kErrorParse` is returned. * @@ -177,7 +177,7 @@ bool StringMatch(const char *aFirstString, const char *aSecondString, StringMatc Error StringParseUint8(const char *&aString, uint8_t &aUint8, uint8_t aMaxValue); /** - * This function parses a decimal number from a string as `uint8_t` and skips over the parsed characters. + * Parses a decimal number from a string as `uint8_t` and skips over the parsed characters. * * If the string does not start with a digit, `kErrorParse` is returned. * @@ -196,7 +196,7 @@ Error StringParseUint8(const char *&aString, uint8_t &aUint8, uint8_t aMaxValue) Error StringParseUint8(const char *&aString, uint8_t &aUint8); /** - * This function converts all uppercase letter characters in a given string to lowercase. + * Converts all uppercase letter characters in a given string to lowercase. * * @param[in,out] aString A pointer to the string to convert. * @@ -204,7 +204,7 @@ Error StringParseUint8(const char *&aString, uint8_t &aUint8); void StringConvertToLowercase(char *aString); /** - * This function converts all lowercase letter characters in a given string to uppercase. + * Converts all lowercase letter characters in a given string to uppercase. * * @param[in,out] aString A pointer to the string to convert. * @@ -212,7 +212,7 @@ void StringConvertToLowercase(char *aString); void StringConvertToUppercase(char *aString); /** - * This function converts an uppercase letter character to lowercase. + * Converts an uppercase letter character to lowercase. * * If @p aChar is uppercase letter it is converted lowercase. Otherwise, it remains unchanged. * @@ -224,7 +224,7 @@ void StringConvertToUppercase(char *aString); char ToLowercase(char aChar); /** - * This function converts a lowercase letter character to uppercase. + * Converts a lowercase letter character to uppercase. * * If @p aChar is lowercase letter it is converted uppercase. Otherwise, it remains unchanged. * @@ -236,7 +236,7 @@ char ToLowercase(char aChar); char ToUppercase(char aChar); /** - * This function coverts a boolean to "yes" or "no" string. + * Coverts a boolean to "yes" or "no" string. * * @param[in] aBool A boolean value to convert. * @@ -246,7 +246,7 @@ char ToUppercase(char aChar); const char *ToYesNo(bool aBool); /** - * This function validates whether a given byte sequence (string) follows UTF-8 encoding. + * Validates whether a given byte sequence (string) follows UTF-8 encoding. * Control characters are not allowed. * * @param[in] aString A null-terminated byte sequence. @@ -258,7 +258,7 @@ const char *ToYesNo(bool aBool); bool IsValidUtf8String(const char *aString); /** - * This function validates whether a given byte sequence (string) follows UTF-8 encoding. + * Validates whether a given byte sequence (string) follows UTF-8 encoding. * Control characters are not allowed. * * @param[in] aString A byte sequence. @@ -291,14 +291,14 @@ inline constexpr bool AreStringsInOrder(const char *aFirst, const char *aSecond) } /** - * This class implements writing to a string buffer. + * Implements writing to a string buffer. * */ class StringWriter { public: /** - * This constructor initializes the object as cleared on the provided buffer. + * Initializes the object as cleared on the provided buffer. * * @param[in] aBuffer A pointer to the char buffer to write into. * @param[in] aSize The size of @p aBuffer. @@ -307,7 +307,7 @@ class StringWriter StringWriter(char *aBuffer, uint16_t aSize); /** - * This method clears the string writer. + * Clears the string writer. * * @returns The string writer. * @@ -315,7 +315,7 @@ class StringWriter StringWriter &Clear(void); /** - * This method returns whether the output is truncated. + * Returns whether the output is truncated. * * @note If the output is truncated, the buffer is still null-terminated. * @@ -326,7 +326,7 @@ class StringWriter bool IsTruncated(void) const { return mLength >= mSize; } /** - * This method gets the length of the wanted string. + * Gets the length of the wanted string. * * Similar to `strlen()` the length does not include the null character at the end of the string. * @@ -336,7 +336,7 @@ class StringWriter uint16_t GetLength(void) const { return mLength; } /** - * This method returns the size (number of chars) in the buffer. + * Returns the size (number of chars) in the buffer. * * @returns The size of the buffer. * @@ -344,7 +344,7 @@ class StringWriter uint16_t GetSize(void) const { return mSize; } /** - * This method appends `printf()` style formatted data to the buffer. + * Appends `printf()` style formatted data to the buffer. * * @param[in] aFormat A pointer to the format string. * @param[in] ... Arguments for the format specification. @@ -355,7 +355,7 @@ class StringWriter StringWriter &Append(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3); /** - * This method appends `printf()` style formatted data to the buffer. + * Appends `printf()` style formatted data to the buffer. * * @param[in] aFormat A pointer to the format string. * @param[in] aArgs Arguments for the format specification (as `va_list`). @@ -366,7 +366,7 @@ class StringWriter StringWriter &AppendVarArgs(const char *aFormat, va_list aArgs); /** - * This method appends an array of bytes in hex representation (using "%02x" style) to the buffer. + * Appends an array of bytes in hex representation (using "%02x" style) to the buffer. * * @param[in] aBytes A pointer to buffer containing the bytes to append. * @param[in] aLength The length of @p aBytes buffer (in bytes). @@ -377,13 +377,13 @@ class StringWriter StringWriter &AppendHexBytes(const uint8_t *aBytes, uint16_t aLength); /** - * This method converts all uppercase letter characters in the string to lowercase. + * Converts all uppercase letter characters in the string to lowercase. * */ void ConvertToLowercase(void) { StringConvertToLowercase(mBuffer); } /** - * This method converts all lowercase letter characters in the string to uppercase. + * Converts all lowercase letter characters in the string to uppercase. * */ void ConvertToUppercase(void) { StringConvertToUppercase(mBuffer); } @@ -395,7 +395,7 @@ class StringWriter }; /** - * This class defines a fixed-size string. + * Defines a fixed-size string. * */ template class String : public StringWriter @@ -404,7 +404,7 @@ template class String : public StringWriter public: /** - * This constructor initializes the string as empty. + * Initializes the string as empty. * */ String(void) @@ -413,7 +413,7 @@ template class String : public StringWriter } /** - * This method returns the string as a null-terminated C string. + * Returns the string as a null-terminated C string. * * @returns The null-terminated C string. * @@ -425,7 +425,7 @@ template class String : public StringWriter }; /** - * This class provides helper methods to convert from a set of `uint16_t` values (e.g., a non-sequential `enum`) to + * Provides helper methods to convert from a set of `uint16_t` values (e.g., a non-sequential `enum`) to * string using binary search in a lookup table. * */ @@ -433,7 +433,7 @@ class Stringify : public BinarySearch { public: /** - * This class represents a entry in the lookup table. + * Represents a entry in the lookup table. * */ class Entry @@ -454,7 +454,7 @@ class Stringify : public BinarySearch }; /** - * This static method looks up a key in a given sorted table array (using binary search) and return the associated + * Looks up a key in a given sorted table array (using binary search) and return the associated * strings with the key. * * @note This method requires the array to be sorted, otherwise its behavior is undefined. diff --git a/src/core/common/tasklet.hpp b/src/core/common/tasklet.hpp index 3694eab8310..48a3f07afe3 100644 --- a/src/core/common/tasklet.hpp +++ b/src/core/common/tasklet.hpp @@ -58,14 +58,14 @@ class TaskletScheduler; */ /** - * This class is used to represent a tasklet. + * Is used to represent a tasklet. * */ class Tasklet : public InstanceLocator { public: /** - * This class implements the tasklet scheduler. + * Implements the tasklet scheduler. * */ class Scheduler : private NonCopyable @@ -74,7 +74,7 @@ class Tasklet : public InstanceLocator public: /** - * This constructor initializes the object. + * Initializes the object. * */ Scheduler(void) @@ -83,7 +83,7 @@ class Tasklet : public InstanceLocator } /** - * This method indicates whether or not there are tasklets pending. + * Indicates whether or not there are tasklets pending. * * @retval TRUE If there are tasklets pending. * @retval FALSE If there are no tasklets pending. @@ -92,7 +92,7 @@ class Tasklet : public InstanceLocator bool AreTaskletsPending(void) const { return mTail != nullptr; } /** - * This method processes all tasklets queued when this is called. + * Processes all tasklets queued when this is called. * */ void ProcessQueuedTasklets(void); @@ -104,7 +104,7 @@ class Tasklet : public InstanceLocator }; /** - * This function reference is called when the tasklet is run. + * Reference is called when the tasklet is run. * * @param[in] aTasklet A reference to the tasklet being run. * @@ -112,7 +112,7 @@ class Tasklet : public InstanceLocator typedef void (&Handler)(Tasklet &aTasklet); /** - * This constructor creates a tasklet instance. + * Creates a tasklet instance. * * @param[in] aInstance A reference to the OpenThread instance object. * @param[in] aHandler A pointer to a function that is called when the tasklet is run. @@ -126,7 +126,7 @@ class Tasklet : public InstanceLocator } /** - * This method puts the tasklet on the tasklet scheduler run queue. + * Puts the tasklet on the tasklet scheduler run queue. * * If the tasklet is already posted, no change is made and run queue stays as before. * @@ -134,7 +134,7 @@ class Tasklet : public InstanceLocator void Post(void); /** - * This method indicates whether the tasklet is posted or not. + * Indicates whether the tasklet is posted or not. * * @retval TRUE The tasklet is posted. * @retval FALSE The tasklet is not posted. @@ -150,7 +150,7 @@ class Tasklet : public InstanceLocator }; /** - * This template class defines a tasklet owned by specific type and using a method on owner type as the callback. + * Defines a tasklet owned by specific type and using a method on owner type as the callback. * * @tparam Owner The type of owner of this tasklet. * @tparam HandleTaskletPtr A pointer to a non-static member method of `Owner` to use as tasklet handler. @@ -162,7 +162,7 @@ template class TaskletIn { public: /** - * This constructor initializes the tasklet. + * Initializes the tasklet. * * @param[in] aInstance The OpenThread instance. * @@ -177,7 +177,7 @@ template class TaskletIn }; /** - * This class defines a tasklet that also maintains a user context pointer. + * Defines a tasklet that also maintains a user context pointer. * * In typical `Tasklet` use, in the handler callback, the owner of the tasklet is determined using `GetOwner` * method. This method works if there is a single instance of `Type` within OpenThread instance hierarchy. The @@ -189,7 +189,7 @@ class TaskletContext : public Tasklet { public: /** - * This constructor creates a tasklet instance. + * Creates a tasklet instance. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aHandler A pointer to a function that is called when the tasklet is run. @@ -203,7 +203,7 @@ class TaskletContext : public Tasklet } /** - * This method returns the pointer to the arbitrary context information. + * Returns the pointer to the arbitrary context information. * * @returns Pointer to the arbitrary context information. * diff --git a/src/core/common/time.hpp b/src/core/common/time.hpp index 6c07fa3c81a..12c16f8b13a 100644 --- a/src/core/common/time.hpp +++ b/src/core/common/time.hpp @@ -55,7 +55,7 @@ namespace ot { */ /** - * This class represents a time instance. + * Represents a time instance. * */ class Time : public Unequatable
d.::." (if longer than a day). @@ -87,7 +93,7 @@ class Uptime : public InstanceLocator, private NonCopyable void GetUptime(char *aBuffer, uint16_t aSize) const; /** - * This method converts an uptime value (number of milliseconds) to a human-readable string. + * Converts an uptime value (number of milliseconds) to a human-readable string. * * The string follows the format "::." for hours, minutes, seconds and millisecond (if uptime is * shorter than one day) or "
d.::." (if longer than a day). @p aIncludeMsec can be used @@ -101,7 +107,7 @@ class Uptime : public InstanceLocator, private NonCopyable static void UptimeToString(uint64_t aUptime, StringWriter &aWriter, bool aIncludeMsec); /** - * This static method converts a given uptime as number of milliseconds to number of seconds. + * Converts a given uptime as number of milliseconds to number of seconds. * * @param[in] aUptimeInMilliseconds Uptime in milliseconds (as `uint64_t`). * @@ -114,7 +120,7 @@ class Uptime : public InstanceLocator, private NonCopyable } /** - * This static method converts a given uptime as number of seconds to number of milliseconds. + * Converts a given uptime as number of seconds to number of milliseconds. * * @param[in] aUptimeInSeconds Uptime in seconds (as `uint32_t`). * diff --git a/src/core/config/border_router.h b/src/core/config/border_router.h index 01ddfe9aa2e..543ea8feda7 100644 --- a/src/core/config/border_router.h +++ b/src/core/config/border_router.h @@ -35,6 +35,8 @@ #ifndef CONFIG_BORDER_ROUTER_H_ #define CONFIG_BORDER_ROUTER_H_ +#include + /** * @def OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE * @@ -71,4 +73,14 @@ #define OPENTHREAD_CONFIG_BORDER_ROUTER_REQUEST_ROUTER_ROLE 1 #endif +/** + * @def OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + * + * Define as 1 to enable mechanism to detect and signal when local or leader Network Data gets full. + * + */ +#ifndef OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL +#define OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE +#endif + #endif // CONFIG_BORDER_ROUTER_H_ diff --git a/src/core/config/border_routing.h b/src/core/config/border_routing.h index 1327901ea06..b016eef6cd5 100644 --- a/src/core/config/border_routing.h +++ b/src/core/config/border_routing.h @@ -104,4 +104,17 @@ #define OPENTHREAD_CONFIG_BORDER_ROUTING_ROUTER_ACTIVE_CHECK_TIMEOUT (60 * 1000) // (in msec). #endif +/** + * @def OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + * + * Specifies whether to support handling platform generated ND messages. + * + * The desired use case is the prefix will be allocated by other software on the interface, and they will advertise the + * assigned prefix to the thread interface via router advertisement messages. + * + */ +#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 0 +#endif + #endif // CONFIG_BORDER_ROUTING_H_ diff --git a/src/core/config/mac.h b/src/core/config/mac.h index 0358b22ebda..2694e0dc84a 100644 --- a/src/core/config/mac.h +++ b/src/core/config/mac.h @@ -489,16 +489,27 @@ #endif /** - * @def OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD * - * The minimum CSL receive window (in microseconds) required to receive an IEEE 802.15.4 frame. - * - Maximum frame size with preamble: 6*2+127*2 symbols - * - AIFS: 12 symbols - * - Maximum ACK size with preamble: 6*2+33*2 symbols + * The minimum time (in microseconds) before the MHR start that the radio should be in receive state and ready to + * properly receive in order to properly receive any IEEE 802.15.4 frame. Defaults to the duration of SHR + PHR. * */ -#ifndef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON -#define OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON 356 * 16 +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD (6 * 32) +#endif + +/** + * @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER + * + * The minimum time (in microseconds) after the MHR start that the radio should be in receive state in order + * to properly receive any IEEE 802.15.4 frame. Defaults to the duration of a maximum size frame, plus AIFS, + * plus the duration of maximum enh-ack frame. Platforms are encouraged to improve this value for energy + * efficiency purposes. + * + */ +#ifndef OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER +#define OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER ((127 + 6 + 39) * 32) #endif /** diff --git a/src/core/config/mesh_forwarder.h b/src/core/config/mesh_forwarder.h new file mode 100644 index 00000000000..497b84f0f23 --- /dev/null +++ b/src/core/config/mesh_forwarder.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2016-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 + * This file includes compile-time configurations for Mesh Forwarder. + */ + +#ifndef CONFIG_MESH_FORWARDER_H_ +#define CONFIG_MESH_FORWARDER_H_ + +/** + * @def OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE + * + * Define as 1 for OpenThread to drop a message (and not send any remaining fragments of the message) if all transmit + * attempts fail for a fragment of the message. For a direct transmission, a failure occurs after all MAC transmission + * attempts for a given fragment are unsuccessful. For an indirect transmission, a failure occurs after all data poll + * triggered transmission attempts for a given fragment fail. + * + * If set to zero (disabled), OpenThread will attempt to send subsequent fragments, whether or not all transmission + * attempts fail for a given fragment. + * + */ +#ifndef OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE +#define OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE 1 +#endif + +/** + * @def OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT + * + * The reassembly timeout between 6LoWPAN fragments in seconds. + * + */ +#ifndef OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT +#define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 2 +#endif + +/** + * @def OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES + * + * The number of fragment priority entries. + * + */ +#ifndef OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES +#define OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES 8 +#endif + +/** + * @def OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE + * + * Define to 1 to enable delay-aware queue management for the send queue. + * + * When enabled device will monitor time-in-queue of messages in the direct tx queue and if the wait time is lager than + * specified thresholds it may update ECN flag (if message indicates it is ECN-capable) or drop the message. + * + */ +#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE +#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE \ + (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3) +#endif + +/** + * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL + * + * Specifies the time-in-queue threshold interval in milliseconds to mark ECN on a message if it is ECN-capable or + * drop the message if not ECN-capable. + * + */ +#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL +#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL 500 +#endif + +/** + * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL + * + * Specifies the time-in-queue threshold interval in milliseconds to drop a message. + * + */ +#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL +#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL 1000 +#endif + +/** + * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME + * + * Specifies the max retain time in seconds of a mesh header fragmentation tag entry in the list. + * + * The entry in list is used to track whether an earlier fragment of same message was dropped by the router and if so + * the next fragments are also dropped. The entry is removed once last fragment is processed or after the retain time + * specified by this config parameter expires. + * + */ +#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME +#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME (4 * 60) // 4 minutes +#endif + +/** + * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE + * + * Specifies the number of mesh header fragmentation tag entries in the list for delay-aware queue management. + * + * The list is used to track whether an earlier fragment of same message was dropped by the router and if so the next + * fragments are also dropped. + * + */ +#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE +#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE 16 +#endif + +/** + * @def OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE + * + * Specifies the maximum number of frames in direct tx queue before new direct tx messages are dropped. + * + * If set to zero then the behavior is disabled, i.e., no check is performed on tx queue length. + * + */ +#ifndef OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3) +#define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 100 +#else +#define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 0 +#endif +#endif + +#endif // CONFIG_MESH_FORWARDER_H_ diff --git a/src/core/config/misc.h b/src/core/config/misc.h index ea973bf63cb..2fb8eaa6b9b 100644 --- a/src/core/config/misc.h +++ b/src/core/config/misc.h @@ -222,32 +222,6 @@ #define OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER 0 #endif -/** - * @def OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE - * - * Define as 1 for OpenThread to drop a message (and not send any remaining fragments of the message) if all transmit - * attempts fail for a fragment of the message. For a direct transmission, a failure occurs after all MAC transmission - * attempts for a given fragment are unsuccessful. For an indirect transmission, a failure occurs after all data poll - * triggered transmission attempts for a given fragment fail. - * - * If set to zero (disabled), OpenThread will attempt to send subsequent fragments, whether or not all transmission - * attempts fail for a given fragment. - * - */ -#ifndef OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE -#define OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE 1 -#endif - -/** - * @def OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT - * - * The reassembly timeout between 6LoWPAN fragments in seconds. - * - */ -#ifndef OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT -#define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 2 -#endif - /** * @def OPENTHREAD_CONFIG_JOINER_UDP_PORT * @@ -461,94 +435,6 @@ #define OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT 1 #endif -/** - * @def OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES - * - * The number of fragment priority entries. - * - */ -#ifndef OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES -#define OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES 8 -#endif - -/** - * @def OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE - * - * Define to 1 to enable delay-aware queue management for the send queue. - * - * When enabled device will monitor time-in-queue of messages in the direct tx queue and if the wait time is lager than - * specified thresholds it may update ECN flag (if message indicates it is ECN-capable) or drop the message. - * - */ -#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE -#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE \ - (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3) -#endif - -/** - * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL - * - * Specifies the time-in-queue threshold interval in milliseconds to mark ECN on a message if it is ECN-capable or - * drop the message if not ECN-capable. - * - */ -#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL -#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL 500 -#endif - -/** - * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL - * - * Specifies the time-in-queue threshold interval in milliseconds to drop a message. - * - */ -#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL -#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL 1000 -#endif - -/** - * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME - * - * Specifies the max retain time in seconds of a mesh header fragmentation tag entry in the list. - * - * The entry in list is used to track whether an earlier fragment of same message was dropped by the router and if so - * the next fragments are also dropped. The entry is removed once last fragment is processed or after the retain time - * specified by this config parameter expires. - * - */ -#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME -#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME (4 * 60) // 4 minutes -#endif - -/** - * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE - * - * Specifies the number of mesh header fragmentation tag entries in the list for delay-aware queue management. - * - * The list is used to track whether an earlier fragment of same message was dropped by the router and if so the next - * fragments are also dropped. - * - */ -#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE -#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE 16 -#endif - -/** - * @def OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE - * - * Specifies the maximum number of frames in direct tx queue before new direct tx messages are dropped. - * - * If set to zero then the behavior is disabled, i.e., no check is performed on tx queue length. - * - */ -#ifndef OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE -#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3) -#define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 100 -#else -#define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 0 -#endif -#endif - /** * @def OPENTHREAD_CONFIG_PLATFORM_RADIO_PROPRIETARY_SUPPORT * diff --git a/src/core/config/openthread-core-config-check.h b/src/core/config/openthread-core-config-check.h index 67976e149fb..5d26a6e0ffc 100644 --- a/src/core/config/openthread-core-config-check.h +++ b/src/core/config/openthread-core-config-check.h @@ -668,4 +668,9 @@ "OPENTHREAD_CONFIG_SRP_SERVER_DEFAULT_ADDRESS_MODE." #endif +#ifdef OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON +#error "OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON was replaced with "\ + "OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD and OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER" +#endif + #endif // OPENTHREAD_CORE_CONFIG_CHECK_H_ diff --git a/src/core/config/radio_link.h b/src/core/config/radio_link.h index e82ea965085..14e9a129236 100644 --- a/src/core/config/radio_link.h +++ b/src/core/config/radio_link.h @@ -55,6 +55,17 @@ #define OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE 0 #endif +/** + * @def OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + * + * Set to 1 to enable support for Radio Statistics. Note that this option only works for OPENTHREAD_FTD and + * OPENTHREAD_MTD. + * + */ +#ifndef OPENTHREAD_CONFIG_RADIO_STATS_ENABLE +#define OPENTHREAD_CONFIG_RADIO_STATS_ENABLE 0 +#endif + //-------------------------------------------------------------- #if !OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE && !OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE diff --git a/src/core/crypto/aes_ccm.hpp b/src/core/crypto/aes_ccm.hpp index 8ae9ccc93f5..05bf6c555a9 100644 --- a/src/core/crypto/aes_ccm.hpp +++ b/src/core/crypto/aes_ccm.hpp @@ -57,7 +57,7 @@ namespace Crypto { */ /** - * This class implements AES CCM computation. + * Implements AES CCM computation. * */ class AesCcm @@ -68,7 +68,7 @@ class AesCcm static constexpr uint8_t kNonceSize = 13; ///< Size of IEEE 802.15.4 Nonce (in bytes). /** - * This enumeration type represent the encryption vs decryption mode. + * Type represent the encryption vs decryption mode. * */ enum Mode : uint8_t @@ -78,7 +78,7 @@ class AesCcm }; /** - * This method sets the key. + * Sets the key. * * @param[in] aKey Crypto Key used in AES operation * @@ -86,7 +86,7 @@ class AesCcm void SetKey(const Key &aKey) { mEcb.SetKey(aKey); } /** - * This method sets the key. + * Sets the key. * * @param[in] aKey A pointer to the key. * @param[in] aKeyLength Length of the key in bytes. @@ -95,7 +95,7 @@ class AesCcm void SetKey(const uint8_t *aKey, uint16_t aKeyLength); /** - * This method sets the key. + * Sets the key. * * @param[in] aMacKey Key Material for AES operation. * @@ -103,7 +103,7 @@ class AesCcm void SetKey(const Mac::KeyMaterial &aMacKey); /** - * This method initializes the AES CCM computation. + * Initializes the AES CCM computation. * * @param[in] aHeaderLength Length of header in bytes. * @param[in] aPlainTextLength Length of plaintext in bytes. @@ -119,7 +119,7 @@ class AesCcm uint8_t aNonceLength); /** - * This method processes the header. + * Processes the header. * * @param[in] aHeader A pointer to the header. * @param[in] aHeaderLength Length of header in bytes. @@ -128,7 +128,7 @@ class AesCcm void Header(const void *aHeader, uint32_t aHeaderLength); /** - * This method processes the header. + * Processes the header. * * @tparam ObjectType The object type. * @@ -143,7 +143,7 @@ class AesCcm } /** - * This method processes the payload. + * Processes the payload. * * @param[in,out] aPlainText A pointer to the plaintext. * @param[in,out] aCipherText A pointer to the ciphertext. @@ -155,9 +155,9 @@ class AesCcm #if !OPENTHREAD_RADIO /** - * This method processes the payload within a given message. + * Processes the payload within a given message. * - * This method encrypts/decrypts the payload content in place within the @p aMessage. + * Encrypts/decrypts the payload content in place within the @p aMessage. * * @param[in,out] aMessage The message to read from and update. * @param[in] aOffset The offset in @p aMessage to start of payload. @@ -169,7 +169,7 @@ class AesCcm #endif /** - * This method returns the tag length in bytes. + * Returns the tag length in bytes. * * @returns The tag length in bytes. * @@ -177,7 +177,7 @@ class AesCcm uint8_t GetTagLength(void) const { return mTagLength; } /** - * This method generates the tag. + * Generates the tag. * * @param[out] aTag A pointer to the tag (must have `GetTagLength()` bytes). * @@ -185,7 +185,7 @@ class AesCcm void Finalize(void *aTag); /** - * This static method generates IEEE 802.15.4 nonce byte sequence. + * Generates IEEE 802.15.4 nonce byte sequence. * * @param[in] aAddress An extended address. * @param[in] aFrameCounter A frame counter. diff --git a/src/core/crypto/aes_ecb.hpp b/src/core/crypto/aes_ecb.hpp index 61680ad2a76..80fa15f6332 100644 --- a/src/core/crypto/aes_ecb.hpp +++ b/src/core/crypto/aes_ecb.hpp @@ -53,7 +53,7 @@ namespace Crypto { */ /** - * This class implements AES ECB computation. + * Implements AES ECB computation. * */ class AesEcb @@ -74,7 +74,7 @@ class AesEcb ~AesEcb(void); /** - * This method sets the key. + * Sets the key. * * @param[in] aKey Crypto Key used for ECB operation * @@ -82,7 +82,7 @@ class AesEcb void SetKey(const Key &aKey); /** - * This method encrypts data. + * Encrypts data. * * @param[in] aInput A pointer to the input buffer. * @param[out] aOutput A pointer to the output buffer. diff --git a/src/core/crypto/ecdsa.hpp b/src/core/crypto/ecdsa.hpp index 41a693d7dda..6fffb29bbda 100644 --- a/src/core/crypto/ecdsa.hpp +++ b/src/core/crypto/ecdsa.hpp @@ -60,7 +60,7 @@ namespace Ecdsa { */ /** - * This class implements ECDSA key-generation, signing, and verification for NIST P-256 curve using SHA-256 hash. + * Implements ECDSA key-generation, signing, and verification for NIST P-256 curve using SHA-256 hash. * * NIST P-256 curve is also known as 256-bit Random ECP Group (RFC 5114 - 2.6), or secp256r1 (RFC 4492 - Appendix A). * @@ -83,7 +83,7 @@ class P256 #endif /** - * This class represents an ECDSA signature. + * 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). @@ -102,7 +102,7 @@ class P256 static constexpr uint8_t kSize = OT_CRYPTO_ECDSA_SIGNATURE_SIZE; ///< Signature size in bytes. /** - * This method returns the signature as a byte array. + * Returns the signature as a byte array. * * @returns A pointer to the byte array containing the signature. * @@ -111,7 +111,7 @@ class P256 } OT_TOOL_PACKED_END; /** - * This class represents a key pair (public and private keys). + * Represents a key pair (public and private keys). * * The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915). * @@ -126,13 +126,13 @@ class P256 static constexpr uint8_t kMaxDerSize = OT_CRYPTO_ECDSA_MAX_DER_SIZE; /** - * This constructor initializes a `KeyPair` as empty (no key). + * Initializes a `KeyPair` as empty (no key). * */ KeyPair(void) { mDerLength = 0; } /** - * This method generates and populates the `KeyPair` with a new public/private keys. + * Generates and populates the `KeyPair` with a new public/private keys. * * @retval kErrorNone A new key pair was generated successfully. * @retval kErrorNoBufs Failed to allocate buffer for key generation. @@ -143,7 +143,7 @@ class P256 Error Generate(void) { return otPlatCryptoEcdsaGenerateKey(this); } /** - * This method gets the associated public key from the `KeyPair`. + * Gets the associated public key from the `KeyPair`. * * @param[out] aPublicKey A reference to a `PublicKey` to output the value. * @@ -154,7 +154,7 @@ class P256 Error GetPublicKey(PublicKey &aPublicKey) const { return otPlatCryptoEcdsaGetPublicKey(this, &aPublicKey); } /** - * This method gets the pointer to start of the buffer containing the key-pair info in DER format. + * Gets the pointer to start of the buffer containing the key-pair info in DER format. * * The length (number of bytes) of DER format is given by `GetDerLength()`. * @@ -164,7 +164,7 @@ class P256 const uint8_t *GetDerBytes(void) const { return mDerBytes; } /** - * This method gets the length of the byte sequence representation of the key-pair in DER format. + * Gets the length of the byte sequence representation of the key-pair in DER format. * * @returns The length of byte sequence representation of the key-pair in DER format. * @@ -172,9 +172,9 @@ class P256 uint8_t GetDerLength(void) const { return mDerLength; } /** - * This method gets the pointer to start of the key-pair buffer in DER format. + * Gets the pointer to start of the key-pair buffer in DER format. * - * This method gives non-const pointer to the buffer and is intended for populating the buffer and setting + * Gives non-const pointer to the buffer and is intended for populating the buffer and setting * the key-pair (e.g., reading the key-pair from non-volatile settings). The buffer contains `kMaxDerSize` * bytes. After populating the buffer, `SetDerLength()` can be used to set the the number of bytes written. * @@ -184,7 +184,7 @@ class P256 uint8_t *GetDerBytes(void) { return mDerBytes; } /** - * This method sets the length of the byte sequence representation of the key-pair in DER format. + * Sets the length of the byte sequence representation of the key-pair in DER format. * * @param[in] aDerLength The length (number of bytes). * @@ -192,9 +192,9 @@ class P256 void SetDerLength(uint8_t aDerLength) { mDerLength = aDerLength; } /** - * This method calculates the ECDSA signature for a hashed message using the private key from `KeyPair`. + * Calculates the ECDSA signature for a hashed message using the private key from `KeyPair`. * - * This method uses the deterministic digital signature generation procedure from RFC 6979. + * Uses the deterministic digital signature generation procedure from RFC 6979. * * @param[in] aHash The SHA-256 hash value of the message to use for signature calculation. * @param[out] aSignature A reference to a `Signature` to output the calculated signature value. @@ -213,21 +213,21 @@ class P256 #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This class represents a key pair (public and private keys) as a PSA KeyRef. + * Represents a key pair (public and private keys) as a PSA KeyRef. * */ class KeyPairAsRef { public: /** - * This constructor initializes a `KeyPairAsRef`. + * Initializes a `KeyPairAsRef`. * * @param[in] aKeyRef PSA key reference to use while using the keypair. */ explicit KeyPairAsRef(otCryptoKeyRef aKeyRef = 0) { mKeyRef = aKeyRef; } /** - * This method generates a new keypair and imports it into PSA ITS. + * Generates a new keypair and imports it into PSA ITS. * * @retval kErrorNone A new key pair was generated successfully. * @retval kErrorNoBufs Failed to allocate buffer for key generation. @@ -238,7 +238,7 @@ class P256 Error Generate(void) const { return otPlatCryptoEcdsaGenerateAndImportKey(mKeyRef); } /** - * This method imports a new keypair into PSA ITS. + * Imports a new keypair into PSA ITS. * * @param[in] aKeyPair KeyPair to be imported in DER format. * @@ -256,7 +256,7 @@ class P256 } /** - * This method gets the associated public key from the keypair referenced by mKeyRef. + * Gets the associated public key from the keypair referenced by mKeyRef. * * @param[out] aPublicKey A reference to a `PublicKey` to output the value. * @@ -270,10 +270,10 @@ class P256 } /** - * This method calculates the ECDSA signature for a hashed message using the private key from keypair + * Calculates the ECDSA signature for a hashed message using the private key from keypair * referenced by mKeyRef. * - * This method uses the deterministic digital signature generation procedure from RFC 6979. + * Uses the deterministic digital signature generation procedure from RFC 6979. * * @param[in] aHash The SHA-256 hash value of the message to use for signature calculation. * @param[out] aSignature A reference to a `Signature` to output the calculated signature value. @@ -290,7 +290,7 @@ class P256 } /** - * This method gets the Key reference for the keypair stored in the PSA. + * Gets the Key reference for the keypair stored in the PSA. * * @returns The PSA key ref. * @@ -298,7 +298,7 @@ class P256 otCryptoKeyRef GetKeyRef(void) const { return mKeyRef; } /** - * This method sets the Key reference. + * Sets the Key reference. * * @param[in] aKeyRef PSA key reference to use while using the keypair. * @@ -311,7 +311,7 @@ class P256 #endif /** - * This class represents a public key. + * Represents a public key. * * The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4). * @@ -328,7 +328,7 @@ class P256 static constexpr uint8_t kSize = OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE; ///< Size of the public key in bytes. /** - * This method gets the pointer to the buffer containing the public key (as an uncompressed curve point). + * Gets the pointer to the buffer containing the public key (as an uncompressed curve point). * * @return The pointer to the buffer containing the public key (with `kSize` bytes). * @@ -336,7 +336,7 @@ class P256 const uint8_t *GetBytes(void) const { return m8; } /** - * This method uses the `PublicKey` to verify the ECDSA signature of a hashed message. + * Uses the `PublicKey` to verify the ECDSA signature of a hashed message. * * @param[in] aHash The SHA-256 hash value of a message to use for signature verification. * @param[in] aSignature The signature value to verify. diff --git a/src/core/crypto/hkdf_sha256.hpp b/src/core/crypto/hkdf_sha256.hpp index 0eb1ae7e777..a3a70f1b6ec 100644 --- a/src/core/crypto/hkdf_sha256.hpp +++ b/src/core/crypto/hkdf_sha256.hpp @@ -53,7 +53,7 @@ namespace Crypto { */ /** - * This class implements HMAC-based Extract-and-Expand Key Derivation Function (HKDF) [RFC5869] using SHA-256. + * Implements HMAC-based Extract-and-Expand Key Derivation Function (HKDF) [RFC5869] using SHA-256. * */ class HkdfSha256 @@ -72,7 +72,7 @@ class HkdfSha256 ~HkdfSha256(void); /** - * This method performs the HKDF Extract step. + * Performs the HKDF Extract step. * * In the Extract step getting an input key extracts from it a pseudo-random key. * @@ -84,7 +84,7 @@ class HkdfSha256 void Extract(const uint8_t *aSalt, uint16_t aSaltLength, const Key &aInputKey); /** - * This method performs the HKDF Expand step. + * Performs the HKDF Expand step. * * The method should be used after a previous `Extract` call, otherwise its behavior is undefined. In the Expand * stage an output key of a given length is derived from the pseudo-random key of Extract stage. diff --git a/src/core/crypto/hmac_sha256.hpp b/src/core/crypto/hmac_sha256.hpp index 37141ceefd5..a8b130356a2 100644 --- a/src/core/crypto/hmac_sha256.hpp +++ b/src/core/crypto/hmac_sha256.hpp @@ -59,14 +59,14 @@ namespace Crypto { */ /** - * This class implements HMAC SHA-256 computation. + * Implements HMAC SHA-256 computation. * */ class HmacSha256 { public: /** - * This type represents a HMAC SHA-256 hash. + * Represents a HMAC SHA-256 hash. * */ typedef Sha256::Hash Hash; @@ -84,7 +84,7 @@ class HmacSha256 ~HmacSha256(void); /** - * This method sets the key and starts the HMAC computation. + * Sets the key and starts the HMAC computation. * * @param[in] aKey The key to use. * @@ -92,7 +92,7 @@ class HmacSha256 void Start(const Key &aKey); /** - * This method inputs bytes into the HMAC computation. + * Inputs bytes into the HMAC computation. * * @param[in] aBuf A pointer to the input buffer. * @param[in] aBufLength The length of @p aBuf in bytes. @@ -101,7 +101,7 @@ class HmacSha256 void Update(const void *aBuf, uint16_t aBufLength); /** - * This method inputs an object (treated as a sequence of bytes) into the HMAC computation. + * Inputs an object (treated as a sequence of bytes) into the HMAC computation. * * @tparam ObjectType The object type. * @@ -115,7 +115,7 @@ class HmacSha256 } /** - * This method inputs the bytes read from a given message into the HMAC computation. + * Inputs the bytes read from a given message into the HMAC computation. * * @param[in] aMessage The message to read the data from. * @param[in] aOffset The offset into @p aMessage to start to read. @@ -125,7 +125,7 @@ class HmacSha256 void Update(const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method finalizes the hash computation. + * Finalizes the hash computation. * * @param[out] aHash A reference to a `Hash` to output the calculated hash. * diff --git a/src/core/crypto/mbedtls.hpp b/src/core/crypto/mbedtls.hpp index a5fd869b604..8db6e740512 100644 --- a/src/core/crypto/mbedtls.hpp +++ b/src/core/crypto/mbedtls.hpp @@ -68,20 +68,20 @@ namespace Crypto { */ /** - * This class implements mbedTLS memory. + * Implements mbedTLS memory. * */ class MbedTls : private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * */ MbedTls(void); /** - * This method converts an mbed TLS error to OpenThread error. + * Converts an mbed TLS error to OpenThread error. * * @param[in] aMbedTlsError The mbed TLS error. * @@ -92,7 +92,7 @@ class MbedTls : private NonCopyable #if !OPENTHREAD_RADIO /** - * This function fills a given buffer with cryptographically secure random bytes. + * Fills a given buffer with cryptographically secure random bytes. * * @param[in] aContext A pointer to arbitrary context. * @param[out] aBuffer A pointer to a buffer to fill with the random bytes. diff --git a/src/core/crypto/sha256.hpp b/src/core/crypto/sha256.hpp index f895c8ec6b0..67b4f49fb7d 100644 --- a/src/core/crypto/sha256.hpp +++ b/src/core/crypto/sha256.hpp @@ -62,14 +62,14 @@ namespace Crypto { */ /** - * This class implements SHA-256 computation. + * Implements SHA-256 computation. * */ class Sha256 { public: /** - * This type represents a SHA-256 hash. + * Represents a SHA-256 hash. * */ class Hash : public otCryptoSha256Hash, public Clearable, public Equatable @@ -78,7 +78,7 @@ class Sha256 static const uint8_t kSize = OT_CRYPTO_SHA256_HASH_SIZE; ///< SHA-256 hash size (bytes) /** - * This method returns a pointer to a byte array containing the hash value. + * Returns a pointer to a byte array containing the hash value. * * @returns A pointer to a byte array containing the hash. * @@ -99,13 +99,13 @@ class Sha256 ~Sha256(void); /** - * This method starts the SHA-256 computation. + * Starts the SHA-256 computation. * */ void Start(void); /** - * This method inputs bytes into the SHA-256 computation. + * Inputs bytes into the SHA-256 computation. * * @param[in] aBuf A pointer to the input buffer. * @param[in] aBufLength The length of @p aBuf in bytes. @@ -114,7 +114,7 @@ class Sha256 void Update(const void *aBuf, uint16_t aBufLength); /** - * This method inputs an object (treated as a sequence of bytes) into the SHA-256 computation. + * Inputs an object (treated as a sequence of bytes) into the SHA-256 computation. * * @tparam ObjectType The object type. * @@ -128,7 +128,7 @@ class Sha256 } /** - * This method inputs the bytes read from a given message into the SHA-256 computation. + * Inputs the bytes read from a given message into the SHA-256 computation. * * @param[in] aMessage The message to read the data from. * @param[in] aOffset The offset into @p aMessage to start to read. @@ -138,7 +138,7 @@ class Sha256 void Update(const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method finalizes the hash computation. + * Finalizes the hash computation. * * @param[out] aHash A reference to a `Hash` to output the calculated hash. * diff --git a/src/core/crypto/storage.hpp b/src/core/crypto/storage.hpp index 8193943fb6a..f585803d05e 100644 --- a/src/core/crypto/storage.hpp +++ b/src/core/crypto/storage.hpp @@ -52,7 +52,7 @@ namespace Crypto { namespace Storage { /** - * This enumeration defines the key types. + * Defines the key types. * */ enum KeyType : uint8_t @@ -64,7 +64,7 @@ enum KeyType : uint8_t }; /** - * This enumeration defines the key algorithms. + * Defines the key algorithms. * */ enum KeyAlgorithm : uint8_t @@ -83,7 +83,7 @@ constexpr uint8_t kUsageSignHash = OT_CRYPTO_KEY_USAGE_SIGN_HASH; ///< Key U constexpr uint8_t kUsageVerifyHash = OT_CRYPTO_KEY_USAGE_VERIFY_HASH; ///< Key Usage: Verify Hash. /** - * This enumeration defines the key storage types. + * Defines the key storage types. * */ enum StorageType : uint8_t @@ -201,7 +201,7 @@ void DestroyPersistentKeys(void); #endif // OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This class represents a crypto key. + * Represents a crypto key. * * The `Key` can represent a literal key (i.e., a pointer to a byte array containing the key along with a key length) * or a `KeyRef` (if `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled). @@ -211,7 +211,7 @@ class Key : public otCryptoKey, public Clearable { public: /** - * This method sets the `Key` as a literal key from a given byte array and length. + * Sets the `Key` as a literal key from a given byte array and length. * * @param[in] aKeyBytes A pointer to buffer containing the key. * @param[in] aKeyLength The key length (number of bytes in @p aKeyBytes). @@ -224,7 +224,7 @@ class Key : public otCryptoKey, public Clearable } /** - * This method gets the pointer to the bye array containing the key. + * Gets the pointer to the bye array containing the key. * * If `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled and `IsKeyRef()` returns `true`, then this * method returns `nullptr`. @@ -235,7 +235,7 @@ class Key : public otCryptoKey, public Clearable const uint8_t *GetBytes(void) const { return mKey; } /** - * This method gets the key length (number of bytes). + * Gets the key length (number of bytes). * * If `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled and `IsKeyRef()` returns `true`, then this * method returns zero. @@ -248,7 +248,7 @@ class Key : public otCryptoKey, public Clearable #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method indicates whether or not the key is represented as a `KeyRef`. + * Indicates whether or not the key is represented as a `KeyRef`. * * @retval TRUE The `Key` represents a `KeyRef` * @retval FALSE The `Key` represents a literal key. @@ -257,9 +257,9 @@ class Key : public otCryptoKey, public Clearable bool IsKeyRef(void) const { return (mKey == nullptr); } /** - * This method gets the `KeyRef`. + * Gets the `KeyRef`. * - * This method MUST be used when `IsKeyRef()` returns `true`, otherwise its behavior is undefined. + * MUST be used when `IsKeyRef()` returns `true`, otherwise its behavior is undefined. * * @returns The `KeyRef` associated with `Key`. * @@ -267,7 +267,7 @@ class Key : public otCryptoKey, public Clearable Storage::KeyRef GetKeyRef(void) const { return mKeyRef; } /** - * This method sets the `Key` as a `KeyRef`. + * Sets the `Key` as a `KeyRef`. * * @param[in] aKeyRef The `KeyRef` to set from. * @@ -280,9 +280,9 @@ class Key : public otCryptoKey, public Clearable } /** - * This method extracts and return the literal key when the key is represented as a `KeyRef` + * Extracts and return the literal key when the key is represented as a `KeyRef` * - * This method MUST be used when `IsKeyRef()` returns `true`. + * MUST be used when `IsKeyRef()` returns `true`. * * @param[out] aKeyBuffer Pointer to a byte array buffer to place the extracted key. * @param[in,out] aKeyLength On input, the size of @p aKeyBuffer. @@ -297,7 +297,7 @@ class Key : public otCryptoKey, public Clearable }; /** - * This class represents a literal key derived from a `Key`. + * Represents a literal key derived from a `Key`. * */ class LiteralKey : public Clearable, private NonCopyable @@ -306,7 +306,7 @@ class LiteralKey : public Clearable, private NonCopyable static constexpr uint16_t kMaxSize = 32; ///< Maximum size of the key. /** - * This constructor initializes the `LiteralKey` from a given `Key`. + * Initializes the `LiteralKey` from a given `Key`. * * If the @p aKey is itself represents a literal key the same key buffer pointers are used. If the @p aKey is * a `KeyRef` then the literal key is extracted. In this case, the extracted key MUST be smaller than `kMaxSize`. @@ -317,7 +317,7 @@ class LiteralKey : public Clearable, private NonCopyable explicit LiteralKey(const Key &aKey); /* - * This method gets the pointer to the byte array containing the literal key. + * Gets the pointer to the byte array containing the literal key. * * @returns The pointer to the byte array containing the literal key. * @@ -325,7 +325,7 @@ class LiteralKey : public Clearable, private NonCopyable const uint8_t *GetBytes(void) const { return mKey; } /** - * This method gets the key length. + * Gets the key length. * * @returns The key length (number of bytes in the byte array from `GetBytes()`). * diff --git a/src/core/diags/factory_diags.hpp b/src/core/diags/factory_diags.hpp index d7ac648f929..5d015d278f2 100644 --- a/src/core/diags/factory_diags.hpp +++ b/src/core/diags/factory_diags.hpp @@ -62,7 +62,7 @@ class Diags : public InstanceLocator, private NonCopyable explicit Diags(Instance &aInstance); /** - * This method processes a factory diagnostics command line. + * Processes a factory diagnostics command line. * * @param[in] aString A null-terminated input string. * @param[out] aOutput The diagnostics execution result. @@ -72,7 +72,7 @@ class Diags : public InstanceLocator, private NonCopyable Error ProcessLine(const char *aString, char *aOutput, size_t aOutputMaxLen); /** - * This method processes a factory diagnostics command line. + * Processes a factory diagnostics command line. * * @param[in] aArgsLength The number of args in @p aArgs. * @param[in] aArgs The arguments of diagnostics command line. @@ -87,7 +87,7 @@ class Diags : public InstanceLocator, private NonCopyable Error ProcessCmd(uint8_t aArgsLength, char *aArgs[], char *aOutput, size_t aOutputMaxLen); /** - * This method indicates whether or not the factory diagnostics mode is enabled. + * Indicates whether or not the factory diagnostics mode is enabled. * * @retval TRUE if factory diagnostics mode is enabled * @retval FALSE if factory diagnostics mode is disabled. diff --git a/src/core/mac/channel_mask.hpp b/src/core/mac/channel_mask.hpp index 200ab5b257e..36ad78d458a 100644 --- a/src/core/mac/channel_mask.hpp +++ b/src/core/mac/channel_mask.hpp @@ -57,7 +57,7 @@ namespace Mac { */ /** - * This class defines a channel mask. + * Defines a channel mask. * * It is a wrapper class around a `uint32_t` bit vector representing a set of channels. * @@ -74,13 +74,13 @@ class ChannelMask : public Unequatable static constexpr uint16_t kInfoStringSize = 45; ///< Recommended buffer size to use with `ToString()`. /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This constructor initializes a `ChannelMask` instance. + * Initializes a `ChannelMask` instance. * */ ChannelMask(void) @@ -89,7 +89,7 @@ class ChannelMask : public Unequatable } /** - * This constructor initializes a `ChannelMask` instance with a given mask. + * Initializes a `ChannelMask` instance with a given mask. * * @param[in] aMask A channel mask (as a `uint32_t` bit-vector mask with bit 0 (lsb) -> channel 0, and so on). * @@ -100,13 +100,13 @@ class ChannelMask : public Unequatable } /** - * This method clears the channel mask. + * Clears the channel mask. * */ void Clear(void) { mMask = 0; } /** - * This method gets the channel mask (as a `uint32_t` bit-vector mask with bit 0 (lsb) -> channel 0, and so on). + * Gets the channel mask (as a `uint32_t` bit-vector mask with bit 0 (lsb) -> channel 0, and so on). * * @returns The channel mask. * @@ -114,7 +114,7 @@ class ChannelMask : public Unequatable uint32_t GetMask(void) const { return mMask; } /** - * This method sets the channel mask. + * Sets the channel mask. * * @param[in] aMask A channel mask (as a `uint32_t` bit-vector mask with bit 0 (lsb) -> channel 0, and so on). * @@ -122,7 +122,7 @@ class ChannelMask : public Unequatable void SetMask(uint32_t aMask) { mMask = aMask; } /** - * This method indicates if the mask is empty. + * Indicates if the mask is empty. * * @returns TRUE if the mask is empty, FALSE otherwise. * @@ -130,7 +130,7 @@ class ChannelMask : public Unequatable bool IsEmpty(void) const { return (mMask == 0); } /** - * This method indicates if the mask contains only a single channel. + * Indicates if the mask contains only a single channel. * * @returns TRUE if channel mask contains a single channel, FALSE otherwise * @@ -138,7 +138,7 @@ class ChannelMask : public Unequatable bool IsSingleChannel(void) const { return ((mMask != 0) && ((mMask & (mMask - 1)) == 0)); } /** - * This method indicates if the mask contains a given channel. + * Indicates if the mask contains a given channel. * * @param[in] aChannel A channel. * @@ -151,7 +151,7 @@ class ChannelMask : public Unequatable } /** - * This method adds a channel to the channel mask. + * Adds a channel to the channel mask. * * @param[in] aChannel A channel * @@ -165,7 +165,7 @@ class ChannelMask : public Unequatable } /** - * This method removes a channel from the channel mask. + * Removes a channel from the channel mask. * * @param[in] aChannel A channel * @@ -179,7 +179,7 @@ class ChannelMask : public Unequatable } /** - * This method updates the channel mask by intersecting it with another mask. + * Updates the channel mask by intersecting it with another mask. * * @param[in] aOtherMask Another channel mask. * @@ -187,7 +187,7 @@ class ChannelMask : public Unequatable void Intersect(const ChannelMask &aOtherMask) { mMask &= aOtherMask.mMask; } /** - * This method returns the number of channels in the mask. + * Returns the number of channels in the mask. * * @returns Number of channels in the mask. * @@ -195,9 +195,9 @@ class ChannelMask : public Unequatable uint8_t GetNumberOfChannels(void) const; /** - * This method gets the next channel in the channel mask. + * Gets the next channel in the channel mask. * - * This method can be used to iterate over all channels in the channel mask. To get the first channel (channel with + * Can be used to iterate over all channels in the channel mask. To get the first channel (channel with * lowest number) in the mask the @p aChannel should be set to `kChannelIteratorFirst`. * * @param[in,out] aChannel A reference to a `uint8_t`. @@ -211,7 +211,7 @@ class ChannelMask : public Unequatable Error GetNextChannel(uint8_t &aChannel) const; /** - * This method randomly chooses a channel from the channel mask. + * Randomly chooses a channel from the channel mask. * * @returns A randomly chosen channel from the given mask, or `kChannelIteratorFirst` if the mask is empty. * @@ -219,7 +219,7 @@ class ChannelMask : public Unequatable uint8_t ChooseRandomChannel(void) const; /** - * This method overloads `==` operator to indicate whether two masks are equal. + * Overloads `==` operator to indicate whether two masks are equal. * * @param[in] aAnother A reference to another mask to compare with the current one. * @@ -229,7 +229,7 @@ class ChannelMask : public Unequatable bool operator==(const ChannelMask &aAnother) const { return (mMask == aAnother.mMask); } /** - * This method converts the channel mask into a human-readable string. + * Converts the channel mask into a human-readable string. * * Examples of possible output: * - empty mask -> "{ }" diff --git a/src/core/mac/data_poll_handler.hpp b/src/core/mac/data_poll_handler.hpp index 11cb531bbeb..da7f744b76e 100644 --- a/src/core/mac/data_poll_handler.hpp +++ b/src/core/mac/data_poll_handler.hpp @@ -60,7 +60,7 @@ namespace ot { class Child; /** - * This class implements the data poll (mac data request command) handler. + * Implements the data poll (mac data request command) handler. * */ class DataPollHandler : public InstanceLocator, private NonCopyable @@ -71,7 +71,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable static constexpr uint8_t kMaxPollTriggeredTxAttempts = OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS; /** - * This enumeration defines frame change request types used as input to `RequestFrameChange()`. + * Defines frame change request types used as input to `RequestFrameChange()`. * */ enum FrameChange : uint8_t @@ -81,7 +81,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable }; /** - * This class defines all the child info required for handling of data polls and indirect frame transmissions. + * Defines all the child info required for handling of data polls and indirect frame transmissions. * * `Child` class publicly inherits from this class. * @@ -136,7 +136,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable }; /** - * This class defines the callbacks used by the `DataPollHandler`. + * Defines the callbacks used by the `DataPollHandler`. * */ class Callbacks : public InstanceLocator @@ -145,7 +145,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable private: /** - * This type defines the frame context associated with a prepared frame. + * Defines the frame context associated with a prepared frame. * * Data poll handler treats `FrameContext` as an opaque data type. Data poll handler provides the buffer/object * for the context when a new frame is prepared (from the callback `PrepareFrameForChild()`). It ensures @@ -156,7 +156,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable typedef IndirectSenderBase::FrameContext FrameContext; /** - * This constructor initializes the callbacks object. + * Initializes the callbacks object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -206,7 +206,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the data poll handler object. + * Initializes the data poll handler object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -214,13 +214,13 @@ class DataPollHandler : public InstanceLocator, private NonCopyable explicit DataPollHandler(Instance &aInstance); /** - * This method clears any state/info saved per child for indirect frame transmission. + * Clears any state/info saved per child for indirect frame transmission. * */ void Clear(void); /** - * This method informs data poll handler that there is a new frame for a given child. + * Informs data poll handler that there is a new frame for a given child. * * After this call, the data poll handler can use the `Callbacks::PrepareFrameForChild()` method to request the * frame to be prepared. A subsequent call to `Callbacks::PrepareFrameForChild()` should ensure to prepare the same @@ -234,7 +234,7 @@ class DataPollHandler : public InstanceLocator, private NonCopyable void HandleNewFrame(Child &aChild); /** - * This method requests a frame change for a given child. + * Requests a frame change for a given child. * * Two types of frame change requests are supported: * diff --git a/src/core/mac/data_poll_sender.cpp b/src/core/mac/data_poll_sender.cpp index acc968c5c9f..4f1aaead6ee 100644 --- a/src/core/mac/data_poll_sender.cpp +++ b/src/core/mac/data_poll_sender.cpp @@ -171,11 +171,7 @@ Error DataPollSender::SetExternalPollPeriod(uint32_t aPeriod) { VerifyOrExit(aPeriod >= OPENTHREAD_CONFIG_MAC_MINIMUM_POLL_PERIOD, error = kErrorInvalidArgs); - // Clipped by the maximal value. - if (aPeriod > kMaxExternalPeriod) - { - aPeriod = kMaxExternalPeriod; - } + aPeriod = Min(aPeriod, kMaxExternalPeriod); } if (mExternalPollPeriod != aPeriod) @@ -414,15 +410,8 @@ void DataPollSender::SendFastPolls(uint8_t aNumFastPolls) aNumFastPolls = kDefaultFastPolls; } - if (aNumFastPolls > kMaxFastPolls) - { - aNumFastPolls = kMaxFastPolls; - } - - if (mRemainingFastPolls < aNumFastPolls) - { - mRemainingFastPolls = aNumFastPolls; - } + aNumFastPolls = Min(aNumFastPolls, kMaxFastPolls); + mRemainingFastPolls = Max(mRemainingFastPolls, aNumFastPolls); if (mEnabled && shouldRecalculatePollPeriod) { diff --git a/src/core/mac/data_poll_sender.hpp b/src/core/mac/data_poll_sender.hpp index 2327bd9ad92..edb66b806cd 100644 --- a/src/core/mac/data_poll_sender.hpp +++ b/src/core/mac/data_poll_sender.hpp @@ -56,7 +56,7 @@ namespace ot { */ /** - * This class implements the data poll (mac data request command) sender. + * Implements the data poll (mac data request command) sender. * */ @@ -68,7 +68,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable static constexpr uint8_t kMaxFastPollsUsers = 63; ///< Maximum number of the users of fast poll tx allowed. /** - * This constructor initializes the data poll sender object. + * Initializes the data poll sender object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -76,19 +76,19 @@ class DataPollSender : public InstanceLocator, private NonCopyable explicit DataPollSender(Instance &aInstance); /** - * This method instructs the data poll sender to start sending periodic data polls. + * Instructs the data poll sender to start sending periodic data polls. * */ void StartPolling(void); /** - * This method instructs the data poll sender to stop sending periodic data polls. + * Instructs the data poll sender to stop sending periodic data polls. * */ void StopPolling(void); /** - * This method enqueues a data poll (an IEEE 802.15.4 Data Request) message. + * Enqueues a data poll (an IEEE 802.15.4 Data Request) message. * * @retval kErrorNone Successfully enqueued a data poll message * @retval kErrorAlready A data poll message is already enqueued. @@ -99,7 +99,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable Error SendDataPoll(void); /** - * This method sets/clears a user-specified/external data poll period. + * Sets/clears a user-specified/external data poll period. * * Value of zero for `aPeriod` clears the user-specified poll period. * @@ -121,7 +121,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable Error SetExternalPollPeriod(uint32_t aPeriod); /** - * This method gets the current user-specified/external data poll period. + * Gets the current user-specified/external data poll period. * * @returns The data poll period in milliseconds. * @@ -129,7 +129,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable uint32_t GetExternalPollPeriod(void) const { return mExternalPollPeriod; } /** - * This method informs the data poll sender of success/error status of a previously requested poll frame + * Informs the data poll sender of success/error status of a previously requested poll frame * transmission. * * In case of transmit failure, the data poll sender may choose to send the next data poll more quickly (up to @@ -142,7 +142,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable void HandlePollSent(Mac::TxFrame &aFrame, Error aError); /** - * This method informs the data poll sender that a data poll timeout happened, i.e., when the ack in response to + * Informs the data poll sender that a data poll timeout happened, i.e., when the ack in response to * a data request command indicated that a frame was pending, but no frame was received after timeout interval. * * Data poll sender may choose to transmit another data poll immediately (up to some fixed number of attempts). @@ -151,7 +151,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable void HandlePollTimeout(void); /** - * This method informs the data poll sender to process a received MAC frame. + * Informs the data poll sender to process a received MAC frame. * * @param[in] aFrame A reference to the received frame to process. * @@ -160,7 +160,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 /** - * This method informs the data poll sender to process a transmitted MAC frame. + * Informs the data poll sender to process a transmitted MAC frame. * * @param[in] aFrame A reference to the frame that was transmitted. * @param[in] aAckFrame A pointer to the ACK frame, `nullptr` if no ACK was received. @@ -174,7 +174,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable #endif /** - * This method asks the data poll sender to recalculate the poll period. + * Asks the data poll sender to recalculate the poll period. * * This is mainly used to inform the poll sender that a parameter impacting the poll period (e.g., the child's * timeout value which is used to determine the default data poll period) is modified. @@ -183,7 +183,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable void RecalculatePollPeriod(void); /** - * This method sets/clears the attach mode on data poll sender. + * Sets/clears the attach mode on data poll sender. * * When attach mode is enabled, the data poll sender will send data polls at a faster rate determined by * poll period configuration option `OPENTHREAD_CONFIG_MAC_ATTACH_DATA_POLL_PERIOD`. @@ -194,7 +194,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable void SetAttachMode(bool aMode); /** - * This method asks data poll sender to send the next given number of polls at a faster rate (poll period defined + * Asks data poll sender to send the next given number of polls at a faster rate (poll period defined * by `kFastPollPeriod`). This is used by OpenThread stack when it expects a response from the parent/sender. * * If @p aNumFastPolls is zero the default value specified by `kDefaultFastPolls` is used instead. The number of @@ -212,13 +212,13 @@ class DataPollSender : public InstanceLocator, private NonCopyable void SendFastPolls(uint8_t aNumFastPolls = 0); /** - * This method asks data poll sender to stop fast polls when the expecting response is received. + * Asks data poll sender to stop fast polls when the expecting response is received. * */ void StopFastPolls(void); /** - * This method gets the maximum data polling period in use. + * Gets the maximum data polling period in use. * * The maximum data poll period is determined based as the minimum of the user-specified poll interval and the * default poll interval. @@ -229,13 +229,13 @@ class DataPollSender : public InstanceLocator, private NonCopyable uint32_t GetKeepAlivePollPeriod(void) const; /** - * This method resets the timer for sending keep-alive messages. + * Resets the timer for sending keep-alive messages. * */ void ResetKeepAliveTimer(void); /** - * This method returns the default maximum poll period. + * Returns the default maximum poll period. * * The default poll period is determined based on the child timeout interval, ensuing the child would send data poll * within the child's timeout. @@ -246,7 +246,7 @@ class DataPollSender : public InstanceLocator, private NonCopyable uint32_t GetDefaultPollPeriod(void) const; /** - * This method prepares and returns a data request command frame. + * Prepares and returns a data request command frame. * * @param[in] aTxFrames The set of TxFrames for all radio links. * diff --git a/src/core/mac/link_raw.hpp b/src/core/mac/link_raw.hpp index ef2a121d35f..f9e87b74d57 100644 --- a/src/core/mac/link_raw.hpp +++ b/src/core/mac/link_raw.hpp @@ -50,7 +50,7 @@ namespace ot { namespace Mac { /** - * This class defines the raw link-layer object. + * Defines the raw link-layer object. * */ class LinkRaw : public InstanceLocator, private NonCopyable @@ -59,7 +59,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -67,13 +67,13 @@ class LinkRaw : public InstanceLocator, private NonCopyable explicit LinkRaw(Instance &aInstance); /** - * This method initializes the states of the raw link-layer. + * Initializes the states of the raw link-layer. * */ void Init(void); /** - * This method returns true if the raw link-layer is enabled. + * Returns true if the raw link-layer is enabled. * * @returns true if enabled, false otherwise. * @@ -81,7 +81,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable bool IsEnabled(void) const { return mReceiveDoneCallback != nullptr; } /** - * This method enables/disables the raw link-layer. + * Enables/disables the raw link-layer. * * @param[in] aCallback A pointer to a function called on receipt of a IEEE 802.15.4 frame, `nullptr` to disable * raw link-layer. @@ -95,7 +95,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetReceiveDone(otLinkRawReceiveDone aCallback); /** - * This method returns the capabilities of the raw link-layer. + * Returns the capabilities of the raw link-layer. * * @returns The radio capability bit vector. * @@ -103,7 +103,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable otRadioCaps GetCaps(void) const { return mSubMac.GetCaps(); } /** - * This method starts a (recurring) Receive on the link-layer. + * Starts a (recurring) Receive on the link-layer. * * @retval kErrorNone Successfully transitioned to Receive. * @retval kErrorInvalidState The radio was disabled or transmitting. @@ -112,7 +112,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error Receive(void); /** - * This method invokes the mReceiveDoneCallback, if set. + * Invokes the mReceiveDoneCallback, if set. * * @param[in] aFrame A pointer to the received frame or `nullptr` if the receive operation failed. * @param[in] aError kErrorNone when successfully received a frame, @@ -123,7 +123,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable void InvokeReceiveDone(RxFrame *aFrame, Error aError); /** - * This method returns true if the raw link-layer is busy transmitting or scanning. + * Returns true if the raw link-layer is busy transmitting or scanning. * * @returns true if busy transmitting or scanning, false otherwise. * @@ -131,7 +131,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable bool IsTransmittingOrScanning(void) const { return mSubMac.IsTransmittingOrScanning(); } /** - * This method gets the radio transmit frame. + * Gets the radio transmit frame. * * @returns The transmit frame. * @@ -139,7 +139,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable TxFrame &GetTransmitFrame(void) { return mSubMac.GetTransmitFrame(); } /** - * This method starts a (single) Transmit on the link-layer. + * Starts a (single) Transmit on the link-layer. * * @note The callback @p aCallback will not be called if this call does not return kErrorNone. * @@ -152,7 +152,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error Transmit(otLinkRawTransmitDone aCallback); /** - * This method invokes the mTransmitDoneCallback, if set. + * Invokes the mTransmitDoneCallback, if set. * * @param[in] aFrame The transmitted frame. * @param[in] aAckFrame A pointer to the ACK frame, `nullptr` if no ACK was received. @@ -165,7 +165,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable void InvokeTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError); /** - * This method starts a (single) Energy Scan on the link-layer. + * Starts a (single) Energy Scan on the link-layer. * * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. @@ -180,7 +180,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration, otLinkRawEnergyScanDone aCallback); /** - * This method invokes the mEnergyScanDoneCallback, if set. + * Invokes the mEnergyScanDoneCallback, if set. * * @param[in] aEnergyScanMaxRssi The max RSSI for energy scan. * @@ -188,7 +188,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable void InvokeEnergyScanDone(int8_t aEnergyScanMaxRssi); /** - * This function returns the short address. + * Returns the short address. * * @returns short address. * @@ -196,7 +196,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable ShortAddress GetShortAddress(void) const { return mSubMac.GetShortAddress(); } /** - * This method updates short address. + * Updates short address. * * @param[in] aShortAddress The short address. * @@ -207,7 +207,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetShortAddress(ShortAddress aShortAddress); /** - * This function returns PANID. + * Returns PANID. * * @returns PANID. * @@ -215,7 +215,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable PanId GetPanId(void) const { return mPanId; } /** - * This method updates PANID. + * Updates PANID. * * @param[in] aPanId The PANID. * @@ -226,7 +226,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetPanId(PanId aPanId); /** - * This method gets the current receiving channel. + * Gets the current receiving channel. * * @returns Current receiving channel. * @@ -234,7 +234,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable uint8_t GetChannel(void) const { return mReceiveChannel; } /** - * This method sets the receiving channel. + * Sets the receiving channel. * * @param[in] aChannel The channel to use for receiving. * @@ -242,7 +242,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetChannel(uint8_t aChannel); /** - * This function returns the extended address. + * Returns the extended address. * * @returns A reference to the extended address. * @@ -250,7 +250,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable const ExtAddress &GetExtAddress(void) const { return mSubMac.GetExtAddress(); } /** - * This method updates extended address. + * Updates extended address. * * @param[in] aExtAddress The extended address. * @@ -261,7 +261,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetExtAddress(const ExtAddress &aExtAddress); /** - * This method updates MAC keys and key index. + * Updates MAC keys and key index. * * @param[in] aKeyIdMode The key ID mode. * @param[in] aKeyId The key index. @@ -277,7 +277,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable Error SetMacKey(uint8_t aKeyIdMode, uint8_t aKeyId, const Key &aPrevKey, const Key &aCurrKey, const Key &aNextKey); /** - * This method sets the current MAC frame counter value. + * Sets the current MAC frame counter value. * * @param[in] aFrameCounter The MAC frame counter value. * @param[in] aSetIfLarger If `true`, set only if the new value @p aFrameCounter is larger than current value. @@ -291,7 +291,7 @@ class LinkRaw : public InstanceLocator, private NonCopyable #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) /** - * This method records the status of a frame transmission attempt and is mainly used for logging failures. + * Records the status of a frame transmission attempt and is mainly used for logging failures. * * Unlike `HandleTransmitDone` which is called after all transmission attempts of frame to indicate final status * of a frame transmission request, this method is invoked on all frame transmission attempts. diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index a29ee3fc534..e2834b24f96 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -119,7 +119,6 @@ Mac::Mac(Instance &aInstance) ResetCounters(); SetEnabled(true); - mLinks.Enable(); Get().UpdateKeyMaterial(); SetPanId(mPanId); @@ -129,6 +128,20 @@ Mac::Mac(Instance &aInstance) mMode2KeyMaterial.SetFrom(AsCoreType(&sMode2Key)); } +void Mac::SetEnabled(bool aEnable) +{ + mEnabled = aEnable; + + if (aEnable) + { + mLinks.Enable(); + } + else + { + mLinks.Disable(); + } +} + Error Mac::ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler, void *aContext) { Error error = kErrorNone; @@ -907,7 +920,7 @@ void Mac::ProcessTransmitSecurity(TxFrame &aFrame) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE // Transmit security will be processed after time IE content is updated. - VerifyOrExit(aFrame.mInfo.mTxInfo.mCslPresent == 0); + VerifyOrExit(!aFrame.IsCslIePresent()); #endif aFrame.ProcessTransmitAesCcm(*extAddress); diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 3566109418d..d433b25a2fe 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -88,32 +88,32 @@ constexpr uint8_t kMaxFrameRetriesCsl = 0; constexpr uint8_t kTxNumBcast = OPENTHREAD_CONFIG_MAC_TX_NUM_BCAST; ///< Num of times broadcast frame is tx. /** - * This type defines the function pointer called on receiving an IEEE 802.15.4 Beacon during an Active Scan. + * Defines the function pointer called on receiving an IEEE 802.15.4 Beacon during an Active Scan. * */ typedef otHandleActiveScanResult ActiveScanHandler; /** - * This type defines an Active Scan result. + * Defines an Active Scan result. * */ typedef otActiveScanResult ActiveScanResult; /** - * This type defines the function pointer which is called during an Energy Scan when the scan result for a channel is + * Defines the function pointer which is called during an Energy Scan when the scan result for a channel is * ready or when the scan completes. * */ typedef otHandleEnergyScanResult EnergyScanHandler; /** - * This type defines an Energy Scan result. + * Defines an Energy Scan result. * */ typedef otEnergyScanResult EnergyScanResult; /** - * This class implements the IEEE 802.15.4 MAC. + * Implements the IEEE 802.15.4 MAC. * */ class Mac : public InstanceLocator, private NonCopyable @@ -122,7 +122,7 @@ class Mac : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the MAC object. + * Initializes the MAC object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -130,7 +130,7 @@ class Mac : public InstanceLocator, private NonCopyable explicit Mac(Instance &aInstance); /** - * This method starts an IEEE 802.15.4 Active Scan. + * Starts an IEEE 802.15.4 Active Scan. * * @param[in] aScanChannels A bit vector indicating which channels to scan. Zero is mapped to all channels. * @param[in] aScanDuration The time in milliseconds to spend scanning each channel. Zero duration maps to @@ -145,7 +145,7 @@ class Mac : public InstanceLocator, private NonCopyable Error ActiveScan(uint32_t aScanChannels, uint16_t aScanDuration, ActiveScanHandler aHandler, void *aContext); /** - * This method starts an IEEE 802.15.4 Energy Scan. + * Starts an IEEE 802.15.4 Energy Scan. * * @param[in] aScanChannels A bit vector indicating on which channels to scan. Zero is mapped to all channels. * @param[in] aScanDuration The time in milliseconds to spend scanning each channel. If the duration is set to @@ -160,7 +160,7 @@ class Mac : public InstanceLocator, private NonCopyable Error EnergyScan(uint32_t aScanChannels, uint16_t aScanDuration, EnergyScanHandler aHandler, void *aContext); /** - * This method indicates the energy scan for the current channel is complete. + * Indicates the energy scan for the current channel is complete. * * @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. * @@ -168,7 +168,7 @@ class Mac : public InstanceLocator, private NonCopyable void EnergyScanDone(int8_t aEnergyScanMaxRssi); /** - * This method indicates whether or not IEEE 802.15.4 Beacon transmissions are enabled. + * Indicates whether or not IEEE 802.15.4 Beacon transmissions are enabled. * * @retval TRUE If IEEE 802.15.4 Beacon transmissions are enabled. * @retval FALSE If IEEE 802.15.4 Beacon transmissions are not enabled. @@ -177,7 +177,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsBeaconEnabled(void) const { return mBeaconsEnabled; } /** - * This method enables/disables IEEE 802.15.4 Beacon transmissions. + * Enables/disables IEEE 802.15.4 Beacon transmissions. * * @param[in] aEnabled TRUE to enable IEEE 802.15.4 Beacon transmissions, FALSE otherwise. * @@ -185,7 +185,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetBeaconEnabled(bool aEnabled) { mBeaconsEnabled = aEnabled; } /** - * This method indicates whether or not rx-on-when-idle is enabled. + * Indicates whether or not rx-on-when-idle is enabled. * * @retval TRUE If rx-on-when-idle is enabled. * @retval FALSE If rx-on-when-idle is not enabled. @@ -193,7 +193,7 @@ class Mac : public InstanceLocator, private NonCopyable bool GetRxOnWhenIdle(void) const { return mRxOnWhenIdle; } /** - * This method sets the rx-on-when-idle mode. + * Sets the rx-on-when-idle mode. * * @param[in] aRxOnWhenIdle The rx-on-when-idle mode. * @@ -201,21 +201,21 @@ class Mac : public InstanceLocator, private NonCopyable void SetRxOnWhenIdle(bool aRxOnWhenIdle); /** - * This method requests a direct data frame transmission. + * Requests a direct data frame transmission. * */ void RequestDirectFrameTransmission(void); #if OPENTHREAD_FTD /** - * This method requests an indirect data frame transmission. + * Requests an indirect data frame transmission. * */ void RequestIndirectFrameTransmission(void); #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE /** - * This method requests `Mac` to start a CSL tx operation after a delay of @p aDelay time. + * Requests `Mac` to start a CSL tx operation after a delay of @p aDelay time. * * @param[in] aDelay Delay time for `Mac` to start a CSL tx, in units of milliseconds. * @@ -226,7 +226,7 @@ class Mac : public InstanceLocator, private NonCopyable #endif /** - * This method requests transmission of a data poll (MAC Data Request) frame. + * Requests transmission of a data poll (MAC Data Request) frame. * * @retval kErrorNone Data poll transmission request is scheduled successfully. * @retval kErrorInvalidState The MAC layer is not enabled. @@ -235,7 +235,7 @@ class Mac : public InstanceLocator, private NonCopyable Error RequestDataPollTransmission(void); /** - * This method returns a reference to the IEEE 802.15.4 Extended Address. + * Returns a reference to the IEEE 802.15.4 Extended Address. * * @returns A pointer to the IEEE 802.15.4 Extended Address. * @@ -243,7 +243,7 @@ class Mac : public InstanceLocator, private NonCopyable const ExtAddress &GetExtAddress(void) const { return mLinks.GetExtAddress(); } /** - * This method sets the IEEE 802.15.4 Extended Address. + * Sets the IEEE 802.15.4 Extended Address. * * @param[in] aExtAddress A reference to the IEEE 802.15.4 Extended Address. * @@ -251,7 +251,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetExtAddress(const ExtAddress &aExtAddress) { mLinks.SetExtAddress(aExtAddress); } /** - * This method returns the IEEE 802.15.4 Short Address. + * Returns the IEEE 802.15.4 Short Address. * * @returns The IEEE 802.15.4 Short Address. * @@ -259,7 +259,7 @@ class Mac : public InstanceLocator, private NonCopyable ShortAddress GetShortAddress(void) const { return mLinks.GetShortAddress(); } /** - * This method sets the IEEE 802.15.4 Short Address. + * Sets the IEEE 802.15.4 Short Address. * * @param[in] aShortAddress The IEEE 802.15.4 Short Address. * @@ -267,7 +267,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetShortAddress(ShortAddress aShortAddress) { mLinks.SetShortAddress(aShortAddress); } /** - * This method returns the IEEE 802.15.4 PAN Channel. + * Returns the IEEE 802.15.4 PAN Channel. * * @returns The IEEE 802.15.4 PAN Channel. * @@ -275,7 +275,7 @@ class Mac : public InstanceLocator, private NonCopyable uint8_t GetPanChannel(void) const { return mPanChannel; } /** - * This method sets the IEEE 802.15.4 PAN Channel. + * Sets the IEEE 802.15.4 PAN Channel. * * @param[in] aChannel The IEEE 802.15.4 PAN Channel. * @@ -286,9 +286,9 @@ class Mac : public InstanceLocator, private NonCopyable Error SetPanChannel(uint8_t aChannel); /** - * This method sets the temporary IEEE 802.15.4 radio channel. + * Sets the temporary IEEE 802.15.4 radio channel. * - * This method allows user to temporarily change the radio channel and use a different channel (during receive) + * Allows user to temporarily change the radio channel and use a different channel (during receive) * instead of the PAN channel (from `SetPanChannel()`). A call to `ClearTemporaryChannel()` would clear the * temporary channel and adopt the PAN channel again. The `SetTemporaryChannel()` can be used multiple times in row * (before a call to `ClearTemporaryChannel()`) to change the temporary channel. @@ -302,13 +302,13 @@ class Mac : public InstanceLocator, private NonCopyable Error SetTemporaryChannel(uint8_t aChannel); /** - * This method clears the use of a previously set temporary channel and adopts the PAN channel. + * Clears the use of a previously set temporary channel and adopts the PAN channel. * */ void ClearTemporaryChannel(void); /** - * This method returns the supported channel mask. + * Returns the supported channel mask. * * @returns The supported channel mask. * @@ -316,7 +316,7 @@ class Mac : public InstanceLocator, private NonCopyable const ChannelMask &GetSupportedChannelMask(void) const { return mSupportedChannelMask; } /** - * This method sets the supported channel mask + * Sets the supported channel mask * * @param[in] aMask The supported channel mask. * @@ -324,7 +324,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetSupportedChannelMask(const ChannelMask &aMask); /** - * This method returns the IEEE 802.15.4 PAN ID. + * Returns the IEEE 802.15.4 PAN ID. * * @returns The IEEE 802.15.4 PAN ID. * @@ -332,7 +332,7 @@ class Mac : public InstanceLocator, private NonCopyable PanId GetPanId(void) const { return mPanId; } /** - * This method sets the IEEE 802.15.4 PAN ID. + * Sets the IEEE 802.15.4 PAN ID. * * @param[in] aPanId The IEEE 802.15.4 PAN ID. * @@ -340,7 +340,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetPanId(PanId aPanId); /** - * This method returns the maximum number of frame retries during direct transmission. + * Returns the maximum number of frame retries during direct transmission. * * @returns The maximum number of retries during direct transmission. * @@ -348,7 +348,7 @@ class Mac : public InstanceLocator, private NonCopyable uint8_t GetMaxFrameRetriesDirect(void) const { return mMaxFrameRetriesDirect; } /** - * This method sets the maximum number of frame retries during direct transmission. + * Sets the maximum number of frame retries during direct transmission. * * @param[in] aMaxFrameRetriesDirect The maximum number of retries during direct transmission. * @@ -357,7 +357,7 @@ class Mac : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method returns the maximum number of frame retries during indirect transmission. + * Returns the maximum number of frame retries during indirect transmission. * * @returns The maximum number of retries during indirect transmission. * @@ -365,7 +365,7 @@ class Mac : public InstanceLocator, private NonCopyable uint8_t GetMaxFrameRetriesIndirect(void) const { return mMaxFrameRetriesIndirect; } /** - * This method sets the maximum number of frame retries during indirect transmission. + * Sets the maximum number of frame retries during indirect transmission. * * @param[in] aMaxFrameRetriesIndirect The maximum number of retries during indirect transmission. * @@ -377,7 +377,7 @@ class Mac : public InstanceLocator, private NonCopyable #endif /** - * This method is called to handle a received frame. + * Is called to handle a received frame. * * @param[in] aFrame A pointer to the received frame, or `nullptr` if the receive operation was aborted. * @param[in] aError kErrorNone when successfully received a frame, @@ -387,7 +387,7 @@ class Mac : public InstanceLocator, private NonCopyable void HandleReceivedFrame(RxFrame *aFrame, Error aError); /** - * This method records CCA status (success/failure) for a frame transmission attempt. + * Records CCA status (success/failure) for a frame transmission attempt. * * @param[in] aCcaSuccess TRUE if the CCA succeeded, FALSE otherwise. * @param[in] aChannel The channel on which CCA was performed. @@ -396,7 +396,7 @@ class Mac : public InstanceLocator, private NonCopyable void RecordCcaStatus(bool aCcaSuccess, uint8_t aChannel); /** - * This method records the status of a frame transmission attempt, updating MAC counters. + * Records the status of a frame transmission attempt, updating MAC counters. * * Unlike `HandleTransmitDone` which is called after all transmission attempts of frame to indicate final status * of a frame transmission request, this method is invoked on all frame transmission attempts. @@ -419,7 +419,7 @@ class Mac : public InstanceLocator, private NonCopyable bool aWillRetx); /** - * This method is called to handle transmit events. + * Is called to handle transmit events. * * @param[in] aFrame The frame that was transmitted. * @param[in] aAckFrame A pointer to the ACK frame, `nullptr` if no ACK was received. @@ -432,20 +432,20 @@ class Mac : public InstanceLocator, private NonCopyable void HandleTransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError); /** - * This method returns if an active scan is in progress. + * Returns if an active scan is in progress. * */ bool IsActiveScanInProgress(void) const { return IsActiveOrPending(kOperationActiveScan); } /** - * This method returns if an energy scan is in progress. + * Returns if an energy scan is in progress. * */ bool IsEnergyScanInProgress(void) const { return IsActiveOrPending(kOperationEnergyScan); } #if OPENTHREAD_FTD /** - * This method indicates whether the MAC layer is performing an indirect transmission (in middle of a tx). + * Indicates whether the MAC layer is performing an indirect transmission (in middle of a tx). * * @returns TRUE if in middle of an indirect transmission, FALSE otherwise. * @@ -454,7 +454,7 @@ class Mac : public InstanceLocator, private NonCopyable #endif /** - * This method returns if the MAC layer is in transmit state. + * Returns if the MAC layer is in transmit state. * * The MAC layer is in transmit state during CSMA/CA, CCA, transmission of Data, Beacon or Data Request frames and * receiving of ACK frames. The MAC layer is not in transmit state during transmission of ACK frames or Beacon @@ -464,7 +464,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsInTransmitState(void) const; /** - * This method registers a callback to provide received raw IEEE 802.15.4 frames. + * Registers a callback to provide received raw IEEE 802.15.4 frames. * * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame * or `nullptr` to disable the callback. @@ -477,7 +477,7 @@ class Mac : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not promiscuous mode is enabled at the link layer. + * Indicates whether or not promiscuous mode is enabled at the link layer. * * @retval true Promiscuous mode is enabled. * @retval false Promiscuous mode is not enabled. @@ -486,7 +486,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsPromiscuous(void) const { return mPromiscuous; } /** - * This method enables or disables the link layer promiscuous mode. + * Enables or disables the link layer promiscuous mode. * * Promiscuous mode keeps the receiver enabled, overriding the value of mRxOnWhenIdle. * @@ -496,13 +496,13 @@ class Mac : public InstanceLocator, private NonCopyable void SetPromiscuous(bool aPromiscuous); /** - * This method resets mac counters + * Resets mac counters * */ void ResetCounters(void) { memset(&mCounters, 0, sizeof(mCounters)); } /** - * This method returns the MAC counter. + * Returns the MAC counter. * * @returns A reference to the MAC counter. * @@ -511,7 +511,7 @@ class Mac : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE /** - * This method returns the MAC retry histogram for direct transmission. + * Returns the MAC retry histogram for direct transmission. * * @param[out] aNumberOfEntries A reference to where the size of returned histogram array is placed. * @@ -523,7 +523,7 @@ class Mac : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method returns the MAC retry histogram for indirect transmission. + * Returns the MAC retry histogram for indirect transmission. * * @param[out] aNumberOfEntries A reference to where the size of returned histogram array is placed. * @@ -535,14 +535,14 @@ class Mac : public InstanceLocator, private NonCopyable #endif /** - * This method resets MAC retry histogram. + * Resets MAC retry histogram. * */ void ResetRetrySuccessHistogram(void); #endif // OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE /** - * This method returns the noise floor value (currently use the radio receive sensitivity value). + * Returns the noise floor value (currently use the radio receive sensitivity value). * * @returns The noise floor value in dBm. * @@ -550,7 +550,7 @@ class Mac : public InstanceLocator, private NonCopyable int8_t GetNoiseFloor(void) const { return mLinks.GetNoiseFloor(); } /** - * This method computes the link margin for a given a received signal strength value using noise floor. + * Computes the link margin for a given a received signal strength value using noise floor. * * @param[in] aRss The received signal strength in dBm. * @@ -560,7 +560,7 @@ class Mac : public InstanceLocator, private NonCopyable uint8_t ComputeLinkMargin(int8_t aRss) const; /** - * This method returns the current CCA (Clear Channel Assessment) failure rate. + * Returns the current CCA (Clear Channel Assessment) failure rate. * * The rate is maintained over a window of (roughly) last `OPENTHREAD_CONFIG_CCA_FAILURE_RATE_AVERAGING_WINDOW` * frame transmissions. @@ -571,15 +571,15 @@ class Mac : public InstanceLocator, private NonCopyable uint16_t GetCcaFailureRate(void) const { return mCcaSuccessRateTracker.GetFailureRate(); } /** - * This method Starts/Stops the Link layer. It may only be used when the Netif Interface is down. + * Starts/Stops the Link layer. It may only be used when the Netif Interface is down. * * @param[in] aEnable The requested State for the MAC layer. true - Start, false - Stop. * */ - void SetEnabled(bool aEnable) { mEnabled = aEnable; } + void SetEnabled(bool aEnable); /** - * This method indicates whether or not the link layer is enabled. + * Indicates whether or not the link layer is enabled. * * @retval true Link layer is enabled. * @retval false Link layer is not enabled. @@ -588,14 +588,14 @@ class Mac : public InstanceLocator, private NonCopyable bool IsEnabled(void) const { return mEnabled; } /** - * This method clears the Mode2Key stored in PSA ITS. + * Clears the Mode2Key stored in PSA ITS. * */ void ClearMode2Key(void) { mMode2KeyMaterial.Clear(); } #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method gets the CSL channel. + * Gets the CSL channel. * * @returns CSL channel. * @@ -603,7 +603,7 @@ class Mac : public InstanceLocator, private NonCopyable uint8_t GetCslChannel(void) const { return mCslChannel; } /** - * This method sets the CSL channel. + * Sets the CSL channel. * * @param[in] aChannel The CSL channel. * @@ -611,13 +611,13 @@ class Mac : public InstanceLocator, private NonCopyable void SetCslChannel(uint8_t aChannel); /** - * This method centralizes CSL state switching conditions evaluating, configuring SubMac accordingly. + * Centralizes CSL state switching conditions evaluating, configuring SubMac accordingly. * */ void UpdateCsl(void); /** - * This method gets the CSL period. + * Gets the CSL period. * * @returns CSL period in units of 10 symbols. * @@ -625,7 +625,7 @@ class Mac : public InstanceLocator, private NonCopyable uint16_t GetCslPeriod(void) const { return mCslPeriod; } /** - * This method gets the CSL period. + * Gets the CSL period. * * @returns CSL period in milliseconds. * @@ -633,7 +633,7 @@ class Mac : public InstanceLocator, private NonCopyable uint32_t GetCslPeriodMs(void) const { return mCslPeriod * kUsPerTenSymbols / 1000; } /** - * This method sets the CSL period. + * Sets the CSL period. * * @param[in] aPeriod The CSL period in 10 symbols. * @@ -641,7 +641,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetCslPeriod(uint16_t aPeriod); /** - * This method indicates whether CSL is started at the moment. + * Indicates whether CSL is started at the moment. * * @retval TRUE If CSL is enabled. * @retval FALSE If CSL is not enabled. @@ -650,7 +650,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsCslEnabled(void) const; /** - * This method indicates whether Link is capable of starting CSL. + * Indicates whether Link is capable of starting CSL. * * @retval TRUE If Link is capable of starting CSL. * @retval FALSE If link is not capable of starting CSL. @@ -659,7 +659,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsCslCapable(void) const; /** - * This method indicates whether the device is connected to a parent which supports CSL. + * Indicates whether the device is connected to a parent which supports CSL. * * @retval TRUE If parent supports CSL. * @retval FALSE If parent does not support CSL. @@ -668,7 +668,7 @@ class Mac : public InstanceLocator, private NonCopyable bool IsCslSupported(void) const; /** - * This method returns parent CSL accuracy (clock accuracy and uncertainty). + * Returns parent CSL accuracy (clock accuracy and uncertainty). * * @returns The parent CSL accuracy. * @@ -676,7 +676,7 @@ class Mac : public InstanceLocator, private NonCopyable const CslAccuracy &GetCslParentAccuracy(void) const { return mLinks.GetSubMac().GetCslParentAccuracy(); } /** - * This method sets parent CSL accuracy. + * Sets parent CSL accuracy. * * @param[in] aCslAccuracy The parent CSL accuracy. * @@ -690,7 +690,7 @@ class Mac : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE && OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE /** - * This method enables/disables the 802.15.4 radio filter. + * Enables/disables the 802.15.4 radio filter. * * When radio filter is enabled, radio is put to sleep instead of receive (to ensure device does not receive any * frame and/or potentially send ack). Also the frame transmission requests return immediately without sending the @@ -702,7 +702,7 @@ class Mac : public InstanceLocator, private NonCopyable void SetRadioFilterEnabled(bool aFilterEnabled); /** - * This method indicates whether the 802.15.4 radio filter is enabled or not. + * Indicates whether the 802.15.4 radio filter is enabled or not. * * @retval TRUE If the radio filter is enabled. * @retval FALSE If the radio filter is disabled. diff --git a/src/core/mac/mac_filter.hpp b/src/core/mac/mac_filter.hpp index d5ff8bba20d..85a9b8bda68 100644 --- a/src/core/mac/mac_filter.hpp +++ b/src/core/mac/mac_filter.hpp @@ -59,20 +59,20 @@ namespace Mac { */ /** - * This class implements Mac Filter on IEEE 802.15.4 frames. + * Implements Mac Filter on IEEE 802.15.4 frames. * */ class Filter : private NonCopyable { public: /** - * This structure represents a Mac Filter entry (used during iteration). + * Represents a Mac Filter entry (used during iteration). * */ typedef otMacFilterEntry Entry; /** - * This type represents an iterator used to iterate through filter entries. + * Represents an iterator used to iterate through filter entries. * * See `GetNextAddress()` and `GetNextRssIn()`. * @@ -80,7 +80,7 @@ class Filter : private NonCopyable typedef otMacFilterIterator Iterator; /** - * This enumeration type represents the MAC Filter mode. + * Type represents the MAC Filter mode. * */ enum Mode : uint8_t @@ -93,13 +93,13 @@ class Filter : private NonCopyable static constexpr int8_t kFixedRssDisabled = OT_MAC_FILTER_FIXED_RSS_DISABLED; ///< Value when no fixed RSS is set. /** - * This constructor initializes the filter. + * Initializes the filter. * */ Filter(void); /** - * This method gets the MAC Filter mode. + * Gets the MAC Filter mode. * * @returns the Filter mode. * @@ -107,7 +107,7 @@ class Filter : private NonCopyable Mode GetMode(void) const { return mMode; } /** - * This method sets the address mode of the filter. + * Sets the address mode of the filter. * * @param[in] aMode The new Filter mode. * @@ -115,7 +115,7 @@ class Filter : private NonCopyable void SetMode(Mode aMode) { mMode = aMode; } /** - * This method adds an Extended Address to filter. + * Adds an Extended Address to filter. * * @param[in] aExtAddress A reference to the Extended Address. * @@ -126,7 +126,7 @@ class Filter : private NonCopyable Error AddAddress(const ExtAddress &aExtAddress); /** - * This method removes an Extended Address from the filter. + * Removes an Extended Address from the filter. * * No action is performed if there is no existing entry in the filter list matching the given Extended Address. * @@ -136,13 +136,13 @@ class Filter : private NonCopyable void RemoveAddress(const ExtAddress &aExtAddress); /** - * This method clears all Extended Addresses from the filter. + * Clears all Extended Addresses from the filter. * */ void ClearAddresses(void); /** - * This method iterates through filter entries. + * Iterates through filter entries. * * @param[in,out] aIterator A reference to the MAC filter iterator context. * To get the first in-use address filter, set it to OT_MAC_FILTER_ITERATOR_INIT. @@ -155,7 +155,7 @@ class Filter : private NonCopyable Error GetNextAddress(Iterator &aIterator, Entry &aEntry) const; /** - * This method adds a fixed received signal strength entry for the messages from a given Extended Address. + * Adds a fixed received signal strength entry for the messages from a given Extended Address. * * @param[in] aExtAddress An Extended Address * @param[in] aRss The received signal strength to set. @@ -167,7 +167,7 @@ class Filter : private NonCopyable Error AddRssIn(const ExtAddress &aExtAddress, int8_t aRss); /** - * This method removes a fixed received signal strength entry for a given Extended Address. + * Removes a fixed received signal strength entry for a given Extended Address. * * No action is performed if there is no existing entry in the filter list matching the given Extended Address. * @@ -177,7 +177,7 @@ class Filter : private NonCopyable void RemoveRssIn(const ExtAddress &aExtAddress); /** - * This method sets the default received signal strength. + * Sets the default received signal strength. * * The default RSS value is used for all received frames from addresses for which there is no explicit RSS-IN entry * in the Filter list (added using `AddRssIn()`). @@ -188,19 +188,19 @@ class Filter : private NonCopyable void SetDefaultRssIn(int8_t aRss) { mDefaultRssIn = aRss; } /** - * This method clears the default received signal strength. + * Clears the default received signal strength. * */ void ClearDefaultRssIn(void) { mDefaultRssIn = kFixedRssDisabled; } /** - * This method clears all the received signal strength settings (including the default RSS-In). + * Clears all the received signal strength settings (including the default RSS-In). * */ void ClearAllRssIn(void); /** - * This method iterates through RssIn filter entry. + * Iterates through RssIn filter entry. * * @param[in,out] aIterator A reference to the MAC filter iterator context. To get the first in-use RssIn * filter entry, it should be set to OT_MAC_FILTER_ITERATOR_INIT. @@ -215,7 +215,7 @@ class Filter : private NonCopyable Error GetNextRssIn(Iterator &aIterator, Entry &aEntry) const; /** - * This method applies the filter rules on a given Extended Address. + * Applies the filter rules on a given Extended Address. * * @param[in] aExtAddress A reference to the Extended Address. * @param[out] aRss A reference to where the received signal strength to be placed. @@ -227,9 +227,9 @@ class Filter : private NonCopyable Error Apply(const ExtAddress &aExtAddress, int8_t &aRss) const; /** - * This method applies the filter rules to a received frame from a given Extended Address. + * Applies the filter rules to a received frame from a given Extended Address. * - * This method can potentially update the signal strength value on the received frame @p aRxFrame. If @p aNeighbor + * Can potentially update the signal strength value on the received frame @p aRxFrame. If @p aNeighbor * is not `nullptr` and filter applies a fixed RSS to the @p aRxFrame, this method will also clear the current RSS * average on @p aNeighbor to ensure that the new fixed RSS takes effect quickly. * diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index 78924bfc2c2..fb4af88254c 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -61,7 +61,7 @@ using ot::Encoding::LittleEndian::WriteUint24; */ /** - * This class implements IEEE 802.15.4 IE (Information Element) header generation and parsing. + * Implements IEEE 802.15.4 IE (Information Element) header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -69,13 +69,13 @@ class HeaderIe { public: /** - * This method initializes the Header IE. + * Initializes the Header IE. * */ void Init(void) { mFields.m16 = 0; } /** - * This method initializes the Header IE with Id and Length. + * Initializes the Header IE with Id and Length. * * @param[in] aId The IE Element Id. * @param[in] aLen The IE content length. @@ -84,7 +84,7 @@ class HeaderIe void Init(uint16_t aId, uint8_t aLen); /** - * This method returns the IE Element Id. + * Returns the IE Element Id. * * @returns the IE Element Id. * @@ -92,7 +92,7 @@ class HeaderIe uint16_t GetId(void) const { return (HostSwap16(mFields.m16) & kIdMask) >> kIdOffset; } /** - * This method sets the IE Element Id. + * Sets the IE Element Id. * * @param[in] aId The IE Element Id. * @@ -103,7 +103,7 @@ class HeaderIe } /** - * This method returns the IE content length. + * Returns the IE content length. * * @returns the IE content length. * @@ -111,7 +111,7 @@ class HeaderIe uint8_t GetLength(void) const { return mFields.m8[0] & kLengthMask; } /** - * This method sets the IE content length. + * Sets the IE content length. * * @param[in] aLength The IE content length. * @@ -143,7 +143,7 @@ class HeaderIe #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || \ OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This class implements vendor specific Header IE generation and parsing. + * Implements vendor specific Header IE generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -154,7 +154,7 @@ class VendorIeHeader static constexpr uint8_t kIeContentSize = sizeof(uint8_t) * 4; /** - * This method returns the Vendor OUI. + * Returns the Vendor OUI. * * @returns The Vendor OUI. * @@ -162,7 +162,7 @@ class VendorIeHeader uint32_t GetVendorOui(void) const { return ReadUint24(mOui); } /** - * This method sets the Vendor OUI. + * Sets the Vendor OUI. * * @param[in] aVendorOui A Vendor OUI. * @@ -170,7 +170,7 @@ class VendorIeHeader void SetVendorOui(uint32_t aVendorOui) { WriteUint24(aVendorOui, mOui); } /** - * This method returns the Vendor IE sub-type. + * Returns the Vendor IE sub-type. * * @returns The Vendor IE sub-type. * @@ -178,7 +178,7 @@ class VendorIeHeader uint8_t GetSubType(void) const { return mSubType; } /** - * This method sets the Vendor IE sub-type. + * Sets the Vendor IE sub-type. * * @param[in] aSubType The Vendor IE sub-type. * @@ -194,7 +194,7 @@ class VendorIeHeader #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This class implements Time Header IE generation and parsing. + * Implements Time Header IE generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -207,7 +207,7 @@ class TimeIe : public VendorIeHeader static constexpr uint8_t kIeContentSize = VendorIeHeader::kIeContentSize + sizeof(uint8_t) + sizeof(uint64_t); /** - * This method initializes the time IE. + * Initializes the time IE. * */ void Init(void) @@ -217,7 +217,7 @@ class TimeIe : public VendorIeHeader } /** - * This method returns the time sync sequence. + * Returns the time sync sequence. * * @returns the time sync sequence. * @@ -225,7 +225,7 @@ class TimeIe : public VendorIeHeader uint8_t GetSequence(void) const { return mSequence; } /** - * This method sets the tine sync sequence. + * Sets the tine sync sequence. * * @param[in] aSequence The time sync sequence. * @@ -233,7 +233,7 @@ class TimeIe : public VendorIeHeader void SetSequence(uint8_t aSequence) { mSequence = aSequence; } /** - * This method returns the network time. + * Returns the network time. * * @returns the network time, in microseconds. * @@ -241,7 +241,7 @@ class TimeIe : public VendorIeHeader uint64_t GetTime(void) const { return HostSwap64(mTime); } /** - * This method sets the network time. + * Sets the network time. * * @param[in] aTime The network time. * @@ -269,14 +269,14 @@ class ThreadIe // OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This class implements IEEE 802.15.4 MAC frame generation and parsing. + * Implements IEEE 802.15.4 MAC frame generation and parsing. * */ class Frame : public otRadioFrame { public: /** - * This enumeration represents the MAC frame type. + * Represents the MAC frame type. * * Values match the Frame Type field in Frame Control Field (FCF) as an `uint16_t`. * @@ -290,7 +290,7 @@ class Frame : public otRadioFrame }; /** - * This enumeration represents the MAC frame version. + * Represents the MAC frame version. * * Values match the Version field in Frame Control Field (FCF) as an `uint16_t`. * @@ -303,7 +303,7 @@ class Frame : public otRadioFrame }; /** - * This enumeration represents the MAC frame security level. + * Represents the MAC frame security level. * * Values match the Security Level field in Security Control Field as an `uint8_t`. * @@ -321,7 +321,7 @@ class Frame : public otRadioFrame }; /** - * This enumeration represents the MAC frame security key identifier mode. + * Represents the MAC frame security key identifier mode. * * Values match the Key Identifier Mode field in Security Control Field as an `uint8_t`. * @@ -335,7 +335,7 @@ class Frame : public otRadioFrame }; /** - * This enumeration represents a subset of MAC Command Identifiers. + * Represents a subset of MAC Command Identifiers. * */ enum CommandId : uint8_t @@ -353,14 +353,23 @@ class Frame : public otRadioFrame static constexpr uint16_t kInfoStringSize = 128; ///< Max chars for `InfoString` (ToInfoString()). + static constexpr uint8_t kPreambleSize = 4; + static constexpr uint8_t kSfdSize = 1; + static constexpr uint8_t kPhrSize = 1; + static constexpr uint8_t kPhyHeaderSize = kPreambleSize + kSfdSize + kPhrSize; + static constexpr uint8_t kFcfSize = sizeof(uint16_t); + static constexpr uint8_t kDsnSize = sizeof(uint8_t); + static constexpr uint8_t k154FcsSize = sizeof(uint16_t); + static constexpr uint8_t kImmAckLength = kFcfSize + kDsnSize + k154FcsSize; + /** - * This type defines the fixed-length `String` object returned from `ToInfoString()` method. + * Defines the fixed-length `String` object returned from `ToInfoString()` method. * */ typedef String InfoString; /** - * This method indicates whether the frame is empty (no payload). + * Indicates whether the frame is empty (no payload). * * @retval TRUE The frame is empty (no PSDU payload). * @retval FALSE The frame is not empty. @@ -369,9 +378,9 @@ class Frame : public otRadioFrame bool IsEmpty(void) const { return (mLength == 0); } /** - * This method initializes the MAC header. + * Initializes the MAC header. * - * This method determines and writes the Frame Control Field (FCF) and Security Control in the frame along with + * Determines and writes the Frame Control Field (FCF) and Security Control in the frame along with * given source and destination addresses and PAN IDs. * * The Ack Request bit in FCF is set if there is destination and it is not broadcast. The Frame Pending and IE @@ -393,7 +402,7 @@ class Frame : public otRadioFrame KeyIdMode aKeyIdMode = kKeyIdMode0); /** - * This method validates the frame. + * Validates the frame. * * @retval kErrorNone Successfully parsed the MAC header. * @retval kErrorParse Failed to parse through the MAC header. @@ -402,7 +411,7 @@ class Frame : public otRadioFrame Error ValidatePsdu(void) const; /** - * This method returns the IEEE 802.15.4 Frame Type. + * Returns the IEEE 802.15.4 Frame Type. * * @returns The IEEE 802.15.4 Frame Type. * @@ -410,7 +419,7 @@ class Frame : public otRadioFrame uint8_t GetType(void) const { return GetPsdu()[0] & kFcfFrameTypeMask; } /** - * This method returns whether the frame is an Ack frame. + * Returns whether the frame is an Ack frame. * * @retval TRUE If this is an Ack. * @retval FALSE If this is not an Ack. @@ -419,7 +428,7 @@ class Frame : public otRadioFrame bool IsAck(void) const { return GetType() == kTypeAck; } /** - * This method returns the IEEE 802.15.4 Frame Version. + * Returns the IEEE 802.15.4 Frame Version. * * @returns The IEEE 802.15.4 Frame Version. * @@ -427,7 +436,7 @@ class Frame : public otRadioFrame uint16_t GetVersion(void) const { return GetFrameControlField() & kFcfFrameVersionMask; } /** - * This method returns if this IEEE 802.15.4 frame's version is 2015. + * Returns if this IEEE 802.15.4 frame's version is 2015. * * @returns TRUE if version is 2015, FALSE otherwise. * @@ -435,7 +444,7 @@ class Frame : public otRadioFrame bool IsVersion2015(void) const { return IsVersion2015(GetFrameControlField()); } /** - * This method indicates whether or not security is enabled. + * Indicates whether or not security is enabled. * * @retval TRUE If security is enabled. * @retval FALSE If security is not enabled. @@ -444,7 +453,7 @@ class Frame : public otRadioFrame bool GetSecurityEnabled(void) const { return (GetPsdu()[0] & kFcfSecurityEnabled) != 0; } /** - * This method indicates whether or not the Frame Pending bit is set. + * Indicates whether or not the Frame Pending bit is set. * * @retval TRUE If the Frame Pending bit is set. * @retval FALSE If the Frame Pending bit is not set. @@ -453,7 +462,7 @@ class Frame : public otRadioFrame bool GetFramePending(void) const { return (GetPsdu()[0] & kFcfFramePending) != 0; } /** - * This method sets the Frame Pending bit. + * Sets the Frame Pending bit. * * @param[in] aFramePending The Frame Pending bit. * @@ -461,7 +470,7 @@ class Frame : public otRadioFrame void SetFramePending(bool aFramePending); /** - * This method indicates whether or not the Ack Request bit is set. + * Indicates whether or not the Ack Request bit is set. * * @retval TRUE If the Ack Request bit is set. * @retval FALSE If the Ack Request bit is not set. @@ -470,7 +479,7 @@ class Frame : public otRadioFrame bool GetAckRequest(void) const { return (GetPsdu()[0] & kFcfAckRequest) != 0; } /** - * This method sets the Ack Request bit. + * Sets the Ack Request bit. * * @param[in] aAckRequest The Ack Request bit. * @@ -478,7 +487,7 @@ class Frame : public otRadioFrame void SetAckRequest(bool aAckRequest); /** - * This method indicates whether or not the PanId Compression bit is set. + * Indicates whether or not the PanId Compression bit is set. * * @retval TRUE If the PanId Compression bit is set. * @retval FALSE If the PanId Compression bit is not set. @@ -487,7 +496,7 @@ class Frame : public otRadioFrame bool IsPanIdCompressed(void) const { return (GetFrameControlField() & kFcfPanidCompression) != 0; } /** - * This method indicates whether or not IEs present. + * Indicates whether or not IEs present. * * @retval TRUE If IEs present. * @retval FALSE If no IE present. @@ -496,7 +505,7 @@ class Frame : public otRadioFrame bool IsIePresent(void) const { return (GetFrameControlField() & kFcfIePresent) != 0; } /** - * This method returns the Sequence Number value. + * Returns the Sequence Number value. * * @returns The Sequence Number value. * @@ -504,7 +513,7 @@ class Frame : public otRadioFrame uint8_t GetSequence(void) const { return GetPsdu()[kSequenceIndex]; } /** - * This method sets the Sequence Number value. + * Sets the Sequence Number value. * * @param[in] aSequence The Sequence Number value. * @@ -512,7 +521,7 @@ class Frame : public otRadioFrame void SetSequence(uint8_t aSequence) { GetPsdu()[kSequenceIndex] = aSequence; } /** - * This method indicates whether or not the Destination PAN ID is present. + * Indicates whether or not the Destination PAN ID is present. * * @returns TRUE if the Destination PAN ID is present, FALSE otherwise. * @@ -520,7 +529,7 @@ class Frame : public otRadioFrame bool IsDstPanIdPresent(void) const { return IsDstPanIdPresent(GetFrameControlField()); } /** - * This method gets the Destination PAN Identifier. + * Gets the Destination PAN Identifier. * * @param[out] aPanId The Destination PAN Identifier. * @@ -531,7 +540,7 @@ class Frame : public otRadioFrame Error GetDstPanId(PanId &aPanId) const; /** - * This method sets the Destination PAN Identifier. + * Sets the Destination PAN Identifier. * * @param[in] aPanId The Destination PAN Identifier. * @@ -539,7 +548,7 @@ class Frame : public otRadioFrame void SetDstPanId(PanId aPanId); /** - * This method indicates whether or not the Destination Address is present for this object. + * Indicates whether or not the Destination Address is present for this object. * * @retval TRUE If the Destination Address is present. * @retval FALSE If the Destination Address is not present. @@ -548,7 +557,7 @@ class Frame : public otRadioFrame bool IsDstAddrPresent() const { return IsDstAddrPresent(GetFrameControlField()); } /** - * This method gets the Destination Address. + * Gets the Destination Address. * * @param[out] aAddress The Destination Address. * @@ -558,7 +567,7 @@ class Frame : public otRadioFrame Error GetDstAddr(Address &aAddress) const; /** - * This method sets the Destination Address. + * Sets the Destination Address. * * @param[in] aShortAddress The Destination Address. * @@ -566,7 +575,7 @@ class Frame : public otRadioFrame void SetDstAddr(ShortAddress aShortAddress); /** - * This method sets the Destination Address. + * Sets the Destination Address. * * @param[in] aExtAddress The Destination Address. * @@ -574,7 +583,7 @@ class Frame : public otRadioFrame void SetDstAddr(const ExtAddress &aExtAddress); /** - * This method sets the Destination Address. + * Sets the Destination Address. * * @param[in] aAddress The Destination Address. * @@ -582,7 +591,7 @@ class Frame : public otRadioFrame void SetDstAddr(const Address &aAddress); /** - * This method indicates whether or not the Source Address is present for this object. + * Indicates whether or not the Source Address is present for this object. * * @retval TRUE If the Source Address is present. * @retval FALSE If the Source Address is not present. @@ -591,7 +600,7 @@ class Frame : public otRadioFrame bool IsSrcPanIdPresent(void) const { return IsSrcPanIdPresent(GetFrameControlField()); } /** - * This method gets the Source PAN Identifier. + * Gets the Source PAN Identifier. * * @param[out] aPanId The Source PAN Identifier. * @@ -601,7 +610,7 @@ class Frame : public otRadioFrame Error GetSrcPanId(PanId &aPanId) const; /** - * This method sets the Source PAN Identifier. + * Sets the Source PAN Identifier. * * @param[in] aPanId The Source PAN Identifier. * @@ -611,7 +620,7 @@ class Frame : public otRadioFrame Error SetSrcPanId(PanId aPanId); /** - * This method indicates whether or not the Source Address is present for this object. + * Indicates whether or not the Source Address is present for this object. * * @retval TRUE If the Source Address is present. * @retval FALSE If the Source Address is not present. @@ -620,7 +629,7 @@ class Frame : public otRadioFrame bool IsSrcAddrPresent(void) const { return IsSrcAddrPresent(GetFrameControlField()); } /** - * This method gets the Source Address. + * Gets the Source Address. * * @param[out] aAddress The Source Address. * @@ -630,7 +639,7 @@ class Frame : public otRadioFrame Error GetSrcAddr(Address &aAddress) const; /** - * This method sets the Source Address. + * Sets the Source Address. * * @param[in] aShortAddress The Source Address. * @@ -638,7 +647,7 @@ class Frame : public otRadioFrame void SetSrcAddr(ShortAddress aShortAddress); /** - * This method sets the Source Address. + * Sets the Source Address. * * @param[in] aExtAddress The Source Address. * @@ -646,7 +655,7 @@ class Frame : public otRadioFrame void SetSrcAddr(const ExtAddress &aExtAddress); /** - * This method sets the Source Address. + * Sets the Source Address. * * @param[in] aAddress The Source Address. * @@ -654,7 +663,7 @@ class Frame : public otRadioFrame void SetSrcAddr(const Address &aAddress); /** - * This method gets the Security Control Field. + * Gets the Security Control Field. * * @param[out] aSecurityControlField The Security Control Field. * @@ -665,7 +674,7 @@ class Frame : public otRadioFrame Error GetSecurityControlField(uint8_t &aSecurityControlField) const; /** - * This method sets the Security Control Field. + * Sets the Security Control Field. * * @param[in] aSecurityControlField The Security Control Field. * @@ -673,7 +682,7 @@ class Frame : public otRadioFrame void SetSecurityControlField(uint8_t aSecurityControlField); /** - * This method gets the Security Level Identifier. + * Gets the Security Level Identifier. * * @param[out] aSecurityLevel The Security Level Identifier. * @@ -683,7 +692,7 @@ class Frame : public otRadioFrame Error GetSecurityLevel(uint8_t &aSecurityLevel) const; /** - * This method gets the Key Identifier Mode. + * Gets the Key Identifier Mode. * * @param[out] aKeyIdMode The Key Identifier Mode. * @@ -693,7 +702,7 @@ class Frame : public otRadioFrame Error GetKeyIdMode(uint8_t &aKeyIdMode) const; /** - * This method gets the Frame Counter. + * Gets the Frame Counter. * * @param[out] aFrameCounter The Frame Counter. * @@ -703,7 +712,7 @@ class Frame : public otRadioFrame Error GetFrameCounter(uint32_t &aFrameCounter) const; /** - * This method sets the Frame Counter. + * Sets the Frame Counter. * * @param[in] aFrameCounter The Frame Counter. * @@ -711,7 +720,7 @@ class Frame : public otRadioFrame void SetFrameCounter(uint32_t aFrameCounter); /** - * This method returns a pointer to the Key Source. + * Returns a pointer to the Key Source. * * @returns A pointer to the Key Source. * @@ -719,7 +728,7 @@ class Frame : public otRadioFrame const uint8_t *GetKeySource(void) const; /** - * This method sets the Key Source. + * Sets the Key Source. * * @param[in] aKeySource A pointer to the Key Source value. * @@ -727,7 +736,7 @@ class Frame : public otRadioFrame void SetKeySource(const uint8_t *aKeySource); /** - * This method gets the Key Identifier. + * Gets the Key Identifier. * * @param[out] aKeyId The Key Identifier. * @@ -737,7 +746,7 @@ class Frame : public otRadioFrame Error GetKeyId(uint8_t &aKeyId) const; /** - * This method sets the Key Identifier. + * Sets the Key Identifier. * * @param[in] aKeyId The Key Identifier. * @@ -745,7 +754,7 @@ class Frame : public otRadioFrame void SetKeyId(uint8_t aKeyId); /** - * This method gets the Command ID. + * Gets the Command ID. * * @param[out] aCommandId The Command ID. * @@ -755,7 +764,7 @@ class Frame : public otRadioFrame Error GetCommandId(uint8_t &aCommandId) const; /** - * This method sets the Command ID. + * Sets the Command ID. * * @param[in] aCommandId The Command ID. * @@ -765,7 +774,7 @@ class Frame : public otRadioFrame Error SetCommandId(uint8_t aCommandId); /** - * This method indicates whether the frame is a MAC Data Request command (data poll). + * Indicates whether the frame is a MAC Data Request command (data poll). * * For 802.15.4-2015 and above frame, the frame should be already decrypted. * @@ -775,7 +784,7 @@ class Frame : public otRadioFrame bool IsDataRequestCommand(void) const; /** - * This method returns the MAC Frame Length. + * Returns the MAC Frame Length. * * @returns The MAC Frame Length. * @@ -783,7 +792,7 @@ class Frame : public otRadioFrame uint16_t GetLength(void) const { return mLength; } /** - * This method sets the MAC Frame Length. + * Sets the MAC Frame Length. * * @param[in] aLength The MAC Frame Length. * @@ -791,7 +800,7 @@ class Frame : public otRadioFrame void SetLength(uint16_t aLength) { mLength = aLength; } /** - * This method returns the MAC header size. + * Returns the MAC header size. * * @returns The MAC header size. * @@ -799,7 +808,7 @@ class Frame : public otRadioFrame uint8_t GetHeaderLength(void) const; /** - * This method returns the MAC footer size. + * Returns the MAC footer size. * * @returns The MAC footer size. * @@ -807,7 +816,7 @@ class Frame : public otRadioFrame uint8_t GetFooterLength(void) const; /** - * This method returns the current MAC Payload length. + * Returns the current MAC Payload length. * * @returns The current MAC Payload length. * @@ -815,7 +824,7 @@ class Frame : public otRadioFrame uint16_t GetPayloadLength(void) const; /** - * This method returns the maximum MAC Payload length for the given MAC header and footer. + * Returns the maximum MAC Payload length for the given MAC header and footer. * * @returns The maximum MAC Payload length for the given MAC header and footer. * @@ -823,13 +832,13 @@ class Frame : public otRadioFrame uint16_t GetMaxPayloadLength(void) const; /** - * This method sets the MAC Payload length. + * Sets the MAC Payload length. * */ void SetPayloadLength(uint16_t aLength); /** - * This method returns the IEEE 802.15.4 channel used for transmission or reception. + * Returns the IEEE 802.15.4 channel used for transmission or reception. * * @returns The IEEE 802.15.4 channel used for transmission or reception. * @@ -837,7 +846,7 @@ class Frame : public otRadioFrame uint8_t GetChannel(void) const { return mChannel; } /** - * This method returns the IEEE 802.15.4 PSDU length. + * Returns the IEEE 802.15.4 PSDU length. * * @returns The IEEE 802.15.4 PSDU length. * @@ -845,7 +854,7 @@ class Frame : public otRadioFrame uint16_t GetPsduLength(void) const { return mLength; } /** - * This method returns a pointer to the PSDU. + * Returns a pointer to the PSDU. * * @returns A pointer to the PSDU. * @@ -853,7 +862,7 @@ class Frame : public otRadioFrame uint8_t *GetPsdu(void) { return mPsdu; } /** - * This const method returns a pointer to the PSDU. + * Returns a pointer to the PSDU. * * @returns A pointer to the PSDU. * @@ -861,7 +870,7 @@ class Frame : public otRadioFrame const uint8_t *GetPsdu(void) const { return mPsdu; } /** - * This method returns a pointer to the MAC Header. + * Returns a pointer to the MAC Header. * * @returns A pointer to the MAC Header. * @@ -869,7 +878,7 @@ class Frame : public otRadioFrame uint8_t *GetHeader(void) { return GetPsdu(); } /** - * This const method returns a pointer to the MAC Header. + * Returns a pointer to the MAC Header. * * @returns A pointer to the MAC Header. * @@ -877,7 +886,7 @@ class Frame : public otRadioFrame const uint8_t *GetHeader(void) const { return GetPsdu(); } /** - * This method returns a pointer to the MAC Payload. + * Returns a pointer to the MAC Payload. * * @returns A pointer to the MAC Payload. * @@ -885,7 +894,7 @@ class Frame : public otRadioFrame uint8_t *GetPayload(void) { return AsNonConst(AsConst(this)->GetPayload()); } /** - * This const method returns a pointer to the MAC Payload. + * Returns a pointer to the MAC Payload. * * @returns A pointer to the MAC Payload. * @@ -893,7 +902,7 @@ class Frame : public otRadioFrame const uint8_t *GetPayload(void) const; /** - * This method returns a pointer to the MAC Footer. + * Returns a pointer to the MAC Footer. * * @returns A pointer to the MAC Footer. * @@ -901,7 +910,7 @@ class Frame : public otRadioFrame uint8_t *GetFooter(void) { return AsNonConst(AsConst(this)->GetFooter()); } /** - * This const method returns a pointer to the MAC Footer. + * Returns a pointer to the MAC Footer. * * @returns A pointer to the MAC Footer. * @@ -911,7 +920,7 @@ class Frame : public otRadioFrame #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method returns a pointer to the vendor specific Time IE. + * Returns a pointer to the vendor specific Time IE. * * @returns A pointer to the Time IE, `nullptr` if not found. * @@ -919,7 +928,7 @@ class Frame : public otRadioFrame TimeIe *GetTimeIe(void) { return AsNonConst(AsConst(this)->GetTimeIe()); } /** - * This method returns a pointer to the vendor specific Time IE. + * Returns a pointer to the vendor specific Time IE. * * @returns A pointer to the Time IE, `nullptr` if not found. * @@ -929,9 +938,9 @@ class Frame : public otRadioFrame #if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT /** - * This template method appends an Header IE at specified index in this frame. + * Appends an Header IE at specified index in this frame. * - * This method also sets the IE present bit in the Frame Control Field (FCF). + * Also sets the IE present bit in the Frame Control Field (FCF). * * @param[in,out] aIndex The index to append IE. If `aIndex` is `0` on input, this method finds the index * for the first IE and appends the IE at that position. If the position is not found @@ -949,7 +958,7 @@ class Frame : public otRadioFrame template Error AppendHeaderIeAt(uint8_t &aIndex); /** - * This method returns a pointer to the Header IE. + * Returns a pointer to the Header IE. * * @param[in] aIeId The Element Id of the Header IE. * @@ -959,7 +968,7 @@ class Frame : public otRadioFrame uint8_t *GetHeaderIe(uint8_t aIeId) { return AsNonConst(AsConst(this)->GetHeaderIe(aIeId)); } /** - * This method returns a pointer to the Header IE. + * Returns a pointer to the Header IE. * * @param[in] aIeId The Element Id of the Header IE. * @@ -969,7 +978,7 @@ class Frame : public otRadioFrame const uint8_t *GetHeaderIe(uint8_t aIeId) const; /** - * This method returns a pointer to a specific Thread IE. + * Returns a pointer to a specific Thread IE. * * A Thread IE is a vendor specific IE with Vendor OUI as `kVendorOuiThreadCompanyId`. * @@ -981,7 +990,7 @@ class Frame : public otRadioFrame uint8_t *GetThreadIe(uint8_t aSubType) { return AsNonConst(AsConst(this)->GetThreadIe(aSubType)); } /** - * This method returns a pointer to a specific Thread IE. + * Returns a pointer to a specific Thread IE. * * A Thread IE is a vendor specific IE with Vendor OUI as `kVendorOuiThreadCompanyId`. * @@ -994,7 +1003,7 @@ class Frame : public otRadioFrame #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method finds CSL IE in the frame and modify its content. + * Finds CSL IE in the frame and modify its content. * * @param[in] aCslPeriod CSL Period in CSL IE. * @param[in] aCslPhase CSL Phase in CSL IE. @@ -1005,7 +1014,7 @@ class Frame : public otRadioFrame #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method finds Enhanced ACK Probing (Vendor Specific) IE and set its value. + * Finds Enhanced ACK Probing (Vendor Specific) IE and set its value. * * @param[in] aValue A pointer to the value to set. * @param[in] aLen The length of @p aValue. @@ -1018,7 +1027,7 @@ class Frame : public otRadioFrame #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method gets the radio link type of the frame. + * Gets the radio link type of the frame. * * @returns Frame's radio link type. * @@ -1026,7 +1035,7 @@ class Frame : public otRadioFrame RadioType GetRadioType(void) const { return static_cast(mRadioType); } /** - * This method sets the radio link type of the frame. + * Sets the radio link type of the frame. * * @param[in] aRadioType A radio link type. * @@ -1035,7 +1044,7 @@ class Frame : public otRadioFrame #endif /** - * This method returns the maximum transmission unit size (MTU). + * Returns the maximum transmission unit size (MTU). * * @returns The maximum transmission unit (MTU). * @@ -1050,7 +1059,7 @@ class Frame : public otRadioFrame #endif /** - * This method returns the FCS size. + * Returns the FCS size. * * @returns This method returns the FCS size. * @@ -1065,7 +1074,7 @@ class Frame : public otRadioFrame #endif /** - * This method returns information about the frame object as an `InfoString` object. + * Returns information about the frame object as an `InfoString` object. * * @returns An `InfoString` containing info about the frame. * @@ -1073,7 +1082,7 @@ class Frame : public otRadioFrame InfoString ToInfoString(void) const; /** - * This method returns the Frame Control field of the frame. + * Returns the Frame Control field of the frame. * * @returns The Frame Control field. * @@ -1081,12 +1090,9 @@ class Frame : public otRadioFrame uint16_t GetFrameControlField(void) const; protected: - static constexpr uint8_t kFcfSize = sizeof(uint16_t); - static constexpr uint8_t kDsnSize = sizeof(uint8_t); static constexpr uint8_t kSecurityControlSize = sizeof(uint8_t); static constexpr uint8_t kFrameCounterSize = sizeof(uint32_t); static constexpr uint8_t kCommandIdSize = sizeof(uint8_t); - static constexpr uint8_t k154FcsSize = sizeof(uint16_t); static constexpr uint8_t kKeyIndexSize = sizeof(uint8_t); static constexpr uint16_t kFcfFrameTypeMask = 7 << 0; @@ -1119,8 +1125,6 @@ class Frame : public otRadioFrame static constexpr uint8_t kKeySourceSizeMode2 = 4; static constexpr uint8_t kKeySourceSizeMode3 = 8; - static constexpr uint8_t kImmAckLength = kFcfSize + kDsnSize + k154FcsSize; - static constexpr uint8_t kInvalidIndex = 0xff; static constexpr uint8_t kInvalidSize = kInvalidIndex; static constexpr uint8_t kMaxPsduSize = kInvalidSize - 1; @@ -1152,10 +1156,12 @@ class Frame : public otRadioFrame static uint8_t CalculateAddrFieldSize(uint16_t aFcf); static uint8_t CalculateSecurityHeaderSize(uint8_t aSecurityControl); static uint8_t CalculateMicSize(uint8_t aSecurityControl); + +public: }; /** - * This class supports received IEEE 802.15.4 MAC frame processing. + * Supports received IEEE 802.15.4 MAC frame processing. * */ class RxFrame : public Frame @@ -1164,7 +1170,7 @@ class RxFrame : public Frame friend class TxFrame; /** - * This method returns the RSSI in dBm used for reception. + * Returns the RSSI in dBm used for reception. * * @returns The RSSI in dBm used for reception. * @@ -1172,7 +1178,7 @@ class RxFrame : public Frame int8_t GetRssi(void) const { return mInfo.mRxInfo.mRssi; } /** - * This method sets the RSSI in dBm used for reception. + * Sets the RSSI in dBm used for reception. * * @param[in] aRssi The RSSI in dBm used for reception. * @@ -1180,7 +1186,7 @@ class RxFrame : public Frame void SetRssi(int8_t aRssi) { mInfo.mRxInfo.mRssi = aRssi; } /** - * This method returns the receive Link Quality Indicator. + * Returns the receive Link Quality Indicator. * * @returns The receive Link Quality Indicator. * @@ -1188,7 +1194,7 @@ class RxFrame : public Frame uint8_t GetLqi(void) const { return mInfo.mRxInfo.mLqi; } /** - * This method sets the receive Link Quality Indicator. + * Sets the receive Link Quality Indicator. * * @param[in] aLqi The receive Link Quality Indicator. * @@ -1196,7 +1202,7 @@ class RxFrame : public Frame void SetLqi(uint8_t aLqi) { mInfo.mRxInfo.mLqi = aLqi; } /** - * This method indicates whether or not the received frame is acknowledged with frame pending set. + * Indicates whether or not the received frame is acknowledged with frame pending set. * * @retval TRUE This frame is acknowledged with frame pending set. * @retval FALSE This frame is acknowledged with frame pending not set. @@ -1205,7 +1211,7 @@ class RxFrame : public Frame bool IsAckedWithFramePending(void) const { return mInfo.mRxInfo.mAckedWithFramePending; } /** - * This method returns the timestamp when the frame was received. + * Returns the timestamp when the frame was received. * The timestamp marks the frame detection time: the end of the last symbol of SFD. * * @returns The timestamp when the frame SFD was received, in microseconds. @@ -1214,7 +1220,7 @@ class RxFrame : public Frame const uint64_t &GetTimestamp(void) const { return mInfo.mRxInfo.mTimestamp; } /** - * This method performs AES CCM on the frame which is received. + * Performs AES CCM on the frame which is received. * * @param[in] aExtAddress A reference to the extended address, which will be used to generate nonce * for AES CCM computation. @@ -1228,7 +1234,7 @@ class RxFrame : public Frame #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method gets the offset to network time. + * Gets the offset to network time. * * @returns The offset to network time. * @@ -1239,7 +1245,7 @@ class RxFrame : public Frame } /** - * This method gets the time sync sequence. + * Gets the time sync sequence. * * @returns The time sync sequence. * @@ -1249,14 +1255,14 @@ class RxFrame : public Frame }; /** - * This class supports IEEE 802.15.4 MAC frame generation for transmission. + * Supports IEEE 802.15.4 MAC frame generation for transmission. * */ class TxFrame : public Frame { public: /** - * This method sets the channel on which to send the frame. + * Sets the channel on which to send the frame. * * It also sets the `RxChannelAfterTxDone` to the same channel. * @@ -1270,7 +1276,7 @@ class TxFrame : public Frame } /** - * This method gets the RX channel after frame TX is done. + * Gets the RX channel after frame TX is done. * * @returns The RX channel after frame TX is done. * @@ -1278,7 +1284,7 @@ class TxFrame : public Frame uint8_t GetRxChannelAfterTxDone(void) const { return mInfo.mTxInfo.mRxChannelAfterTxDone; } /** - * This method sets the RX channel after frame TX is done. + * Sets the RX channel after frame TX is done. * * @param[in] aChannel The RX channel after frame TX is done. * @@ -1286,7 +1292,7 @@ class TxFrame : public Frame void SetRxChannelAfterTxDone(uint8_t aChannel) { mInfo.mTxInfo.mRxChannelAfterTxDone = aChannel; } /** - * This method returns the maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel + * Returns the maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel * access failure. * * Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006. @@ -1298,7 +1304,7 @@ class TxFrame : public Frame uint8_t GetMaxCsmaBackoffs(void) const { return mInfo.mTxInfo.mMaxCsmaBackoffs; } /** - * This method sets the maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel + * Sets the maximum number of backoffs the CSMA-CA algorithm will attempt before declaring a channel * access failure. * * Equivalent to macMaxCSMABackoffs in IEEE 802.15.4-2006. @@ -1310,7 +1316,7 @@ class TxFrame : public Frame void SetMaxCsmaBackoffs(uint8_t aMaxCsmaBackoffs) { mInfo.mTxInfo.mMaxCsmaBackoffs = aMaxCsmaBackoffs; } /** - * This method returns the maximum number of retries allowed after a transmission failure. + * Returns the maximum number of retries allowed after a transmission failure. * * Equivalent to macMaxFrameRetries in IEEE 802.15.4-2006. * @@ -1320,7 +1326,7 @@ class TxFrame : public Frame uint8_t GetMaxFrameRetries(void) const { return mInfo.mTxInfo.mMaxFrameRetries; } /** - * This method sets the maximum number of retries allowed after a transmission failure. + * Sets the maximum number of retries allowed after a transmission failure. * * Equivalent to macMaxFrameRetries in IEEE 802.15.4-2006. * @@ -1330,7 +1336,7 @@ class TxFrame : public Frame void SetMaxFrameRetries(uint8_t aMaxFrameRetries) { mInfo.mTxInfo.mMaxFrameRetries = aMaxFrameRetries; } /** - * This method indicates whether or not the frame is a retransmission. + * Indicates whether or not the frame is a retransmission. * * @retval TRUE Frame is a retransmission * @retval FALSE This is a new frame and not a retransmission of an earlier frame. @@ -1339,7 +1345,7 @@ class TxFrame : public Frame bool IsARetransmission(void) const { return mInfo.mTxInfo.mIsARetx; } /** - * This method sets the retransmission flag attribute. + * Sets the retransmission flag attribute. * * @param[in] aIsARetx TRUE if frame is a retransmission of an earlier frame, FALSE otherwise. * @@ -1347,7 +1353,7 @@ class TxFrame : public Frame void SetIsARetransmission(bool aIsARetx) { mInfo.mTxInfo.mIsARetx = aIsARetx; } /** - * This method indicates whether or not CSMA-CA is enabled. + * Indicates whether or not CSMA-CA is enabled. * * @retval TRUE CSMA-CA is enabled. * @retval FALSE CSMA-CA is not enabled is not enabled. @@ -1356,7 +1362,7 @@ class TxFrame : public Frame bool IsCsmaCaEnabled(void) const { return mInfo.mTxInfo.mCsmaCaEnabled; } /** - * This method sets the CSMA-CA enabled attribute. + * Sets the CSMA-CA enabled attribute. * * @param[in] aCsmaCaEnabled TRUE if CSMA-CA must be enabled for this packet, FALSE otherwise. * @@ -1364,7 +1370,7 @@ class TxFrame : public Frame void SetCsmaCaEnabled(bool aCsmaCaEnabled) { mInfo.mTxInfo.mCsmaCaEnabled = aCsmaCaEnabled; } /** - * This method returns the key used for frame encryption and authentication (AES CCM). + * Returns the key used for frame encryption and authentication (AES CCM). * * @returns The pointer to the key. * @@ -1375,7 +1381,7 @@ class TxFrame : public Frame } /** - * This method sets the key used for frame encryption and authentication (AES CCM). + * Sets the key used for frame encryption and authentication (AES CCM). * * @param[in] aAesKey The pointer to the key. * @@ -1383,7 +1389,7 @@ class TxFrame : public Frame void SetAesKey(const Mac::KeyMaterial &aAesKey) { mInfo.mTxInfo.mAesKey = &aAesKey; } /** - * This method copies the PSDU and all attributes (except for frame link type) from another frame. + * Copies the PSDU and all attributes (except for frame link type) from another frame. * * @note This method performs a deep copy meaning the content of PSDU buffer from the given frame is copied into * the PSDU buffer of the current frame. @@ -1394,7 +1400,7 @@ class TxFrame : public Frame void CopyFrom(const TxFrame &aFromFrame); /** - * This method performs AES CCM on the frame which is going to be sent. + * Performs AES CCM on the frame which is going to be sent. * * @param[in] aExtAddress A reference to the extended address, which will be used to generate nonce * for AES CCM computation. @@ -1403,7 +1409,7 @@ class TxFrame : public Frame void ProcessTransmitAesCcm(const ExtAddress &aExtAddress); /** - * This method indicates whether or not the frame has security processed. + * Indicates whether or not the frame has security processed. * * @retval TRUE The frame already has security processed. * @retval FALSE The frame does not have security processed. @@ -1412,7 +1418,7 @@ class TxFrame : public Frame bool IsSecurityProcessed(void) const { return mInfo.mTxInfo.mIsSecurityProcessed; } /** - * This method sets the security processed flag attribute. + * Sets the security processed flag attribute. * * @param[in] aIsSecurityProcessed TRUE if the frame already has security processed. * @@ -1423,7 +1429,23 @@ class TxFrame : public Frame } /** - * This method indicates whether or not the frame header is updated. + * Indicates whether or not the frame contains the CSL IE. + * + * @retval TRUE The frame contains the CSL IE. + * @retval FALSE The frame does not contain the CSL IE. + * + */ + bool IsCslIePresent(void) const { return mInfo.mTxInfo.mCslPresent; } + + /** + * Sets the CSL IE present flag. + * + * @param[in] aCslPresent TRUE if the frame contains the CSL IE. + */ + void SetCslIePresent(bool aCslPresent) { mInfo.mTxInfo.mCslPresent = aCslPresent; } + + /** + * Indicates whether or not the frame header is updated. * * @retval TRUE The frame already has the header updated. * @retval FALSE The frame does not have the header updated. @@ -1432,7 +1454,7 @@ class TxFrame : public Frame bool IsHeaderUpdated(void) const { return mInfo.mTxInfo.mIsHeaderUpdated; } /** - * This method sets the header updated flag attribute. + * Sets the header updated flag attribute. * * @param[in] aIsHeaderUpdated TRUE if the frame header is updated. * @@ -1441,7 +1463,7 @@ class TxFrame : public Frame #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method sets the Time IE offset. + * Sets the Time IE offset. * * @param[in] aOffset The Time IE offset, 0 means no Time IE. * @@ -1449,7 +1471,7 @@ class TxFrame : public Frame void SetTimeIeOffset(uint8_t aOffset) { mInfo.mTxInfo.mIeInfo->mTimeIeOffset = aOffset; } /** - * This method gets the Time IE offset. + * Gets the Time IE offset. * * @returns The Time IE offset, 0 means no Time IE. * @@ -1457,7 +1479,7 @@ class TxFrame : public Frame uint8_t GetTimeIeOffset(void) const { return mInfo.mTxInfo.mIeInfo->mTimeIeOffset; } /** - * This method sets the offset to network time. + * Sets the offset to network time. * * @param[in] aNetworkTimeOffset The offset to network time. * @@ -1468,7 +1490,7 @@ class TxFrame : public Frame } /** - * This method sets the time sync sequence. + * Sets the time sync sequence. * * @param[in] aTimeSyncSeq The time sync sequence. * @@ -1525,7 +1547,7 @@ class Beacon static constexpr uint16_t kSuperFrameSpec = 0x0fff; ///< Superframe Specification value. /** - * This method initializes the Beacon message. + * Initializes the Beacon message. * */ void Init(void) @@ -1536,7 +1558,7 @@ class Beacon } /** - * This method indicates whether or not the beacon appears to be a valid Thread Beacon message. + * Indicates whether or not the beacon appears to be a valid Thread Beacon message. * * @retval TRUE If the beacon appears to be a valid Thread Beacon message. * @retval FALSE If the beacon does not appear to be a valid Thread Beacon message. @@ -1548,7 +1570,7 @@ class Beacon } /** - * This method returns the pointer to the beacon payload. + * Returns the pointer to the beacon payload. * * @returns A pointer to the beacon payload. * @@ -1556,7 +1578,7 @@ class Beacon uint8_t *GetPayload(void) { return reinterpret_cast(this) + sizeof(*this); } /** - * This method returns the pointer to the beacon payload. + * Returns the pointer to the beacon payload. * * @returns A pointer to the beacon payload. * @@ -1570,7 +1592,7 @@ class Beacon } OT_TOOL_PACKED_END; /** - * This class implements IEEE 802.15.4 Beacon Payload generation and parsing. + * Implements IEEE 802.15.4 Beacon Payload generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1585,7 +1607,7 @@ class BeaconPayload static constexpr uint8_t kJoiningFlag = 1 << 0; ///< Joining Permitted flag. /** - * This method initializes the Beacon Payload. + * Initializes the Beacon Payload. * */ void Init(void) @@ -1595,7 +1617,7 @@ class BeaconPayload } /** - * This method indicates whether or not the beacon appears to be a valid Thread Beacon Payload. + * Indicates whether or not the beacon appears to be a valid Thread Beacon Payload. * * @retval TRUE If the beacon appears to be a valid Thread Beacon Payload. * @retval FALSE If the beacon does not appear to be a valid Thread Beacon Payload. @@ -1604,7 +1626,7 @@ class BeaconPayload bool IsValid(void) const { return (mProtocolId == kProtocolId); } /** - * This method returns the Protocol ID value. + * Returns the Protocol ID value. * * @returns the Protocol ID value. * @@ -1612,7 +1634,7 @@ class BeaconPayload uint8_t GetProtocolId(void) const { return mProtocolId; } /** - * This method returns the Protocol Version value. + * Returns the Protocol Version value. * * @returns The Protocol Version value. * @@ -1620,7 +1642,7 @@ class BeaconPayload uint8_t GetProtocolVersion(void) const { return mFlags >> kVersionOffset; } /** - * This method indicates whether or not the Native Commissioner flag is set. + * Indicates whether or not the Native Commissioner flag is set. * * @retval TRUE If the Native Commissioner flag is set. * @retval FALSE If the Native Commissioner flag is not set. @@ -1629,19 +1651,19 @@ class BeaconPayload bool IsNative(void) const { return (mFlags & kNativeFlag) != 0; } /** - * This method clears the Native Commissioner flag. + * Clears the Native Commissioner flag. * */ void ClearNative(void) { mFlags &= ~kNativeFlag; } /** - * This method sets the Native Commissioner flag. + * Sets the Native Commissioner flag. * */ void SetNative(void) { mFlags |= kNativeFlag; } /** - * This method indicates whether or not the Joining Permitted flag is set. + * Indicates whether or not the Joining Permitted flag is set. * * @retval TRUE If the Joining Permitted flag is set. * @retval FALSE If the Joining Permitted flag is not set. @@ -1650,13 +1672,13 @@ class BeaconPayload bool IsJoiningPermitted(void) const { return (mFlags & kJoiningFlag) != 0; } /** - * This method clears the Joining Permitted flag. + * Clears the Joining Permitted flag. * */ void ClearJoiningPermitted(void) { mFlags &= ~kJoiningFlag; } /** - * This method sets the Joining Permitted flag. + * Sets the Joining Permitted flag. * */ void SetJoiningPermitted(void) @@ -1670,7 +1692,7 @@ class BeaconPayload } /** - * This method gets the Network Name field. + * Gets the Network Name field. * * @returns The Network Name field as `NameData`. * @@ -1678,7 +1700,7 @@ class BeaconPayload MeshCoP::NameData GetNetworkName(void) const { return MeshCoP::NameData(mNetworkName, sizeof(mNetworkName)); } /** - * This method sets the Network Name field. + * Sets the Network Name field. * * @param[in] aNameData The Network Name (as a `NameData`). * @@ -1686,7 +1708,7 @@ class BeaconPayload void SetNetworkName(const MeshCoP::NameData &aNameData) { aNameData.CopyTo(mNetworkName, sizeof(mNetworkName)); } /** - * This method returns the Extended PAN ID field. + * Returns the Extended PAN ID field. * * @returns The Extended PAN ID field. * @@ -1694,7 +1716,7 @@ class BeaconPayload const otExtendedPanId &GetExtendedPanId(void) const { return mExtendedPanId; } /** - * This method sets the Extended PAN ID field. + * Sets the Extended PAN ID field. * * @param[in] aExtPanId An Extended PAN ID. * @@ -1709,7 +1731,7 @@ class BeaconPayload } OT_TOOL_PACKED_END; /** - * This class implements CSL IE data structure. + * Implements CSL IE data structure. * */ OT_TOOL_PACKED_BEGIN @@ -1720,7 +1742,7 @@ class CslIe static constexpr uint8_t kIeContentSize = sizeof(uint16_t) * 2; /** - * This method returns the CSL Period. + * Returns the CSL Period. * * @returns the CSL Period. * @@ -1728,7 +1750,7 @@ class CslIe uint16_t GetPeriod(void) const { return HostSwap16(mPeriod); } /** - * This method sets the CSL Period. + * Sets the CSL Period. * * @param[in] aPeriod The CSL Period. * @@ -1736,7 +1758,7 @@ class CslIe void SetPeriod(uint16_t aPeriod) { mPeriod = HostSwap16(aPeriod); } /** - * This method returns the CSL Phase. + * Returns the CSL Phase. * * @returns the CSL Phase. * @@ -1744,7 +1766,7 @@ class CslIe uint16_t GetPhase(void) const { return HostSwap16(mPhase); } /** - * This method sets the CSL Phase. + * Sets the CSL Phase. * * @param[in] aPhase The CSL Phase. * @@ -1757,9 +1779,9 @@ class CslIe } OT_TOOL_PACKED_END; /** - * This class implements Termination2 IE. + * Implements Termination2 IE. * - * This class is empty for template specialization. + * Is empty for template specialization. * */ class Termination2Ie diff --git a/src/core/mac/mac_links.hpp b/src/core/mac/mac_links.hpp index cc30ef0cd1a..605866d1831 100644 --- a/src/core/mac/mac_links.hpp +++ b/src/core/mac/mac_links.hpp @@ -58,7 +58,7 @@ namespace Mac { */ /** - * This class represents tx frames for different radio link types. + * Represents tx frames for different radio link types. * */ class TxFrames : InstanceLocator @@ -68,9 +68,9 @@ class TxFrames : InstanceLocator public: #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method gets the `TxFrame` for a given radio link type. + * Gets the `TxFrame` for a given radio link type. * - * This method also updates the selected radio types (from `GetSelectedRadioTypes()`) to include the @p aRadioType. + * Also updates the selected radio types (from `GetSelectedRadioTypes()`) to include the @p aRadioType. * * @param[in] aRadioType A radio link type. * @@ -80,9 +80,9 @@ class TxFrames : InstanceLocator TxFrame &GetTxFrame(RadioType aRadioType); /** - * This method gets the `TxFrame` with the smallest MTU size among a given set of radio types. + * Gets the `TxFrame` with the smallest MTU size among a given set of radio types. * - * This method also updates the selected radio types (from `GetSelectedRadioTypes()`) to include the set + * Also updates the selected radio types (from `GetSelectedRadioTypes()`) to include the set * @p aRadioTypes. * * @param[in] aRadioTypes A set of radio link types. @@ -93,9 +93,9 @@ class TxFrames : InstanceLocator TxFrame &GetTxFrame(RadioTypes aRadioTypes); /** - * This method gets the `TxFrame` for sending a broadcast frame. + * Gets the `TxFrame` for sending a broadcast frame. * - * This method also updates the selected radio type (from `GetSelectedRadioTypes()`) to include all radio types + * Also updates the selected radio type (from `GetSelectedRadioTypes()`) to include all radio types * (supported by device). * * The broadcast frame is the `TxFrame` with the smallest MTU size among all radio types. @@ -106,7 +106,7 @@ class TxFrames : InstanceLocator TxFrame &GetBroadcastTxFrame(void); /** - * This method gets the selected radio types. + * Gets the selected radio types. * * This set specifies the radio links the frame should be sent over (in parallel). The set starts a empty after * method `Clear()` is called. It gets updated through calls to methods `GetTxFrame(aType)`, @@ -118,7 +118,7 @@ class TxFrames : InstanceLocator RadioTypes GetSelectedRadioTypes(void) const { return mSelectedRadioTypes; } /** - * This method gets the required radio types. + * Gets the required radio types. * * This set specifies the radio links for which we expect the frame tx to be successful to consider the overall tx * successful. If the set is empty, successful tx over any radio link is sufficient for overall tx to be considered @@ -132,7 +132,7 @@ class TxFrames : InstanceLocator RadioTypes GetRequiredRadioTypes(void) const { return mRequiredRadioTypes; } /** - * This method sets the required types. + * Sets the required types. * * Please see `GetRequiredRadioTypes()` for more details on how this set is used during tx. * @@ -145,7 +145,7 @@ class TxFrames : InstanceLocator #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE /** - * This method gets the tx frame. + * Gets the tx frame. * * @returns A reference to `TxFrame`. * @@ -153,7 +153,7 @@ class TxFrames : InstanceLocator TxFrame &GetTxFrame(void) { return mTxFrame802154; } #elif OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method gets the tx frame. + * Gets the tx frame. * * @returns A reference to `TxFrame`. * @@ -161,7 +161,7 @@ class TxFrames : InstanceLocator TxFrame &GetTxFrame(void) { return mTxFrameTrel; } #endif /** - * This method gets a tx frame for sending a broadcast frame. + * Gets a tx frame for sending a broadcast frame. * * @returns A reference to a `TxFrame` for broadcast. * @@ -171,7 +171,7 @@ class TxFrames : InstanceLocator #endif // #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method clears all supported radio tx frames (sets the PSDU length to zero and clears flags). + * Clears all supported radio tx frames (sets the PSDU length to zero and clears flags). * */ void Clear(void) @@ -186,6 +186,9 @@ class TxFrames : InstanceLocator mTxFrame802154.SetTxDelay(0); mTxFrame802154.SetTxDelayBaseTime(0); #endif +#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE + mTxFrame802154.SetCslIePresent(false); +#endif #endif #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE mTxFrameTrel.SetLength(0); @@ -202,7 +205,7 @@ class TxFrames : InstanceLocator } /** - * This method sets the channel on all supported radio tx frames. + * Sets the channel on all supported radio tx frames. * * @param[in] aChannel A channel. * @@ -218,7 +221,7 @@ class TxFrames : InstanceLocator } /** - * This method sets the Sequence Number value on all supported radio tx frames. + * Sets the Sequence Number value on all supported radio tx frames. * * @param[in] aSequence The Sequence Number value. * @@ -234,7 +237,7 @@ class TxFrames : InstanceLocator } /** - * This method sets the maximum number of the CSMA-CA backoffs on all supported radio tx + * Sets the maximum number of the CSMA-CA backoffs on all supported radio tx * frames. * * @param[in] aMaxCsmaBackoffs The maximum number of CSMA-CA backoffs. @@ -251,7 +254,7 @@ class TxFrames : InstanceLocator } /** - * This method sets the maximum number of retries allowed after a transmission failure on all supported radio tx + * Sets the maximum number of retries allowed after a transmission failure on all supported radio tx * frames. * * @param[in] aMaxFrameRetries The maximum number of retries allowed after a transmission failure. @@ -284,7 +287,7 @@ class TxFrames : InstanceLocator }; /** - * This class represents MAC radio links (multi radio). + * Represents MAC radio links (multi radio). * */ class Links : public InstanceLocator @@ -293,7 +296,7 @@ class Links : public InstanceLocator public: /** - * This constructor initializes the `Links` object. + * Initializes the `Links` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -301,7 +304,7 @@ class Links : public InstanceLocator explicit Links(Instance &aInstance); /** - * This method sets the PAN ID. + * Sets the PAN ID. * * @param[in] aPanId The PAN ID. * @@ -317,7 +320,7 @@ class Links : public InstanceLocator } /** - * This method gets the MAC Short Address. + * Gets the MAC Short Address. * * @returns The MAC Short Address. * @@ -333,7 +336,7 @@ class Links : public InstanceLocator } /** - * This method sets the MAC Short Address. + * Sets the MAC Short Address. * * @param[in] aShortAddress A MAC Short Address. * @@ -348,7 +351,7 @@ class Links : public InstanceLocator } /** - * This method gets the MAC Extended Address. + * Gets the MAC Extended Address. * * @returns The MAC Extended Address. * @@ -364,7 +367,7 @@ class Links : public InstanceLocator } /** - * This method sets the MAC Extended Address. + * Sets the MAC Extended Address. * * @param[in] aExtAddress A MAC Extended Address. * @@ -382,7 +385,7 @@ class Links : public InstanceLocator } /** - * This method registers a callback to provide received packet capture for IEEE 802.15.4 frames. + * Registers a callback to provide received packet capture for IEEE 802.15.4 frames. * * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame * or nullptr to disable the callback. @@ -399,7 +402,7 @@ class Links : public InstanceLocator } /** - * This method indicates whether radio should stay in Receive or Sleep during CSMA backoff. + * Indicates whether radio should stay in Receive or Sleep during CSMA backoff. * * @param[in] aRxOnWhenBackoff TRUE to keep radio in Receive, FALSE to put to Sleep during CSMA backoff. * @@ -413,7 +416,7 @@ class Links : public InstanceLocator } /** - * This method enables all radio links. + * Enables all radio links. * */ void Enable(void) @@ -427,7 +430,7 @@ class Links : public InstanceLocator } /** - * This method disables all radio links. + * Disables all radio links. * */ void Disable(void) @@ -441,7 +444,7 @@ class Links : public InstanceLocator } /** - * This method transitions all radio links to Sleep. + * Transitions all radio links to Sleep. * */ void Sleep(void) @@ -456,7 +459,7 @@ class Links : public InstanceLocator #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method configures CSL parameters in all radios. + * Configures CSL parameters in all radios. * * @param[in] aPeriod The CSL period. * @param[in] aChannel The CSL channel. @@ -482,7 +485,7 @@ class Links : public InstanceLocator } /** - * This method transitions all radios link to CSL sample state, given that a non-zero CSL period is configured. + * Transitions all radios link to CSL sample state, given that a non-zero CSL period is configured. * * CSL sample state is only applicable and used for 15.4 radio link. Other link are transitioned to sleep state * when CSL period is non-zero. @@ -500,7 +503,7 @@ class Links : public InstanceLocator #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method transitions all radio links to Receive. + * Transitions all radio links to Receive. * * @param[in] aChannel The channel to use for receiving. * @@ -516,7 +519,7 @@ class Links : public InstanceLocator } /** - * This method gets the radio transmit frames. + * Gets the radio transmit frames. * * @returns The transmit frames. * @@ -526,7 +529,7 @@ class Links : public InstanceLocator #if !OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method sends a prepared frame. + * Sends a prepared frame. * * The prepared frame is from `GetTxFrames()`. This method is available only in single radio link mode. * @@ -544,7 +547,7 @@ class Links : public InstanceLocator #else // #if !OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method sends prepared frames over a given set of radio links. + * Sends prepared frames over a given set of radio links. * * The prepared frame must be from `GetTxFrames()`. This method is available only in multi radio link mode. * @@ -557,7 +560,7 @@ class Links : public InstanceLocator #endif // !OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method gets the number of transmit retries for the last transmitted frame. + * Gets the number of transmit retries for the last transmitted frame. * * @returns Number of transmit retries. * @@ -573,7 +576,7 @@ class Links : public InstanceLocator } /** - * This method gets the most recent RSSI measurement from radio link. + * Gets the most recent RSSI measurement from radio link. * * @returns The RSSI in dBm when it is valid. `Radio::kInvalidRssi` when RSSI is invalid. * @@ -589,7 +592,7 @@ class Links : public InstanceLocator } /** - * This method begins energy scan. + * Begins energy scan. * * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. @@ -614,7 +617,7 @@ class Links : public InstanceLocator } /** - * This method returns the noise floor value (currently use the radio receive sensitivity value). + * Returns the noise floor value (currently use the radio receive sensitivity value). * * @returns The noise floor value in dBm. * @@ -630,7 +633,7 @@ class Links : public InstanceLocator } /** - * This methods gets a reference to the `SubMac` instance. + * Gets a reference to the `SubMac` instance. * * @returns A reference to the `SubMac` instance. * @@ -638,7 +641,7 @@ class Links : public InstanceLocator SubMac &GetSubMac(void) { return mSubMac; } /** - * This methods gets a reference to the `SubMac` instance. + * Gets a reference to the `SubMac` instance. * * @returns A reference to the `SubMac` instance. * @@ -646,7 +649,7 @@ class Links : public InstanceLocator const SubMac &GetSubMac(void) const { return mSubMac; } /** - * This method returns a reference to the current MAC key (for Key Mode 1) for a given Frame. + * Returns a reference to the current MAC key (for Key Mode 1) for a given Frame. * * @param[in] aFrame The frame for which to get the MAC key. * @@ -656,7 +659,7 @@ class Links : public InstanceLocator const KeyMaterial *GetCurrentMacKey(const Frame &aFrame) const; /** - * This method returns a reference to the temporary MAC key (for Key Mode 1) for a given Frame based on a given + * Returns a reference to the temporary MAC key (for Key Mode 1) for a given Frame based on a given * Key Sequence. * * @param[in] aFrame The frame for which to get the MAC key. @@ -669,7 +672,7 @@ class Links : public InstanceLocator #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method sets the current MAC frame counter value from the value from a `TxFrame`. + * Sets the current MAC frame counter value from the value from a `TxFrame`. * * @param[in] TxFrame The `TxFrame` from which to get the counter value. * diff --git a/src/core/mac/mac_types.cpp b/src/core/mac/mac_types.cpp index 7ed4b1b31b6..9ea115e445b 100644 --- a/src/core/mac/mac_types.cpp +++ b/src/core/mac/mac_types.cpp @@ -57,7 +57,7 @@ PanId GenerateRandomPanId(void) #if !OPENTHREAD_RADIO void ExtAddress::GenerateRandom(void) { - IgnoreError(Random::Crypto::FillBuffer(m8, sizeof(ExtAddress))); + IgnoreError(Random::Crypto::Fill(*this)); SetGroup(false); SetLocal(true); } @@ -229,17 +229,11 @@ uint32_t LinkFrameCounters::GetMaximum(void) const uint32_t counter = 0; #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE - if (counter < m154Counter) - { - counter = m154Counter; - } + counter = Max(counter, m154Counter); #endif #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - if (counter < mTrelCounter) - { - counter = mTrelCounter; - } + counter = Max(counter, mTrelCounter); #endif return counter; diff --git a/src/core/mac/mac_types.hpp b/src/core/mac/mac_types.hpp index 6a73244d2b6..1530b7361f0 100644 --- a/src/core/mac/mac_types.hpp +++ b/src/core/mac/mac_types.hpp @@ -60,7 +60,7 @@ namespace Mac { */ /** - * This type represents the IEEE 802.15.4 PAN ID. + * Represents the IEEE 802.15.4 PAN ID. * */ typedef otPanId PanId; @@ -68,7 +68,7 @@ typedef otPanId PanId; constexpr PanId kPanIdBroadcast = 0xffff; ///< Broadcast PAN ID. /** - * This type represents the IEEE 802.15.4 Short Address. + * Represents the IEEE 802.15.4 Short Address. * */ typedef otShortAddress ShortAddress; @@ -77,7 +77,7 @@ constexpr ShortAddress kShortAddrBroadcast = 0xffff; ///< Broadcast Short Addres constexpr ShortAddress kShortAddrInvalid = 0xfffe; ///< Invalid Short Address. /** - * This function generates a random IEEE 802.15.4 PAN ID. + * Generates a random IEEE 802.15.4 PAN ID. * * @returns A randomly generated IEEE 802.15.4 PAN ID (excluding `kPanIdBroadcast`). * @@ -85,7 +85,7 @@ constexpr ShortAddress kShortAddrInvalid = 0xfffe; ///< Invalid Short Address. PanId GenerateRandomPanId(void); /** - * This structure represents an IEEE 802.15.4 Extended Address. + * Represents an IEEE 802.15.4 Extended Address. * */ OT_TOOL_PACKED_BEGIN @@ -95,13 +95,13 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle static constexpr uint16_t kInfoStringSize = 17; ///< Max chars for the info string (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This enumeration type specifies the copy byte order when Extended Address is being copied to/from a buffer. + * Type specifies the copy byte order when Extended Address is being copied to/from a buffer. * */ enum CopyByteOrder : uint8_t @@ -111,7 +111,7 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle }; /** - * This method fills all bytes of address with a given byte value. + * Fills all bytes of address with a given byte value. * * @param[in] aByte A byte value to fill address with. * @@ -119,13 +119,13 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle void Fill(uint8_t aByte) { memset(this, aByte, sizeof(*this)); } /** - * This method generates a random IEEE 802.15.4 Extended Address. + * Generates a random IEEE 802.15.4 Extended Address. * */ void GenerateRandom(void); /** - * This method sets the Extended Address from a given byte array. + * Sets the Extended Address from a given byte array. * * @param[in] aBuffer Pointer to an array containing the Extended Address. `OT_EXT_ADDRESS_SIZE` bytes from * buffer are copied to form the Extended Address. @@ -138,7 +138,7 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle } /** - * This method indicates whether or not the Group bit is set. + * Indicates whether or not the Group bit is set. * * @retval TRUE If the group bit is set. * @retval FALSE If the group bit is not set. @@ -147,7 +147,7 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle bool IsGroup(void) const { return (m8[0] & kGroupFlag) != 0; } /** - * This method sets the Group bit. + * Sets the Group bit. * * @param[in] aGroup TRUE if group address, FALSE otherwise. * @@ -165,13 +165,13 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle } /** - * This method toggles the Group bit. + * Toggles the Group bit. * */ void ToggleGroup(void) { m8[0] ^= kGroupFlag; } /** - * This method indicates whether or not the Local bit is set. + * Indicates whether or not the Local bit is set. * * @retval TRUE If the local bit is set. * @retval FALSE If the local bit is not set. @@ -180,7 +180,7 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle bool IsLocal(void) const { return (m8[0] & kLocalFlag) != 0; } /** - * This method sets the Local bit. + * Sets the Local bit. * * @param[in] aLocal TRUE if locally administered, FALSE otherwise. * @@ -198,13 +198,13 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle } /** - * This method toggles the Local bit. + * Toggles the Local bit. * */ void ToggleLocal(void) { m8[0] ^= kLocalFlag; } /** - * This method copies the Extended Address into a given buffer. + * Copies the Extended Address into a given buffer. * * @param[out] aBuffer A pointer to a buffer to copy the Extended Address into. * @param[in] aByteOrder The byte order to copy the address. @@ -216,7 +216,7 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle } /** - * This method converts an address to a string. + * Converts an address to a string. * * @returns An `InfoString` containing the string representation of the Extended Address. * @@ -231,20 +231,20 @@ class ExtAddress : public otExtAddress, public Equatable, public Cle } OT_TOOL_PACKED_END; /** - * This class represents an IEEE 802.15.4 Short or Extended Address. + * Represents an IEEE 802.15.4 Short or Extended Address. * */ class Address { public: /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef ExtAddress::InfoString InfoString; /** - * This enumeration specifies the IEEE 802.15.4 Address type. + * Specifies the IEEE 802.15.4 Address type. * */ enum Type : uint8_t @@ -255,7 +255,7 @@ class Address }; /** - * This constructor initializes an Address. + * Initializes an Address. * */ Address(void) @@ -264,7 +264,7 @@ class Address } /** - * This method gets the address type (Short Address, Extended Address, or none). + * Gets the address type (Short Address, Extended Address, or none). * * @returns The address type. * @@ -272,7 +272,7 @@ class Address Type GetType(void) const { return mType; } /** - * This method indicates whether or not there is an address. + * Indicates whether or not there is an address. * * @returns TRUE if there is no address (i.e. address type is `kTypeNone`), FALSE otherwise. * @@ -280,7 +280,7 @@ class Address bool IsNone(void) const { return (mType == kTypeNone); } /** - * This method indicates whether or not the Address is a Short Address. + * Indicates whether or not the Address is a Short Address. * * @returns TRUE if it is a Short Address, FALSE otherwise. * @@ -288,7 +288,7 @@ class Address bool IsShort(void) const { return (mType == kTypeShort); } /** - * This method indicates whether or not the Address is an Extended Address. + * Indicates whether or not the Address is an Extended Address. * * @returns TRUE if it is an Extended Address, FALSE otherwise. * @@ -296,9 +296,9 @@ class Address bool IsExtended(void) const { return (mType == kTypeExtended); } /** - * This method gets the address as a Short Address. + * Gets the address as a Short Address. * - * This method MUST be used only if the address type is Short Address. + * MUST be used only if the address type is Short Address. * * @returns The Short Address. * @@ -306,9 +306,9 @@ class Address ShortAddress GetShort(void) const { return mShared.mShortAddress; } /** - * This method gets the address as an Extended Address. + * Gets the address as an Extended Address. * - * This method MUST be used only if the address type is Extended Address. + * MUST be used only if the address type is Extended Address. * * @returns A constant reference to the Extended Address. * @@ -316,9 +316,9 @@ class Address const ExtAddress &GetExtended(void) const { return mShared.mExtAddress; } /** - * This method gets the address as an Extended Address. + * Gets the address as an Extended Address. * - * This method MUST be used only if the address type is Extended Address. + * MUST be used only if the address type is Extended Address. * * @returns A reference to the Extended Address. * @@ -326,7 +326,7 @@ class Address ExtAddress &GetExtended(void) { return mShared.mExtAddress; } /** - * This method sets the address to none (i.e., clears the address). + * Sets the address to none (i.e., clears the address). * * Address type will be updated to `kTypeNone`. * @@ -334,7 +334,7 @@ class Address void SetNone(void) { mType = kTypeNone; } /** - * This method sets the address with a Short Address. + * Sets the address with a Short Address. * * The type is also updated to indicate that address is Short. * @@ -348,7 +348,7 @@ class Address } /** - * This method sets the address with an Extended Address. + * Sets the address with an Extended Address. * * The type is also updated to indicate that the address is Extended. * @@ -362,7 +362,7 @@ class Address } /** - * This method sets the address with an Extended Address given as a byte array. + * Sets the address with an Extended Address given as a byte array. * * The type is also updated to indicate that the address is Extended. * @@ -378,7 +378,7 @@ class Address } /** - * This method indicates whether or not the address is a Short Broadcast Address. + * Indicates whether or not the address is a Short Broadcast Address. * * @returns TRUE if address is Short Broadcast Address, FALSE otherwise. * @@ -386,7 +386,7 @@ class Address bool IsBroadcast(void) const { return ((mType == kTypeShort) && (GetShort() == kShortAddrBroadcast)); } /** - * This method indicates whether or not the address is a Short Invalid Address. + * Indicates whether or not the address is a Short Invalid Address. * * @returns TRUE if address is Short Invalid Address, FALSE otherwise. * @@ -394,7 +394,7 @@ class Address bool IsShortAddrInvalid(void) const { return ((mType == kTypeShort) && (GetShort() == kShortAddrInvalid)); } /** - * This method converts an address to a null-terminated string + * Converts an address to a null-terminated string * * @returns A `String` representing the address. * @@ -412,7 +412,7 @@ class Address }; /** - * This structure represents two MAC addresses corresponding to source and destination. + * Represents two MAC addresses corresponding to source and destination. * */ struct Addresses @@ -422,7 +422,7 @@ struct Addresses }; /** - * This structure represents two PAN IDs corresponding to source and destination. + * Represents two PAN IDs corresponding to source and destination. * */ struct PanIds @@ -432,7 +432,7 @@ struct PanIds }; /** - * This class represents a MAC key. + * Represents a MAC key. * */ OT_TOOL_PACKED_BEGIN @@ -442,7 +442,7 @@ class Key : public otMacKey, public Equatable, public Clearable static constexpr uint16_t kSize = OT_MAC_KEY_SIZE; ///< Key size in bytes. /** - * This method gets a pointer to the bytes array containing the key + * Gets a pointer to the bytes array containing the key * * @returns A pointer to the byte array containing the key. * @@ -452,20 +452,20 @@ class Key : public otMacKey, public Equatable, public Clearable } OT_TOOL_PACKED_END; /** - * This type represents a MAC Key Ref used by PSA. + * Represents a MAC Key Ref used by PSA. * */ typedef otMacKeyRef KeyRef; /** - * This class represents a MAC Key Material. + * Represents a MAC Key Material. * */ class KeyMaterial : public otMacKeyMaterial, public Unequatable { public: /** - * This constructor initializes a `KeyMaterial`. + * Initializes a `KeyMaterial`. * */ KeyMaterial(void) @@ -478,7 +478,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method overload `=` operator to assign the `KeyMaterial` from another one. + * Overload `=` operator to assign the `KeyMaterial` from another one. * * If the `KeyMaterial` currently stores a valid and different `KeyRef`, the assignment of new value will ensure to * delete the previous one before using the new `KeyRef` from @p aOther. @@ -504,7 +504,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable #if !OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method gets the literal `Key`. + * Gets the literal `Key`. * * @returns The literal `Key` * @@ -513,7 +513,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable #else /** - * This method gets the stored `KeyRef` + * Gets the stored `KeyRef` * * @returns The `KeyRef` * @@ -522,7 +522,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable #endif /** - * This method sets the `KeyMaterial` from a given Key. + * Sets the `KeyMaterial` from a given Key. * * If the `KeyMaterial` currently stores a valid `KeyRef`, the `SetFrom()` call will ensure to delete the previous * one before creating and using a new `KeyRef` associated with the new `Key`. @@ -535,7 +535,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable void SetFrom(const Key &aKey, bool aIsExportable = false); /** - * This method extracts the literal key from `KeyMaterial` + * Extracts the literal key from `KeyMaterial` * * @param[out] aKey A reference to the output the key. * @@ -543,7 +543,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable void ExtractKey(Key &aKey) const; /** - * This method converts `KeyMaterial` to a `Crypto::Key`. + * Converts `KeyMaterial` to a `Crypto::Key`. * * @param[out] aCryptoKey A reference to a `Crypto::Key` to populate. * @@ -551,7 +551,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable void ConvertToCryptoKey(Crypto::Key &aCryptoKey) const; /** - * This method overloads operator `==` to evaluate whether or not two `KeyMaterial` instances are equal. + * Overloads operator `==` to evaluate whether or not two `KeyMaterial` instances are equal. * * @param[in] aOther The other `KeyMaterial` instance to compare with. * @@ -575,7 +575,7 @@ class KeyMaterial : public otMacKeyMaterial, public Unequatable #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This enumeration defines the radio link types. + * Defines the radio link types. * */ enum RadioType : uint8_t @@ -596,7 +596,7 @@ constexpr uint8_t kNumRadioTypes = (((OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4 ((OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE) ? 1 : 0)); /** - * This class represents a set of radio links. + * Represents a set of radio links. * */ class RadioTypes @@ -605,7 +605,7 @@ class RadioTypes static constexpr uint16_t kInfoStringSize = 32; ///< Max chars for the info string (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; @@ -617,7 +617,7 @@ class RadioTypes static const RadioType kAllRadioTypes[kNumRadioTypes]; /** - * This constructor initializes a `RadioTypes` object as empty set + * Initializes a `RadioTypes` object as empty set * */ RadioTypes(void) @@ -626,7 +626,7 @@ class RadioTypes } /** - * This constructor initializes a `RadioTypes` object with a given bit-mask. + * Initializes a `RadioTypes` object with a given bit-mask. * * @param[in] aMask A bit-mask representing the radio types (the first bit corresponds to radio type 0, and so on) * @@ -637,13 +637,13 @@ class RadioTypes } /** - * This method clears the set. + * Clears the set. * */ void Clear(void) { mBitMask = 0; } /** - * This method indicates whether the set is empty or not + * Indicates whether the set is empty or not * * @returns TRUE if the set is empty, FALSE otherwise. * @@ -659,7 +659,7 @@ class RadioTypes bool ContainsSingleRadio(void) const { return !IsEmpty() && ((mBitMask & (mBitMask - 1)) == 0); } /** - * This method indicates whether or not the set contains a given radio type. + * Indicates whether or not the set contains a given radio type. * * @param[in] aType A radio link type. * @@ -669,7 +669,7 @@ class RadioTypes bool Contains(RadioType aType) const { return ((mBitMask & BitFlag(aType)) != 0); } /** - * This method adds a radio type to the set. + * Adds a radio type to the set. * * @param[in] aType A radio link type. * @@ -677,7 +677,7 @@ class RadioTypes void Add(RadioType aType) { mBitMask |= BitFlag(aType); } /** - * This method adds another radio types set to the current one. + * Adds another radio types set to the current one. * * @param[in] aTypes A radio link type set to add. * @@ -685,13 +685,13 @@ class RadioTypes void Add(RadioTypes aTypes) { mBitMask |= aTypes.mBitMask; } /** - * This method adds all radio types supported by device to the set. + * Adds all radio types supported by device to the set. * */ void AddAll(void); /** - * This method removes a given radio type from the set. + * Removes a given radio type from the set. * * @param[in] aType A radio link type. * @@ -699,7 +699,7 @@ class RadioTypes void Remove(RadioType aType) { mBitMask &= ~BitFlag(aType); } /** - * This method gets the radio type set as a bitmask. + * Gets the radio type set as a bitmask. * * The first bit in the mask corresponds to first radio type (radio type with value zero), and so on. * @@ -709,7 +709,7 @@ class RadioTypes uint8_t GetAsBitMask(void) const { return mBitMask; } /** - * This method overloads operator `-` to return a new set which is the set difference between current set and + * Overloads operator `-` to return a new set which is the set difference between current set and * a given set. * * @param[in] aOther Another radio type set. @@ -720,7 +720,7 @@ class RadioTypes RadioTypes operator-(const RadioTypes &aOther) const { return RadioTypes(mBitMask & ~aOther.mBitMask); } /** - * This method converts the radio set to human-readable string. + * Converts the radio set to human-readable string. * * @return A string representation of the set of radio types. * @@ -734,7 +734,7 @@ class RadioTypes }; /** - * This function converts a link type to a string + * Converts a link type to a string * * @param[in] aRadioType A link type value. * @@ -746,14 +746,14 @@ const char *RadioTypeToString(RadioType aRadioType); #endif // OPENTHREAD_CONFIG_MULTI_RADIO /** - * This class represents Link Frame Counters for all supported radio links. + * Represents Link Frame Counters for all supported radio links. * */ class LinkFrameCounters { public: /** - * This method resets all counters (set them all to zero). + * Resets all counters (set them all to zero). * */ void Reset(void) { SetAll(0); } @@ -761,7 +761,7 @@ class LinkFrameCounters #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method gets the link Frame Counter for a given radio link. + * Gets the link Frame Counter for a given radio link. * * @param[in] aRadioType A radio link type. * @@ -771,7 +771,7 @@ class LinkFrameCounters uint32_t Get(RadioType aRadioType) const; /** - * This method sets the Link Frame Counter for a given radio link. + * Sets the Link Frame Counter for a given radio link. * * @param[in] aRadioType A radio link type. * @param[in] aCounter The new counter value. @@ -782,7 +782,7 @@ class LinkFrameCounters #else /** - * This method gets the Link Frame Counter value. + * Gets the Link Frame Counter value. * * @return The Link Frame Counter value. * @@ -799,7 +799,7 @@ class LinkFrameCounters #endif /** - * This method sets the Link Frame Counter for a given radio link. + * Sets the Link Frame Counter for a given radio link. * * @param[in] aCounter The new counter value. * @@ -819,7 +819,7 @@ class LinkFrameCounters #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE /** - * This method gets the Link Frame Counter for 802.15.4 radio link. + * Gets the Link Frame Counter for 802.15.4 radio link. * * @returns The Link Frame Counter for 802.15.4 radio link. * @@ -827,7 +827,7 @@ class LinkFrameCounters uint32_t Get154(void) const { return m154Counter; } /** - * This method sets the Link Frame Counter for 802.15.4 radio link. + * Sets the Link Frame Counter for 802.15.4 radio link. * * @param[in] aCounter The new counter value. * @@ -837,7 +837,7 @@ class LinkFrameCounters #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method gets the Link Frame Counter for TREL radio link. + * Gets the Link Frame Counter for TREL radio link. * * @returns The Link Frame Counter for TREL radio link. * @@ -845,14 +845,14 @@ class LinkFrameCounters uint32_t GetTrel(void) const { return mTrelCounter; } /** - * This method increments the Link Frame Counter for TREL radio link. + * Increments the Link Frame Counter for TREL radio link. * */ void IncrementTrel(void) { mTrelCounter++; } #endif /** - * This method gets the maximum Link Frame Counter among all supported radio links. + * Gets the maximum Link Frame Counter among all supported radio links. * * @return The maximum Link frame Counter among all supported radio links. * @@ -860,7 +860,7 @@ class LinkFrameCounters uint32_t GetMaximum(void) const; /** - * This method sets the Link Frame Counter value for all radio links. + * Sets the Link Frame Counter value for all radio links. * * @param[in] aCounter The Link Frame Counter value. * @@ -877,7 +877,7 @@ class LinkFrameCounters }; /** - * This class represents CSL accuracy. + * Represents CSL accuracy. * */ class CslAccuracy @@ -887,7 +887,7 @@ class CslAccuracy static constexpr uint8_t kWorstUncertainty = 255; ///< Worst possible uncertainty, in units of 10 microseconds. /** - * This method initializes the CSL accuracy using `kWorstClockAccuracy` and `kWorstUncertainty` values. + * Initializes the CSL accuracy using `kWorstClockAccuracy` and `kWorstUncertainty` values. * */ void Init(void) @@ -897,7 +897,7 @@ class CslAccuracy } /** - * This method returns the CSL clock accuracy. + * Returns the CSL clock accuracy. * * @returns The CSL clock accuracy in ± ppm. * @@ -905,7 +905,7 @@ class CslAccuracy uint8_t GetClockAccuracy(void) const { return mClockAccuracy; } /** - * This method sets the CSL clock accuracy. + * Sets the CSL clock accuracy. * * @param[in] aClockAccuracy The CSL clock accuracy in ± ppm. * @@ -913,7 +913,7 @@ class CslAccuracy void SetClockAccuracy(uint8_t aClockAccuracy) { mClockAccuracy = aClockAccuracy; } /** - * This method returns the CSL uncertainty. + * Returns the CSL uncertainty. * * @returns The uncertainty in units 10 microseconds. * @@ -921,7 +921,7 @@ class CslAccuracy uint8_t GetUncertainty(void) const { return mUncertainty; } /** - * This method gets the CLS uncertainty in microseconds. + * Gets the CLS uncertainty in microseconds. * * @returns the CLS uncertainty in microseconds. * @@ -929,7 +929,7 @@ class CslAccuracy uint16_t GetUncertaintyInMicrosec(void) const { return static_cast(mUncertainty) * kUsPerUncertUnit; } /** - * This method sets the CSL uncertainty. + * Sets the CSL uncertainty. * * @param[in] aUncertainty The CSL uncertainty in units 10 microseconds. * diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 7d7ac175083..9b6879ff0e8 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -276,6 +276,61 @@ void SubMac::CslSample(void) } #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE +#if OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE +void SubMac::LogReceived(RxFrame *aFrame) +{ + static constexpr uint8_t kLogStringSize = 72; + + String logString; + Address dst; + int32_t deviation; + uint32_t sampleTime, ahead, after; + + IgnoreError(aFrame->GetDstAddr(dst)); + + VerifyOrExit((dst.GetType() == Address::kTypeShort && dst.GetShort() == GetShortAddress()) || + (dst.GetType() == Address::kTypeExtended && dst.GetExtended() == GetExtAddress())); + + LogDebg("Received frame in state (SubMac %s, CSL %s), timestamp %lu", StateToString(mState), + mIsCslSampling ? "CslSample" : "CslSleep", + ToUlong(static_cast(aFrame->mInfo.mRxInfo.mTimestamp))); + + VerifyOrExit(mState == kStateCslSample); + + GetCslWindowEdges(ahead, after); + ahead -= kMinReceiveOnAhead + kCslReceiveTimeAhead; + + sampleTime = mCslSampleTime.GetValue() - mCslPeriod * kUsPerTenSymbols; + deviation = aFrame->mInfo.mRxInfo.mTimestamp + kRadioHeaderPhrDuration - sampleTime; + + // This logs three values (all in microseconds): + // - Absolute sample time in which the CSL receiver expected the MHR of the received frame. + // - Allowed margin around that time accounting for accuracy and uncertainty from both devices. + // - Real deviation on the reception of the MHR with regards to expected sample time. This can + // be due to clocks drift and/or CSL Phase rounding error. + // This means that a deviation absolute value greater than the margin would result in the frame + // not being received out of the debug mode. + logString.Append("Expected sample time %lu, margin ±%lu, deviation %d", ToUlong(sampleTime), ToUlong(ahead), + deviation); + + // Treat as a warning when the deviation is not within the margins. Neither kCslReceiveTimeAhead + // or kMinReceiveOnAhead/kMinReceiveOnAfter are considered for the margin since they have no + // impact on understanding possible deviation errors between transmitter and receiver. So in this + // case ahead equals after. + if ((deviation + ahead > 0) && (deviation < static_cast(ahead))) + { + LogDebg("%s", logString.AsCString()); + } + else + { + LogWarn("%s", logString.AsCString()); + } + +exit: + return; +} +#endif + void SubMac::HandleReceiveDone(RxFrame *aFrame, Error aError) { if (mPcapCallback.IsSet() && (aFrame != nullptr) && (aError == kErrorNone)) @@ -291,20 +346,14 @@ void SubMac::HandleReceiveDone(RxFrame *aFrame, Error aError) #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE if (aFrame != nullptr && aError == kErrorNone) { +#if OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE + LogReceived(aFrame); +#endif // Assuming the risk of the parent missing the Enh-ACK in favor of smaller CSL receive window if ((mCslPeriod > 0) && aFrame->mInfo.mRxInfo.mAckedWithSecEnhAck) { mCslLastSync = TimeMicro(static_cast(aFrame->mInfo.mRxInfo.mTimestamp)); } - -#if OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE - // Split the log into two lines for RTT to output - LogDebg("Received frame in state (SubMac %s, CSL %s), timestamp %lu", StateToString(mState), - mIsCslSampling ? "CslSample" : "CslSleep", - ToUlong(static_cast(aFrame->mInfo.mRxInfo.mTimestamp))); - LogDebg("Target sample start time %lu, time drift %lu", ToUlong(mCslSampleTime.GetValue()), - ToUlong(static_cast(aFrame->mInfo.mRxInfo.mTimestamp) - mCslSampleTime.GetValue())); -#endif } #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE @@ -443,10 +492,7 @@ void SubMac::StartCsmaBackoff(void) VerifyOrExit(ShouldHandleCsmaBackOff(), BeginTransmit()); - if (backoffExponent > kCsmaMaxBe) - { - backoffExponent = kCsmaMaxBe; - } + backoffExponent = Min(backoffExponent, kCsmaMaxBe); StartTimerForBackoff(backoffExponent); @@ -1132,7 +1178,7 @@ void SubMac::HandleCslTimer(void) * */ uint32_t periodUs = mCslPeriod * kUsPerTenSymbols; - uint32_t timeAhead, timeAfter; + uint32_t timeAhead, timeAfter, winStart, winDuration; GetCslWindowEdges(timeAhead, timeAfter); @@ -1152,32 +1198,34 @@ void SubMac::HandleCslTimer(void) { if (RadioSupportsReceiveTiming()) { - mCslSampleTime += periodUs; - mCslTimer.FireAt(mCslSampleTime - timeAhead); + mCslTimer.FireAt(mCslSampleTime - timeAhead + periodUs); timeAhead -= kCslReceiveTimeAhead; + winStart = mCslSampleTime.GetValue() - timeAhead; } else { mCslTimer.FireAt(mCslSampleTime + timeAfter); mIsCslSampling = true; - mCslSampleTime += periodUs; + winStart = ot::TimerMicro::GetNow().GetValue(); } + winDuration = timeAhead + timeAfter; + mCslSampleTime += periodUs; + Get().UpdateCslSampleTime(mCslSampleTime.GetValue()); // Schedule reception window for any state except RX - so that CSL RX Window has lower priority // than scanning or RX after the data poll. if (RadioSupportsReceiveTiming() && (mState != kStateDisabled) && (mState != kStateReceive)) { - IgnoreError(Get().ReceiveAt(mCslChannel, mCslSampleTime.GetValue() - periodUs - timeAhead, - timeAhead + timeAfter)); + IgnoreError(Get().ReceiveAt(mCslChannel, winStart, winDuration)); } else if (mState == kStateCslSample) { IgnoreError(Get().Receive(mCslChannel)); - LogDebg("CSL sample %lu, duration %lu", ToUlong(mCslTimer.GetNow().GetValue()), - ToUlong(timeAhead + timeAfter)); } + + LogDebg("CSL window start %lu, duration %lu", ToUlong(winStart), ToUlong(winDuration)); } } @@ -1195,8 +1243,8 @@ void SubMac::GetCslWindowEdges(uint32_t &aAhead, uint32_t &aAfter) (Get().GetCslAccuracy() + mCslParentAccuracy.GetClockAccuracy()) / 1000000); semiWindow += mCslParentAccuracy.GetUncertaintyInMicrosec() + Get().GetCslUncertainty() * 10; - aAhead = Min(semiPeriod, semiWindow + kCslReceiveTimeAhead); - aAfter = Min(semiPeriod, semiWindow + kMinCslWindow); + aAhead = Min(semiPeriod, semiWindow + kMinReceiveOnAhead + kCslReceiveTimeAhead); + aAfter = Min(semiPeriod, semiWindow + kMinReceiveOnAfter); } #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index b7f10e670a9..0634c68af62 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -87,7 +87,7 @@ class LinkRaw; #endif /** - * This class implements the IEEE 802.15.4 MAC (sub-MAC). + * Implements the IEEE 802.15.4 MAC (sub-MAC). * * Sub-MAC layer implements a subset of IEEE802.15.4 MAC primitives which are shared by both MAC layer (in FTD/MTD * modes) and Raw Link (Radio only mode). @@ -110,14 +110,14 @@ class SubMac : public InstanceLocator, private NonCopyable public: /** - * This class defines the callbacks notifying `SubMac` user of changes and events. + * Defines the callbacks notifying `SubMac` user of changes and events. * */ class Callbacks : public InstanceLocator { public: /** - * This constructor initializes the `Callbacks` object. + * Initializes the `Callbacks` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -125,7 +125,7 @@ class SubMac : public InstanceLocator, private NonCopyable explicit Callbacks(Instance &aInstance); /** - * This method notifies user of `SubMac` of a received frame. + * Notifies user of `SubMac` of a received frame. * * @param[in] aFrame A pointer to the received frame or `nullptr` if the receive operation failed. * @param[in] aError kErrorNone when successfully received a frame, @@ -136,7 +136,7 @@ class SubMac : public InstanceLocator, private NonCopyable void ReceiveDone(RxFrame *aFrame, Error aError); /** - * This method notifies user of `SubMac` of CCA status (success/failure) for a frame transmission attempt. + * Notifies user of `SubMac` of CCA status (success/failure) for a frame transmission attempt. * * This is intended for updating counters, logging, and/or tracking CCA failure rate statistics. * @@ -147,7 +147,7 @@ class SubMac : public InstanceLocator, private NonCopyable void RecordCcaStatus(bool aCcaSuccess, uint8_t aChannel); /** - * This method notifies user of `SubMac` of the status of a frame transmission attempt. + * Notifies user of `SubMac` of the status of a frame transmission attempt. * * This is intended for updating counters, logging, and/or collecting statistics. * @@ -186,7 +186,7 @@ class SubMac : public InstanceLocator, private NonCopyable void TransmitDone(TxFrame &aFrame, RxFrame *aAckFrame, Error aError); /** - * This method notifies user of `SubMac` that energy scan is complete. + * Notifies user of `SubMac` that energy scan is complete. * * @param[in] aMaxRssi Maximum RSSI seen on the channel, or `Radio::kInvalidRssi` if failed. * @@ -194,7 +194,7 @@ class SubMac : public InstanceLocator, private NonCopyable void EnergyScanDone(int8_t aMaxRssi); /** - * This method notifies user of `SubMac` that a specific MAC frame counter is used for transmission. + * Notifies user of `SubMac` that a specific MAC frame counter is used for transmission. * * It is possible that this callback is invoked out of order in terms of counter values (i.e., called for a * smaller counter value after a call for a larger counter value). @@ -206,7 +206,7 @@ class SubMac : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `SubMac` object. + * Initializes the `SubMac` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -214,7 +214,7 @@ class SubMac : public InstanceLocator, private NonCopyable explicit SubMac(Instance &aInstance); /** - * This method gets the capabilities provided by platform radio. + * Gets the capabilities provided by platform radio. * * @returns The capability bit vector (see `OT_RADIO_CAP_*` definitions). * @@ -222,7 +222,7 @@ class SubMac : public InstanceLocator, private NonCopyable otRadioCaps GetRadioCaps(void) const { return mRadioCaps; } /** - * This method gets the capabilities provided by `SubMac` layer. + * Gets the capabilities provided by `SubMac` layer. * * @returns The capability bit vector (see `OT_RADIO_CAP_*` definitions). * @@ -230,7 +230,7 @@ class SubMac : public InstanceLocator, private NonCopyable otRadioCaps GetCaps(void) const; /** - * This method sets the PAN ID. + * Sets the PAN ID. * * @param[in] aPanId The PAN ID. * @@ -238,7 +238,7 @@ class SubMac : public InstanceLocator, private NonCopyable void SetPanId(PanId aPanId); /** - * This method gets the short address. + * Gets the short address. * * @returns The short address. * @@ -246,7 +246,7 @@ class SubMac : public InstanceLocator, private NonCopyable ShortAddress GetShortAddress(void) const { return mShortAddress; } /** - * This method sets the short address. + * Sets the short address. * * @param[in] aShortAddress The short address. * @@ -254,7 +254,7 @@ class SubMac : public InstanceLocator, private NonCopyable void SetShortAddress(ShortAddress aShortAddress); /** - * This function gets the extended address. + * Gets the extended address. * * @returns A reference to the extended address. * @@ -262,7 +262,7 @@ class SubMac : public InstanceLocator, private NonCopyable const ExtAddress &GetExtAddress(void) const { return mExtAddress; } /** - * This method sets extended address. + * Sets extended address. * * @param[in] aExtAddress The extended address. * @@ -270,7 +270,7 @@ class SubMac : public InstanceLocator, private NonCopyable void SetExtAddress(const ExtAddress &aExtAddress); /** - * This method registers a callback to provide received packet capture for IEEE 802.15.4 frames. + * Registers a callback to provide received packet capture for IEEE 802.15.4 frames. * * @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame * or `nullptr` to disable the callback. @@ -283,7 +283,7 @@ class SubMac : public InstanceLocator, private NonCopyable } /** - * This method indicates whether radio should stay in Receive or Sleep during CSMA backoff. + * Indicates whether radio should stay in Receive or Sleep during CSMA backoff. * * @param[in] aRxOnWhenBackoff TRUE to keep radio in Receive, FALSE to put to Sleep during CSMA backoff. * @@ -291,7 +291,7 @@ class SubMac : public InstanceLocator, private NonCopyable void SetRxOnWhenBackoff(bool aRxOnWhenBackoff) { mRxOnWhenBackoff = aRxOnWhenBackoff; } /** - * This method enables the radio. + * Enables the radio. * * @retval kErrorNone Successfully enabled. * @retval kErrorFailed The radio could not be enabled. @@ -300,7 +300,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error Enable(void); /** - * This method disables the radio. + * Disables the radio. * * @retval kErrorNone Successfully disabled the radio. * @@ -308,7 +308,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error Disable(void); /** - * This method transitions the radio to Sleep. + * Transitions the radio to Sleep. * * @retval kErrorNone Successfully transitioned to Sleep. * @retval kErrorBusy The radio was transmitting. @@ -318,7 +318,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error Sleep(void); /** - * This method indicates whether the sub-mac is busy transmitting or scanning. + * Indicates whether the sub-mac is busy transmitting or scanning. * * @retval TRUE if the sub-mac is busy transmitting or scanning. * @retval FALSE if the sub-mac is not busy transmitting or scanning. @@ -334,7 +334,7 @@ class SubMac : public InstanceLocator, private NonCopyable } /** - * This method transitions the radio to Receive. + * Transitions the radio to Receive. * * @param[in] aChannel The channel to use for receiving. * @@ -345,7 +345,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error Receive(uint8_t aChannel); /** - * This method gets the radio transmit frame. + * Gets the radio transmit frame. * * @returns The transmit frame. * @@ -353,7 +353,7 @@ class SubMac : public InstanceLocator, private NonCopyable TxFrame &GetTransmitFrame(void) { return mTransmitFrame; } /** - * This method sends a prepared frame. + * Sends a prepared frame. * * The frame should be placed in `GetTransmitFrame()` frame. * @@ -366,7 +366,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error Send(void); /** - * This method gets the number of transmit retries of last transmitted frame. + * Gets the number of transmit retries of last transmitted frame. * * @returns Number of transmit retries. * @@ -374,7 +374,7 @@ class SubMac : public InstanceLocator, private NonCopyable uint8_t GetTransmitRetries(void) const { return mTransmitRetries; } /** - * This method gets the most recent RSSI measurement. + * Gets the most recent RSSI measurement. * * @returns The RSSI in dBm when it is valid. `Radio::kInvalidRssi` when RSSI is invalid. * @@ -382,7 +382,7 @@ class SubMac : public InstanceLocator, private NonCopyable int8_t GetRssi(void) const; /** - * This method begins energy scan. + * Begins energy scan. * * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. @@ -396,7 +396,7 @@ class SubMac : public InstanceLocator, private NonCopyable Error EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration); /** - * This method returns the noise floor value (currently use the radio receive sensitivity value). + * Returns the noise floor value (currently use the radio receive sensitivity value). * * @returns The noise floor value in dBm. * @@ -405,7 +405,7 @@ class SubMac : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method configures CSL parameters in 'SubMac'. + * Configures CSL parameters in 'SubMac'. * * @param[in] aPeriod The CSL period. * @param[in] aChannel The CSL channel. @@ -419,7 +419,7 @@ class SubMac : public InstanceLocator, private NonCopyable bool UpdateCsl(uint16_t aPeriod, uint8_t aChannel, otShortAddress aShortAddr, const otExtAddress *aExtAddr); /** - * This method lets `SubMac` start CSL sample mode given a configured non-zero CSL period. + * Lets `SubMac` start CSL sample mode given a configured non-zero CSL period. * * `SubMac` would switch the radio state between `Receive` and `Sleep` according the CSL timer. * @@ -427,7 +427,7 @@ class SubMac : public InstanceLocator, private NonCopyable void CslSample(void); /** - * This method returns parent CSL accuracy (clock accuracy and uncertainty). + * Returns parent CSL accuracy (clock accuracy and uncertainty). * * @returns The parent CSL accuracy. * @@ -435,7 +435,7 @@ class SubMac : public InstanceLocator, private NonCopyable const CslAccuracy &GetCslParentAccuracy(void) const { return mCslParentAccuracy; } /** - * This method sets parent CSL accuracy. + * Sets parent CSL accuracy. * * @param[in] aCslAccuracy The parent CSL accuracy. * @@ -445,7 +445,7 @@ class SubMac : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method sets MAC keys and key index. + * Sets MAC keys and key index. * * @param[in] aKeyIdMode MAC key ID mode. * @param[in] aKeyId The key ID. @@ -461,7 +461,7 @@ class SubMac : public InstanceLocator, private NonCopyable const KeyMaterial &aNextKey); /** - * This method returns a reference to the current MAC key. + * Returns a reference to the current MAC key. * * @returns A reference to the current MAC key. * @@ -469,7 +469,7 @@ class SubMac : public InstanceLocator, private NonCopyable const KeyMaterial &GetCurrentMacKey(void) const { return mCurrKey; } /** - * This method returns a reference to the previous MAC key. + * Returns a reference to the previous MAC key. * * @returns A reference to the previous MAC key. * @@ -477,7 +477,7 @@ class SubMac : public InstanceLocator, private NonCopyable const KeyMaterial &GetPreviousMacKey(void) const { return mPrevKey; } /** - * This method returns a reference to the next MAC key. + * Returns a reference to the next MAC key. * * @returns A reference to the next MAC key. * @@ -485,7 +485,7 @@ class SubMac : public InstanceLocator, private NonCopyable const KeyMaterial &GetNextMacKey(void) const { return mNextKey; } /** - * This method clears the stored MAC keys. + * Clears the stored MAC keys. * */ void ClearMacKeys(void) @@ -496,7 +496,7 @@ class SubMac : public InstanceLocator, private NonCopyable } /** - * This method returns the current MAC frame counter value. + * Returns the current MAC frame counter value. * * @returns The current MAC frame counter value. * @@ -504,7 +504,7 @@ class SubMac : public InstanceLocator, private NonCopyable uint32_t GetFrameCounter(void) const { return mFrameCounter; } /** - * This method sets the current MAC Frame Counter value. + * Sets the current MAC Frame Counter value. * * @param[in] aFrameCounter The MAC Frame Counter value. * @param[in] aSetIfLarger If `true`, set only if the new value @p aFrameCounter is larger than the current value. @@ -515,7 +515,7 @@ class SubMac : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE /** - * This method enables/disables the radio filter. + * Enables/disables the radio filter. * * When radio filter is enabled, radio is put to sleep instead of receive (to ensure device does not receive any * frame and/or potentially send ack). Also the frame transmission requests return immediately without sending the @@ -527,7 +527,7 @@ class SubMac : public InstanceLocator, private NonCopyable void SetRadioFilterEnabled(bool aFilterEnabled) { mRadioFilterEnabled = aFilterEnabled; } /** - * This method indicates whether the radio filter is enabled or not. + * Indicates whether the radio filter is enabled or not. * * @retval TRUE If the radio filter is enabled. * @retval FALSE If the radio filter is disabled. @@ -541,6 +541,9 @@ class SubMac : public InstanceLocator, private NonCopyable static void HandleCslTimer(Timer &aTimer); void HandleCslTimer(void); void GetCslWindowEdges(uint32_t &aAhead, uint32_t &aAfter); +#if OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE + void LogReceived(RxFrame *aFrame); +#endif #endif static constexpr uint8_t kCsmaMinBe = 3; // macMinBE (IEEE 802.15.4-2006). @@ -580,9 +583,9 @@ class SubMac : public InstanceLocator, private NonCopyable }; #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE - // CSL receive window for the longest possible frame and - // ack duration. - static constexpr uint32_t kMinCslWindow = OPENTHREAD_CONFIG_CSL_MIN_RECEIVE_ON; + // Radio on times needed before and after MHR time for proper frame detection + static constexpr uint32_t kMinReceiveOnAhead = OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD; + static constexpr uint32_t kMinReceiveOnAfter = OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AFTER; // CSL receivers would wake up `kCslReceiveTimeAhead` earlier // than expected sample window. The value is in usec. @@ -597,7 +600,7 @@ class SubMac : public InstanceLocator, private NonCopyable #endif /** - * This method initializes the states of the sub-MAC layer. + * Initializes the states of the sub-MAC layer. * */ void Init(void); diff --git a/src/core/meshcop/announce_begin_client.hpp b/src/core/meshcop/announce_begin_client.hpp index 1960a50721d..8ae027a4abb 100644 --- a/src/core/meshcop/announce_begin_client.hpp +++ b/src/core/meshcop/announce_begin_client.hpp @@ -46,20 +46,20 @@ namespace ot { /** - * This class implements handling Announce Begin Requests. + * Implements handling Announce Begin Requests. * */ class AnnounceBeginClient : public InstanceLocator { public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit AnnounceBeginClient(Instance &aInstance); /** - * This method sends a Announce Begin message. + * Sends a Announce Begin message. * * @param[in] aChannelMask The channel mask value. * @param[in] aCount The number of Announce messages sent per channel. diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index 9081751673a..6548d58298a 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -41,6 +41,7 @@ #include "common/instance.hpp" #include "common/locator_getters.hpp" #include "common/log.hpp" +#include "common/settings.hpp" #include "meshcop/meshcop.hpp" #include "meshcop/meshcop_tlvs.hpp" #include "thread/thread_netif.hpp" @@ -233,29 +234,43 @@ BorderAgent::BorderAgent(Instance &aInstance) } #if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE -Error BorderAgent::GetId(uint8_t *aId, uint16_t &aLength) +Error BorderAgent::GetId(Id &aId) { - Error error = kErrorNone; + Error error = kErrorNone; + Settings::BorderAgentId id; - VerifyOrExit(aLength >= sizeof(mId), error = kErrorInvalidArgs); VerifyOrExit(!mIdInitialized, error = kErrorNone); - if (Get().Read(mId) != kErrorNone) + if (Get().Read(id) != kErrorNone) { - Random::NonCrypto::FillBuffer(mId.GetId(), sizeof(mId)); - SuccessOrExit(error = Get().Save(mId)); + Random::NonCrypto::Fill(id.GetId()); + SuccessOrExit(error = Get().Save(id)); } + mId = id.GetId(); mIdInitialized = true; exit: if (error == kErrorNone) { - memcpy(aId, mId.GetId(), sizeof(mId)); - aLength = static_cast(sizeof(mId)); + aId = mId; } return error; } + +Error BorderAgent::SetId(const Id &aId) +{ + Error error = kErrorNone; + Settings::BorderAgentId id; + + id.SetId(aId); + SuccessOrExit(error = Get().Save(id)); + mId = aId; + mIdInitialized = true; + +exit: + return error; +} #endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE void BorderAgent::HandleNotifierEvents(Events aEvents) diff --git a/src/core/meshcop/border_agent.hpp b/src/core/meshcop/border_agent.hpp index 4a047a5e27a..c16c1c80bdf 100644 --- a/src/core/meshcop/border_agent.hpp +++ b/src/core/meshcop/border_agent.hpp @@ -44,7 +44,6 @@ #include "common/locator.hpp" #include "common/non_copyable.hpp" #include "common/notifier.hpp" -#include "common/settings.hpp" #include "net/udp6.hpp" #include "thread/tmf.hpp" #include "thread/uri_paths.hpp" @@ -60,8 +59,10 @@ class BorderAgent : public InstanceLocator, private NonCopyable friend class Tmf::SecureAgent; public: + typedef otBorderAgentId Id; ///< Border Agent ID. + /** - * This enumeration defines the Border Agent state. + * Defines the Border Agent state. * */ enum State : uint8_t @@ -72,7 +73,7 @@ class BorderAgent : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `BorderAgent` object. + * Initializes the `BorderAgent` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -87,19 +88,32 @@ class BorderAgent : public InstanceLocator, private NonCopyable * be published in the MeshCoP mDNS service as the `id` TXT value for the client to identify this * Border Router/Agent device. * - * @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. + * @param[out] aId Reference to return the Border Agent ID. + * + * @retval kErrorNone If successfully retrieved the Border Agent ID. + * @retval ... If failed to retrieve the Border Agent ID. + * + */ + Error GetId(Id &aId); + + /** + * Sets the Border Agent ID. + * + * The Border Agent ID will be saved in persistent storage and survive reboots. It's required + * to set the ID only once after factory reset. If the ID has never been set by calling this + * method, a random ID will be generated and returned when `GetId()` is called. + * + * @param[out] aId specifies the Border Agent ID. * - * @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. + * @retval kErrorNone If successfully set the Border Agent ID. + * @retval ... If failed to set the Border Agent ID. * */ - Error GetId(uint8_t *aId, uint16_t &aLength); + Error SetId(const Id &aId); #endif /** - * This method gets the UDP port of this service. + * Gets the UDP port of this service. * * @returns UDP port number. * @@ -107,19 +121,19 @@ class BorderAgent : public InstanceLocator, private NonCopyable uint16_t GetUdpPort(void) const; /** - * This method starts the Border Agent service. + * Starts the Border Agent service. * */ void Start(void); /** - * This method stops the Border Agent service. + * Stops the Border Agent service. * */ void Stop(void); /** - * This method gets the state of the Border Agent service. + * Gets the state of the Border Agent service. * * @returns The state of the Border Agent service. * @@ -127,13 +141,13 @@ class BorderAgent : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method applies the Mesh Local Prefix. + * Applies the Mesh Local Prefix. * */ void ApplyMeshLocalPrefix(void); /** - * This method returns the UDP Proxy port to which the commissioner is currently + * Returns the UDP Proxy port to which the commissioner is currently * bound. * * @returns The current UDP Proxy port or 0 if no Proxy Transmit has been received yet. @@ -199,8 +213,8 @@ class BorderAgent : public InstanceLocator, private NonCopyable State mState; uint16_t mUdpProxyPort; #if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE - Settings::BorderAgentId mId; - bool mIdInitialized; + Id mId; + bool mIdInitialized; #endif }; @@ -219,6 +233,7 @@ DeclareTmfHandler(BorderAgent, kUriProxyTx); } // namespace MeshCoP DefineMapEnum(otBorderAgentState, MeshCoP::BorderAgent::State); +DefineCoreType(otBorderAgentId, MeshCoP::BorderAgent::Id); } // namespace ot diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 0bac4320f2a..27cf796d3e4 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -948,8 +948,8 @@ template <> void Commissioner::HandleTmf(Coap::Message &aMessage, c Ip6::InterfaceIdentifier joinerIid; uint16_t joinerRloc; Ip6::MessageInfo joinerMessageInfo; - uint16_t offset; - uint16_t length; + uint16_t startOffset; + uint16_t endOffset; VerifyOrExit(mState == kStateActive, error = kErrorInvalidState); @@ -959,8 +959,8 @@ template <> void Commissioner::HandleTmf(Coap::Message &aMessage, c SuccessOrExit(error = Tlv::Find(aMessage, joinerIid)); SuccessOrExit(error = Tlv::Find(aMessage, joinerRloc)); - SuccessOrExit(error = Tlv::FindTlvValueOffset(aMessage, Tlv::kJoinerDtlsEncapsulation, offset, length)); - VerifyOrExit(length <= aMessage.GetLength() - offset, error = kErrorParse); + SuccessOrExit( + error = Tlv::FindTlvValueStartEndOffsets(aMessage, Tlv::kJoinerDtlsEncapsulation, startOffset, endOffset)); if (!Get().IsConnectionActive()) { @@ -997,8 +997,8 @@ template <> void Commissioner::HandleTmf(Coap::Message &aMessage, c LogInfo("Received %s (%s, 0x%04x)", UriToString(), mJoinerIid.ToString().AsCString(), mJoinerRloc); - aMessage.SetOffset(offset); - SuccessOrExit(error = aMessage.SetLength(offset + length)); + aMessage.SetOffset(startOffset); + SuccessOrExit(error = aMessage.SetLength(endOffset)); joinerMessageInfo.SetPeerAddr(Get().GetMeshLocal64()); joinerMessageInfo.GetPeerAddr().SetIid(mJoinerIid); diff --git a/src/core/meshcop/commissioner.hpp b/src/core/meshcop/commissioner.hpp index 22e061fb5c0..8a277da23fd 100644 --- a/src/core/meshcop/commissioner.hpp +++ b/src/core/meshcop/commissioner.hpp @@ -70,7 +70,7 @@ class Commissioner : public InstanceLocator, private NonCopyable public: /** - * This enumeration type represents the Commissioner State. + * Type represents the Commissioner State. * */ enum State : uint8_t @@ -81,7 +81,7 @@ class Commissioner : public InstanceLocator, private NonCopyable }; /** - * This enumeration type represents Joiner Event. + * Type represents Joiner Event. * */ enum JoinerEvent : uint8_t @@ -97,14 +97,14 @@ class Commissioner : public InstanceLocator, private NonCopyable typedef otCommissionerJoinerCallback JoinerCallback; ///< Joiner state change callback function pointer type. /** - * This type represents a Commissioning Dataset. + * Represents a Commissioning Dataset. * */ class Dataset : public otCommissioningDataset, public Clearable { public: /** - * This method indicates whether or not the Border Router RLOC16 Locator is set in the Dataset. + * Indicates whether or not the Border Router RLOC16 Locator is set in the Dataset. * * @returns TRUE if Border Router RLOC16 Locator is set, FALSE otherwise. * @@ -112,9 +112,9 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsLocatorSet(void) const { return mIsLocatorSet; } /** - * This method gets the Border Router RLOC16 Locator in the Dataset. + * Gets the Border Router RLOC16 Locator in the Dataset. * - * This method MUST be used when Locator is set in the Dataset, otherwise its behavior is undefined. + * MUST be used when Locator is set in the Dataset, otherwise its behavior is undefined. * * @returns The Border Router RLOC16 Locator in the Dataset. * @@ -122,7 +122,7 @@ class Commissioner : public InstanceLocator, private NonCopyable uint16_t GetLocator(void) const { return mLocator; } /** - * This method sets the Border Router RLOCG16 Locator in the Dataset. + * Sets the Border Router RLOCG16 Locator in the Dataset. * * @param[in] aLocator A Locator. * @@ -134,7 +134,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the Session ID is set in the Dataset. + * Indicates whether or not the Session ID is set in the Dataset. * * @returns TRUE if Session ID is set, FALSE otherwise. * @@ -142,9 +142,9 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsSessionIdSet(void) const { return mIsSessionIdSet; } /** - * This method gets the Session ID in the Dataset. + * Gets the Session ID in the Dataset. * - * This method MUST be used when Session ID is set in the Dataset, otherwise its behavior is undefined. + * MUST be used when Session ID is set in the Dataset, otherwise its behavior is undefined. * * @returns The Session ID in the Dataset. * @@ -152,7 +152,7 @@ class Commissioner : public InstanceLocator, private NonCopyable uint16_t GetSessionId(void) const { return mSessionId; } /** - * This method sets the Session ID in the Dataset. + * Sets the Session ID in the Dataset. * * @param[in] aSessionId The Session ID. * @@ -164,7 +164,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the Steering Data is set in the Dataset. + * Indicates whether or not the Steering Data is set in the Dataset. * * @returns TRUE if Steering Data is set, FALSE otherwise. * @@ -172,9 +172,9 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsSteeringDataSet(void) const { return mIsSteeringDataSet; } /** - * This method gets the Steering Data in the Dataset. + * Gets the Steering Data in the Dataset. * - * This method MUST be used when Steering Data is set in the Dataset, otherwise its behavior is undefined. + * MUST be used when Steering Data is set in the Dataset, otherwise its behavior is undefined. * * @returns The Steering Data in the Dataset. * @@ -182,7 +182,7 @@ class Commissioner : public InstanceLocator, private NonCopyable const SteeringData &GetSteeringData(void) const { return AsCoreType(&mSteeringData); } /** - * This method returns a reference to the Steering Data in the Dataset to be updated by caller. + * Returns a reference to the Steering Data in the Dataset to be updated by caller. * * @returns A reference to the Steering Data in the Dataset. * @@ -194,7 +194,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the Joiner UDP port is set in the Dataset. + * Indicates whether or not the Joiner UDP port is set in the Dataset. * * @returns TRUE if Joiner UDP port is set, FALSE otherwise. * @@ -202,9 +202,9 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsJoinerUdpPortSet(void) const { return mIsJoinerUdpPortSet; } /** - * This method gets the Joiner UDP port in the Dataset. + * Gets the Joiner UDP port in the Dataset. * - * This method MUST be used when Joiner UDP port is set in the Dataset, otherwise its behavior is undefined. + * MUST be used when Joiner UDP port is set in the Dataset, otherwise its behavior is undefined. * * @returns The Joiner UDP port in the Dataset. * @@ -212,7 +212,7 @@ class Commissioner : public InstanceLocator, private NonCopyable uint16_t GetJoinerUdpPort(void) const { return mJoinerUdpPort; } /** - * This method sets the Joiner UDP Port in the Dataset. + * Sets the Joiner UDP Port in the Dataset. * * @param[in] aJoinerUdpPort The Joiner UDP Port. * @@ -225,7 +225,7 @@ class Commissioner : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the Commissioner object. + * Initializes the Commissioner object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -233,7 +233,7 @@ class Commissioner : public InstanceLocator, private NonCopyable explicit Commissioner(Instance &aInstance); /** - * This method starts the Commissioner service. + * Starts the Commissioner service. * * @param[in] aStateCallback A pointer to a function that is called when the commissioner state changes. * @param[in] aJoinerCallback A pointer to a function that is called when a joiner event occurs. @@ -247,7 +247,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error Start(StateCallback aStateCallback, JoinerCallback aJoinerCallback, void *aCallbackContext); /** - * This method stops the Commissioner service. + * Stops the Commissioner service. * * @retval kErrorNone Successfully stopped the Commissioner service. * @retval kErrorAlready Commissioner is already stopped. @@ -256,7 +256,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error Stop(void) { return Stop(kSendKeepAliveToResign); } /** - * This method returns the Commissioner Id. + * Returns the Commissioner Id. * * @returns The Commissioner Id. * @@ -264,7 +264,7 @@ class Commissioner : public InstanceLocator, private NonCopyable const char *GetId(void) const { return mCommissionerId; } /** - * This method sets the Commissioner Id. + * Sets the Commissioner Id. * * @param[in] aId A pointer to a string character array. Must be null terminated. * @@ -276,13 +276,13 @@ class Commissioner : public InstanceLocator, private NonCopyable Error SetId(const char *aId); /** - * This method clears all Joiner entries. + * Clears all Joiner entries. * */ void ClearJoiners(void); /** - * This method adds a Joiner entry accepting any Joiner. + * Adds a Joiner entry accepting any Joiner. * * @param[in] aPskd A pointer to the PSKd. * @param[in] aTimeout A time after which a Joiner is automatically removed, in seconds. @@ -295,7 +295,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error AddJoinerAny(const char *aPskd, uint32_t aTimeout) { return AddJoiner(nullptr, nullptr, aPskd, aTimeout); } /** - * This method adds a Joiner entry. + * Adds a Joiner entry. * * @param[in] aEui64 The Joiner's IEEE EUI-64. * @param[in] aPskd A pointer to the PSKd. @@ -312,7 +312,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method adds a Joiner entry with a Joiner Discerner. + * Adds a Joiner entry with a Joiner Discerner. * * @param[in] aDiscerner A Joiner Discerner. * @param[in] aPskd A pointer to the PSKd. @@ -329,7 +329,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method get joiner info at aIterator position. + * Get joiner info at aIterator position. * * @param[in,out] aIterator A iterator to the index of the joiner. * @param[out] aJoiner A reference to Joiner info. @@ -341,7 +341,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error GetNextJoinerInfo(uint16_t &aIterator, otJoinerInfo &aJoiner) const; /** - * This method removes a Joiner entry accepting any Joiner. + * Removes a Joiner entry accepting any Joiner. * * @param[in] aDelay The delay to remove Joiner (in seconds). * @@ -353,7 +353,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error RemoveJoinerAny(uint32_t aDelay) { return RemoveJoiner(nullptr, nullptr, aDelay); } /** - * This method removes a Joiner entry. + * Removes a Joiner entry. * * @param[in] aEui64 The Joiner's IEEE EUI-64. * @param[in] aDelay The delay to remove Joiner (in seconds). @@ -369,7 +369,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method removes a Joiner entry. + * Removes a Joiner entry. * * @param[in] aDiscerner A Joiner Discerner. * @param[in] aDelay The delay to remove Joiner (in seconds). @@ -385,7 +385,7 @@ class Commissioner : public InstanceLocator, private NonCopyable } /** - * This method gets the Provisioning URL. + * Gets the Provisioning URL. * * @returns A pointer to char buffer containing the URL string. * @@ -393,7 +393,7 @@ class Commissioner : public InstanceLocator, private NonCopyable const char *GetProvisioningUrl(void) const { return mProvisioningUrl; } /** - * This method sets the Provisioning URL. + * Sets the Provisioning URL. * * @param[in] aProvisioningUrl A pointer to the Provisioning URL (may be `nullptr` to set URL to empty string). * @@ -404,7 +404,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error SetProvisioningUrl(const char *aProvisioningUrl); /** - * This method returns the Commissioner Session ID. + * Returns the Commissioner Session ID. * * @returns The Commissioner Session ID. * @@ -412,7 +412,7 @@ class Commissioner : public InstanceLocator, private NonCopyable uint16_t GetSessionId(void) const { return mSessionId; } /** - * This method indicates whether or not the Commissioner role is active. + * Indicates whether or not the Commissioner role is active. * * @returns TRUE if the Commissioner role is active, FALSE otherwise. * @@ -420,7 +420,7 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsActive(void) const { return mState == kStateActive; } /** - * This method indicates whether or not the Commissioner role is disabled. + * Indicates whether or not the Commissioner role is disabled. * * @returns TRUE if the Commissioner role is disabled, FALSE otherwise. * @@ -428,7 +428,7 @@ class Commissioner : public InstanceLocator, private NonCopyable bool IsDisabled(void) const { return mState == kStateDisabled; } /** - * This method gets the Commissioner State. + * Gets the Commissioner State. * * @returns The Commissioner State. * @@ -436,7 +436,7 @@ class Commissioner : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method sends MGMT_COMMISSIONER_GET. + * Sends MGMT_COMMISSIONER_GET. * * @param[in] aTlvs A pointer to Commissioning Data TLVs. * @param[in] aLength The length of requested TLVs in bytes. @@ -449,7 +449,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error SendMgmtCommissionerGetRequest(const uint8_t *aTlvs, uint8_t aLength); /** - * This method sends MGMT_COMMISSIONER_SET. + * Sends MGMT_COMMISSIONER_SET. * * @param[in] aDataset A reference to Commissioning Data. * @param[in] aTlvs A pointer to user specific Commissioning Data TLVs. @@ -463,7 +463,7 @@ class Commissioner : public InstanceLocator, private NonCopyable Error SendMgmtCommissionerSetRequest(const Dataset &aDataset, const uint8_t *aTlvs, uint8_t aLength); /** - * This method returns a reference to the AnnounceBeginClient instance. + * Returns a reference to the AnnounceBeginClient instance. * * @returns A reference to the AnnounceBeginClient instance. * @@ -471,7 +471,7 @@ class Commissioner : public InstanceLocator, private NonCopyable AnnounceBeginClient &GetAnnounceBeginClient(void) { return mAnnounceBegin; } /** - * This method returns a reference to the EnergyScanClient instance. + * Returns a reference to the EnergyScanClient instance. * * @returns A reference to the EnergyScanClient instance. * @@ -479,7 +479,7 @@ class Commissioner : public InstanceLocator, private NonCopyable EnergyScanClient &GetEnergyScanClient(void) { return mEnergyScan; } /** - * This method returns a reference to the PanIdQueryClient instance. + * Returns a reference to the PanIdQueryClient instance. * * @returns A reference to the PanIdQueryClient instance. * @@ -487,7 +487,7 @@ class Commissioner : public InstanceLocator, private NonCopyable PanIdQueryClient &GetPanIdQueryClient(void) { return mPanIdQuery; } /** - * This method applies the Mesh Local Prefix. + * Applies the Mesh Local Prefix. * */ void ApplyMeshLocalPrefix(void); diff --git a/src/core/meshcop/dataset.cpp b/src/core/meshcop/dataset.cpp index 5d9a02877de..60aa0dae04f 100644 --- a/src/core/meshcop/dataset.cpp +++ b/src/core/meshcop/dataset.cpp @@ -80,7 +80,7 @@ Error Dataset::Info::GenerateRandom(Instance &aInstance) SuccessOrExit(error = AsCoreType(&mNetworkKey).GenerateRandom()); SuccessOrExit(error = AsCoreType(&mPskc).GenerateRandom()); - SuccessOrExit(error = Random::Crypto::FillBuffer(mExtendedPanId.m8, sizeof(mExtendedPanId.m8))); + SuccessOrExit(error = Random::Crypto::Fill(mExtendedPanId)); SuccessOrExit(error = AsCoreType(&mMeshLocalPrefix).GenerateRandomUla()); snprintf(mNetworkName.m8, sizeof(mNetworkName), "%s-%04x", NetworkName::kNetworkNameInit, mPanId); diff --git a/src/core/meshcop/dataset.hpp b/src/core/meshcop/dataset.hpp index d45ea027866..ac7b9acdbbe 100644 --- a/src/core/meshcop/dataset.hpp +++ b/src/core/meshcop/dataset.hpp @@ -53,7 +53,7 @@ namespace ot { namespace MeshCoP { /** - * This class represents MeshCop Dataset. + * Represents MeshCop Dataset. * */ class Dataset @@ -66,7 +66,7 @@ class Dataset static constexpr uint8_t kMaxGetTypes = 64; ///< Max number of types in MGMT_GET.req /** - * This enumeration represents the Dataset type (active or pending). + * Represents the Dataset type (active or pending). * */ enum Type : uint8_t @@ -76,14 +76,14 @@ class Dataset }; /** - * This class represents presence of different components in Active or Pending Operational Dataset. + * Represents presence of different components in Active or Pending Operational Dataset. * */ class Components : public otOperationalDatasetComponents, public Clearable { public: /** - * This method indicates whether or not the Active Timestamp is present in the Dataset. + * Indicates whether or not the Active Timestamp is present in the Dataset. * * @returns TRUE if Active Timestamp is present, FALSE otherwise. * @@ -91,7 +91,7 @@ class Dataset bool IsActiveTimestampPresent(void) const { return mIsActiveTimestampPresent; } /** - * This method indicates whether or not the Pending Timestamp is present in the Dataset. + * Indicates whether or not the Pending Timestamp is present in the Dataset. * * @returns TRUE if Pending Timestamp is present, FALSE otherwise. * @@ -99,7 +99,7 @@ class Dataset bool IsPendingTimestampPresent(void) const { return mIsPendingTimestampPresent; } /** - * This method indicates whether or not the Network Key is present in the Dataset. + * Indicates whether or not the Network Key is present in the Dataset. * * @returns TRUE if Network Key is present, FALSE otherwise. * @@ -107,7 +107,7 @@ class Dataset bool IsNetworkKeyPresent(void) const { return mIsNetworkKeyPresent; } /** - * This method indicates whether or not the Network Name is present in the Dataset. + * Indicates whether or not the Network Name is present in the Dataset. * * @returns TRUE if Network Name is present, FALSE otherwise. * @@ -115,7 +115,7 @@ class Dataset bool IsNetworkNamePresent(void) const { return mIsNetworkNamePresent; } /** - * This method indicates whether or not the Extended PAN ID is present in the Dataset. + * Indicates whether or not the Extended PAN ID is present in the Dataset. * * @returns TRUE if Extended PAN ID is present, FALSE otherwise. * @@ -123,7 +123,7 @@ class Dataset bool IsExtendedPanIdPresent(void) const { return mIsExtendedPanIdPresent; } /** - * This method indicates whether or not the Mesh Local Prefix is present in the Dataset. + * Indicates whether or not the Mesh Local Prefix is present in the Dataset. * * @returns TRUE if Mesh Local Prefix is present, FALSE otherwise. * @@ -131,7 +131,7 @@ class Dataset bool IsMeshLocalPrefixPresent(void) const { return mIsMeshLocalPrefixPresent; } /** - * This method indicates whether or not the Delay Timer is present in the Dataset. + * Indicates whether or not the Delay Timer is present in the Dataset. * * @returns TRUE if Delay Timer is present, FALSE otherwise. * @@ -139,7 +139,7 @@ class Dataset bool IsDelayPresent(void) const { return mIsDelayPresent; } /** - * This method indicates whether or not the PAN ID is present in the Dataset. + * Indicates whether or not the PAN ID is present in the Dataset. * * @returns TRUE if PAN ID is present, FALSE otherwise. * @@ -147,7 +147,7 @@ class Dataset bool IsPanIdPresent(void) const { return mIsPanIdPresent; } /** - * This method indicates whether or not the Channel is present in the Dataset. + * Indicates whether or not the Channel is present in the Dataset. * * @returns TRUE if Channel is present, FALSE otherwise. * @@ -155,7 +155,7 @@ class Dataset bool IsChannelPresent(void) const { return mIsChannelPresent; } /** - * This method indicates whether or not the PSKc is present in the Dataset. + * Indicates whether or not the PSKc is present in the Dataset. * * @returns TRUE if PSKc is present, FALSE otherwise. * @@ -163,7 +163,7 @@ class Dataset bool IsPskcPresent(void) const { return mIsPskcPresent; } /** - * This method indicates whether or not the Security Policy is present in the Dataset. + * Indicates whether or not the Security Policy is present in the Dataset. * * @returns TRUE if Security Policy is present, FALSE otherwise. * @@ -171,7 +171,7 @@ class Dataset bool IsSecurityPolicyPresent(void) const { return mIsSecurityPolicyPresent; } /** - * This method indicates whether or not the Channel Mask is present in the Dataset. + * Indicates whether or not the Channel Mask is present in the Dataset. * * @returns TRUE if Channel Mask is present, FALSE otherwise. * @@ -180,14 +180,14 @@ class Dataset }; /** - * This type represents the information about the fields contained an Active or Pending Operational Dataset. + * Represents the information about the fields contained an Active or Pending Operational Dataset. * */ class Info : public otOperationalDataset, public Clearable { public: /** - * This method indicates whether or not the Active Timestamp is present in the Dataset. + * Indicates whether or not the Active Timestamp is present in the Dataset. * * @returns TRUE if Active Timestamp is present, FALSE otherwise. * @@ -195,9 +195,9 @@ class Dataset bool IsActiveTimestampPresent(void) const { return mComponents.mIsActiveTimestampPresent; } /** - * This method gets the Active Timestamp in the Dataset. + * Gets the Active Timestamp in the Dataset. * - * This method MUST be used when Active Timestamp component is present in the Dataset, otherwise its behavior is + * MUST be used when Active Timestamp component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Active Timestamp in the Dataset. @@ -206,7 +206,7 @@ class Dataset void GetActiveTimestamp(Timestamp &aTimestamp) const { aTimestamp.SetFromTimestamp(mActiveTimestamp); } /** - * This method sets the Active Timestamp in the Dataset. + * Sets the Active Timestamp in the Dataset. * * @param[in] aTimestamp A Timestamp value. * @@ -218,7 +218,7 @@ class Dataset } /** - * This method indicates whether or not the Pending Timestamp is present in the Dataset. + * Indicates whether or not the Pending Timestamp is present in the Dataset. * * @returns TRUE if Pending Timestamp is present, FALSE otherwise. * @@ -226,9 +226,9 @@ class Dataset bool IsPendingTimestampPresent(void) const { return mComponents.mIsPendingTimestampPresent; } /** - * This method gets the Pending Timestamp in the Dataset. + * Gets the Pending Timestamp in the Dataset. * - * This method MUST be used when Pending Timestamp component is present in the Dataset, otherwise its behavior + * MUST be used when Pending Timestamp component is present in the Dataset, otherwise its behavior * is undefined. * * @returns The Pending Timestamp in the Dataset. @@ -237,7 +237,7 @@ class Dataset void GetPendingTimestamp(Timestamp &aTimestamp) const { aTimestamp.SetFromTimestamp(mPendingTimestamp); } /** - * This method sets the Pending Timestamp in the Dataset. + * Sets the Pending Timestamp in the Dataset. * * @param[in] aTimestamp A Timestamp value. * @@ -249,7 +249,7 @@ class Dataset } /** - * This method indicates whether or not the Network Key is present in the Dataset. + * Indicates whether or not the Network Key is present in the Dataset. * * @returns TRUE if Network Key is present, FALSE otherwise. * @@ -257,9 +257,9 @@ class Dataset bool IsNetworkKeyPresent(void) const { return mComponents.mIsNetworkKeyPresent; } /** - * This method gets the Network Key in the Dataset. + * Gets the Network Key in the Dataset. * - * This method MUST be used when Network Key component is present in the Dataset, otherwise its behavior + * MUST be used when Network Key component is present in the Dataset, otherwise its behavior * is undefined. * * @returns The Network Key in the Dataset. @@ -268,7 +268,7 @@ class Dataset const NetworkKey &GetNetworkKey(void) const { return AsCoreType(&mNetworkKey); } /** - * This method sets the Network Key in the Dataset. + * Sets the Network Key in the Dataset. * * @param[in] aNetworkKey A Network Key. * @@ -280,7 +280,7 @@ class Dataset } /** - * This method returns a reference to the Network Key in the Dataset to be updated by caller. + * Returns a reference to the Network Key in the Dataset to be updated by caller. * * @returns A reference to the Network Key in the Dataset. * @@ -292,7 +292,7 @@ class Dataset } /** - * This method indicates whether or not the Network Name is present in the Dataset. + * Indicates whether or not the Network Name is present in the Dataset. * * @returns TRUE if Network Name is present, FALSE otherwise. * @@ -300,9 +300,9 @@ class Dataset bool IsNetworkNamePresent(void) const { return mComponents.mIsNetworkNamePresent; } /** - * This method gets the Network Name in the Dataset. + * Gets the Network Name in the Dataset. * - * This method MUST be used when Network Name component is present in the Dataset, otherwise its behavior is + * MUST be used when Network Name component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Network Name in the Dataset. @@ -311,7 +311,7 @@ class Dataset const NetworkName &GetNetworkName(void) const { return AsCoreType(&mNetworkName); } /** - * This method sets the Network Name in the Dataset. + * Sets the Network Name in the Dataset. * * @param[in] aNetworkNameData A Network Name Data. * @@ -323,7 +323,7 @@ class Dataset } /** - * This method indicates whether or not the Extended PAN ID is present in the Dataset. + * Indicates whether or not the Extended PAN ID is present in the Dataset. * * @returns TRUE if Extended PAN ID is present, FALSE otherwise. * @@ -331,9 +331,9 @@ class Dataset bool IsExtendedPanIdPresent(void) const { return mComponents.mIsExtendedPanIdPresent; } /** - * This method gets the Extended PAN ID in the Dataset. + * Gets the Extended PAN ID in the Dataset. * - * This method MUST be used when Extended PAN ID component is present in the Dataset, otherwise its behavior is + * MUST be used when Extended PAN ID component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Extended PAN ID in the Dataset. @@ -342,7 +342,7 @@ class Dataset const ExtendedPanId &GetExtendedPanId(void) const { return AsCoreType(&mExtendedPanId); } /** - * This method sets the Extended PAN ID in the Dataset. + * Sets the Extended PAN ID in the Dataset. * * @param[in] aExtendedPanId An Extended PAN ID. * @@ -354,7 +354,7 @@ class Dataset } /** - * This method indicates whether or not the Mesh Local Prefix is present in the Dataset. + * Indicates whether or not the Mesh Local Prefix is present in the Dataset. * * @returns TRUE if Mesh Local Prefix is present, FALSE otherwise. * @@ -362,9 +362,9 @@ class Dataset bool IsMeshLocalPrefixPresent(void) const { return mComponents.mIsMeshLocalPrefixPresent; } /** - * This method gets the Mesh Local Prefix in the Dataset. + * Gets the Mesh Local Prefix in the Dataset. * - * This method MUST be used when Mesh Local Prefix component is present in the Dataset, otherwise its behavior + * MUST be used when Mesh Local Prefix component is present in the Dataset, otherwise its behavior * is undefined. * * @returns The Mesh Local Prefix in the Dataset. @@ -376,7 +376,7 @@ class Dataset } /** - * This method sets the Mesh Local Prefix in the Dataset. + * Sets the Mesh Local Prefix in the Dataset. * * @param[in] aMeshLocalPrefix A Mesh Local Prefix. * @@ -388,7 +388,7 @@ class Dataset } /** - * This method indicates whether or not the Delay Timer is present in the Dataset. + * Indicates whether or not the Delay Timer is present in the Dataset. * * @returns TRUE if Delay Timer is present, FALSE otherwise. * @@ -396,9 +396,9 @@ class Dataset bool IsDelayPresent(void) const { return mComponents.mIsDelayPresent; } /** - * This method gets the Delay Timer in the Dataset. + * Gets the Delay Timer in the Dataset. * - * This method MUST be used when Delay Timer component is present in the Dataset, otherwise its behavior is + * MUST be used when Delay Timer component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Delay Timer in the Dataset. @@ -407,7 +407,7 @@ class Dataset uint32_t GetDelay(void) const { return mDelay; } /** - * This method sets the Delay Timer in the Dataset. + * Sets the Delay Timer in the Dataset. * * @param[in] aDelay A Delay value. * @@ -419,7 +419,7 @@ class Dataset } /** - * This method indicates whether or not the PAN ID is present in the Dataset. + * Indicates whether or not the PAN ID is present in the Dataset. * * @returns TRUE if PAN ID is present, FALSE otherwise. * @@ -427,9 +427,9 @@ class Dataset bool IsPanIdPresent(void) const { return mComponents.mIsPanIdPresent; } /** - * This method gets the PAN ID in the Dataset. + * Gets the PAN ID in the Dataset. * - * This method MUST be used when PAN ID component is present in the Dataset, otherwise its behavior is + * MUST be used when PAN ID component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The PAN ID in the Dataset. @@ -438,7 +438,7 @@ class Dataset Mac::PanId GetPanId(void) const { return mPanId; } /** - * This method sets the PAN ID in the Dataset. + * Sets the PAN ID in the Dataset. * * @param[in] aPanId A PAN ID. * @@ -450,7 +450,7 @@ class Dataset } /** - * This method indicates whether or not the Channel is present in the Dataset. + * Indicates whether or not the Channel is present in the Dataset. * * @returns TRUE if Channel is present, FALSE otherwise. * @@ -458,9 +458,9 @@ class Dataset bool IsChannelPresent(void) const { return mComponents.mIsChannelPresent; } /** - * This method gets the Channel in the Dataset. + * Gets the Channel in the Dataset. * - * This method MUST be used when Channel component is present in the Dataset, otherwise its behavior is + * MUST be used when Channel component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Channel in the Dataset. @@ -469,7 +469,7 @@ class Dataset uint16_t GetChannel(void) const { return mChannel; } /** - * This method sets the Channel in the Dataset. + * Sets the Channel in the Dataset. * * @param[in] aChannel A Channel. * @@ -481,7 +481,7 @@ class Dataset } /** - * This method indicates whether or not the PSKc is present in the Dataset. + * Indicates whether or not the PSKc is present in the Dataset. * * @returns TRUE if PSKc is present, FALSE otherwise. * @@ -489,9 +489,9 @@ class Dataset bool IsPskcPresent(void) const { return mComponents.mIsPskcPresent; } /** - * This method gets the PSKc in the Dataset. + * Gets the PSKc in the Dataset. * - * This method MUST be used when PSKc component is present in the Dataset, otherwise its behavior is undefined. + * MUST be used when PSKc component is present in the Dataset, otherwise its behavior is undefined. * * @returns The PSKc in the Dataset. * @@ -499,7 +499,7 @@ class Dataset const Pskc &GetPskc(void) const { return AsCoreType(&mPskc); } /** - * This method set the PSKc in the Dataset. + * Set the PSKc in the Dataset. * * @param[in] aPskc A PSKc value. * @@ -511,7 +511,7 @@ class Dataset } /** - * This method indicates whether or not the Security Policy is present in the Dataset. + * Indicates whether or not the Security Policy is present in the Dataset. * * @returns TRUE if Security Policy is present, FALSE otherwise. * @@ -519,9 +519,9 @@ class Dataset bool IsSecurityPolicyPresent(void) const { return mComponents.mIsSecurityPolicyPresent; } /** - * This method gets the Security Policy in the Dataset. + * Gets the Security Policy in the Dataset. * - * This method MUST be used when Security Policy component is present in the Dataset, otherwise its behavior is + * MUST be used when Security Policy component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Security Policy in the Dataset. @@ -530,7 +530,7 @@ class Dataset const SecurityPolicy &GetSecurityPolicy(void) const { return AsCoreType(&mSecurityPolicy); } /** - * This method sets the Security Policy in the Dataset. + * Sets the Security Policy in the Dataset. * * @param[in] aSecurityPolicy A Security Policy to set in Dataset. * @@ -542,7 +542,7 @@ class Dataset } /** - * This method indicates whether or not the Channel Mask is present in the Dataset. + * Indicates whether or not the Channel Mask is present in the Dataset. * * @returns TRUE if Channel Mask is present, FALSE otherwise. * @@ -550,9 +550,9 @@ class Dataset bool IsChannelMaskPresent(void) const { return mComponents.mIsChannelMaskPresent; } /** - * This method gets the Channel Mask in the Dataset. + * Gets the Channel Mask in the Dataset. * - * This method MUST be used when Channel Mask component is present in the Dataset, otherwise its behavior is + * MUST be used when Channel Mask component is present in the Dataset, otherwise its behavior is * undefined. * * @returns The Channel Mask in the Dataset. @@ -561,7 +561,7 @@ class Dataset otChannelMask GetChannelMask(void) const { return mChannelMask; } /** - * This method sets the Channel Mask in the Dataset. + * Sets the Channel Mask in the Dataset. * * @param[in] aChannelMask A Channel Mask value. * @@ -573,7 +573,7 @@ class Dataset } /** - * This method populates the Dataset with random fields. + * Populates the Dataset with random fields. * * The Network Key, PSKc, Mesh Local Prefix, PAN ID, and Extended PAN ID are generated randomly (crypto-secure) * with Network Name set to "OpenThread-%04x" with PAN ID appended as hex. The Channel is chosen randomly from @@ -588,7 +588,7 @@ class Dataset Error GenerateRandom(Instance &aInstance); /** - * This method checks whether the Dataset is a subset of another one, i.e., all the components in the current + * Checks whether the Dataset is a subset of another one, i.e., all the components in the current * Dataset are also present in the @p aOther and the component values fully match. * * The matching of components in the two Datasets excludes Active/Pending Timestamp and Delay components. @@ -603,19 +603,19 @@ class Dataset }; /** - * This constructor initializes the object. + * Initializes the object. * */ Dataset(void); /** - * This method clears the Dataset. + * Clears the Dataset. * */ void Clear(void); /** - * This method indicates whether or not the dataset appears to be well-formed. + * Indicates whether or not the dataset appears to be well-formed. * * @returns TRUE if the dataset appears to be well-formed, FALSE otherwise. * @@ -623,7 +623,7 @@ class Dataset bool IsValid(void) const; /** - * This method returns a pointer to the TLV with a given type. + * Returns a pointer to the TLV with a given type. * * @param[in] aType A TLV type. * @@ -633,7 +633,7 @@ class Dataset Tlv *GetTlv(Tlv::Type aType) { return AsNonConst(AsConst(this)->GetTlv(aType)); } /** - * This method returns a pointer to the TLV with a given type. + * Returns a pointer to the TLV with a given type. * * @param[in] aType The TLV type. * @@ -643,7 +643,7 @@ class Dataset const Tlv *GetTlv(Tlv::Type aType) const; /** - * This template method returns a pointer to the TLV with a given template type `TlvType` + * Returns a pointer to the TLV with a given template type `TlvType` * * @returns A pointer to the TLV or `nullptr` if none is found. * @@ -654,7 +654,7 @@ class Dataset } /** - * This template method returns a pointer to the TLV with a given template type `TlvType` + * Returns a pointer to the TLV with a given template type `TlvType` * * @returns A pointer to the TLV or `nullptr` if none is found. * @@ -665,7 +665,7 @@ class Dataset } /** - * This method returns a pointer to the byte representation of the Dataset. + * Returns a pointer to the byte representation of the Dataset. * * @returns A pointer to the byte representation of the Dataset. * @@ -673,7 +673,7 @@ class Dataset uint8_t *GetBytes(void) { return mTlvs; } /** - * This method returns a pointer to the byte representation of the Dataset. + * Returns a pointer to the byte representation of the Dataset. * * @returns A pointer to the byte representation of the Dataset. * @@ -681,7 +681,7 @@ class Dataset const uint8_t *GetBytes(void) const { return mTlvs; } /** - * This method converts the TLV representation to structure representation. + * Converts the TLV representation to structure representation. * * @param[out] aDatasetInfo A reference to `Info` object to output the Dataset. * @@ -689,7 +689,7 @@ class Dataset void ConvertTo(Info &aDatasetInfo) const; /** - * This method converts the TLV representation to structure representation. + * Converts the TLV representation to structure representation. * * @param[out] aDataset A reference to `otOperationalDatasetTlvs` to output the Dataset. * @@ -697,7 +697,7 @@ class Dataset void ConvertTo(otOperationalDatasetTlvs &aDataset) const; /** - * This method returns the Dataset size in bytes. + * Returns the Dataset size in bytes. * * @returns The Dataset size in bytes. * @@ -705,7 +705,7 @@ class Dataset uint16_t GetSize(void) const { return mLength; } /** - * This method sets the Dataset size in bytes. + * Sets the Dataset size in bytes. * * @param[in] aSize The Dataset size in bytes. * @@ -713,7 +713,7 @@ class Dataset void SetSize(uint16_t aSize) { mLength = aSize; } /** - * This method returns the local time the dataset was last updated. + * Returns the local time the dataset was last updated. * * @returns The local time the dataset was last updated. * @@ -721,7 +721,7 @@ class Dataset TimeMilli GetUpdateTime(void) const { return mUpdateTime; } /** - * This method gets the Timestamp (Active or Pending). + * Gets the Timestamp (Active or Pending). * * @param[in] aType The type: active or pending. * @param[out] aTimestamp A reference to a `Timestamp` to output the value. @@ -733,7 +733,7 @@ class Dataset Error GetTimestamp(Type aType, Timestamp &aTimestamp) const; /** - * This method sets the Timestamp value. + * Sets the Timestamp value. * * @param[in] aType The type: active or pending. * @param[in] aTimestamp A Timestamp. @@ -742,7 +742,7 @@ class Dataset void SetTimestamp(Type aType, const Timestamp &aTimestamp); /** - * This method sets a TLV in the Dataset. + * Sets a TLV in the Dataset. * * @param[in] aTlv A reference to the TLV. * @@ -753,7 +753,7 @@ class Dataset Error SetTlv(const Tlv &aTlv); /** - * This method sets a TLV with a given TLV Type and Value. + * Sets a TLV with a given TLV Type and Value. * * @param[in] aType The TLV Type. * @param[in] aValue A pointer to TLV Value. @@ -766,7 +766,7 @@ class Dataset Error SetTlv(Tlv::Type aType, const void *aValue, uint8_t aLength); /** - * This template method sets a TLV with a given TLV Type and Value. + * Sets a TLV with a given TLV Type and Value. * * @tparam ValueType The type of TLV's Value. * @@ -785,7 +785,7 @@ class Dataset } /** - * This method reads the Dataset from a given message and checks that it is well-formed and valid. + * Reads the Dataset from a given message and checks that it is well-formed and valid. * * @param[in] aMessage The message to read from. * @param[in] aOffset The offset in @p aMessage to start reading the Dataset TLVs. @@ -798,7 +798,7 @@ class Dataset Error ReadFromMessage(const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method sets the Dataset using an existing Dataset. + * Sets the Dataset using an existing Dataset. * * If this Dataset is an Active Dataset, any Pending Timestamp and Delay Timer TLVs will be omitted in the copy * from @p aDataset. @@ -810,7 +810,7 @@ class Dataset void Set(Type aType, const Dataset &aDataset); /** - * This method sets the Dataset from a given structure representation. + * Sets the Dataset from a given structure representation. * * @param[in] aDatasetInfo The input Dataset as `Dataset::Info`. * @@ -821,7 +821,7 @@ class Dataset Error SetFrom(const Info &aDatasetInfo); /** - * This method sets the Dataset using @p aDataset. + * Sets the Dataset using @p aDataset. * * @param[in] aDataset The input Dataset as otOperationalDatasetTlvs. * @@ -829,7 +829,7 @@ class Dataset void SetFrom(const otOperationalDatasetTlvs &aDataset); /** - * This method removes a TLV from the Dataset. + * Removes a TLV from the Dataset. * * @param[in] aType The type of a specific TLV. * @@ -837,7 +837,7 @@ class Dataset void RemoveTlv(Tlv::Type aType); /** - * This method appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV. + * Appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV. * * @param[in] aType The type of the dataset, active or pending. * @param[in] aMessage A message to append to. @@ -849,7 +849,7 @@ class Dataset Error AppendMleDatasetTlv(Type aType, Message &aMessage) const; /** - * This method applies the Active or Pending Dataset to the Thread interface. + * Applies the Active or Pending Dataset to the Thread interface. * * @param[in] aInstance A reference to the OpenThread instance. * @param[out] aIsNetworkKeyUpdated A pointer to where to place whether network key was updated. @@ -861,15 +861,15 @@ class Dataset Error ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdated = nullptr) const; /** - * This method converts a Pending Dataset to an Active Dataset. + * Converts a Pending Dataset to an Active Dataset. * - * This method removes the Delay Timer and Pending Timestamp TLVs + * Removes the Delay Timer and Pending Timestamp TLVs * */ void ConvertToActive(void); /** - * This method returns a pointer to the start of Dataset TLVs sequence. + * Returns a pointer to the start of Dataset TLVs sequence. * * @return A pointer to the start of Dataset TLVs sequence. * @@ -877,7 +877,7 @@ class Dataset Tlv *GetTlvsStart(void) { return reinterpret_cast(mTlvs); } /** - * This method returns a pointer to the start of Dataset TLVs sequence. + * Returns a pointer to the start of Dataset TLVs sequence. * * @return A pointer to start of Dataset TLVs sequence. * @@ -885,7 +885,7 @@ class Dataset const Tlv *GetTlvsStart(void) const { return reinterpret_cast(mTlvs); } /** - * This method returns a pointer to the past-the-end of Dataset TLVs sequence. + * Returns a pointer to the past-the-end of Dataset TLVs sequence. * * Note that past-the-end points to the byte after the end of the last TLV in Dataset TLVs sequence. * @@ -895,7 +895,7 @@ class Dataset Tlv *GetTlvsEnd(void) { return reinterpret_cast(mTlvs + mLength); } /** - * This method returns a pointer to the past-the-end of Dataset TLVs sequence. + * Returns a pointer to the past-the-end of Dataset TLVs sequence. * * Note that past-the-end points to the byte after the end of the last TLV in Dataset TLVs sequence. * @@ -905,7 +905,7 @@ class Dataset const Tlv *GetTlvsEnd(void) const { return reinterpret_cast(mTlvs + mLength); } /** - * This static method converts a Dataset Type to a string. + * Converts a Dataset Type to a string. * * @param[in] aType A Dataset type. * diff --git a/src/core/meshcop/dataset_local.hpp b/src/core/meshcop/dataset_local.hpp index c91c11e56c1..2981b7c0270 100644 --- a/src/core/meshcop/dataset_local.hpp +++ b/src/core/meshcop/dataset_local.hpp @@ -48,7 +48,7 @@ class DatasetLocal : public InstanceLocator { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to an OpenThread instance. * @param[in] aType The type of the dataset, active or pending. @@ -57,7 +57,7 @@ class DatasetLocal : public InstanceLocator DatasetLocal(Instance &aInstance, Dataset::Type aType); /** - * This method indicates whether this is an Active or Pending Dataset. + * Indicates whether this is an Active or Pending Dataset. * * @returns The Dataset type. * @@ -65,13 +65,13 @@ class DatasetLocal : public InstanceLocator Dataset::Type GetType(void) const { return mType; } /** - * This method clears the Dataset. + * Clears the Dataset. * */ void Clear(void); /** - * This method indicates whether an Active or Pending Dataset is saved in non-volatile memory. + * Indicates whether an Active or Pending Dataset is saved in non-volatile memory. * * @retval TRUE if an Active or Pending Dataset is saved in non-volatile memory. * @retval FALSE if an Active or Pending Dataset is not saved in non-volatile memory. @@ -80,7 +80,7 @@ class DatasetLocal : public InstanceLocator bool IsSaved(void) const { return mSaved; } /** - * This method indicates whether an Active (Pending) Timestamp is present in the Active (Pending) Dataset. + * Indicates whether an Active (Pending) Timestamp is present in the Active (Pending) Dataset. * * @retval TRUE if an Active/Pending Timestamp is present. * @retval FALSE if an Active/Pending Timestamp is not present. @@ -89,7 +89,7 @@ class DatasetLocal : public InstanceLocator bool IsTimestampPresent(void) const { return mTimestampPresent; } /** - * This method returns a pointer to the Timestamp or `nullptr` when it is not present in the Dataset. + * Returns a pointer to the Timestamp or `nullptr` when it is not present in the Dataset. * * @returns A pointer to the Timestamp or `nullptr` if timestamp is not present in the Dataset. * @@ -97,9 +97,9 @@ class DatasetLocal : public InstanceLocator const Timestamp *GetTimestamp(void) const { return mTimestampPresent ? &mTimestamp : nullptr; } /** - * This method restores and retrieves the dataset from non-volatile memory. + * Restores and retrieves the dataset from non-volatile memory. * - * This method also sets the memory-cached timestamp for subsequent calls to `Compare()`. + * Also sets the memory-cached timestamp for subsequent calls to `Compare()`. * * @param[out] aDataset Where to place the dataset. * @@ -110,7 +110,7 @@ class DatasetLocal : public InstanceLocator Error Restore(Dataset &aDataset); /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDataset Where to place the dataset. * @@ -121,7 +121,7 @@ class DatasetLocal : public InstanceLocator Error Read(Dataset &aDataset) const; /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDatasetInfo Where to place the dataset as `Dataset::Info`. * @@ -132,7 +132,7 @@ class DatasetLocal : public InstanceLocator Error Read(Dataset::Info &aDatasetInfo) const; /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDataset Where to place the dataset. * @@ -143,7 +143,7 @@ class DatasetLocal : public InstanceLocator Error Read(otOperationalDatasetTlvs &aDataset) const; /** - * This method returns the local time this dataset was last updated or restored. + * Returns the local time this dataset was last updated or restored. * * @returns The local time this dataset was last updated or restored. * @@ -151,7 +151,7 @@ class DatasetLocal : public InstanceLocator TimeMilli GetUpdateTime(void) const { return mUpdateTime; } /** - * This method stores the dataset into non-volatile memory. + * Stores the dataset into non-volatile memory. * * @param[in] aDatasetInfo The Dataset to save as `Dataset::Info`. * @@ -162,7 +162,7 @@ class DatasetLocal : public InstanceLocator Error Save(const Dataset::Info &aDatasetInfo); /** - * This method stores the dataset into non-volatile memory. + * Stores the dataset into non-volatile memory. * * @param[in] aDataset The Dataset to save as `otOperationalDatasetTlvs`. * @@ -173,7 +173,7 @@ class DatasetLocal : public InstanceLocator Error Save(const otOperationalDatasetTlvs &aDataset); /** - * This method stores the dataset into non-volatile memory. + * Stores the dataset into non-volatile memory. * * @param[in] aDataset The Dataset to save. * diff --git a/src/core/meshcop/dataset_manager.hpp b/src/core/meshcop/dataset_manager.hpp index d6e1bbf7f85..c1af58a6772 100644 --- a/src/core/meshcop/dataset_manager.hpp +++ b/src/core/meshcop/dataset_manager.hpp @@ -55,7 +55,7 @@ class DatasetManager : public InstanceLocator { public: /** - * This method returns a pointer to the Timestamp. + * Returns a pointer to the Timestamp. * * @returns A pointer to the Timestamp. * @@ -63,7 +63,7 @@ class DatasetManager : public InstanceLocator const Timestamp *GetTimestamp(void) const; /** - * This method restores the Operational Dataset from non-volatile memory. + * Restores the Operational Dataset from non-volatile memory. * * @retval kErrorNone Successfully restore the dataset. * @retval kErrorNotFound There is no corresponding dataset stored in non-volatile memory. @@ -72,7 +72,7 @@ class DatasetManager : public InstanceLocator Error Restore(void); /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDataset Where to place the dataset. * @@ -83,7 +83,7 @@ class DatasetManager : public InstanceLocator Error Read(Dataset &aDataset) const { return mLocal.Read(aDataset); } /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDatasetInfo Where to place the dataset (as `Dataset::Info`). * @@ -94,7 +94,7 @@ class DatasetManager : public InstanceLocator Error Read(Dataset::Info &aDatasetInfo) const { return mLocal.Read(aDatasetInfo); } /** - * This method retrieves the dataset from non-volatile memory. + * Retrieves the dataset from non-volatile memory. * * @param[out] aDataset Where to place the dataset. * @@ -105,7 +105,7 @@ class DatasetManager : public InstanceLocator Error Read(otOperationalDatasetTlvs &aDataset) const { return mLocal.Read(aDataset); } /** - * This method retrieves the channel mask from local dataset. + * Retrieves the channel mask from local dataset. * * @param[out] aChannelMask A reference to the channel mask. * @@ -116,7 +116,7 @@ class DatasetManager : public InstanceLocator Error GetChannelMask(Mac::ChannelMask &aChannelMask) const; /** - * This method applies the Active or Pending Dataset to the Thread interface. + * Applies the Active or Pending Dataset to the Thread interface. * * @retval kErrorNone Successfully applied configuration. * @retval kErrorParse The dataset has at least one TLV with invalid format. @@ -125,7 +125,7 @@ class DatasetManager : public InstanceLocator Error ApplyConfiguration(void) const; /** - * This method updates the Operational Dataset when detaching from the network. + * Updates the Operational Dataset when detaching from the network. * * On detach, the Operational Dataset is restored from non-volatile memory. * @@ -133,7 +133,7 @@ class DatasetManager : public InstanceLocator void HandleDetach(void); /** - * This method sends a MGMT_SET request to the Leader. + * Sends a MGMT_SET request to the Leader. * * @param[in] aDatasetInfo The Operational Dataset. * @param[in] aTlvs Any additional raw TLVs to include. @@ -153,7 +153,7 @@ class DatasetManager : public InstanceLocator void *aContext); /** - * This method sends a MGMT_GET request. + * Sends a MGMT_GET request. * * @param[in] aDatasetComponents An Operational Dataset components structure specifying components to request. * @param[in] aTlvTypes A pointer to array containing additional raw TLV types to be requested. @@ -170,7 +170,7 @@ class DatasetManager : public InstanceLocator const otIp6Address *aAddress) const; #if OPENTHREAD_FTD /** - * This method appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV. + * Appends the MLE Dataset TLV but excluding MeshCoP Sub Timestamp TLV. * * @param[in] aMessage The message to append the TLV to. * @@ -183,7 +183,7 @@ class DatasetManager : public InstanceLocator protected: /** - * This class defines a generic Dataset TLV to read from a message. + * Defines a generic Dataset TLV to read from a message. * */ OT_TOOL_PACKED_BEGIN @@ -191,7 +191,7 @@ class DatasetManager : public InstanceLocator { public: /** - * This method reads the Dataset TLV from a given message at a given offset. + * Reads the Dataset TLV from a given message at a given offset. * * @param[in] aMessage A message to read the TLV from. * @param[in] aOffset An offset into the message to read from. @@ -207,7 +207,7 @@ class DatasetManager : public InstanceLocator } OT_TOOL_PACKED_END; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aType Dataset type, Active or Pending. @@ -217,7 +217,7 @@ class DatasetManager : public InstanceLocator DatasetManager(Instance &aInstance, Dataset::Type aType, TimerMilli::Handler aTimerHandler); /** - * This method gets the Operational Dataset type (Active or Pending). + * Gets the Operational Dataset type (Active or Pending). * * @returns The Operational Dataset type. * @@ -225,13 +225,13 @@ class DatasetManager : public InstanceLocator Dataset::Type GetType(void) const { return mLocal.GetType(); } /** - * This method clears the Operational Dataset. + * Clears the Operational Dataset. * */ void Clear(void); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * * @param[in] aDataset The Operational Dataset. * @@ -242,7 +242,7 @@ class DatasetManager : public InstanceLocator Error Save(const Dataset &aDataset); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * * @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`. * @@ -253,7 +253,7 @@ class DatasetManager : public InstanceLocator Error Save(const Dataset::Info &aDatasetInfo); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * * @param[in] aDataset The Operational Dataset. * @@ -264,9 +264,9 @@ class DatasetManager : public InstanceLocator Error Save(const otOperationalDatasetTlvs &aDataset); /** - * This method sets the Operational Dataset for the partition. + * Sets the Operational Dataset for the partition. * - * This method also updates the non-volatile version if the partition's Operational Dataset is newer. + * Also updates the non-volatile version if the partition's Operational Dataset is newer. * * @param[in] aTimestamp The timestamp for the Operational Dataset. * @param[in] aMessage The message buffer. @@ -280,7 +280,7 @@ class DatasetManager : public InstanceLocator Error Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint8_t aLength); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * * @param[in] aDataset The Operational Dataset. * @@ -291,7 +291,7 @@ class DatasetManager : public InstanceLocator Error SaveLocal(const Dataset &aDataset); /** - * This method handles a MGMT_GET request message. + * Handles a MGMT_GET request message. * * @param[in] aMessage The CoAP message buffer. * @param[in] aMessageInfo The message info. @@ -300,7 +300,7 @@ class DatasetManager : public InstanceLocator void HandleGet(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo) const; /** - * This method compares the partition's Operational Dataset with that stored in non-volatile memory. + * Compares the partition's Operational Dataset with that stored in non-volatile memory. * * If the partition's Operational Dataset is newer, the non-volatile storage is updated. * If the partition's Operational Dataset is older, the registration process is started. @@ -309,14 +309,14 @@ class DatasetManager : public InstanceLocator void HandleNetworkUpdate(void); /** - * This method initiates a network data registration message with the Leader. + * Initiates a network data registration message with the Leader. * */ void HandleTimer(void); #if OPENTHREAD_FTD /** - * This method handles the MGMT_SET request message. + * Handles the MGMT_SET request message. * * @param[in] aMessage The CoAP message buffer. * @param[in] aMessageInfo The message info. @@ -369,7 +369,7 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable public: /** - * This constructor initializes the ActiveDatasetManager object. + * Initializes the ActiveDatasetManager object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -377,9 +377,9 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable explicit ActiveDatasetManager(Instance &aInstance); /** - * This method indicates whether the Active Dataset is partially complete. + * Indicates whether the Active Dataset is partially complete. * - * This method is primarily used to determine whether a user has supplied a partial Active Dataset for use + * Is primarily used to determine whether a user has supplied a partial Active Dataset for use * with joining a network. * * @retval TRUE if an Active Dataset is saved but does not include an Active Timestamp. @@ -389,7 +389,7 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable bool IsPartiallyComplete(void) const; /** - * This method indicates whether or not a valid network is present in the Active Operational Dataset. + * Indicates whether or not a valid network is present in the Active Operational Dataset. * * @retval TRUE if a valid network is present in the Active Dataset. * @retval FALSE if a valid network is not present in the Active Dataset. @@ -398,15 +398,15 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable bool IsCommissioned(void) const; /** - * This method clears the Active Operational Dataset. + * Clears the Active Operational Dataset. * */ void Clear(void) { DatasetManager::Clear(); } /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * - * This method also reconfigures the Thread interface. + * Also reconfigures the Thread interface. * * @param[in] aDataset The Operational Dataset. * @@ -414,10 +414,10 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable void Save(const Dataset &aDataset) { IgnoreError(DatasetManager::Save(aDataset)); } /** - * This method sets the Operational Dataset for the partition. + * Sets the Operational Dataset for the partition. * - * This method also reconfigures the Thread interface. - * This method also updates the non-volatile version if the partition's Operational Dataset is newer. + * Also reconfigures the Thread interface. + * Also updates the non-volatile version if the partition's Operational Dataset is newer. * * @param[in] aTimestamp The timestamp for the Operational Dataset. * @param[in] aMessage The message buffer. @@ -431,7 +431,7 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable Error Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method sets the Operational Dataset in non-volatile memory. + * Sets the Operational Dataset in non-volatile memory. * * @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`. * @@ -442,7 +442,7 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable Error Save(const Dataset::Info &aDatasetInfo) { return DatasetManager::Save(aDatasetInfo); } /** - * This method sets the Operational Dataset in non-volatile memory. + * Sets the Operational Dataset in non-volatile memory. * * @param[in] aDataset The Operational Dataset. * @@ -455,7 +455,7 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable #if OPENTHREAD_FTD /** - * This method creates a new Operational Dataset to use when forming a new network. + * Creates a new Operational Dataset to use when forming a new network. * * @param[out] aDatasetInfo The Operational Dataset as `Dataset::Info`. * @@ -466,13 +466,13 @@ class ActiveDatasetManager : public DatasetManager, private NonCopyable Error CreateNewNetwork(Dataset::Info &aDatasetInfo) { return aDatasetInfo.GenerateRandom(GetInstance()); } /** - * This method starts the Leader functions for maintaining the Active Operational Dataset. + * Starts the Leader functions for maintaining the Active Operational Dataset. * */ void StartLeader(void); /** - * This method generate a default Active Operational Dataset. + * Generate a default Active Operational Dataset. * * @retval kErrorNone Successfully generated an Active Operational Dataset. * @retval kErrorAlready A valid Active Operational Dataset already exists. @@ -500,7 +500,7 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable public: /** - * This constructor initializes the PendingDatasetManager object. + * Initializes the PendingDatasetManager object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -508,25 +508,25 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable explicit PendingDatasetManager(Instance &aInstance); /** - * This method clears the Pending Operational Dataset. + * Clears the Pending Operational Dataset. * - * This method also stops the Delay Timer if it was active. + * Also stops the Delay Timer if it was active. * */ void Clear(void); /** - * This method clears the network Pending Operational Dataset. + * Clears the network Pending Operational Dataset. * - * This method also stops the Delay Timer if it was active. + * Also stops the Delay Timer if it was active. * */ void ClearNetwork(void); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * - * This method also starts the Delay Timer. + * Also starts the Delay Timer. * * @param[in] aDatasetInfo The Operational Dataset as `Dataset::Info`. * @@ -537,9 +537,9 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable Error Save(const Dataset::Info &aDatasetInfo); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * - * This method also starts the Delay Timer. + * Also starts the Delay Timer. * * @param[in] aDataset The Operational Dataset. * @@ -550,11 +550,11 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable Error Save(const otOperationalDatasetTlvs &aDataset); /** - * This method sets the Operational Dataset for the partition. + * Sets the Operational Dataset for the partition. * - * This method also updates the non-volatile version if the partition's Operational Dataset is newer. + * Also updates the non-volatile version if the partition's Operational Dataset is newer. * - * This method also starts the Delay Timer. + * Also starts the Delay Timer. * * @param[in] aTimestamp The timestamp for the Operational Dataset. * @param[in] aMessage The message buffer. @@ -565,7 +565,7 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable Error Save(const Timestamp &aTimestamp, const Message &aMessage, uint16_t aOffset, uint16_t aLength); /** - * This method saves the Operational Dataset in non-volatile memory. + * Saves the Operational Dataset in non-volatile memory. * * @param[in] aDataset The Operational Dataset. * @@ -577,13 +577,13 @@ class PendingDatasetManager : public DatasetManager, private NonCopyable #if OPENTHREAD_FTD /** - * This method starts the Leader functions for maintaining the Active Operational Dataset. + * Starts the Leader functions for maintaining the Active Operational Dataset. * */ void StartLeader(void); /** - * This method generates a Pending Dataset from an Active Dataset. + * Generates a Pending Dataset from an Active Dataset. * * @param[in] aTimestamp The Active Dataset Timestamp. * @param[in] aMessage The MGMT_SET message that contains an Active Dataset. diff --git a/src/core/meshcop/dataset_updater.hpp b/src/core/meshcop/dataset_updater.hpp index ecc998d7086..7d0a93cee3a 100644 --- a/src/core/meshcop/dataset_updater.hpp +++ b/src/core/meshcop/dataset_updater.hpp @@ -53,7 +53,7 @@ namespace ot { namespace MeshCoP { /** - * This class implements the Dataset Updater. + * Implements the Dataset Updater. * */ class DatasetUpdater : public InstanceLocator, private NonCopyable @@ -62,7 +62,7 @@ class DatasetUpdater : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes a `DatasetUpdater` object. + * Initializes a `DatasetUpdater` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -70,7 +70,7 @@ class DatasetUpdater : public InstanceLocator, private NonCopyable explicit DatasetUpdater(Instance &aInstance); /** - * This type represents the callback function pointer which is called when a Dataset update request finishes, + * Represents the callback function pointer which is called when a Dataset update request finishes, * reporting success or failure status of the request. * * The function pointer has the syntax `void (*UpdaterCallback)(Error aError, void *aContext)`. @@ -79,7 +79,7 @@ class DatasetUpdater : public InstanceLocator, private NonCopyable typedef otDatasetUpdaterCallback UpdaterCallback; /** - * This method requests an update to Operational Dataset. + * Requests an update to Operational Dataset. * * @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 (`kDefaultDelay`) would be used. @@ -98,13 +98,13 @@ class DatasetUpdater : public InstanceLocator, private NonCopyable Error RequestUpdate(const Dataset::Info &aDataset, UpdaterCallback aCallback, void *aContext); /** - * This method cancels an ongoing (if any) Operational Dataset update request. + * Cancels an ongoing (if any) Operational Dataset update request. * */ void CancelUpdate(void); /** - * This method indicates whether there is an ongoing Operation Dataset update request. + * Indicates whether there is an ongoing Operation Dataset update request. * * @retval TRUE There is an ongoing update. * @retval FALSE There is no ongoing update. diff --git a/src/core/meshcop/dtls.hpp b/src/core/meshcop/dtls.hpp index 129ed3c7767..1ff30e41d17 100644 --- a/src/core/meshcop/dtls.hpp +++ b/src/core/meshcop/dtls.hpp @@ -71,7 +71,7 @@ class Dtls : public InstanceLocator static constexpr uint8_t kPskMaxLength = 32; ///< Maximum PSK length. /** - * This constructor initializes the DTLS object. + * Initializes the DTLS object. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aLayerTwoSecurity Specifies whether to use layer two security or not. @@ -80,7 +80,7 @@ class Dtls : public InstanceLocator explicit Dtls(Instance &aInstance, bool aLayerTwoSecurity); /** - * This function pointer is called when a connection is established or torn down. + * Pointer is called when a connection is established or torn down. * * @param[in] aContext A pointer to application-specific context. * @param[in] aConnected TRUE if a connection was established, FALSE otherwise. @@ -89,7 +89,7 @@ class Dtls : public InstanceLocator typedef void (*ConnectedHandler)(void *aContext, bool aConnected); /** - * This function pointer is called when data is received from the DTLS session. + * Pointer is called when data is received from the DTLS session. * * @param[in] aContext A pointer to application-specific context. * @param[in] aBuf A pointer to the received data buffer. @@ -99,7 +99,7 @@ class Dtls : public InstanceLocator typedef void (*ReceiveHandler)(void *aContext, uint8_t *aBuf, uint16_t aLength); /** - * This function pointer is called when secure CoAP server want to send encrypted message. + * Pointer is called when secure CoAP server want to send encrypted message. * * @param[in] aContext A pointer to arbitrary context information. * @param[in] aMessage A reference to the message to send. @@ -109,7 +109,7 @@ class Dtls : public InstanceLocator typedef Error (*TransportCallback)(void *aContext, ot::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This method opens the DTLS socket. + * Opens the DTLS socket. * * @param[in] aReceiveHandler A pointer to a function that is called to receive DTLS payload. * @param[in] aConnectedHandler A pointer to a function that is called when connected or disconnected. @@ -122,7 +122,7 @@ class Dtls : public InstanceLocator Error Open(ReceiveHandler aReceiveHandler, ConnectedHandler aConnectedHandler, void *aContext); /** - * This method binds this DTLS to a UDP port. + * Binds this DTLS to a UDP port. * * @param[in] aPort The port to bind. * @@ -134,7 +134,7 @@ class Dtls : public InstanceLocator Error Bind(uint16_t aPort); /** - * This method gets the UDP port of this session. + * Gets the UDP port of this session. * * @returns UDP port number. * @@ -142,7 +142,7 @@ class Dtls : public InstanceLocator uint16_t GetUdpPort(void) const; /** - * This method binds this DTLS with a transport callback. + * Binds this DTLS with a transport callback. * * @param[in] aCallback A pointer to a function for sending messages. * @param[in] aContext A pointer to arbitrary context information. @@ -155,7 +155,7 @@ class Dtls : public InstanceLocator Error Bind(TransportCallback aCallback, void *aContext); /** - * This method establishes a DTLS session. + * Establishes a DTLS session. * * For CoAP Secure API do first: * Set X509 Pk and Cert for use DTLS mode ECDHE ECDSA with AES 128 CCM 8 or @@ -170,7 +170,7 @@ class Dtls : public InstanceLocator Error Connect(const Ip6::SockAddr &aSockAddr); /** - * This method indicates whether or not the DTLS session is active. + * Indicates whether or not the DTLS session is active. * * @retval TRUE If DTLS session is active. * @retval FALSE If DTLS session is not active. @@ -179,7 +179,7 @@ class Dtls : public InstanceLocator bool IsConnectionActive(void) const { return mState >= kStateConnecting; } /** - * This method indicates whether or not the DTLS session is connected. + * Indicates whether or not the DTLS session is connected. * * @retval TRUE The DTLS session is connected. * @retval FALSE The DTLS session is not connected. @@ -188,19 +188,19 @@ class Dtls : public InstanceLocator bool IsConnected(void) const { return mState == kStateConnected; } /** - * This method disconnects the DTLS session. + * Disconnects the DTLS session. * */ void Disconnect(void); /** - * This method closes the DTLS socket. + * Closes the DTLS socket. * */ void Close(void); /** - * This method sets the PSK. + * Sets the PSK. * * @param[in] aPsk A pointer to the PSK. * @@ -213,7 +213,7 @@ class Dtls : public InstanceLocator #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE #ifdef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED /** - * This method sets the Pre-Shared Key (PSK) for DTLS sessions- + * Sets the Pre-Shared Key (PSK) for DTLS sessions- * identified by a PSK. * * DTLS mode "PSK with AES 128 CCM 8" for Application CoAPS. @@ -232,7 +232,7 @@ class Dtls : public InstanceLocator #ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED /** - * This method sets a reference to the own x509 certificate with corresponding private key. + * Sets a reference to the own x509 certificate with corresponding private key. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. * @@ -248,7 +248,7 @@ class Dtls : public InstanceLocator uint32_t aPrivateKeyLength); /** - * This method sets the trusted top level CAs. It is needed for validate the + * Sets the trusted top level CAs. It is needed for validate the * certificate of the peer. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. @@ -262,7 +262,7 @@ class Dtls : public InstanceLocator #if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) /** - * This method returns the peer x509 certificate base64 encoded. + * Returns the peer x509 certificate base64 encoded. * * DTLS mode "ECDHE ECDSA with AES 128 CCM 8" for Application CoAPS. * @@ -279,7 +279,7 @@ class Dtls : public InstanceLocator #endif // defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) /** - * This method set the authentication mode for a dtls connection. + * Set the authentication mode for a dtls connection. * * Disable or enable the verification of peer certificate. * Must called before start. @@ -292,7 +292,7 @@ class Dtls : public InstanceLocator #ifdef MBEDTLS_SSL_SRV_C /** - * This method sets the Client ID used for generating the Hello Cookie. + * Sets the Client ID used for generating the Hello Cookie. * * @param[in] aClientId A pointer to the Client ID. * @param[in] aLength Number of bytes in the Client ID. @@ -304,7 +304,7 @@ class Dtls : public InstanceLocator #endif /** - * This method sends data within the DTLS session. + * Sends data within the DTLS session. * * @param[in] aMessage A message to send via DTLS. * @param[in] aLength Number of bytes in the data buffer. @@ -316,7 +316,7 @@ class Dtls : public InstanceLocator Error Send(Message &aMessage, uint16_t aLength); /** - * This method provides a received DTLS message to the DTLS object. + * Provides a received DTLS message to the DTLS object. * * @param[in] aMessage A reference to the message. * @@ -324,7 +324,7 @@ class Dtls : public InstanceLocator void Receive(Message &aMessage); /** - * This method sets the default message sub-type that will be used for all messages without defined + * Sets the default message sub-type that will be used for all messages without defined * sub-type. * * @param[in] aMessageSubType The default message sub-type. @@ -333,7 +333,7 @@ class Dtls : public InstanceLocator void SetDefaultMessageSubType(Message::SubType aMessageSubType) { mMessageDefaultSubType = aMessageSubType; } /** - * This method returns the DTLS session's peer address. + * Returns the DTLS session's peer address. * * @return DTLS session's message info. * diff --git a/src/core/meshcop/energy_scan_client.hpp b/src/core/meshcop/energy_scan_client.hpp index 97d9873bb9b..8e40060b1dc 100644 --- a/src/core/meshcop/energy_scan_client.hpp +++ b/src/core/meshcop/energy_scan_client.hpp @@ -50,7 +50,7 @@ namespace ot { /** - * This class implements handling PANID Query Requests. + * Implements handling PANID Query Requests. * */ class EnergyScanClient : public InstanceLocator @@ -59,13 +59,13 @@ class EnergyScanClient : public InstanceLocator public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit EnergyScanClient(Instance &aInstance); /** - * This method sends an Energy Scan Query message. + * Sends an Energy Scan Query message. * * @param[in] aChannelMask The channel mask value. * @param[in] aCount The number of energy measurements per channel. diff --git a/src/core/meshcop/extended_panid.hpp b/src/core/meshcop/extended_panid.hpp index 9bf5cf91a1d..2ea04aace4b 100644 --- a/src/core/meshcop/extended_panid.hpp +++ b/src/core/meshcop/extended_panid.hpp @@ -50,7 +50,7 @@ namespace ot { namespace MeshCoP { /** - * This class represents an Extended PAN Identifier. + * Represents an Extended PAN Identifier. * */ OT_TOOL_PACKED_BEGIN @@ -60,13 +60,13 @@ class ExtendedPanId : public otExtendedPanId, public Equatable, p static constexpr uint16_t kInfoStringSize = 17; ///< Max chars for the info string (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method converts an address to a string. + * Converts an address to a string. * * @returns An `InfoString` containing the string representation of the Extended PAN Identifier. * @@ -87,7 +87,7 @@ class ExtendedPanIdManager : public InstanceLocator, private NonCopyable explicit ExtendedPanIdManager(Instance &aInstance); /** - * This method returns the Extended PAN Identifier. + * Returns the Extended PAN Identifier. * * @returns The Extended PAN Identifier. * @@ -95,7 +95,7 @@ class ExtendedPanIdManager : public InstanceLocator, private NonCopyable const ExtendedPanId &GetExtPanId(void) const { return mExtendedPanId; } /** - * This method sets the Extended PAN Identifier. + * Sets the Extended PAN Identifier. * * @param[in] aExtendedPanId The Extended PAN Identifier. * diff --git a/src/core/meshcop/joiner.hpp b/src/core/meshcop/joiner.hpp index 81e4b2bbbd1..1b42c6ad344 100644 --- a/src/core/meshcop/joiner.hpp +++ b/src/core/meshcop/joiner.hpp @@ -65,7 +65,7 @@ class Joiner : public InstanceLocator, private NonCopyable public: /** - * This enumeration type defines the Joiner State. + * Type defines the Joiner State. * */ enum State : uint8_t @@ -79,7 +79,7 @@ class Joiner : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the Joiner object. + * Initializes the Joiner object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -87,7 +87,7 @@ class Joiner : public InstanceLocator, private NonCopyable explicit Joiner(Instance &aInstance); /** - * This method starts the Joiner service. + * Starts the Joiner service. * * @param[in] aPskd A pointer to the PSKd. * @param[in] aProvisioningUrl A pointer to the Provisioning URL (may be `nullptr`). @@ -113,13 +113,13 @@ class Joiner : public InstanceLocator, private NonCopyable void *aContext); /** - * This method stops the Joiner service. + * Stops the Joiner service. * */ void Stop(void); /** - * This method gets the Joiner State. + * Gets the Joiner State. * * @returns The Joiner state (see `State`). * @@ -127,7 +127,7 @@ class Joiner : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method retrieves the Joiner ID. + * Retrieves the Joiner ID. * * @returns The Joiner ID. * @@ -135,7 +135,7 @@ class Joiner : public InstanceLocator, private NonCopyable const Mac::ExtAddress &GetId(void) const { return mId; } /** - * This method gets the Jointer Discerner. + * Gets the Jointer Discerner. * * @returns A pointer to the current Joiner Discerner or `nullptr` if none is set. * @@ -143,7 +143,7 @@ class Joiner : public InstanceLocator, private NonCopyable const JoinerDiscerner *GetDiscerner(void) const; /** - * This method sets the Joiner Discerner. + * Sets the Joiner Discerner. * * The Joiner Discerner is used to calculate the Joiner ID used during commissioning/joining process. * @@ -161,7 +161,7 @@ class Joiner : public InstanceLocator, private NonCopyable Error SetDiscerner(const JoinerDiscerner &aDiscerner); /** - * This method clears any previously set Joiner Discerner. + * Clears any previously set Joiner Discerner. * * When cleared, Joiner ID is derived as first 64 bits of SHA-256 of factory-assigned IEEE EUI-64. * @@ -172,7 +172,7 @@ class Joiner : public InstanceLocator, private NonCopyable Error ClearDiscerner(void); /** - * This method converts a given Joiner state to its human-readable string representation. + * Converts a given Joiner state to its human-readable string representation. * * @param[in] aState The Joiner state to convert. * diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp index 4831c2f2bf1..d17c6429068 100644 --- a/src/core/meshcop/joiner_router.hpp +++ b/src/core/meshcop/joiner_router.hpp @@ -61,7 +61,7 @@ class JoinerRouter : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the Joiner Router object. + * Initializes the Joiner Router object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -69,7 +69,7 @@ class JoinerRouter : public InstanceLocator, private NonCopyable explicit JoinerRouter(Instance &aInstance); /** - * This method returns the Joiner UDP Port. + * Returns the Joiner UDP Port. * * @returns The Joiner UDP Port number . * @@ -77,7 +77,7 @@ class JoinerRouter : public InstanceLocator, private NonCopyable uint16_t GetJoinerUdpPort(void); /** - * This method sets the Joiner UDP Port. + * Sets the Joiner UDP Port. * * @param[in] aJoinerUdpPort The Joiner UDP Port number. * diff --git a/src/core/meshcop/meshcop.hpp b/src/core/meshcop/meshcop.hpp index a1485dbca53..7bf6f7806ce 100644 --- a/src/core/meshcop/meshcop.hpp +++ b/src/core/meshcop/meshcop.hpp @@ -60,7 +60,7 @@ class ThreadNetif; namespace MeshCoP { /** - * This type represents a Joiner PSKd. + * Represents a Joiner PSKd. * */ class JoinerPskd : public otJoinerPskd, public Clearable, public Unequatable @@ -70,7 +70,7 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une static constexpr uint8_t kMaxLength = OT_JOINER_MAX_PSKD_LENGTH; ///< Max PSKd string length (excludes null char) /** - * This method indicates whether the PSKd if well-formed and valid. + * Indicates whether the PSKd if well-formed and valid. * * Per Thread specification, a Joining Device Credential is encoded as uppercase alphanumeric characters * (base32-thread: 0-9, A-Z excluding I, O, Q, and Z for readability) with a minimum length of 6 such characters @@ -82,7 +82,7 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une bool IsValid(void) const { return IsPskdValid(m8); } /** - * This method sets the joiner PSKd from a given C string. + * Sets the joiner PSKd from a given C string. * * @param[in] aPskdString A pointer to the PSKd C string array. * @@ -93,9 +93,9 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une Error SetFrom(const char *aPskdString); /** - * This method gets the PSKd as a null terminated C string. + * Gets the PSKd as a null terminated C string. * - * This method must be used after the PSKd is validated, otherwise its behavior is undefined. + * Must be used after the PSKd is validated, otherwise its behavior is undefined. * * @returns The PSKd as a C string. * @@ -103,9 +103,9 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une const char *GetAsCString(void) const { return m8; } /** - * This method gets the PSKd string length. + * Gets the PSKd string length. * - * This method must be used after the PSKd is validated, otherwise its behavior is undefined. + * Must be used after the PSKd is validated, otherwise its behavior is undefined. * * @returns The PSKd string length. * @@ -113,7 +113,7 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une uint8_t GetLength(void) const { return static_cast(StringLength(m8, kMaxLength + 1)); } /** - * This method overloads operator `==` to evaluate whether or not two PSKds are equal. + * Overloads operator `==` to evaluate whether or not two PSKds are equal. * * @param[in] aOther The other PSKd to compare with. * @@ -124,7 +124,7 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une bool operator==(const JoinerPskd &aOther) const; /** - * This static method indicates whether a given PSKd string if well-formed and valid. + * Indicates whether a given PSKd string if well-formed and valid. * * @param[in] aPskdString A pointer to a PSKd string array. * @@ -137,7 +137,7 @@ class JoinerPskd : public otJoinerPskd, public Clearable, public Une }; /** - * This type represents a Joiner Discerner. + * Represents a Joiner Discerner. * */ class JoinerDiscerner : public otJoinerDiscerner, public Unequatable @@ -150,19 +150,19 @@ class JoinerDiscerner : public otJoinerDiscerner, public Unequatable InfoString; /** - * This method clears the Joiner Discerner. + * Clears the Joiner Discerner. * */ void Clear(void) { mLength = 0; } /** - * This method indicates whether the Joiner Discerner is empty (no value set). + * Indicates whether the Joiner Discerner is empty (no value set). * * @returns TRUE if empty, FALSE otherwise. * @@ -170,7 +170,7 @@ class JoinerDiscerner : public otJoinerDiscerner, public Unequatable 0) && DoesAllMatch(kPermitAll); } /** - * This method indicates whether the bloom filter contains a given Joiner ID. + * Indicates whether the bloom filter contains a given Joiner ID. * * @param[in] aJoinerId A Joiner ID. * @@ -349,7 +349,7 @@ class SteeringData : public otSteeringData bool Contains(const Mac::ExtAddress &aJoinerId) const; /** - * This method indicates whether the bloom filter contains a given Joiner Discerner. + * Indicates whether the bloom filter contains a given Joiner Discerner. * * @param[in] aDiscerner A Joiner Discerner. * @@ -359,7 +359,7 @@ class SteeringData : public otSteeringData bool Contains(const JoinerDiscerner &aDiscerner) const; /** - * This method indicates whether the bloom filter contains the hash bit indexes (derived from a Joiner ID). + * Indicates whether the bloom filter contains the hash bit indexes (derived from a Joiner ID). * * @param[in] aIndexes A hash bit index structure (derived from a Joiner ID). * @@ -369,7 +369,7 @@ class SteeringData : public otSteeringData bool Contains(const HashBitIndexes &aIndexes) const; /** - * This static method calculates the bloom filter hash bit indexes from a given Joiner ID. + * Calculates the bloom filter hash bit indexes from a given Joiner ID. * * The first hash bit index is derived using CRC16-CCITT and second one using CRC16-ANSI. * @@ -380,7 +380,7 @@ class SteeringData : public otSteeringData static void CalculateHashBitIndexes(const Mac::ExtAddress &aJoinerId, HashBitIndexes &aIndexes); /** - * This static method calculates the bloom filter hash bit indexes from a given Joiner Discerner. + * Calculates the bloom filter hash bit indexes from a given Joiner Discerner. * * The first hash bit index is derived using CRC16-CCITT and second one using CRC16-ANSI. * @@ -407,7 +407,7 @@ class SteeringData : public otSteeringData }; /** - * This function generates PSKc. + * Generates PSKc. * * PSKc is used to establish the Commissioner Session. * @@ -426,7 +426,7 @@ Error GeneratePskc(const char *aPassPhrase, Pskc &aPskc); /** - * This function computes the Joiner ID from a factory-assigned IEEE EUI-64. + * Computes the Joiner ID from a factory-assigned IEEE EUI-64. * * @param[in] aEui64 The factory-assigned IEEE EUI-64. * @param[out] aJoinerId The Joiner ID. @@ -435,7 +435,7 @@ Error GeneratePskc(const char *aPassPhrase, void ComputeJoinerId(const Mac::ExtAddress &aEui64, Mac::ExtAddress &aJoinerId); /** - * This function gets the border agent RLOC. + * Gets the border agent RLOC. * * @param[in] aNetIf A reference to the thread interface. * @param[out] aRloc Border agent RLOC. @@ -448,7 +448,7 @@ Error GetBorderAgentRloc(ThreadNetif &aNetIf, uint16_t &aRloc); #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) /** - * This function emits a log message indicating an error during a MeshCoP action. + * Emits a log message indicating an error during a MeshCoP action. * * Note that log message is emitted only if there is an error, i.e. @p aError is not `kErrorNone`. The log * message will have the format "Failed to {aActionText} : {ErrorString}". diff --git a/src/core/meshcop/meshcop_leader.hpp b/src/core/meshcop/meshcop_leader.hpp index fa2a288d78a..7a78ff9f2dd 100644 --- a/src/core/meshcop/meshcop_leader.hpp +++ b/src/core/meshcop/meshcop_leader.hpp @@ -70,7 +70,7 @@ class Leader : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the Leader object. + * Initializes the Leader object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -78,7 +78,7 @@ class Leader : public InstanceLocator, private NonCopyable explicit Leader(Instance &aInstance); /** - * This method sends a MGMT_DATASET_CHANGED message to commissioner. + * Sends a MGMT_DATASET_CHANGED message to commissioner. * * @param[in] aAddress The IPv6 address of destination. * @@ -86,7 +86,7 @@ class Leader : public InstanceLocator, private NonCopyable void SendDatasetChanged(const Ip6::Address &aAddress); /** - * This method sets minimal delay timer. + * Sets minimal delay timer. * * @param[in] aDelayTimerMinimal The value of minimal delay timer (in ms). * @@ -97,7 +97,7 @@ class Leader : public InstanceLocator, private NonCopyable Error SetDelayTimerMinimal(uint32_t aDelayTimerMinimal); /** - * This method gets minimal delay timer. + * Gets minimal delay timer. * * @retval the minimal delay timer (in ms). * @@ -105,7 +105,7 @@ class Leader : public InstanceLocator, private NonCopyable uint32_t GetDelayTimerMinimal(void) const; /** - * This method sets empty Commissioner Data TLV in the Thread Network Data. + * Sets empty Commissioner Data TLV in the Thread Network Data. * */ void SetEmptyCommissionerData(void); diff --git a/src/core/meshcop/meshcop_tlvs.cpp b/src/core/meshcop/meshcop_tlvs.cpp index 8a0e3ee0f2f..399b7102dfb 100644 --- a/src/core/meshcop/meshcop_tlvs.cpp +++ b/src/core/meshcop/meshcop_tlvs.cpp @@ -359,8 +359,7 @@ uint32_t ChannelMaskTlv::GetChannelMask(const Message &aMessage) uint16_t offset; uint16_t end; - SuccessOrExit(FindTlvValueOffset(aMessage, kChannelMask, offset, end)); - end += offset; + SuccessOrExit(FindTlvValueStartEndOffsets(aMessage, kChannelMask, offset, end)); while (offset + sizeof(ChannelMaskEntryBase) <= end) { diff --git a/src/core/meshcop/meshcop_tlvs.hpp b/src/core/meshcop/meshcop_tlvs.hpp index 1cd2755059c..0b04a4ff0d5 100644 --- a/src/core/meshcop/meshcop_tlvs.hpp +++ b/src/core/meshcop/meshcop_tlvs.hpp @@ -65,7 +65,7 @@ using ot::Encoding::BigEndian::ReadUint24; using ot::Encoding::BigEndian::WriteUint24; /** - * This class implements MeshCoP TLV generation and parsing. + * Implements MeshCoP TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -132,7 +132,7 @@ class Tlv : public ot::Tlv static constexpr uint8_t kMaxVendorDataLength = 64; ///< Max length of Vendor Data TLV. /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -140,7 +140,7 @@ class Tlv : public ot::Tlv Type GetType(void) const { return static_cast(ot::Tlv::GetType()); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -148,7 +148,7 @@ class Tlv : public ot::Tlv void SetType(Type aType) { ot::Tlv::SetType(static_cast(aType)); } /** - * This method returns a pointer to the next TLV. + * Returns a pointer to the next TLV. * * @returns A pointer to the next TLV. * @@ -156,7 +156,7 @@ class Tlv : public ot::Tlv Tlv *GetNext(void) { return As(ot::Tlv::GetNext()); } /** - * This method returns a pointer to the next TLV. + * Returns a pointer to the next TLV. * * @returns A pointer to the next TLV. * @@ -164,7 +164,7 @@ class Tlv : public ot::Tlv const Tlv *GetNext(void) const { return As(ot::Tlv::GetNext()); } /** - * This static method reads the requested TLV out of @p aMessage. + * Reads the requested TLV out of @p aMessage. * * @param[in] aMessage A reference to the message. * @param[in] aType The Type value to search for. @@ -181,9 +181,9 @@ class Tlv : public ot::Tlv } /** - * This static method reads the requested TLV out of @p aMessage. + * Reads the requested TLV out of @p aMessage. * - * This method can be used independent of whether the read TLV (from message) is an Extended TLV or not. + * Can be used independent of whether the read TLV (from message) is an Extended TLV or not. * * @tparam TlvType The TlvType to search for (must be a sub-class of `Tlv`). * @@ -201,7 +201,7 @@ class Tlv : public ot::Tlv } /** - * This static method indicates whether a TLV appears to be well-formed. + * Indicates whether a TLV appears to be well-formed. * * @param[in] aTlv A reference to the TLV. * @@ -211,7 +211,7 @@ class Tlv : public ot::Tlv static bool IsValid(const Tlv &aTlv); /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given template Type. + * Searches in a given sequence of TLVs to find the first TLV with a given template Type. * * @param[in] aTlvsStart A pointer to the start of the sequence of TLVs to search within. * @param[in] aTlvsLength The length (number of bytes) in TLV sequence. @@ -226,7 +226,7 @@ class Tlv : public ot::Tlv } /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given template Type. + * Searches in a given sequence of TLVs to find the first TLV with a given template Type. * * @param[in] aTlvsStart A pointer to the start of the sequence of TLVs to search within. * @param[in] aTlvsLength The length (number of bytes) in TLV sequence. @@ -270,7 +270,7 @@ class Tlv : public ot::Tlv } OT_TOOL_PACKED_END; /** - * This class implements extended MeshCoP TLV generation and parsing. + * Implements extended MeshCoP TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -278,7 +278,7 @@ class ExtendedTlv : public ot::ExtendedTlv { public: /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -286,7 +286,7 @@ class ExtendedTlv : public ot::ExtendedTlv MeshCoP::Tlv::Type GetType(void) const { return static_cast(ot::ExtendedTlv::GetType()); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -295,55 +295,55 @@ class ExtendedTlv : public ot::ExtendedTlv } OT_TOOL_PACKED_END; /** - * This class defines Commissioner UDP Port TLV constants and types. + * Defines Commissioner UDP Port TLV constants and types. * */ typedef UintTlvInfo CommissionerUdpPortTlv; /** - * This class defines IPv6 Address TLV constants and types. + * Defines IPv6 Address TLV constants and types. * */ typedef SimpleTlvInfo Ip6AddressTlv; /** - * This class defines Joiner IID TLV constants and types. + * Defines Joiner IID TLV constants and types. * */ typedef SimpleTlvInfo JoinerIidTlv; /** - * This class defines Joiner Router Locator TLV constants and types. + * Defines Joiner Router Locator TLV constants and types. * */ typedef UintTlvInfo JoinerRouterLocatorTlv; /** - * This class defines Joiner Router KEK TLV constants and types. + * Defines Joiner Router KEK TLV constants and types. * */ typedef SimpleTlvInfo JoinerRouterKekTlv; /** - * This class defines Count TLV constants and types. + * Defines Count TLV constants and types. * */ typedef UintTlvInfo CountTlv; /** - * This class defines Period TLV constants and types. + * Defines Period TLV constants and types. * */ typedef UintTlvInfo PeriodTlv; /** - * This class defines Scan Duration TLV constants and types. + * Defines Scan Duration TLV constants and types. * */ typedef UintTlvInfo ScanDurationTlv; /** - * This class implements Channel TLV generation and parsing. + * Implements Channel TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -351,7 +351,7 @@ class ChannelTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -361,7 +361,7 @@ class ChannelTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -370,7 +370,7 @@ class ChannelTlv : public Tlv, public TlvInfo bool IsValid(void) const; /** - * This method returns the ChannelPage value. + * Returns the ChannelPage value. * * @returns The ChannelPage value. * @@ -378,7 +378,7 @@ class ChannelTlv : public Tlv, public TlvInfo uint8_t GetChannelPage(void) const { return mChannelPage; } /** - * This method sets the ChannelPage value. + * Sets the ChannelPage value. * * @param[in] aChannelPage The ChannelPage value. * @@ -386,7 +386,7 @@ class ChannelTlv : public Tlv, public TlvInfo void SetChannelPage(uint8_t aChannelPage) { mChannelPage = aChannelPage; } /** - * This method returns the Channel value. + * Returns the Channel value. * * @returns The Channel value. * @@ -394,7 +394,7 @@ class ChannelTlv : public Tlv, public TlvInfo uint16_t GetChannel(void) const { return HostSwap16(mChannel); } /** - * This method sets the Channel value. + * Sets the Channel value. * Note: This method also sets the channel page according to the channel value. * * @param[in] aChannel The Channel value. @@ -408,7 +408,7 @@ class ChannelTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements PAN ID TLV generation and parsing. + * Implements PAN ID TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -416,7 +416,7 @@ class PanIdTlv : public Tlv, public UintTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -426,7 +426,7 @@ class PanIdTlv : public Tlv, public UintTlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -435,7 +435,7 @@ class PanIdTlv : public Tlv, public UintTlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the PAN ID value. + * Returns the PAN ID value. * * @returns The PAN ID value. * @@ -443,7 +443,7 @@ class PanIdTlv : public Tlv, public UintTlvInfo uint16_t GetPanId(void) const { return HostSwap16(mPanId); } /** - * This method sets the PAN ID value. + * Sets the PAN ID value. * * @param[in] aPanId The PAN ID value. * @@ -455,7 +455,7 @@ class PanIdTlv : public Tlv, public UintTlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Extended PAN ID TLV generation and parsing. + * Implements Extended PAN ID TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -463,7 +463,7 @@ class ExtendedPanIdTlv : public Tlv, public SimpleTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Extended PAN ID value. + * Returns the Extended PAN ID value. * * @returns The Extended PAN ID value. * @@ -490,7 +490,7 @@ class ExtendedPanIdTlv : public Tlv, public SimpleTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -520,7 +520,7 @@ class NetworkNameTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -529,7 +529,7 @@ class NetworkNameTlv : public Tlv, public TlvInfo bool IsValid(void) const; /** - * This method gets the Network Name value. + * Gets the Network Name value. * * @returns The Network Name value (as `NameData`). * @@ -537,7 +537,7 @@ class NetworkNameTlv : public Tlv, public TlvInfo NameData GetNetworkName(void) const; /** - * This method sets the Network Name value. + * Sets the Network Name value. * * @param[in] aNameData A Network Name value (as `NameData`). * @@ -549,7 +549,7 @@ class NetworkNameTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements PSKc TLV generation and parsing. + * Implements PSKc TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -557,7 +557,7 @@ class PskcTlv : public Tlv, public SimpleTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -567,7 +567,7 @@ class PskcTlv : public Tlv, public SimpleTlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -576,7 +576,7 @@ class PskcTlv : public Tlv, public SimpleTlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the PSKc value. + * Returns the PSKc value. * * @returns The PSKc value. * @@ -584,7 +584,7 @@ class PskcTlv : public Tlv, public SimpleTlvInfo const Pskc &GetPskc(void) const { return mPskc; } /** - * This method sets the PSKc value. + * Sets the PSKc value. * * @param[in] aPskc A pointer to the PSKc value. * @@ -596,7 +596,7 @@ class PskcTlv : public Tlv, public SimpleTlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Network Network Key TLV generation and parsing. + * Implements Network Network Key TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -604,7 +604,7 @@ class NetworkKeyTlv : public Tlv, public SimpleTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Network Network Key value. + * Returns the Network Network Key value. * * @returns The Network Network Key value. * @@ -631,7 +631,7 @@ class NetworkKeyTlv : public Tlv, public SimpleTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Network Key Sequence value. + * Returns the Network Key Sequence value. * * @returns The Network Key Sequence value. * @@ -678,7 +678,7 @@ class NetworkKeySequenceTlv : public Tlv, public UintTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the size (in bytes) of the Mesh Local Prefix field. + * Returns the size (in bytes) of the Mesh Local Prefix field. * * @returns The size (in bytes) of the Mesh Local Prefix field (8 bytes). * @@ -725,7 +725,7 @@ class MeshLocalPrefixTlv : public Tlv, public SimpleTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -766,7 +766,7 @@ class SteeringDataTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -775,7 +775,7 @@ class SteeringDataTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() > 0; } /** - * This method returns the Steering Data length. + * Returns the Steering Data length. * * @returns The Steering Data length. * @@ -786,13 +786,13 @@ class SteeringDataTlv : public Tlv, public TlvInfo } /** - * This method sets all bits in the Bloom Filter to zero. + * Sets all bits in the Bloom Filter to zero. * */ void Clear(void) { memset(mSteeringData, 0, GetSteeringDataLength()); } /** - * This method copies the Steering Data from the TLV into a given `SteeringData` variable. + * Copies the Steering Data from the TLV into a given `SteeringData` variable. * * @param[out] aSteeringData A reference to a `SteeringData` to copy into. * @@ -804,7 +804,7 @@ class SteeringDataTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Border Agent Locator TLV generation and parsing. + * Implements Border Agent Locator TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -812,7 +812,7 @@ class BorderAgentLocatorTlv : public Tlv, public UintTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Border Agent Locator value. + * Returns the Border Agent Locator value. * * @returns The Border Agent Locator value. * @@ -839,7 +839,7 @@ class BorderAgentLocatorTlv : public Tlv, public UintTlvInfo static constexpr uint8_t kMaxLength = 64; ///< maximum length (bytes) /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -871,7 +871,7 @@ class CommissionerIdTlv : public Tlv, public TlvInfo } /** - * This method returns the Commissioner ID length. + * Returns the Commissioner ID length. * * @returns The Commissioner ID length. * @@ -882,7 +882,7 @@ class CommissionerIdTlv : public Tlv, public TlvInfo } /** - * This method returns the Commissioner ID value. + * Returns the Commissioner ID value. * * @returns The Commissioner ID value. * @@ -890,7 +890,7 @@ class CommissionerIdTlv : public Tlv, public TlvInfo const char *GetCommissionerId(void) const { return mCommissionerId; } /** - * This method sets the Commissioner ID value. + * Sets the Commissioner ID value. * * @param[in] aCommissionerId A pointer to the Commissioner ID value. * @@ -907,7 +907,7 @@ class CommissionerIdTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Commissioner Session ID TLV generation and parsing. + * Implements Commissioner Session ID TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -915,7 +915,7 @@ class CommissionerSessionIdTlv : public Tlv, public UintTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Commissioner Session ID value. + * Returns the Commissioner Session ID value. * * @returns The Commissioner Session ID value. * @@ -942,7 +942,7 @@ class CommissionerSessionIdTlv : public Tlv, public UintTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -972,7 +972,7 @@ class SecurityPolicyTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -981,7 +981,7 @@ class SecurityPolicyTlv : public Tlv, public TlvInfo bool IsValid(void) const; /** - * This method returns the Security Policy. + * Returns the Security Policy. * * @returns The Security Policy. * @@ -989,7 +989,7 @@ class SecurityPolicyTlv : public Tlv, public TlvInfo SecurityPolicy GetSecurityPolicy(void) const; /** - * This method sets the Security Policy. + * Sets the Security Policy. * * @param[in] aSecurityPolicy The Security Policy which will be set. * @@ -1013,7 +1013,7 @@ class SecurityPolicyTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Active Timestamp TLV generation and parsing. + * Implements Active Timestamp TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1021,7 +1021,7 @@ class ActiveTimestampTlv : public Tlv, public SimpleTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method gets the timestamp. + * Gets the timestamp. * * @returns The timestamp. * @@ -1049,7 +1049,7 @@ class ActiveTimestampTlv : public Tlv, public SimpleTlvInfo @@ -1090,7 +1090,7 @@ class StateTlv : public UintTlvInfo }; /** - * This class implements Joiner UDP Port TLV generation and parsing. + * Implements Joiner UDP Port TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1098,7 +1098,7 @@ class JoinerUdpPortTlv : public Tlv, public UintTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the UDP Port value. + * Returns the UDP Port value. * * @returns The UDP Port value. * @@ -1125,7 +1125,7 @@ class JoinerUdpPortTlv : public Tlv, public UintTlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method gets the timestamp. + * Gets the timestamp. * * @returns The timestamp. * @@ -1173,7 +1173,7 @@ class PendingTimestampTlv : public Tlv, public SimpleTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1211,7 +1211,7 @@ class DelayTimerTlv : public Tlv, public UintTlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1220,7 +1220,7 @@ class DelayTimerTlv : public Tlv, public UintTlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Delay Timer value. + * Returns the Delay Timer value. * * @returns The Delay Timer value. * @@ -1228,7 +1228,7 @@ class DelayTimerTlv : public Tlv, public UintTlvInfo uint32_t GetDelayTimer(void) const { return HostSwap32(mDelayTimer); } /** - * This method sets the Delay Timer value. + * Sets the Delay Timer value. * * @param[in] aDelayTimer The Delay Timer value. * @@ -1257,7 +1257,7 @@ class DelayTimerTlv : public Tlv, public UintTlvInfo class ChannelMaskTlv; /** - * This class implements Channel Mask Entry generation and parsing. + * Implements Channel Mask Entry generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1265,7 +1265,7 @@ class ChannelMaskEntryBase { public: /** - * This method gets the ChannelPage value. + * Gets the ChannelPage value. * * @returns The ChannelPage value. * @@ -1273,7 +1273,7 @@ class ChannelMaskEntryBase uint8_t GetChannelPage(void) const { return mChannelPage; } /** - * This method sets the ChannelPage value. + * Sets the ChannelPage value. * * @param[in] aChannelPage The ChannelPage value. * @@ -1281,7 +1281,7 @@ class ChannelMaskEntryBase void SetChannelPage(uint8_t aChannelPage) { mChannelPage = aChannelPage; } /** - * This method gets the MaskLength value. + * Gets the MaskLength value. * * @returns The MaskLength value. * @@ -1289,7 +1289,7 @@ class ChannelMaskEntryBase uint8_t GetMaskLength(void) const { return mMaskLength; } /** - * This method sets the MaskLength value. + * Sets the MaskLength value. * * @param[in] aMaskLength The MaskLength value. * @@ -1297,7 +1297,7 @@ class ChannelMaskEntryBase void SetMaskLength(uint8_t aMaskLength) { mMaskLength = aMaskLength; } /** - * This method returns the total size of this Channel Mask Entry including the mask. + * Returns the total size of this Channel Mask Entry including the mask. * * @returns The total size of this entry (number of bytes). * @@ -1305,7 +1305,7 @@ class ChannelMaskEntryBase uint16_t GetEntrySize(void) const { return sizeof(ChannelMaskEntryBase) + mMaskLength; } /** - * This method clears the bit corresponding to @p aChannel in ChannelMask. + * Clears the bit corresponding to @p aChannel in ChannelMask. * * @param[in] aChannel The channel in ChannelMask to clear. * @@ -1317,7 +1317,7 @@ class ChannelMaskEntryBase } /** - * This method sets the bit corresponding to @p aChannel in ChannelMask. + * Sets the bit corresponding to @p aChannel in ChannelMask. * * @param[in] aChannel The channel in ChannelMask to set. * @@ -1329,7 +1329,7 @@ class ChannelMaskEntryBase } /** - * This method indicates whether or not the bit corresponding to @p aChannel in ChannelMask is set. + * Indicates whether or not the bit corresponding to @p aChannel in ChannelMask is set. * * @param[in] aChannel The channel in ChannelMask to get. * @@ -1341,7 +1341,7 @@ class ChannelMaskEntryBase } /** - * This method gets the next Channel Mask Entry in a Channel Mask TLV. + * Gets the next Channel Mask Entry in a Channel Mask TLV. * * @returns A pointer to next Channel Mask Entry. * @@ -1352,7 +1352,7 @@ class ChannelMaskEntryBase } /** - * This method gets the next Channel Mask Entry in a Channel Mask TLV. + * Gets the next Channel Mask Entry in a Channel Mask TLV. * * @returns A pointer to next Channel Mask Entry. * @@ -1365,7 +1365,7 @@ class ChannelMaskEntryBase } OT_TOOL_PACKED_END; /** - * This class implements Channel Mask Entry Page 0 generation and parsing. + * Implements Channel Mask Entry Page 0 generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1373,7 +1373,7 @@ class ChannelMaskEntry : public ChannelMaskEntryBase { public: /** - * This method initializes the entry. + * Initializes the entry. * */ void Init(void) @@ -1383,7 +1383,7 @@ class ChannelMaskEntry : public ChannelMaskEntryBase } /** - * This method indicates whether or not the entry appears to be well-formed. + * Indicates whether or not the entry appears to be well-formed. * * @retval TRUE If the entry appears to be well-formed. * @retval FALSE If the entry does not appear to be well-formed. @@ -1392,7 +1392,7 @@ class ChannelMaskEntry : public ChannelMaskEntryBase bool IsValid(void) const { return GetMaskLength() == sizeof(mMask); } /** - * This method returns the Channel Mask value as a `uint32_t` bit mask. + * Returns the Channel Mask value as a `uint32_t` bit mask. * * @returns The Channel Mask value. * @@ -1400,7 +1400,7 @@ class ChannelMaskEntry : public ChannelMaskEntryBase uint32_t GetMask(void) const { return Encoding::Reverse32(HostSwap32(mMask)); } /** - * This method sets the Channel Mask value. + * Sets the Channel Mask value. * * @param[in] aMask The Channel Mask value. * @@ -1412,7 +1412,7 @@ class ChannelMaskEntry : public ChannelMaskEntryBase } OT_TOOL_PACKED_END; /** - * This class implements Channel Mask TLV generation and parsing. + * Implements Channel Mask TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1420,7 +1420,7 @@ class ChannelMaskBaseTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1430,7 +1430,7 @@ class ChannelMaskBaseTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1439,7 +1439,7 @@ class ChannelMaskBaseTlv : public Tlv, public TlvInfo bool IsValid(void) const; /** - * This method gets the first Channel Mask Entry in the Channel Mask TLV. + * Gets the first Channel Mask Entry in the Channel Mask TLV. * * @returns A pointer to first Channel Mask Entry or `nullptr` if not found. * @@ -1447,7 +1447,7 @@ class ChannelMaskBaseTlv : public Tlv, public TlvInfo const ChannelMaskEntryBase *GetFirstEntry(void) const; /** - * This method gets the first Channel Mask Entry in the Channel Mask TLV. + * Gets the first Channel Mask Entry in the Channel Mask TLV. * * @returns A pointer to first Channel Mask Entry or `nullptr` if not found. * @@ -1456,7 +1456,7 @@ class ChannelMaskBaseTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Channel Mask TLV generation and parsing. + * Implements Channel Mask TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1464,7 +1464,7 @@ class ChannelMaskTlv : public ChannelMaskBaseTlv { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1475,7 +1475,7 @@ class ChannelMaskTlv : public ChannelMaskBaseTlv } /** - * This method sets the Channel Mask Entries. + * Sets the Channel Mask Entries. * * @param[in] aChannelMask The Channel Mask value. * @@ -1483,7 +1483,7 @@ class ChannelMaskTlv : public ChannelMaskBaseTlv void SetChannelMask(uint32_t aChannelMask); /** - * This method returns the Channel Mask value as a `uint32_t` bit mask. + * Returns the Channel Mask value as a `uint32_t` bit mask. * * @returns The Channel Mask or 0 if not found. * @@ -1491,7 +1491,7 @@ class ChannelMaskTlv : public ChannelMaskBaseTlv uint32_t GetChannelMask(void) const; /** - * This method reads message and returns the Channel Mask value as a `uint32_t` bit mask. + * Reads message and returns the Channel Mask value as a `uint32_t` bit mask. * * @param[in] aMessage A reference to the message. * @@ -1507,7 +1507,7 @@ class ChannelMaskTlv : public ChannelMaskBaseTlv } OT_TOOL_PACKED_END; /** - * This class implements Energy List TLV generation and parsing. + * Implements Energy List TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1515,7 +1515,7 @@ class EnergyListTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1525,7 +1525,7 @@ class EnergyListTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1534,7 +1534,7 @@ class EnergyListTlv : public Tlv, public TlvInfo bool IsValid(void) const { return true; } /** - * This method returns a pointer to the start of energy measurement list. + * Returns a pointer to the start of energy measurement list. * * @returns A pointer to the start start of energy energy measurement list. * @@ -1542,7 +1542,7 @@ class EnergyListTlv : public Tlv, public TlvInfo const uint8_t *GetEnergyList(void) const { return mEnergyList; } /** - * This method returns the length of energy measurement list. + * Returns the length of energy measurement list. * * @returns The length of energy measurement list. * @@ -1556,37 +1556,37 @@ class EnergyListTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class defines Provisioning TLV constants and types. + * Defines Provisioning TLV constants and types. * */ typedef StringTlvInfo ProvisioningUrlTlv; /** - * This class defines Vendor Name TLV constants and types. + * Defines Vendor Name TLV constants and types. * */ typedef StringTlvInfo VendorNameTlv; /** - * This class defines Vendor Model TLV constants and types. + * Defines Vendor Model TLV constants and types. * */ typedef StringTlvInfo VendorModelTlv; /** - * This class defines Vendor SW Version TLV constants and types. + * Defines Vendor SW Version TLV constants and types. * */ typedef StringTlvInfo VendorSwVersionTlv; /** - * This class defines Vendor Data TLV constants and types. + * Defines Vendor Data TLV constants and types. * */ typedef StringTlvInfo VendorDataTlv; /** - * This class implements Vendor Stack Version TLV generation and parsing. + * Implements Vendor Stack Version TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1604,7 +1604,7 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Stack Vendor OUI value. + * Returns the Stack Vendor OUI value. * * @returns The Vendor Stack Vendor OUI value. * @@ -1631,7 +1631,7 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo> kBuildOffset; } /** - * This method sets the Build value. + * Sets the Build value. * * @param[in] aBuild The Build value. * @@ -1659,7 +1659,7 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo> kRevOffset; } /** - * This method sets the Revision value. + * Sets the Revision value. * * @param[in] aRevision The Revision value. * @@ -1678,7 +1678,7 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo> kMinorOffset; } /** - * This method sets the Minor value. + * Sets the Minor value. * * @param[in] aMinor The Minor value. * @@ -1697,7 +1697,7 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo> kMajorOffset; } /** - * This method sets the Major value. + * Sets the Major value. * * @param[in] aMajor The Major value. * @@ -1734,13 +1734,13 @@ class VendorStackVersionTlv : public Tlv, public TlvInfo UdpEncapsulationTlv; /** - * This class represents UDP Encapsulation TLV value header (source and destination ports). + * Represents UDP Encapsulation TLV value header (source and destination ports). * */ OT_TOOL_PACKED_BEGIN @@ -1748,7 +1748,7 @@ class UdpEncapsulationTlvHeader { public: /** - * This method returns the source port. + * Returns the source port. * * @returns The source port. * @@ -1756,7 +1756,7 @@ class UdpEncapsulationTlvHeader uint16_t GetSourcePort(void) const { return HostSwap16(mSourcePort); } /** - * This method updates the source port. + * Updates the source port. * * @param[in] aSourcePort The source port. * @@ -1764,7 +1764,7 @@ class UdpEncapsulationTlvHeader void SetSourcePort(uint16_t aSourcePort) { mSourcePort = HostSwap16(aSourcePort); } /** - * This method returns the destination port. + * Returns the destination port. * * @returns The destination port. * @@ -1772,7 +1772,7 @@ class UdpEncapsulationTlvHeader uint16_t GetDestinationPort(void) const { return HostSwap16(mDestinationPort); } /** - * This method updates the destination port. + * Updates the destination port. * * @param[in] aDestinationPort The destination port. * @@ -1786,7 +1786,7 @@ class UdpEncapsulationTlvHeader } OT_TOOL_PACKED_END; /** - * This class implements Discovery Request TLV generation and parsing. + * Implements Discovery Request TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1794,7 +1794,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1806,7 +1806,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1815,7 +1815,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Version value. + * Returns the Version value. * * @returns The Version value. * @@ -1823,7 +1823,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo uint8_t GetVersion(void) const { return mFlags >> kVersionOffset; } /** - * This method sets the Version value. + * Sets the Version value. * * @param[in] aVersion The Version value. * @@ -1834,7 +1834,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the Joiner flag is set. + * Indicates whether or not the Joiner flag is set. * * @retval TRUE If the Joiner flag is set. * @retval FALSE If the Joiner flag is not set. @@ -1843,7 +1843,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo bool IsJoiner(void) const { return (mFlags & kJoinerMask) != 0; } /** - * This method sets the Joiner flag. + * Sets the Joiner flag. * * @param[in] aJoiner TRUE if set, FALSE otherwise. * @@ -1871,7 +1871,7 @@ class DiscoveryRequestTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Discovery Response TLV generation and parsing. + * Implements Discovery Response TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1879,7 +1879,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1891,7 +1891,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1900,7 +1900,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Version value. + * Returns the Version value. * * @returns The Version value. * @@ -1908,7 +1908,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo uint8_t GetVersion(void) const { return mFlags >> kVersionOffset; } /** - * This method sets the Version value. + * Sets the Version value. * * @param[in] aVersion The Version value. * @@ -1919,7 +1919,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the Native Commissioner flag is set. + * Indicates whether or not the Native Commissioner flag is set. * * @retval TRUE If the Native Commissioner flag is set. * @retval FALSE If the Native Commissioner flag is not set. @@ -1928,7 +1928,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo bool IsNativeCommissioner(void) const { return (mFlags & kNativeMask) != 0; } /** - * This method sets the Native Commissioner flag. + * Sets the Native Commissioner flag. * * @param[in] aNativeCommissioner TRUE if set, FALSE otherwise. * @@ -1946,7 +1946,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the Commercial Commissioning Mode flag is set. + * Indicates whether or not the Commercial Commissioning Mode flag is set. * * @retval TRUE If the Commercial Commissioning Mode flag is set. * @retval FALSE If the Commercial Commissioning Mode flag is not set. @@ -1955,7 +1955,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo bool IsCommercialCommissioningMode(void) const { return (mFlags & kCCMMask) != 0; } /** - * This method sets the Commercial Commissioning Mode flag. + * Sets the Commercial Commissioning Mode flag. * * @param[in] aCCM TRUE if set, FALSE otherwise. * @@ -1985,7 +1985,7 @@ class DiscoveryResponseTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Joiner Advertisement TLV generation and parsing. + * Implements Joiner Advertisement TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1995,7 +1995,7 @@ class JoinerAdvertisementTlv : public Tlv, public TlvInfo= sizeof(mOui) && GetLength() <= sizeof(mOui) + sizeof(mAdvData); } /** - * This method returns the Vendor OUI value. + * Returns the Vendor OUI value. * * @returns The Vendor OUI value. * @@ -2022,7 +2022,7 @@ class JoinerAdvertisementTlv : public Tlv, public TlvInfo public: /** - * This constructor initializes the NameData object. + * Initializes the NameData object. * * @param[in] aBuffer A pointer to a `char` buffer (does not need to be null terminated). * @param[in] aLength The length (number of chars) in the buffer. @@ -70,7 +70,7 @@ class NameData : private Data NameData(const char *aBuffer, uint8_t aLength) { Init(aBuffer, aLength); } /** - * This method returns the pointer to char buffer (not necessarily null terminated). + * Returns the pointer to char buffer (not necessarily null terminated). * * @returns The pointer to the char buffer. * @@ -78,7 +78,7 @@ class NameData : private Data const char *GetBuffer(void) const { return reinterpret_cast(GetBytes()); } /** - * This method returns the length (number of chars in buffer). + * Returns the length (number of chars in buffer). * * @returns The name length. * @@ -86,7 +86,7 @@ class NameData : private Data uint8_t GetLength(void) const { return Data::GetLength(); } /** - * This method copies the name data into a given char buffer with a given size. + * Copies the name data into a given char buffer with a given size. * * The given buffer is cleared (`memset` to zero) before copying the name into it. The copied string * in @p aBuffer is NOT necessarily null terminated. @@ -101,7 +101,7 @@ class NameData : private Data }; /** - * This structure represents an Network Name. + * Represents an Network Name. * */ class NetworkName : public otNetworkName, public Unequatable @@ -117,13 +117,13 @@ class NetworkName : public otNetworkName, public Unequatable static constexpr uint8_t kMaxSize = OT_NETWORK_NAME_MAX_SIZE; /** - * This constructor initializes the Network Name as an empty string. + * Initializes the Network Name as an empty string. * */ NetworkName(void) { m8[0] = '\0'; } /** - * This method gets the Network Name as a null terminated C string. + * Gets the Network Name as a null terminated C string. * * @returns The Network Name as a null terminated C string array. * @@ -131,7 +131,7 @@ class NetworkName : public otNetworkName, public Unequatable const char *GetAsCString(void) const { return m8; } /** - * This method gets the Network Name as NameData. + * Gets the Network Name as NameData. * * @returns The Network Name as NameData. * @@ -139,9 +139,9 @@ class NetworkName : public otNetworkName, public Unequatable NameData GetAsData(void) const; /** - * This method sets the Network Name from a given null terminated C string. + * Sets the Network Name from a given null terminated C string. * - * This method also validates that the given @p aNameString follows UTF-8 encoding and can fit in `kMaxSize` + * Also validates that the given @p aNameString follows UTF-8 encoding and can fit in `kMaxSize` * chars. * * @param[in] aNameString A name C string. @@ -154,7 +154,7 @@ class NetworkName : public otNetworkName, public Unequatable Error Set(const char *aNameString); /** - * This method sets the Network Name. + * Sets the Network Name. * * @param[in] aNameData A reference to name data. * @@ -166,7 +166,7 @@ class NetworkName : public otNetworkName, public Unequatable Error Set(const NameData &aNameData); /** - * This method overloads operator `==` to evaluate whether or not two given `NetworkName` objects are equal. + * Overloads operator `==` to evaluate whether or not two given `NetworkName` objects are equal. * * @param[in] aOther The other `NetworkName` to compare with. * @@ -179,14 +179,14 @@ class NetworkName : public otNetworkName, public Unequatable #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) /** - * This type represents a Thread Domain Name. + * Represents a Thread Domain Name. * */ typedef NetworkName DomainName; #endif /** - * This class manages the Network Name value. + * Manages the Network Name value. * */ class NetworkNameManager : public InstanceLocator, private NonCopyable @@ -201,7 +201,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable explicit NetworkNameManager(Instance &aInstance); /** - * This method returns the Network Name. + * Returns the Network Name. * * @returns The Network Name. * @@ -209,7 +209,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable const NetworkName &GetNetworkName(void) const { return mNetworkName; } /** - * This method sets the Network Name. + * Sets the Network Name. * * @param[in] aNameString A pointer to a string character array. Must be null terminated. * @@ -220,7 +220,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable Error SetNetworkName(const char *aNameString); /** - * This method sets the Network Name. + * Sets the Network Name. * * @param[in] aNameData A name data (pointer to char buffer and length). * @@ -232,7 +232,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) /** - * This method returns the Thread Domain Name. + * Returns the Thread Domain Name. * * @returns The Thread Domain Name. * @@ -240,7 +240,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable const DomainName &GetDomainName(void) const { return mDomainName; } /** - * This method sets the Thread Domain Name. + * Sets the Thread Domain Name. * * @param[in] aNameString A pointer to a string character array. Must be null terminated. * @@ -251,7 +251,7 @@ class NetworkNameManager : public InstanceLocator, private NonCopyable Error SetDomainName(const char *aNameString); /** - * This method sets the Thread Domain Name. + * Sets the Thread Domain Name. * * @param[in] aNameData A name data (pointer to char buffer and length). * diff --git a/src/core/meshcop/panid_query_client.hpp b/src/core/meshcop/panid_query_client.hpp index 46b1ff78415..1a5d1157997 100644 --- a/src/core/meshcop/panid_query_client.hpp +++ b/src/core/meshcop/panid_query_client.hpp @@ -49,7 +49,7 @@ namespace ot { /** - * This class implements handling PANID Query Requests. + * Implements handling PANID Query Requests. * */ class PanIdQueryClient : public InstanceLocator @@ -58,13 +58,13 @@ class PanIdQueryClient : public InstanceLocator public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit PanIdQueryClient(Instance &aInstance); /** - * This method sends a PAN ID Query message. + * Sends a PAN ID Query message. * * @param[in] aPanId The PAN ID to query. * @param[in] aChannelMask The channel mask value. diff --git a/src/core/meshcop/timestamp.hpp b/src/core/meshcop/timestamp.hpp index 1eace251d5a..5d7abb32276 100644 --- a/src/core/meshcop/timestamp.hpp +++ b/src/core/meshcop/timestamp.hpp @@ -53,7 +53,7 @@ using ot::Encoding::BigEndian::HostSwap16; using ot::Encoding::BigEndian::HostSwap32; /** - * This class implements Timestamp generation and parsing. + * Implements Timestamp generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -61,19 +61,19 @@ class Timestamp : public Clearable { public: /** - * This method converts the timestamp to `otTimestamp`. + * Converts the timestamp to `otTimestamp`. * */ void ConvertTo(otTimestamp &aTimestamp) const; /** - * This method sets the timestamp from `otTimestamp`. + * Sets the timestamp from `otTimestamp`. * */ void SetFromTimestamp(const otTimestamp &aTimestamp); /** - * This method returns the Seconds value. + * Returns the Seconds value. * * @returns The Seconds value. * @@ -84,7 +84,7 @@ class Timestamp : public Clearable } /** - * This method sets the Seconds value. + * Sets the Seconds value. * * @param[in] aSeconds The Seconds value. * @@ -96,7 +96,7 @@ class Timestamp : public Clearable } /** - * This method returns the Ticks value. + * Returns the Ticks value. * * @returns The Ticks value. * @@ -104,7 +104,7 @@ class Timestamp : public Clearable uint16_t GetTicks(void) const { return HostSwap16(mTicks) >> kTicksOffset; } /** - * This method sets the Ticks value. + * Sets the Ticks value. * * @param[in] aTicks The Ticks value. * @@ -115,7 +115,7 @@ class Timestamp : public Clearable } /** - * This method returns the Authoritative value. + * Returns the Authoritative value. * * @returns The Authoritative value. * @@ -123,7 +123,7 @@ class Timestamp : public Clearable bool GetAuthoritative(void) const { return (HostSwap16(mTicks) & kAuthoritativeMask) != 0; } /** - * This method sets the Authoritative value. + * Sets the Authoritative value. * * @param[in] aAuthoritative The Authoritative value. * @@ -135,13 +135,13 @@ class Timestamp : public Clearable } /** - * This method increments the timestamp by a random number of ticks [0, 32767]. + * Increments the timestamp by a random number of ticks [0, 32767]. * */ void AdvanceRandomTicks(void); /** - * This method indicates whether the timestamp indicates an MLE Orphan Announce message. + * Indicates whether the timestamp indicates an MLE Orphan Announce message. * * @retval TRUE The timestamp indicates an Orphan Announce message. * @retval FALSE If the timestamp does not indicate an Orphan Announce message. @@ -150,7 +150,7 @@ class Timestamp : public Clearable bool IsOrphanTimestamp(void) const { return GetSeconds() == 0 && GetTicks() == 0 && GetAuthoritative(); } /** - * This static method compares two timestamps. + * Compares two timestamps. * * Either one or both @p aFirst or @p aSecond can be `nullptr`. A non-null timestamp is considered greater than * a null one. If both are null, they are considered as equal. @@ -166,7 +166,7 @@ class Timestamp : public Clearable static int Compare(const Timestamp *aFirst, const Timestamp *aSecond); /** - * This static method compares two timestamps. + * Compares two timestamps. * * @param[in] aFirst A reference to the first timestamp to compare. * @param[in] aSecond A reference to the second timestamp to compare. diff --git a/src/core/net/checksum.hpp b/src/core/net/checksum.hpp index 06d6e69014d..e41b28fc03b 100644 --- a/src/core/net/checksum.hpp +++ b/src/core/net/checksum.hpp @@ -47,7 +47,7 @@ namespace ot { /** - * This class implements IP checksum calculation and verification. + * Implements IP checksum calculation and verification. * */ class Checksum @@ -56,7 +56,7 @@ class Checksum public: /** - * This static method verifies the checksum in a given message (if UDP/ICMP6). + * Verifies the checksum in a given message (if UDP/ICMP6). * * @param[in] aMessage The message to verify its checksum. The `aMessage.GetOffset()` should point to start * UDP/ICMP6 header. @@ -70,7 +70,7 @@ class Checksum static Error VerifyMessageChecksum(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo, uint8_t aIpProto); /** - * This static method calculates and then updates the checksum in a given message (if TCP/UDP/ICMPv6). + * Calculates and then updates the checksum in a given message (if TCP/UDP/ICMPv6). * * @param[in,out] aMessage The message to update the checksum in. The `aMessage.GetOffset()` should point to start * of the TCP/UDP/ICMPv6 header. On exit the checksum field in TCP/UDP/ICMPv6 header in the @@ -86,7 +86,7 @@ class Checksum uint8_t aIpProto); /** - * This static method calculates and then updates the checksum in a given IPv4 message (if TCP/UDP/ICMP(v4)). + * Calculates and then updates the checksum in a given IPv4 message (if TCP/UDP/ICMP(v4)). * * @param[in,out] aMessage The message to update the checksum in. The `aMessage.GetOffset()` should point to start * of the TCP/UDP/ICMP(v4) header. On exit the checksum field in TCP/UDP/ICMP(v4) header in @@ -102,7 +102,7 @@ class Checksum uint8_t aIpProto); /** - * This static method calculates and then updates the checksum field in the IPv4 header. + * Calculates and then updates the checksum field in the IPv4 header. * * @param[in,out] aHeader The IPv4 header to update the checksum in. * diff --git a/src/core/net/dhcp6.hpp b/src/core/net/dhcp6.hpp index 5d65f2163f0..b2a0c187e98 100644 --- a/src/core/net/dhcp6.hpp +++ b/src/core/net/dhcp6.hpp @@ -91,7 +91,7 @@ enum Type : uint8_t }; /** - * This class represents a DHCP6 transaction identifier. + * Represents a DHCP6 transaction identifier. * */ OT_TOOL_PACKED_BEGIN @@ -101,20 +101,25 @@ class TransactionId : public Equatable, public Clearable { public: /** - * This method returns the DHCPv6 message type. + * Returns the DHCPv6 message type. * * @returns The DHCPv6 message type. * @@ -130,7 +135,7 @@ class Header : public Clearable
Type GetType(void) const { return mType; } /** - * This method sets the DHCPv6 message type. + * Sets the DHCPv6 message type. * * @param[in] aType The DHCPv6 message type. * @@ -138,7 +143,7 @@ class Header : public Clearable
void SetType(Type aType) { mType = aType; } /** - * This method returns the DHCPv6 message transaction identifier. + * Returns the DHCPv6 message transaction identifier. * * @returns The DHCPv6 message transaction identifier. * @@ -146,7 +151,7 @@ class Header : public Clearable
const TransactionId &GetTransactionId(void) const { return mTransactionId; } /** - * This method sets the DHCPv6 message transaction identifier. + * Sets the DHCPv6 message transaction identifier. * * @param[in] aTransactionId The DHCPv6 message transaction identifier. * @@ -189,7 +194,7 @@ enum Code : uint16_t }; /** - * This class implements DHCPv6 option. + * Implements DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -197,7 +202,7 @@ class Option { public: /** - * This method initializes the DHCPv6 option to all zeros. + * Initializes the DHCPv6 option to all zeros. * */ void Init(void) @@ -207,7 +212,7 @@ class Option } /** - * This method returns the DHCPv6 option code. + * Returns the DHCPv6 option code. * * @returns The DHCPv6 option code. * @@ -215,7 +220,7 @@ class Option Code GetCode(void) const { return static_cast(HostSwap16(mCode)); } /** - * This method sets the DHCPv6 option code. + * Sets the DHCPv6 option code. * * @param[in] aCode The DHCPv6 option code. * @@ -223,7 +228,7 @@ class Option void SetCode(Code aCode) { mCode = HostSwap16(static_cast(aCode)); } /** - * This method returns the length of DHCPv6 option. + * Returns the length of DHCPv6 option. * * @returns The length of DHCPv6 option. * @@ -231,7 +236,7 @@ class Option uint16_t GetLength(void) const { return HostSwap16(mLength); } /** - * This method sets the length of DHCPv6 option. + * Sets the length of DHCPv6 option. * * @param[in] aLength The length of DHCPv6 option. * @@ -259,7 +264,7 @@ class ClientIdentifier : public Option { public: /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -269,7 +274,7 @@ class ClientIdentifier : public Option } /** - * This method returns the client DUID Type. + * Returns the client DUID Type. * * @returns The client DUID Type. * @@ -277,7 +282,7 @@ class ClientIdentifier : public Option DuidType GetDuidType(void) const { return static_cast(HostSwap16(mDuidType)); } /** - * This method sets the client DUID Type. + * Sets the client DUID Type. * * @param[in] aDuidType The client DUID Type. * @@ -285,7 +290,7 @@ class ClientIdentifier : public Option void SetDuidType(DuidType aDuidType) { mDuidType = HostSwap16(static_cast(aDuidType)); } /** - * This method returns the client Duid HardwareType. + * Returns the client Duid HardwareType. * * @returns The client Duid HardwareType. * @@ -293,7 +298,7 @@ class ClientIdentifier : public Option uint16_t GetDuidHardwareType(void) const { return HostSwap16(mDuidHardwareType); } /** - * This method sets the client Duid HardwareType. + * Sets the client Duid HardwareType. * * @param[in] aDuidHardwareType The client Duid HardwareType. * @@ -301,7 +306,7 @@ class ClientIdentifier : public Option void SetDuidHardwareType(uint16_t aDuidHardwareType) { mDuidHardwareType = HostSwap16(aDuidHardwareType); } /** - * This method returns the client LinkLayerAddress. + * Returns the client LinkLayerAddress. * * @returns The link-layer address. * @@ -309,7 +314,7 @@ class ClientIdentifier : public Option const Mac::ExtAddress &GetDuidLinkLayerAddress(void) const { return mDuidLinkLayerAddress; } /** - * This method sets the client LinkLayerAddress. + * Sets the client LinkLayerAddress. * * @param[in] aDuidLinkLayerAddress The client LinkLayerAddress. * @@ -330,7 +335,7 @@ class ServerIdentifier : public Option { public: /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -340,7 +345,7 @@ class ServerIdentifier : public Option } /** - * This method returns the server DUID Type. + * Returns the server DUID Type. * * @returns The server DUID Type. * @@ -348,7 +353,7 @@ class ServerIdentifier : public Option DuidType GetDuidType(void) const { return static_cast(HostSwap16(mDuidType)); } /** - * This method sets the server DUID Type. + * Sets the server DUID Type. * * @param[in] aDuidType The server DUID Type. * @@ -356,7 +361,7 @@ class ServerIdentifier : public Option void SetDuidType(DuidType aDuidType) { mDuidType = HostSwap16(static_cast(aDuidType)); } /** - * This method returns the server DUID HardwareType. + * Returns the server DUID HardwareType. * * @returns The server DUID HardwareType. * @@ -364,7 +369,7 @@ class ServerIdentifier : public Option uint16_t GetDuidHardwareType(void) const { return HostSwap16(mDuidHardwareType); } /** - * This method sets the server DUID HardwareType. + * Sets the server DUID HardwareType. * * @param[in] aDuidHardwareType The server DUID HardwareType. * @@ -372,7 +377,7 @@ class ServerIdentifier : public Option void SetDuidHardwareType(uint16_t aDuidHardwareType) { mDuidHardwareType = HostSwap16(aDuidHardwareType); } /** - * This method returns the server LinkLayerAddress. + * Returns the server LinkLayerAddress. * * @returns The link-layer address. * @@ -380,7 +385,7 @@ class ServerIdentifier : public Option const Mac::ExtAddress &GetDuidLinkLayerAddress(void) const { return mDuidLinkLayerAddress; } /** - * This method sets the server LinkLayerAddress. + * Sets the server LinkLayerAddress. * * @param[in] aDuidLinkLayerAddress The server LinkLayerAddress. * @@ -397,7 +402,7 @@ class ServerIdentifier : public Option } OT_TOOL_PACKED_END; /** - * This type represents an Identity Association for Non-temporary Address DHCPv6 option. + * Represents an Identity Association for Non-temporary Address DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -408,7 +413,7 @@ class IaNa : public Option static constexpr uint32_t kDefaultT2 = 0xffffffffU; ///< Default T2 value. /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -418,7 +423,7 @@ class IaNa : public Option } /** - * This method returns client IAID. + * Returns client IAID. * * @returns The client IAID. * @@ -426,7 +431,7 @@ class IaNa : public Option uint32_t GetIaid(void) const { return HostSwap32(mIaid); } /** - * This method sets the client IAID. + * Sets the client IAID. * * @param[in] aIaid The client IAID. * @@ -434,7 +439,7 @@ class IaNa : public Option void SetIaid(uint32_t aIaid) { mIaid = HostSwap32(aIaid); } /** - * This method returns T1. + * Returns T1. * * @returns The value of T1. * @@ -442,7 +447,7 @@ class IaNa : public Option uint32_t GetT1(void) const { return HostSwap32(mT1); } /** - * This method sets the value of T1. + * Sets the value of T1. * * @param[in] aT1 The value of T1. * @@ -450,7 +455,7 @@ class IaNa : public Option void SetT1(uint32_t aT1) { mT1 = HostSwap32(aT1); } /** - * This method returns T2. + * Returns T2. * * @returns The value of T2. * @@ -458,7 +463,7 @@ class IaNa : public Option uint32_t GetT2(void) const { return HostSwap32(mT2); } /** - * This method sets the value of T2. + * Sets the value of T2. * * @param[in] aT2 The value of T2. * @@ -472,7 +477,7 @@ class IaNa : public Option } OT_TOOL_PACKED_END; /** - * This type represents an Identity Association Address DHCPv6 option. + * Represents an Identity Association Address DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -483,7 +488,7 @@ class IaAddress : public Option static constexpr uint32_t kDefaultValidLifetime = 0xffffffffU; ///< Default valid lifetime. /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -493,7 +498,7 @@ class IaAddress : public Option } /** - * This method returns a reference to the IPv6 address. + * Returns a reference to the IPv6 address. * * @returns A reference to the IPv6 address. * @@ -501,7 +506,7 @@ class IaAddress : public Option Ip6::Address &GetAddress(void) { return mAddress; } /** - * This method returns a reference to the IPv6 address. + * Returns a reference to the IPv6 address. * * @returns A reference to the IPv6 address. * @@ -509,7 +514,7 @@ class IaAddress : public Option const Ip6::Address &GetAddress(void) const { return mAddress; } /** - * This method sets the IPv6 address. + * Sets the IPv6 address. * * @param[in] aAddress The reference to the IPv6 address to set. * @@ -517,7 +522,7 @@ class IaAddress : public Option void SetAddress(const Ip6::Address &aAddress) { mAddress = aAddress; } /** - * This method returns the preferred lifetime of the IPv6 address. + * Returns the preferred lifetime of the IPv6 address. * * @returns The preferred lifetime of the IPv6 address. * @@ -525,7 +530,7 @@ class IaAddress : public Option uint32_t GetPreferredLifetime(void) const { return HostSwap32(mPreferredLifetime); } /** - * This method sets the preferred lifetime of the IPv6 address. + * Sets the preferred lifetime of the IPv6 address. * * @param[in] aPreferredLifetime The preferred lifetime of the IPv6 address. * @@ -533,7 +538,7 @@ class IaAddress : public Option void SetPreferredLifetime(uint32_t aPreferredLifetime) { mPreferredLifetime = HostSwap32(aPreferredLifetime); } /** - * This method returns the valid lifetime of the IPv6 address. + * Returns the valid lifetime of the IPv6 address. * * @returns The valid lifetime of the IPv6 address. * @@ -541,7 +546,7 @@ class IaAddress : public Option uint32_t GetValidLifetime(void) const { return HostSwap32(mValidLifetime); } /** - * This method sets the valid lifetime of the IPv6 address. + * Sets the valid lifetime of the IPv6 address. * * @param[in] aValidLifetime The valid lifetime of the IPv6 address. * @@ -555,7 +560,7 @@ class IaAddress : public Option } OT_TOOL_PACKED_END; /** - * This type represents an Elapsed Time DHCPv6 option. + * Represents an Elapsed Time DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -563,7 +568,7 @@ class ElapsedTime : public Option { public: /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -573,7 +578,7 @@ class ElapsedTime : public Option } /** - * This method returns the elapsed time since solicit starts. + * Returns the elapsed time since solicit starts. * * @returns The elapsed time since solicit starts. * @@ -581,7 +586,7 @@ class ElapsedTime : public Option uint16_t GetElapsedTime(void) const { return HostSwap16(mElapsedTime); } /** - * This method sets the elapsed time since solicit starts. + * Sets the elapsed time since solicit starts. * * @param[in] aElapsedTime The elapsed time since solicit starts. * @@ -611,7 +616,7 @@ enum Status : uint16_t }; /** - * This type represents an Status Code DHCPv6 option. + * Represents an Status Code DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -619,7 +624,7 @@ class StatusCode : public Option { public: /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) @@ -629,7 +634,7 @@ class StatusCode : public Option } /** - * This method returns the status code. + * Returns the status code. * * @returns The status code. * @@ -637,7 +642,7 @@ class StatusCode : public Option Status GetStatusCode(void) const { return static_cast(HostSwap16(mStatus)); } /** - * This method sets the status code. + * Sets the status code. * * @param[in] aStatus The status code. * @@ -649,7 +654,7 @@ class StatusCode : public Option } OT_TOOL_PACKED_END; /** - * This type represents an Rapid Commit DHCPv6 option. + * Represents an Rapid Commit DHCPv6 option. * */ OT_TOOL_PACKED_BEGIN @@ -657,7 +662,7 @@ class RapidCommit : public Option { public: /** - * This method initializes the DHCPv6 Option. + * Initializes the DHCPv6 Option. * */ void Init(void) diff --git a/src/core/net/dhcp6_client.hpp b/src/core/net/dhcp6_client.hpp index 533ded73f2b..c50b138894b 100644 --- a/src/core/net/dhcp6_client.hpp +++ b/src/core/net/dhcp6_client.hpp @@ -64,14 +64,14 @@ namespace Dhcp6 { */ /** - * This class implements DHCPv6 Client. + * Implements DHCPv6 Client. * */ class Client : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -79,7 +79,7 @@ class Client : public InstanceLocator, private NonCopyable explicit Client(Instance &aInstance); /** - * This method update addresses that shall be automatically created using DHCP. + * Update addresses that shall be automatically created using DHCP. * * */ diff --git a/src/core/net/dhcp6_server.hpp b/src/core/net/dhcp6_server.hpp index fa14e8bd991..d38c40edc5e 100644 --- a/src/core/net/dhcp6_server.hpp +++ b/src/core/net/dhcp6_server.hpp @@ -67,7 +67,7 @@ class Server : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -75,13 +75,13 @@ class Server : public InstanceLocator, private NonCopyable explicit Server(Instance &aInstance); /** - * This method updates DHCP Agents and DHCP ALOCs. + * Updates DHCP Agents and DHCP ALOCs. * */ Error UpdateService(void); /** - * This method applies the Mesh Local Prefix. + * Applies the Mesh Local Prefix. * */ void ApplyMeshLocalPrefix(void); @@ -91,7 +91,7 @@ class Server : public InstanceLocator, private NonCopyable { public: /** - * This method indicates whether or not @p aAddress has a matching prefix. + * Indicates whether or not @p aAddress has a matching prefix. * * @param[in] aAddress The IPv6 address to compare. * @@ -102,7 +102,7 @@ class Server : public InstanceLocator, private NonCopyable bool IsPrefixMatch(const Ip6::Address &aAddress) const { return aAddress.MatchesPrefix(GetPrefix()); } /** - * This method indicates whether or not this entry is valid. + * Indicates whether or not this entry is valid. * * @retval TRUE if this entry is valid. * @retval FALSE if this entry is not valid. @@ -111,13 +111,13 @@ class Server : public InstanceLocator, private NonCopyable bool IsValid(void) const { return mAloc.mValid; } /** - * This method sets the entry to invalid. + * Sets the entry to invalid. * */ void Clear(void) { mAloc.mValid = false; } /** - * This method returns the 6LoWPAN context ID. + * Returns the 6LoWPAN context ID. * * @returns The 6LoWPAN context ID. * @@ -125,7 +125,7 @@ class Server : public InstanceLocator, private NonCopyable uint8_t GetContextId(void) const { return mAloc.mAddress.mFields.m8[15]; } /** - * This method returns the ALOC. + * Returns the ALOC. * * @returns the ALOC. * @@ -133,7 +133,7 @@ class Server : public InstanceLocator, private NonCopyable Ip6::Netif::UnicastAddress &GetAloc(void) { return mAloc; } /** - * This method returns the IPv6 prefix. + * Returns the IPv6 prefix. * * @returns The IPv6 prefix. * @@ -141,7 +141,7 @@ class Server : public InstanceLocator, private NonCopyable const Ip6::Prefix &GetPrefix(void) const { return mPrefix; } /** - * This method returns the IPv6 prefix. + * Returns the IPv6 prefix. * * @returns The IPv6 prefix. * @@ -149,7 +149,7 @@ class Server : public InstanceLocator, private NonCopyable Ip6::Prefix &GetPrefix(void) { return mPrefix; } /** - * This method returns the IPv6 prefix as an IPv6 address. + * Returns the IPv6 prefix as an IPv6 address. * * @returns The IPv6 prefix as an IPv6 address. * @@ -160,7 +160,7 @@ class Server : public InstanceLocator, private NonCopyable } /** - * This method sets the ALOC. + * Sets the ALOC. * * @param[in] aPrefix The IPv6 prefix. * @param[in] aMeshLocalPrefix The Mesh Local Prefix. diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp index da1672535e4..2dd9531dee7 100644 --- a/src/core/net/dns_client.cpp +++ b/src/core/net/dns_client.cpp @@ -309,6 +309,8 @@ Error Client::Response::ReadServiceInfo(Section aSection, const Name &aName, Ser // Search in additional section for AAAA record for the host name. + VerifyOrExit(AsCoreType(&aServiceInfo.mHostAddress).IsUnspecified()); + error = FindHostAddress(kAdditionalDataSection, hostName, /* aIndex */ 0, AsCoreType(&aServiceInfo.mHostAddress), aServiceInfo.mHostAddressTtl); @@ -598,6 +600,27 @@ Error Client::ServiceResponse::GetServiceInfo(ServiceInfo &aServiceInfo) const info.ReadFrom(*response->mQuery); + switch (info.mQueryType) + { + case kIp6AddressQuery: +#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE + case kIp4AddressQuery: +#endif + IgnoreError(response->FindHostAddress(kAnswerSection, name, /* aIndex */ 0, + AsCoreType(&aServiceInfo.mHostAddress), + aServiceInfo.mHostAddressTtl)); + + continue; // to `for()` loop + + case kServiceQuerySrvTxt: + case kServiceQuerySrv: + case kServiceQueryTxt: + break; + + default: + continue; + } + // Determine from which section we should try to read the SRV and // TXT records based on the query type. // @@ -639,7 +662,25 @@ Error Client::ServiceResponse::GetHostAddress(const char *aHostName, for (const Response *response = this; response != nullptr; response = response->mNext) { - error = response->FindHostAddress(kAdditionalDataSection, Name(aHostName), aIndex, aAddress, aTtl); + Section section = kAdditionalDataSection; + QueryInfo info; + + info.ReadFrom(*response->mQuery); + + switch (info.mQueryType) + { + case kIp6AddressQuery: +#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE + case kIp4AddressQuery: +#endif + section = kAnswerSection; + break; + + default: + break; + } + + error = response->FindHostAddress(section, Name(aHostName), aIndex, aAddress, aTtl); if (error == kErrorNone) { @@ -863,6 +904,25 @@ Error Client::ResolveService(const char *aInstanceLabel, ServiceCallback aCallback, void *aContext, const QueryConfig *aConfig) +{ + return Resolve(aInstanceLabel, aServiceName, aCallback, aContext, aConfig, false); +} + +Error Client::ResolveServiceAndHostAddress(const char *aInstanceLabel, + const char *aServiceName, + ServiceCallback aCallback, + void *aContext, + const QueryConfig *aConfig) +{ + return Resolve(aInstanceLabel, aServiceName, aCallback, aContext, aConfig, true); +} + +Error Client::Resolve(const char *aInstanceLabel, + const char *aServiceName, + ServiceCallback aCallback, + void *aContext, + const QueryConfig *aConfig, + bool aShouldResolveHostAddr) { QueryInfo info; Error error; @@ -873,6 +933,7 @@ Error Client::ResolveService(const char *aInstanceLabel, info.Clear(); info.mConfig.SetFrom(aConfig, mDefaultConfig); + info.mShouldResolveHostAddr = aShouldResolveHostAddr; switch (info.mConfig.GetServiceMode()) { @@ -887,6 +948,7 @@ Error Client::ResolveService(const char *aInstanceLabel, case QueryConfig::kServiceModeTxt: info.mQueryType = kServiceQueryTxt; + VerifyOrExit(!info.mShouldResolveHostAddr, error = kErrorInvalidArgs); break; case QueryConfig::kServiceModeSrvTxt: @@ -1274,6 +1336,10 @@ void Client::ProcessResponse(const Message &aResponseMessage) // Received successful response from server. +#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + ResolveHostAddressIfNeeded(*query, aResponseMessage); +#endif + if (!CanFinalizeQuery(*query)) { SaveQueryResponse(*query, aResponseMessage); @@ -1551,6 +1617,51 @@ Error Client::ReplaceWithSeparateSrvTxtQueries(Query &aQuery) return error; } +void Client::ResolveHostAddressIfNeeded(Query &aQuery, const Message &aResponseMessage) +{ + QueryInfo info; + Response response; + ServiceInfo serviceInfo; + char hostName[Name::kMaxNameSize]; + + info.ReadFrom(aQuery); + + VerifyOrExit(info.mQueryType == kServiceQuerySrvTxt || info.mQueryType == kServiceQuerySrv); + VerifyOrExit(info.mShouldResolveHostAddr); + + PopulateResponse(response, aQuery, aResponseMessage); + + memset(&serviceInfo, 0, sizeof(serviceInfo)); + serviceInfo.mHostNameBuffer = hostName; + serviceInfo.mHostNameBufferSize = sizeof(hostName); + SuccessOrExit(response.ReadServiceInfo(Response::kAnswerSection, Name(aQuery, kNameOffsetInQuery), serviceInfo)); + + // Check whether AAAA record for host address is provided in the SRV query response + + if (AsCoreType(&serviceInfo.mHostAddress).IsUnspecified()) + { + Query *newQuery; + + info.mQueryType = kIp6AddressQuery; + info.mMessageId = 0; + info.mTransmissionCount = 0; + info.mMainQuery = &FindMainQuery(aQuery); + + SuccessOrExit(AllocateQuery(info, nullptr, hostName, newQuery)); + IgnoreError(SendQuery(*newQuery, info, /* aUpdateTimer */ true)); + + // Update `aQuery` to be linked with new query (inserting + // the `newQuery` into the linked-list after `aQuery`). + + info.ReadFrom(aQuery); + info.mNextQuery = newQuery; + UpdateQuery(aQuery, info); + } + +exit: + return; +} + #endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE #if OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE diff --git a/src/core/net/dns_client.hpp b/src/core/net/dns_client.hpp index 12c63b9a9f5..d663c91f87b 100644 --- a/src/core/net/dns_client.hpp +++ b/src/core/net/dns_client.hpp @@ -66,7 +66,7 @@ #endif /** - * This struct represents an opaque (and empty) type for a response to an address resolution DNS query. + * Represents an opaque (and empty) type for a response to an address resolution DNS query. * */ struct otDnsAddressResponse @@ -76,7 +76,7 @@ struct otDnsAddressResponse #if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE /** - * This struct represents an opaque (and empty) type for a response to browse (service instance enumeration) DNS query. + * Represents an opaque (and empty) type for a response to browse (service instance enumeration) DNS query. * */ struct otDnsBrowseResponse @@ -84,7 +84,7 @@ struct otDnsBrowseResponse }; /** - * This struct represents an opaque (and empty) type for a response to service inst resolution DNS query. + * Represents an opaque (and empty) type for a response to service inst resolution DNS query. * */ struct otDnsServiceResponse @@ -102,7 +102,7 @@ class Client; namespace Dns { /** - * This class implements DNS client. + * Implements DNS client. * */ class Client : public InstanceLocator, private NonCopyable @@ -113,7 +113,7 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This type represents a DNS query configuration (e.g., server address, response wait timeout, etc). + * Represents a DNS query configuration (e.g., server address, response wait timeout, etc). * */ class QueryConfig : public otDnsQueryConfig, public Clearable @@ -122,7 +122,7 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This enumeration type represents the "Recursion Desired" (RD) flag in a `otDnsQueryConfig`. + * Type represents the "Recursion Desired" (RD) flag in a `otDnsQueryConfig`. * */ enum RecursionFlag : uint8_t @@ -134,7 +134,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE /** - * This enumeration type represents the NAT64 mode. + * Type represents the NAT64 mode. * */ enum Nat64Mode : uint8_t @@ -146,7 +146,7 @@ class Client : public InstanceLocator, private NonCopyable #endif /** - * This enumeration type represents the service resolution mode. + * Type represents the service resolution mode. * */ enum ServiceMode : uint8_t @@ -160,7 +160,7 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This enumeration type represents the DNS transport protocol selection. + * Type represents the DNS transport protocol selection. * */ enum TransportProto : uint8_t @@ -177,7 +177,7 @@ class Client : public InstanceLocator, private NonCopyable QueryConfig(void) = default; /** - * This method gets the server socket address (IPv6 address and port number). + * Gets the server socket address (IPv6 address and port number). * * @returns The server socket address. * @@ -188,7 +188,7 @@ class Client : public InstanceLocator, private NonCopyable } /** - * This method gets the wait time to receive response from server (in msec). + * Gets the wait time to receive response from server (in msec). * * @returns The timeout interval in msec. * @@ -196,7 +196,7 @@ class Client : public InstanceLocator, private NonCopyable uint32_t GetResponseTimeout(void) const { return mResponseTimeout; } /** - * This method gets the maximum number of query transmit attempts before reporting failure. + * Gets the maximum number of query transmit attempts before reporting failure. * * @returns The maximum number of query transmit attempts. * @@ -204,7 +204,7 @@ class Client : public InstanceLocator, private NonCopyable uint8_t GetMaxTxAttempts(void) const { return mMaxTxAttempts; } /** - * This method gets the recursion flag indicating whether the server can resolve the query recursively or not. + * Gets the recursion flag indicating whether the server can resolve the query recursively or not. * * @returns The recursion flag. * @@ -213,7 +213,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE /** - * This method gets the NAT64 mode. + * Gets the NAT64 mode. * * @returns The NAT64 mode. * @@ -221,7 +221,7 @@ class Client : public InstanceLocator, private NonCopyable Nat64Mode GetNat64Mode(void) const { return static_cast(mNat64Mode); } #endif /** - * This method gets the service resolution mode. + * Gets the service resolution mode. * * @returns The service resolution mode. * @@ -229,7 +229,7 @@ class Client : public InstanceLocator, private NonCopyable ServiceMode GetServiceMode(void) const { return static_cast(mServiceMode); } /** - * This method gets the transport protocol. + * Gets the transport protocol. * * @returns The transport protocol. * @@ -278,14 +278,14 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE /** - * This structure provides info for a DNS service instance. + * Provides info for a DNS service instance. * */ typedef otDnsServiceInfo ServiceInfo; #endif /** - * This class represents a DNS query response. + * Represents a DNS query response. * */ class Response : public otDnsAddressResponse, @@ -343,14 +343,14 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This type represents the function pointer callback which is called when a DNS response for an address resolution + * Represents the function pointer callback which is called when a DNS response for an address resolution * query is received. * */ typedef otDnsAddressCallback AddressCallback; /** - * This type represents an address resolution query DNS response. + * Represents an address resolution query DNS response. * */ class AddressResponse : public Response @@ -359,9 +359,9 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This method gets the host name associated with an address resolution DNS response. + * Gets the host name associated with an address resolution DNS response. * - * This method MUST only be used from `AddressCallback`. + * MUST only be used from `AddressCallback`. * * @param[out] aNameBuffer A buffer to char array to output the host name. * @param[in] aNameBufferSize The size of @p aNameBuffer. @@ -376,9 +376,9 @@ class Client : public InstanceLocator, private NonCopyable } /** - * This method gets the IPv6 address associated with an address resolution DNS response. + * Gets the IPv6 address associated with an address resolution DNS response. * - * This method MUST only be used from `AddressCallback`. + * MUST only be used from `AddressCallback`. * * The response may include multiple IPv6 address records. @p aIndex can be used to iterate through the list of * addresses. Index zero gets the the first address and so on. When we reach end of the list, this method @@ -405,14 +405,14 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE /** - * This type represents the function pointer callback which is called when a response for a browse (service + * Represents the function pointer callback which is called when a response for a browse (service * instance enumeration) DNS query is received. * */ typedef otDnsBrowseCallback BrowseCallback; /** - * This type represents a browse (service instance enumeration) DNS response. + * Represents a browse (service instance enumeration) DNS response. * */ class BrowseResponse : public Response @@ -421,9 +421,9 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This method gets the service name associated with a DNS browse response. + * Gets the service name associated with a DNS browse response. * - * This method MUST only be used from `BrowseCallback`. + * MUST only be used from `BrowseCallback`. * * @param[out] aNameBuffer A buffer to char array to output the host name. * @param[in] aNameBufferSize The size of @p aNameBuffer. @@ -438,9 +438,9 @@ class Client : public InstanceLocator, private NonCopyable } /** - * This method gets a service instance associated with a DNS browse (service instance enumeration) response. + * Gets a service instance associated with a DNS browse (service instance enumeration) response. * - * This method MUST only be used from `BrowseCallback`. + * MUST only be used from `BrowseCallback`. * * A response may include multiple service instance records. @p aIndex can be used to iterate through the list. * Index zero gives the the first record. When we reach end of the list, `kErrorNotFound` is returned. @@ -461,9 +461,9 @@ class Client : public InstanceLocator, private NonCopyable Error GetServiceInstance(uint16_t aIndex, char *aLabelBuffer, uint8_t aLabelBufferSize) const; /** - * This method gets info for a service instance from a DNS browse (service instance enumeration) response. + * Gets info for a service instance from a DNS browse (service instance enumeration) response. * - * This method MUST only be used from `BrowseCallback`. + * MUST only be used from `BrowseCallback`. * * 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 method tries to retrieve this info @@ -488,9 +488,9 @@ class Client : public InstanceLocator, private NonCopyable Error GetServiceInfo(const char *aInstanceLabel, ServiceInfo &aServiceInfo) const; /** - * This method gets the host IPv6 address from a DNS browse (service instance enumeration) response. + * Gets the host IPv6 address from a DNS browse (service instance enumeration) response. * - * This method MUST only be used from `BrowseCallback`. + * MUST only be used from `BrowseCallback`. * * The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the * list of addresses. Index zero gets the first address and so on. When we reach end of the list, this method @@ -513,14 +513,14 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This type represents the function pointer callback which is called when a response for a service instance + * Represents the function pointer callback which is called when a response for a service instance * resolution DNS query is received. * */ typedef otDnsServiceCallback ServiceCallback; /** - * This type represents a service instance resolution DNS response. + * Represents a service instance resolution DNS response. * */ class ServiceResponse : public Response @@ -529,9 +529,9 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This method gets the service instance name associated with a DNS service instance resolution response. + * Gets the service instance name associated with a DNS service instance resolution response. * - * This method MUST only be used from `ServiceCallback`. + * MUST only be used from `ServiceCallback`. * * @param[out] aLabelBuffer A buffer to char array to output the service instance label (MUST NOT be NULL). * @param[in] aLabelBufferSize The size of @p aLabelBuffer. @@ -549,9 +549,9 @@ class Client : public InstanceLocator, private NonCopyable uint16_t aNameBufferSize) const; /** - * This method gets info for a service instance from a DNS service instance resolution response. + * Gets info for a service instance from a DNS service instance resolution response. * - * This method MUST only be used from `ServiceCallback`. + * MUST only be used from `ServiceCallback`. * * - If no matching SRV record is found, `kErrorNotFound` is returned. * - If a matching SRV record is found, @p aServiceInfo is updated and `kErrorNone` is returned. @@ -571,9 +571,9 @@ class Client : public InstanceLocator, private NonCopyable Error GetServiceInfo(ServiceInfo &aServiceInfo) const; /** - * This method gets the host IPv6 address from a DNS service instance resolution response. + * Gets the host IPv6 address from a DNS service instance resolution response. * - * This method MUST only be used from `ServiceCallback`. + * MUST only be used from `ServiceCallback`. * * The response can include zero or more IPv6 address records. @p aIndex can be used to iterate through the * list of addresses. Index zero gets the first address and so on. When we reach end of the list, this method @@ -595,7 +595,7 @@ class Client : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -603,7 +603,7 @@ class Client : public InstanceLocator, private NonCopyable explicit Client(Instance &aInstance); /** - * This method starts the DNS client. + * Starts the DNS client. * * @retval kErrorNone Successfully started the DNS client. * @retval kErrorAlready The socket is already open. @@ -612,13 +612,13 @@ class Client : public InstanceLocator, private NonCopyable Error Start(void); /** - * This method stops the DNS client. + * Stops the DNS client. * */ void Stop(void); /** - * This method gets the current default query config being used by DNS client. + * Gets the current default query config being used by DNS client. * * @returns The current default query config. * @@ -626,7 +626,7 @@ class Client : public InstanceLocator, private NonCopyable const QueryConfig &GetDefaultConfig(void) const { return mDefaultConfig; } /** - * This method sets the default query config. + * Sets the default query config. * * @param[in] aQueryConfig The new default query config. * @@ -634,7 +634,7 @@ class Client : public InstanceLocator, private NonCopyable void SetDefaultConfig(const QueryConfig &aQueryConfig); /** - * This method resets the default config to the config used when the OpenThread stack starts. + * Resets the default config to the config used when the OpenThread stack starts. * * When OpenThread stack starts, the default DNS query config is determined from a set of OT config options such as * `OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS`, `_DEFAULT_SERVER_PORT`, or `_DEFAULT_RESPONSE_TIMEOUT` @@ -644,7 +644,7 @@ class Client : public InstanceLocator, private NonCopyable void ResetDefaultConfig(void); /** - * This method sends an address resolution DNS query for AAAA (IPv6) record for a given host name. + * Sends an address resolution DNS query for AAAA (IPv6) record for a given host name. * * The @p aConfig can be nullptr. In this case the default config (from `GetDefaultConfig()`) will be used as * the config for this query. In a non-nullptr @p aConfig, some of the fields can be left unspecified (value zero). @@ -668,7 +668,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE /** - * This method sends an address resolution DNS query for A (IPv4) record for a given host name. + * Sends an address resolution DNS query for A (IPv4) record for a given host name. * * When a successful response is received, the addresses are returned from @p aCallback as NAT64 IPv6 translated * versions of the IPv4 addresses from the query response. @@ -697,7 +697,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE /** - * This method sends a browse (service instance enumeration) DNS query for a given service name. + * Sends a browse (service instance enumeration) DNS query for a given service name. * * The @p aConfig can be nullptr. In this case the default config (from `GetDefaultConfig()`) will be used as * the config for this query. In a non-nullptr @p aConfig, some of the fields can be left unspecified (value zero). @@ -718,7 +718,7 @@ class Client : public InstanceLocator, private NonCopyable const QueryConfig *aConfig = nullptr); /** - * This method sends a DNS service instance resolution query for a given service instance. + * Starts a DNS service instance resolution for a given service instance. * * The @p aConfig can be `nullptr`. In this case the default config (from `GetDefaultConfig()`) will be used as * the config for this query. In a non-`nullptr` @p aConfig, some of the fields can be left unspecified (value @@ -741,6 +741,32 @@ class Client : public InstanceLocator, private NonCopyable void *aContext, const QueryConfig *aConfig = nullptr); + /** + * Starts a DNS service instance resolution for a given service instance, with a potential follow-up + * host name resolution (if the server/resolver does not provide AAAA/A records for the host name in the response + * to SRV query). + * + * The @p aConfig can be `nullptr`. In this case the default config (from `GetDefaultConfig()`) will be used as + * the config for this query. In a non-`nullptr` @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. + * + * @param[in] aInstanceLabel The service instance label. + * @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name). + * @param[in] aCallback A function pointer that shall be called on response reception or time-out. + * @param[in] aContext A pointer to arbitrary context information. + * @param[in] aConfig The config to use for this query. + * + * @retval kErrorNone Query sent successfully. @p aCallback will be invoked to report the status. + * @retval kErrorNoBufs Insufficient buffer to prepare and send query. + * @retval kErrorInvalidArgs @p aInstanceLabel is `nullptr` or the @p aConfig is invalid. + * + */ + Error ResolveServiceAndHostAddress(const char *aInstanceLabel, + const char *aServiceName, + ServiceCallback aCallback, + void *aContext, + const QueryConfig *aConfig = nullptr); + #endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE private: @@ -791,6 +817,7 @@ class Client : public InstanceLocator, private NonCopyable TimeMilli mRetransmissionTime; QueryConfig mConfig; uint8_t mTransmissionCount; + bool mShouldResolveHostAddr; Query *mMainQuery; Query *mNextQuery; Message *mSavedResponse; @@ -823,7 +850,14 @@ class Client : public InstanceLocator, private NonCopyable Error ReplaceWithIp4Query(Query &aQuery); #endif #if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE + Error Resolve(const char *aInstanceLabel, + const char *aServiceName, + ServiceCallback aCallback, + void *aContext, + const QueryConfig *aConfig, + bool aShouldResolveHostAddr); Error ReplaceWithSeparateSrvTxtQueries(Query &aQuery); + void ResolveHostAddressIfNeeded(Query &aQuery, const Message &aResponseMessage); #endif #if OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE diff --git a/src/core/net/dns_dso.hpp b/src/core/net/dns_dso.hpp index 6ab6800ce18..447fa509a10 100644 --- a/src/core/net/dns_dso.hpp +++ b/src/core/net/dns_dso.hpp @@ -70,7 +70,7 @@ extern "C" void otPlatDsoHandleReceive(otPlatDsoConnection *aConnection, otMessa extern "C" void otPlatDsoHandleDisconnected(otPlatDsoConnection *aConnection, otPlatDsoDisconnectMode aMode); /** - * This class implements DNS Stateful Operations (DSO). + * Implements DNS Stateful Operations (DSO). * */ class Dso : public InstanceLocator, private NonCopyable @@ -126,7 +126,7 @@ class Dso : public InstanceLocator, private NonCopyable static constexpr uint32_t kMinServerInactivityWaitTime = TimeMilli::SecToMsec(5); /** - * This class represents a DSO TLV. + * Represents a DSO TLV. * */ OT_TOOL_PACKED_BEGIN @@ -141,7 +141,7 @@ class Dso : public InstanceLocator, private NonCopyable static constexpr Type kEncryptionPaddingType = 3; ///< Encryption Padding TLV type. /** - * This method initializes the `Tlv` instance with a given type and length. + * Initializes the `Tlv` instance with a given type and length. * * @param[in] aType The TLV type. * @param[in] aLength The TLV length. @@ -154,7 +154,7 @@ class Dso : public InstanceLocator, private NonCopyable } /** - * This method gets the TLV type. + * Gets the TLV type. * * @returns The TLV type. * @@ -162,7 +162,7 @@ class Dso : public InstanceLocator, private NonCopyable Type GetType(void) const { return HostSwap16(mType); } /** - * This method gets the TLV length. + * Gets the TLV length. * * @returns The TLV length (in bytes). * @@ -170,7 +170,7 @@ class Dso : public InstanceLocator, private NonCopyable uint16_t GetLength(void) const { return HostSwap16(mLength); } /** - * This method returns the total size of the TLV (including the type and length fields). + * Returns the total size of the TLV (including the type and length fields). * * @returns The total size (number of bytes) of the TLV. * @@ -183,7 +183,7 @@ class Dso : public InstanceLocator, private NonCopyable } OT_TOOL_PACKED_END; /** - * This class represents a DSO connection to a peer. + * Represents a DSO connection to a peer. * */ class Connection : public otPlatDsoConnection, @@ -202,7 +202,7 @@ class Dso : public InstanceLocator, private NonCopyable typedef uint16_t MessageId; ///< This type represents a DSO Message Identifier. /** - * This enumeration defines the `Connection` states. + * Defines the `Connection` states. * */ enum State : uint8_t @@ -215,7 +215,7 @@ class Dso : public InstanceLocator, private NonCopyable }; /** - * This enumeration defines the disconnect modes. + * Defines the disconnect modes. * */ enum DisconnectMode : uint8_t @@ -225,7 +225,7 @@ class Dso : public InstanceLocator, private NonCopyable }; /** - * This enumeration defines the disconnect reason. + * Defines the disconnect reason. * */ enum DisconnectReason : uint8_t @@ -243,7 +243,7 @@ class Dso : public InstanceLocator, private NonCopyable }; /** - * This class defines the callback functions used by a `Connection`. + * Defines the callback functions used by a `Connection`. * */ class Callbacks @@ -365,7 +365,7 @@ class Dso : public InstanceLocator, private NonCopyable Tlv::Type aResponseTlvType, Tlv::Type aRequestTlvType); /** - * This constructor initializes a `Callbacks` object setting all the callback functions. + * Initializes a `Callbacks` object setting all the callback functions. * * @param[in] aHandleConnected The `HandleConnected` callback. * @param[in] aHandleSessionEstablished The `HandleSessionEstablished` callback. @@ -400,7 +400,7 @@ class Dso : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes a `Connection` instance. + * Initializes a `Connection` instance. * * The `kDefaultTimeout` will be used for @p aInactivityTimeout and @p aKeepAliveInterval. The * @p aKeepAliveInterval MUST NOT be less than `kMinKeepAliveInterval`. @@ -419,7 +419,7 @@ class Dso : public InstanceLocator, private NonCopyable uint32_t aKeepAliveInterval = kDefaultTimeout); /** - * This method gets the current state of the `Connection`. + * Gets the current state of the `Connection`. * * @returns The `Connection` state. * @@ -427,7 +427,7 @@ class Dso : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method returns the `Connection` peer socket address. + * Returns the `Connection` peer socket address. * * @returns The peer socket address. * @@ -435,7 +435,7 @@ class Dso : public InstanceLocator, private NonCopyable const Ip6::SockAddr &GetPeerSockAddr(void) const { return mPeerSockAddr; } /** - * This method indicates whether or not the device is acting as a DSO server on this `Connection`. + * Indicates whether or not the device is acting as a DSO server on this `Connection`. * * Server is the software entity with a listening socket, awaiting incoming connection requests. * @@ -446,7 +446,7 @@ class Dso : public InstanceLocator, private NonCopyable bool IsServer(void) const { return mIsServer; } /** - * This method indicates whether or not the device is acting as a DSO client on this `Connection`. + * Indicates whether or not the device is acting as a DSO client on this `Connection`. * * Client is the software entity that initiates a connection to the server's listening socket. * @@ -457,7 +457,7 @@ class Dso : public InstanceLocator, private NonCopyable bool IsClient(void) const { return !mIsServer; } /** - * This method allocates a new DSO message. + * Allocates a new DSO message. * * @returns A pointer to the allocated message or `nullptr` if out of message buffers. * @@ -465,10 +465,10 @@ class Dso : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method requests the device to initiate a connection (connect as a client) to the peer (acting as a + * Requests the device to initiate a connection (connect as a client) to the peer (acting as a * server). * - * This method MUST be called when `Connection` is `kStateDisconnected` state. + * MUST be called when `Connection` is `kStateDisconnected` state. * * After calling `Connect()`, either * - `Callbacks::HandleConnected()` is invoked when connection is successfully established, or @@ -485,7 +485,7 @@ class Dso : public InstanceLocator, private NonCopyable void Connect(void); /** - * This method requests the connection to be disconnected. + * Requests the connection to be disconnected. * * Note that calling `Disconnect()` does not trigger the `Callbacks::HandleDisconnected()` to be invoked (as * this callback is used when DSO module itself or the peer disconnects the connections). @@ -500,7 +500,7 @@ class Dso : public InstanceLocator, private NonCopyable void Disconnect(DisconnectMode aMode, DisconnectReason aReason); /** - * This method returns the last disconnect reason. + * Returns the last disconnect reason. * * @returns The last disconnect reason. * @@ -508,14 +508,14 @@ class Dso : public InstanceLocator, private NonCopyable DisconnectReason GetDisconnectReason(void) const { return mDisconnectReason; } /** - * This method implicitly marks the DSO session as established (set state to `kStateSessionEstablished`). + * Implicitly marks the DSO session as established (set state to `kStateSessionEstablished`). * - * This method MUST be called when `Connection is in `kStateConnectedButSessionless` state. + * MUST be called when `Connection is in `kStateConnectedButSessionless` state. * * The DSO module itself will mark the session as established after the first successful DSO message exchange * (sending a request message from client and receiving a response from server). * - * This method is intended for implicit DSO session establishment where it may be known in advance by some + * Is intended for implicit DSO session establishment where it may be known in advance by some * external means that both client and server support DSO and then the session may be established as soon as * the connection is established. * @@ -523,9 +523,9 @@ class Dso : public InstanceLocator, private NonCopyable void MarkSessionEstablished(void); /** - * This method sends a DSO request message. + * Sends a DSO request message. * - * This method MUST be called when `Connection` is in certain states depending on whether it is acting as a + * MUST be called when `Connection` is in certain states depending on whether it is acting as a * client or server: * - On client, a request message can be sent after connection is established (`kStateConnectedButSessionless`). * The first request is used to establish the DSO session. While in `kStateEstablishingSession` or @@ -553,9 +553,9 @@ class Dso : public InstanceLocator, private NonCopyable uint32_t aResponseTimeout = kResponseTimeout); /** - * This method sends a DSO unidirectional message. + * Sends a DSO unidirectional message. * - * This method MUST be called when session is established (in `kStateSessionEstablished` state). + * MUST be called when session is established (in `kStateSessionEstablished` state). * * Similar to `SendRequestMessage()` method, only TLV(s) need to be included in the message. The DNS header and * Encryption Padding TLV will be added by the DSO module. @@ -572,7 +572,7 @@ class Dso : public InstanceLocator, private NonCopyable Error SendUnidirectionalMessage(Message &aMessage); /** - * This method sends a DSO response message for a received request message. + * Sends a DSO response message for a received request message. * * Similar to `SendRequestMessage()` method, only TLV(s) need to be included in the message. The DNS header and * Encryption Padding TLV will be added by DSO module. @@ -590,7 +590,7 @@ class Dso : public InstanceLocator, private NonCopyable Error SendResponseMessage(Message &aMessage, MessageId aResponseId); /** - * This method returns the Keep Alive timeout interval (in msec). + * Returns the Keep Alive timeout interval (in msec). * * On client, this indicates the value granted by server, on server the value to grant. * @@ -600,7 +600,7 @@ class Dso : public InstanceLocator, private NonCopyable uint32_t GetKeepAliveInterval(void) const { return mKeepAlive.GetInterval(); } /** - * This method returns the Inactivity timeout interval (in msec). + * Returns the Inactivity timeout interval (in msec). * * On client, this indicates the value granted by server, on server the value to grant. * @@ -610,9 +610,9 @@ class Dso : public InstanceLocator, private NonCopyable uint32_t GetInactivityTimeout(void) const { return mInactivity.GetInterval(); } /** - * This method sends a Keep Alive message. + * Sends a Keep Alive message. * - * This method MUST be called when `Connection` is in certain states depending on whether it is acting as a + * MUST be called when `Connection` is in certain states depending on whether it is acting as a * client or server: * - On client, it can be called in any state after the connection is established. Sending Keep Alive message * can be used to initiate establishing DSO session. @@ -628,13 +628,13 @@ class Dso : public InstanceLocator, private NonCopyable Error SendKeepAliveMessage(void); /** - * This method sets the Inactivity and Keep Alive timeout intervals. + * Sets the Inactivity and Keep Alive timeout intervals. * * On client, the specified timeout intervals are used in Keep Alive request message, i.e., they are the values * that client would wish to get. On server, the given timeout intervals specify the values that server would * grant to a client upon receiving a Keep Alive request from it. * - * This method can be called in any `Connection` state. If current state allows, calling this method will also + * Can be called in any `Connection` state. If current state allows, calling this method will also * trigger sending of a Keep Alive message (as if `SendKeepAliveMessage()` is also called). For states which * trigger the tx, see `SendKeepAliveMessage()`. * @@ -653,7 +653,7 @@ class Dso : public InstanceLocator, private NonCopyable Error SetTimeouts(uint32_t aInactivityTimeout, uint32_t aKeepAliveInterval); /** - * This method enables/disables long-lived operation on the session. + * Enables/disables long-lived operation on the session. * * When a long-lived operation is active, the Inactivity timeout is always cleared, i.e., the DSO session stays * connected even if no messages are exchanged. @@ -664,9 +664,9 @@ class Dso : public InstanceLocator, private NonCopyable void SetLongLivedOperation(bool aLongLivedOperation); /** - * This method sends a unidirectional Retry Delay message from server to client. + * Sends a unidirectional Retry Delay message from server to client. * - * This method MUST be used on a server only and when DSO session is already established, i.e., in state + * MUST be used on a server only and when DSO session is already established, i.e., in state * `kStateSessionEstablished`. It sends a unidirectional Retry Delay message to client requesting it to close * the connection and not connect again for at least the specified delay amount. * @@ -685,9 +685,9 @@ class Dso : public InstanceLocator, private NonCopyable Dns::Header::Response aResponseCode = Dns::Header::kResponseSuccess); /** - * This method returns the requested retry delay interval (in msec) by server. + * Returns the requested retry delay interval (in msec) by server. * - * This method MUST be used after a `HandleDisconnected()` callback with `kReasonServerRetryDelayRequest` + * MUST be used after a `HandleDisconnected()` callback with `kReasonServerRetryDelayRequest` * * @returns The retry delay interval requested by server. * @@ -695,9 +695,9 @@ class Dso : public InstanceLocator, private NonCopyable uint32_t GetRetryDelay(void) const { return mRetryDelay; } /** - * This method returns the DNS error code in the last retry delay message received on client from server. + * Returns the DNS error code in the last retry delay message received on client from server. * - * This method MUST be used after a `HandleDisconnected()` callback with `kReasonServerRetryDelayRequest` + * MUST be used after a `HandleDisconnected()` callback with `kReasonServerRetryDelayRequest` * * @returns The DNS error code in the last Retry Delay message received on client from server. * @@ -856,13 +856,13 @@ class Dso : public InstanceLocator, private NonCopyable typedef Connection *(*AcceptHandler)(Instance &aInstance, const Ip6::SockAddr &aPeerSockAddr); /** - * This constructor initializes the `Dso` module. + * Initializes the `Dso` module. * */ explicit Dso(Instance &aInstance); /** - * This method starts listening for DSO connection requests from peers. + * Starts listening for DSO connection requests from peers. * * Once a connection request (from a peer) is received, the `Dso` module will invoke the `AcceptHandler` to * determine whether to accept or reject the request. @@ -873,13 +873,13 @@ class Dso : public InstanceLocator, private NonCopyable void StartListening(AcceptHandler aAcceptHandler); /** - * This method stops listening for DSO connection requests from peers. + * Stops listening for DSO connection requests from peers. * */ void StopListening(void); /** - * This method finds a client `Connection` instance (being currently managed by the `Dso` module) matching a given + * Finds a client `Connection` instance (being currently managed by the `Dso` module) matching a given * peer socket address. * * @param[in] aPeerSockAddr The peer socket address. @@ -890,7 +890,7 @@ class Dso : public InstanceLocator, private NonCopyable Connection *FindClientConnection(const Ip6::SockAddr &aPeerSockAddr); /** - * This method finds a server `Connection` instance (being currently managed by the `Dso` module) matching a given + * Finds a server `Connection` instance (being currently managed by the `Dso` module) matching a given * peer socket address. * * @param[in] aPeerSockAddr The peer socket address. diff --git a/src/core/net/dns_types.cpp b/src/core/net/dns_types.cpp index 7c3241e95cb..dcbb65a534e 100644 --- a/src/core/net/dns_types.cpp +++ b/src/core/net/dns_types.cpp @@ -336,7 +336,7 @@ Error Name::ReadName(const Message &aMessage, uint16_t &aOffset, char *aNameBuff } labelLength = static_cast(Min(static_cast(kMaxLabelSize), aNameBufferSize)); - SuccessOrExit(error = iterator.ReadLabel(aNameBuffer, labelLength, /* aAllowDotCharInLabel */ false)); + SuccessOrExit(error = iterator.ReadLabel(aNameBuffer, labelLength, /* aAllowDotCharInLabel */ firstLabel)); aNameBuffer += labelLength; aNameBufferSize -= labelLength; firstLabel = false; diff --git a/src/core/net/dns_types.hpp b/src/core/net/dns_types.hpp index 19b9061ea0b..55dfc26465d 100644 --- a/src/core/net/dns_types.hpp +++ b/src/core/net/dns_types.hpp @@ -73,7 +73,7 @@ using ot::Encoding::BigEndian::HostSwap32; */ /** - * This class implements DNS header generation and parsing. + * Implements DNS header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -87,7 +87,7 @@ class Header : public Clearable
Header(void) { Clear(); } /** - * This method returns the Message ID. + * Returns the Message ID. * * @returns The Message ID value. * @@ -95,7 +95,7 @@ class Header : public Clearable
uint16_t GetMessageId(void) const { return HostSwap16(mMessageId); } /** - * This method sets the Message ID. + * Sets the Message ID. * * @param[in] aMessageId The Message ID value. * @@ -103,7 +103,7 @@ class Header : public Clearable
void SetMessageId(uint16_t aMessageId) { mMessageId = HostSwap16(aMessageId); } /** - * This method sets the Message ID to a crypto-secure randomly generated number. + * Sets the Message ID to a crypto-secure randomly generated number. * * @retval kErrorNone Successfully generated random Message ID. * @retval kErrorFailed Could not generate random Message ID. @@ -122,7 +122,7 @@ class Header : public Clearable
}; /** - * This method returns the type of the message. + * Returns the type of the message. * * @returns The type of the message. * @@ -130,7 +130,7 @@ class Header : public Clearable
Type GetType(void) const { return static_cast((mFlags[0] & kQrFlagMask) >> kQrFlagOffset); } /** - * This method sets the type of the message. + * Sets the type of the message. * * @param[in] aType The type of the message. * @@ -156,7 +156,7 @@ class Header : public Clearable
}; /** - * This method returns the type of the query. + * Returns the type of the query. * * @returns The type of the query. * @@ -164,7 +164,7 @@ class Header : public Clearable
QueryType GetQueryType(void) const { return static_cast((mFlags[0] & kOpCodeMask) >> kOpCodeOffset); } /** - * This method sets the type of the query. + * Sets the type of the query. * * @param[in] aType The type of the query. * @@ -176,7 +176,7 @@ class Header : public Clearable
} /** - * This method specifies in response message if the responding name server is an + * Specifies in response message if the responding name server is an * authority for the domain name in question section. * * @returns True if Authoritative Answer flag (AA) is set in the header, false otherwise. @@ -185,19 +185,19 @@ class Header : public Clearable
bool IsAuthoritativeAnswerFlagSet(void) const { return (mFlags[0] & kAaFlagMask) == kAaFlagMask; } /** - * This method clears the Authoritative Answer flag (AA) in the header. + * Clears the Authoritative Answer flag (AA) in the header. * */ void ClearAuthoritativeAnswerFlag(void) { mFlags[0] &= ~kAaFlagMask; } /** - * This method sets the Authoritative Answer flag (AA) in the header. + * Sets the Authoritative Answer flag (AA) in the header. * */ void SetAuthoritativeAnswerFlag(void) { mFlags[0] |= kAaFlagMask; } /** - * This method specifies if message is truncated. + * Specifies if message is truncated. * * @returns True if Truncation flag (TC) is set in the header, false otherwise. * @@ -205,19 +205,19 @@ class Header : public Clearable
bool IsTruncationFlagSet(void) const { return (mFlags[0] & kTcFlagMask) == kTcFlagMask; } /** - * This method clears the Truncation flag (TC) in the header. + * Clears the Truncation flag (TC) in the header. * */ void ClearTruncationFlag(void) { mFlags[0] &= ~kTcFlagMask; } /** - * This method sets the Truncation flag (TC) in the header. + * Sets the Truncation flag (TC) in the header. * */ void SetTruncationFlag(void) { mFlags[0] |= kTcFlagMask; } /** - * This method specifies if resolver wants to direct the name server to pursue + * Specifies if resolver wants to direct the name server to pursue * the query recursively. * * @returns True if Recursion Desired flag (RD) is set in the header, false otherwise. @@ -226,19 +226,19 @@ class Header : public Clearable
bool IsRecursionDesiredFlagSet(void) const { return (mFlags[0] & kRdFlagMask) == kRdFlagMask; } /** - * This method clears the Recursion Desired flag (RD) in the header. + * Clears the Recursion Desired flag (RD) in the header. * */ void ClearRecursionDesiredFlag(void) { mFlags[0] &= ~kRdFlagMask; } /** - * This method sets the Recursion Desired flag (RD) in the header. + * Sets the Recursion Desired flag (RD) in the header. * */ void SetRecursionDesiredFlag(void) { mFlags[0] |= kRdFlagMask; } /** - * This method denotes whether recursive query support is available in the name server. + * Denotes whether recursive query support is available in the name server. * * @returns True if Recursion Available flag (RA) is set in the header, false otherwise. * @@ -246,13 +246,13 @@ class Header : public Clearable
bool IsRecursionAvailableFlagSet(void) const { return (mFlags[1] & kRaFlagMask) == kRaFlagMask; } /** - * This method clears the Recursion Available flag (RA) in the header. + * Clears the Recursion Available flag (RA) in the header. * */ void ClearRecursionAvailableFlag(void) { mFlags[1] &= ~kRaFlagMask; } /** - * This method sets the Recursion Available flag (RA) in the header. + * Sets the Recursion Available flag (RA) in the header. * */ void SetRecursionAvailableFlag(void) { mFlags[1] |= kRaFlagMask; } @@ -281,7 +281,7 @@ class Header : public Clearable
}; /** - * This method returns the response code. + * Returns the response code. * * @returns The response code from the header. * @@ -289,7 +289,7 @@ class Header : public Clearable
Response GetResponseCode(void) const { return static_cast((mFlags[1] & kRCodeMask) >> kRCodeOffset); } /** - * This method sets the response code. + * Sets the response code. * * @param[in] aResponse The type of the response. * @@ -301,7 +301,7 @@ class Header : public Clearable
} /** - * This method converts a Response Code into a related `Error`. + * Converts a Response Code into a related `Error`. * * - kResponseSuccess (0) : Success (no error condition) -> kErrorNone * - kResponseFormatError (1) : Server unable to interpret due to format error -> kErrorParse @@ -326,7 +326,7 @@ class Header : public Clearable
static Error ResponseCodeToError(Response aResponse); /** - * This method returns the number of entries in question section. + * Returns the number of entries in question section. * * @returns The number of entries in question section. * @@ -334,7 +334,7 @@ class Header : public Clearable
uint16_t GetQuestionCount(void) const { return HostSwap16(mQdCount); } /** - * This method sets the number of entries in question section. + * Sets the number of entries in question section. * * @param[in] aCount The number of entries in question section. * @@ -342,7 +342,7 @@ class Header : public Clearable
void SetQuestionCount(uint16_t aCount) { mQdCount = HostSwap16(aCount); } /** - * This method returns the number of entries in answer section. + * Returns the number of entries in answer section. * * @returns The number of entries in answer section. * @@ -350,7 +350,7 @@ class Header : public Clearable
uint16_t GetAnswerCount(void) const { return HostSwap16(mAnCount); } /** - * This method sets the number of entries in answer section. + * Sets the number of entries in answer section. * * @param[in] aCount The number of entries in answer section. * @@ -358,7 +358,7 @@ class Header : public Clearable
void SetAnswerCount(uint16_t aCount) { mAnCount = HostSwap16(aCount); } /** - * This method returns the number of entries in authority records section. + * Returns the number of entries in authority records section. * * @returns The number of entries in authority records section. * @@ -366,7 +366,7 @@ class Header : public Clearable
uint16_t GetAuthorityRecordCount(void) const { return HostSwap16(mNsCount); } /** - * This method sets the number of entries in authority records section. + * Sets the number of entries in authority records section. * * @param[in] aCount The number of entries in authority records section. * @@ -374,7 +374,7 @@ class Header : public Clearable
void SetAuthorityRecordCount(uint16_t aCount) { mNsCount = HostSwap16(aCount); } /** - * This method returns the number of entries in additional records section. + * Returns the number of entries in additional records section. * * @returns The number of entries in additional records section. * @@ -382,7 +382,7 @@ class Header : public Clearable
uint16_t GetAdditionalRecordCount(void) const { return HostSwap16(mArCount); } /** - * This method sets the number of entries in additional records section. + * Sets the number of entries in additional records section. * * @param[in] aCount The number of entries in additional records section. * @@ -416,7 +416,7 @@ class Header : public Clearable
} OT_TOOL_PACKED_END; /** - * This class implements DNS Update message header generation and parsing. + * Implements DNS Update message header generation and parsing. * * The DNS header specifies record counts for its four sections: Question, Answer, Authority, and Additional. A DNS * Update header uses the same fields, and the same section formats, but the naming and use of these sections differs: @@ -434,7 +434,7 @@ class UpdateHeader : public Header UpdateHeader(void) { SetQueryType(kQueryTypeUpdate); } /** - * This method returns the number of records in Zone section. + * Returns the number of records in Zone section. * * @returns The number of records in Zone section. * @@ -442,7 +442,7 @@ class UpdateHeader : public Header uint16_t GetZoneRecordCount(void) const { return GetQuestionCount(); } /** - * This method sets the number of records in Zone section. + * Sets the number of records in Zone section. * * @param[in] aCount The number of records in Zone section. * @@ -450,7 +450,7 @@ class UpdateHeader : public Header void SetZoneRecordCount(uint16_t aCount) { SetQuestionCount(aCount); } /** - * This method returns the number of records in Prerequisite section. + * Returns the number of records in Prerequisite section. * * @returns The number of records in Prerequisite section. * @@ -458,7 +458,7 @@ class UpdateHeader : public Header uint16_t GetPrerequisiteRecordCount(void) const { return GetAnswerCount(); } /** - * This method sets the number of records in Prerequisite section. + * Sets the number of records in Prerequisite section. * * @param[in] aCount The number of records in Prerequisite section. * @@ -466,7 +466,7 @@ class UpdateHeader : public Header void SetPrerequisiteRecordCount(uint16_t aCount) { SetAnswerCount(aCount); } /** - * This method returns the number of records in Update section. + * Returns the number of records in Update section. * * @returns The number of records in Update section. * @@ -474,7 +474,7 @@ class UpdateHeader : public Header uint16_t GetUpdateRecordCount(void) const { return GetAuthorityRecordCount(); } /** - * This method sets the number of records in Update section. + * Sets the number of records in Update section. * * @param[in] aCount The number of records in Update section. * @@ -484,7 +484,7 @@ class UpdateHeader : public Header } OT_TOOL_PACKED_END; /** - * This class represents a DNS name and implements helper methods for encoding/decoding of DNS Names. + * Represents a DNS name and implements helper methods for encoding/decoding of DNS Names. * */ class Name : public Clearable @@ -517,7 +517,7 @@ class Name : public Clearable static constexpr char kLabelSeparatorChar = '.'; /** - * This enumeration represents the name type. + * Represents the name type. * */ enum Type : uint8_t @@ -528,7 +528,7 @@ class Name : public Clearable }; /** - * This constructor initializes the `Name` object as empty (not specified). + * Initializes the `Name` object as empty (not specified). * */ Name(void) @@ -537,7 +537,7 @@ class Name : public Clearable } /** - * This constructor initializes the `Name` object with a given string. + * Initializes the `Name` object with a given string. * * @param[in] aString A C string specifying the name (dot '.' separated sequence of labels'). * @@ -548,7 +548,7 @@ class Name : public Clearable } /** - * This constructor initializes the `Name` object from a message at a given offset. + * Initializes the `Name` object from a message at a given offset. * * @param[in] aMessage The message containing the encoded name. `aMessage.GetOffset()` MUST point to the start of * the DNS header in the message (used to parse compressed name). @@ -561,7 +561,7 @@ class Name : public Clearable } /** - * This method indicates whether the name is empty (not specified). + * Indicates whether the name is empty (not specified). * * @returns TRUE if the name is empty, FALSE otherwise. * @@ -569,7 +569,7 @@ class Name : public Clearable bool IsEmpty(void) const { return (mString == nullptr) && (mMessage == nullptr); } /** - * This method indicates whether the name is specified from a C string. + * Indicates whether the name is specified from a C string. * * @returns TRUE if the name is specified from a string, FALSE otherwise. * @@ -577,7 +577,7 @@ class Name : public Clearable bool IsFromCString(void) const { return mString != nullptr; } /** - * This method indicates whether the name is specified from a message. + * Indicates whether the name is specified from a message. * * @returns TRUE if the name is specified from a message, FALSE otherwise. * @@ -585,7 +585,7 @@ class Name : public Clearable bool IsFromMessage(void) const { return mMessage != nullptr; } /** - * This method gets the type of `Name` object indicating whether it is empty, specified by a C string or from a + * Gets the type of `Name` object indicating whether it is empty, specified by a C string or from a * message * * @returns The name type. @@ -597,7 +597,7 @@ class Name : public Clearable } /** - * This method sets the name from a given C string. + * Sets the name from a given C string. * * @param[in] aString A C string specifying the name (dot '.' separated sequence of labels). * @@ -609,7 +609,7 @@ class Name : public Clearable } /** - * This method sets the name from a message at a given offset. + * Sets the name from a message at a given offset. * * @param[in] aMessage The message containing the encoded name. `aMessage.GetOffset()` MUST point to the start of * the DNS header in the message (used to parse compressed name). @@ -624,9 +624,9 @@ class Name : public Clearable } /** - * This method gets the name as a C string. + * Gets the name as a C string. * - * This method MUST be used only when the type is `kTypeString`. Otherwise its behavior is undefined. + * MUST be used only when the type is `kTypeString`. Otherwise its behavior is undefined. * * @returns A pointer to the C string. * @@ -634,9 +634,9 @@ class Name : public Clearable const char *GetAsCString(void) const { return mString; } /** - * This method gets the name message and offset. + * Gets the name message and offset. * - * This method MUST be used only when the type is `kTypeMessage`. Otherwise its behavior is undefined. + * MUST be used only when the type is `kTypeMessage`. Otherwise its behavior is undefined. * * @param[out] aOffset A reference to a variable to output the offset of the start of the name in the message. * @@ -650,7 +650,7 @@ class Name : public Clearable } /** - * This method encodes and appends the name to a message. + * Encodes and appends the name to a message. * * If the name is empty (not specified), then root "." is appended to @p aMessage. If the name is from a C string * then the string is checked and appended (similar to static `AppendName(const char *aName, Message &)` method). @@ -668,7 +668,7 @@ class Name : public Clearable Error AppendTo(Message &aMessage) const; /** - * This static method encodes and appends a single name label to a message. + * Encodes and appends a single name label to a message. * * The @p aLabel is assumed to contain a single name label as a C string (null-terminated). Unlike * `AppendMultipleLabels()` which parses the label string and treats it as sequence of multiple (dot-separated) @@ -687,7 +687,7 @@ class Name : public Clearable static Error AppendLabel(const char *aLabel, Message &aMessage); /** - * This static method encodes and appends a single name label of specified length to a message. + * Encodes and appends a single name label of specified length to a message. * * The @p aLabel is assumed to contain a single name label of given @p aLength. @p aLabel must not contain * '\0' characters within the length @p aLength. Unlike `AppendMultipleLabels()` which parses the label string @@ -707,12 +707,12 @@ class Name : public Clearable static Error AppendLabel(const char *aLabel, uint8_t aLength, Message &aMessage); /** - * This static method encodes and appends a sequence of name labels to a given message. + * Encodes and appends a sequence of name labels to a given message. * * The @p aLabels must follow "..", i.e., a sequence of labels separated by dot '.' char. * E.g., "_http._tcp", "_http._tcp." (same as previous one), "host-1.test". * - * This method validates that the @p aLabels is a valid name format, i.e., no empty label, and labels are + * Validates that the @p aLabels is a valid name format, i.e., no empty label, and labels are * `kMaxLabelLength` (63) characters or less. * * @note This method NEVER adds a label terminator (empty label) to the message, even in the case where @p aLabels @@ -729,16 +729,16 @@ class Name : public Clearable static Error AppendMultipleLabels(const char *aLabels, Message &aMessage); /** - * This static method encodes and appends a sequence of name labels within the specified length to a given message. - * This method stops appending labels if @p aLength characters are read or '\0' is found before @p aLength + * Encodes and appends a sequence of name labels within the specified length to a given message. + * Stops appending labels if @p aLength characters are read or '\0' is found before @p aLength * characters. * - * This method is useful for appending a number of labels of the name instead of appending all labels. + * Is useful for appending a number of labels of the name instead of appending all labels. * * The @p aLabels must follow "..", i.e., a sequence of labels separated by dot '.' char. * E.g., "_http._tcp", "_http._tcp." (same as previous one), "host-1.test". * - * This method validates that the @p aLabels is a valid name format, i.e., no empty label, and labels are + * Validates that the @p aLabels is a valid name format, i.e., no empty label, and labels are * `kMaxLabelLength` (63) characters or less. * * @note This method NEVER adds a label terminator (empty label) to the message, even in the case where @p aLabels @@ -756,7 +756,7 @@ class Name : public Clearable static Error AppendMultipleLabels(const char *aLabels, uint8_t aLength, Message &aMessage); /** - * This static method appends a name label terminator to a message. + * Appends a name label terminator to a message. * * An encoded name is terminated by an empty label (a zero byte). * @@ -769,7 +769,7 @@ class Name : public Clearable static Error AppendTerminator(Message &aMessage); /** - * This static method appends a pointer type name label to a message. + * Appends a pointer type name label to a message. * * Pointer label is used for name compression. It allows an entire name or a list of labels at the end of an * encoded name to be replaced with a pointer to a prior occurrence of the same name within the message. @@ -784,12 +784,12 @@ class Name : public Clearable static Error AppendPointerLabel(uint16_t aOffset, Message &aMessage); /** - * This static method encodes and appends a full name to a message. + * Encodes and appends a full name to a message. * * The @p aName must follow "..", i.e., a sequence of labels separated by dot '.' char. * E.g., "example.com", "example.com." (same as previous one), "local.", "default.service.arpa", "." or "" (root). * - * This method validates that the @p aName is a valid name format, i.e. no empty labels, and labels are + * Validates that the @p aName is a valid name format, i.e. no empty labels, and labels are * `kMaxLabelLength` (63) characters or less, and the name is `kMaxLength` (255) characters or less. * * @param[in] aName A name string. Can be `nullptr` (then treated as "." or root). @@ -803,7 +803,7 @@ class Name : public Clearable static Error AppendName(const char *aName, Message &aMessage); /** - * This static method parses and skips over a full name in a message. + * Parses and skips over a full name in a message. * * @param[in] aMessage The message to parse the name from. `aMessage.GetOffset()` MUST point to * the start of DNS header (this is used to handle compressed names). @@ -818,9 +818,9 @@ class Name : public Clearable static Error ParseName(const Message &aMessage, uint16_t &aOffset); /** - * This static method reads a name label from a message. + * Reads a name label from a message. * - * This method can be used to read labels one by one in a name. After a successful label read, @p aOffset is + * Can be used to read labels one by one in a name. After a successful label read, @p aOffset is * updated to point to the start of the next label. When we reach the end of the name, kErrorNotFound is * returned. This method handles compressed names which use pointer labels. So as the labels in a name are read, * the @p aOffset may jump back in the message and at the end the @p aOffset does not necessarily point to the end @@ -848,13 +848,13 @@ class Name : public Clearable static Error ReadLabel(const Message &aMessage, uint16_t &aOffset, char *aLabelBuffer, uint8_t &aLabelLength); /** - * This static method reads a full name from a message. + * Reads a full name from a message. * * On successful read, the read name follows "...", i.e., a sequence of labels separated by * dot '.' character. The read name will ALWAYS end with a dot. * - * This method verifies that the read labels in message do not contain any dot character, otherwise it returns - * `kErrorParse`). + * Verifies that the labels after the first label in message do not contain any dot character. If they do, + * returns `kErrorParse`. * * @param[in] aMessage The message to read the name from. `aMessage.GetOffset()` MUST point to * the start of DNS header (this is used to handle compressed names). @@ -872,9 +872,9 @@ class Name : public Clearable static Error ReadName(const Message &aMessage, uint16_t &aOffset, char *aNameBuffer, uint16_t aNameBufferSize); /** - * This static method compares a single name label from a message with a given label string. + * Compares a single name label from a message with a given label string. * - * This method can be used to compare labels one by one. It checks whether the label read from @p aMessage matches + * Can be used to compare labels one by one. It checks whether the label read from @p aMessage matches * @p aLabel string (case-insensitive comparison). * * Unlike `CompareName()` which requires the labels in the the name string to contain no dot '.' character, this @@ -896,9 +896,9 @@ class Name : public Clearable static Error CompareLabel(const Message &aMessage, uint16_t &aOffset, const char *aLabel); /** - * This static method parses and compares a full name from a message with a given name. + * Parses and compares a full name from a message with a given name. * - * This method checks whether the encoded name in a message matches a given name string (using case-insensitive + * Checks whether the encoded name in a message matches a given name string (using case-insensitive * comparison). It checks the name in the message in place and handles compressed names. If the name read from the * message does not match @p aName, it returns `kErrorNotFound`. `kErrorNone` indicates that the name matches * @p aName. @@ -924,9 +924,9 @@ class Name : public Clearable static Error CompareName(const Message &aMessage, uint16_t &aOffset, const char *aName); /** - * This static method parses and compares a full name from a message with a name from another message. + * Parses and compares a full name from a message with a name from another message. * - * This method checks whether the encoded name in @p aMessage matches the name from @p aMessage2 (using + * Checks whether the encoded name in @p aMessage matches the name from @p aMessage2 (using * case-insensitive comparison). It compares the names in both messages in place and handles compressed names. Note * that this method works correctly even when the same message instance is used for both @p aMessage and * @p aMessage2 (e.g., at different offsets). @@ -957,7 +957,7 @@ class Name : public Clearable static Error CompareName(const Message &aMessage, uint16_t &aOffset, const Message &aMessage2, uint16_t aOffset2); /** - * This static method parses and compares a full name from a message with a given name (using case-insensitive + * Parses and compares a full name from a message with a given name (using case-insensitive * comparison). * * If @p aName is empty (not specified), then any name in @p aMessage is considered a match to it. @@ -978,7 +978,7 @@ class Name : public Clearable static Error CompareName(const Message &aMessage, uint16_t &aOffset, const Name &aName); /** - * This static method tests if a DNS name is a sub-domain of a given domain. + * Tests if a DNS name is a sub-domain of a given domain. * * Both @p aName and @p aDomain can end without dot ('.'). * @@ -991,7 +991,7 @@ class Name : public Clearable static bool IsSubDomainOf(const char *aName, const char *aDomain); /** - * This static method tests if the two DNS name are the same domain. + * Tests if the two DNS name are the same domain. * * Both @p aDomain1 and @p aDomain2 can end without dot ('.'). * @@ -1062,7 +1062,7 @@ class Name : public Clearable }; /** - * This type represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3). + * Represents a TXT record entry representing a key/value pair (RFC 6763 - section 6.3). * */ class TxtEntry : public otDnsTxtEntry @@ -1083,7 +1083,7 @@ class TxtEntry : public otDnsTxtEntry static constexpr uint8_t kMaxKeyLength = OT_DNS_TXT_KEY_MAX_LENGTH; /** - * This class represents an iterator for TXT record entries (key/value pairs). + * Represents an iterator for TXT record entries (key/value pairs). * */ class Iterator : public otDnsTxtEntryIterator @@ -1092,7 +1092,7 @@ class TxtEntry : public otDnsTxtEntry public: /** - * This method initializes a TXT record iterator. + * Initializes a TXT record iterator. * * The buffer pointer @p aTxtData and its content MUST persist and remain unchanged while the iterator object * is being used. @@ -1104,7 +1104,7 @@ class TxtEntry : public otDnsTxtEntry void Init(const uint8_t *aTxtData, uint16_t aTxtDataLength); /** - * This method parses the TXT data from the `Iterator` and gets the next TXT record entry (key/value pair). + * Parses the TXT data from the `Iterator` and gets the next TXT record entry (key/value pair). * * The `Iterator` instance MUST be initialized using `Init()` before calling this method and the TXT data * buffer used to initialize the iterator MUST persist and remain unchanged. @@ -1144,7 +1144,7 @@ class TxtEntry : public otDnsTxtEntry TxtEntry(void) = default; /** - * This constructor initializes a `TxtEntry` object. + * Initializes a `TxtEntry` object. * * @param[in] aKey A pointer to the key string. * @param[in] aValue A pointer to a buffer containing the value. @@ -1154,7 +1154,7 @@ class TxtEntry : public otDnsTxtEntry TxtEntry(const char *aKey, const uint8_t *aValue, uint8_t aValueLength) { Init(aKey, aValue, aValueLength); } /** - * This method initializes a `TxtEntry` object. + * Initializes a `TxtEntry` object. * * @param[in] aKey A pointer to the key string. * @param[in] aValue A pointer to a buffer containing the value. @@ -1169,7 +1169,7 @@ class TxtEntry : public otDnsTxtEntry } /** - * This method encodes and appends the `TxtEntry` to a message. + * Encodes and appends the `TxtEntry` to a message. * * @param[in] aMessage The message to append to. * @@ -1181,7 +1181,7 @@ class TxtEntry : public otDnsTxtEntry Error AppendTo(Message &aMessage) const; /** - * This static method appends an array of `TxtEntry` items to a message. + * Appends an array of `TxtEntry` items to a message. * * @param[in] aEntries A pointer to array of `TxtEntry` items. * @param[in] aNumEntries The number of entries in @p aEntries array. @@ -1195,7 +1195,7 @@ class TxtEntry : public otDnsTxtEntry static Error AppendEntries(const TxtEntry *aEntries, uint8_t aNumEntries, Message &aMessage); /** - * This static method appends an array of `TxtEntry` items to a `MutableData` buffer. + * Appends an array of `TxtEntry` items to a `MutableData` buffer. * * @param[in] aEntries A pointer to array of `TxtEntry` items. * @param[in] aNumEntries The number of entries in @p aEntries array. @@ -1217,7 +1217,7 @@ class TxtEntry : public otDnsTxtEntry }; /** - * This class implements Resource Record (RR) body format. + * Implements Resource Record (RR) body format. * */ OT_TOOL_PACKED_BEGIN @@ -1246,9 +1246,9 @@ class ResourceRecord static constexpr uint16_t kClassAny = 255; ///< Class code Any (ANY). /** - * This method initializes the resource record by setting its type and class. + * Initializes the resource record by setting its type and class. * - * This method only sets the type and class fields. Other fields (TTL and length) remain unchanged/uninitialized. + * Only sets the type and class fields. Other fields (TTL and length) remain unchanged/uninitialized. * * @param[in] aType The type of the resource record. * @param[in] aClass The class of the resource record (default is `kClassInternet`). @@ -1261,7 +1261,7 @@ class ResourceRecord } /** - * This method indicates whether the resources records matches a given type and class code. + * Indicates whether the resources records matches a given type and class code. * * @param[in] aType The resource record type to compare with. * @param[in] aClass The resource record class code to compare with (default is `kClassInternet`). @@ -1275,7 +1275,7 @@ class ResourceRecord } /** - * This method returns the type of the resource record. + * Returns the type of the resource record. * * @returns The type of the resource record. * @@ -1283,7 +1283,7 @@ class ResourceRecord uint16_t GetType(void) const { return HostSwap16(mType); } /** - * This method sets the type of the resource record. + * Sets the type of the resource record. * * @param[in] aType The type of the resource record. * @@ -1291,7 +1291,7 @@ class ResourceRecord void SetType(uint16_t aType) { mType = HostSwap16(aType); } /** - * This method returns the class of the resource record. + * Returns the class of the resource record. * * @returns The class of the resource record. * @@ -1299,7 +1299,7 @@ class ResourceRecord uint16_t GetClass(void) const { return HostSwap16(mClass); } /** - * This method sets the class of the resource record. + * Sets the class of the resource record. * * @param[in] aClass The class of the resource record. * @@ -1307,7 +1307,7 @@ class ResourceRecord void SetClass(uint16_t aClass) { mClass = HostSwap16(aClass); } /** - * This method returns the time to live field of the resource record. + * Returns the time to live field of the resource record. * * @returns The time to live field of the resource record. * @@ -1315,7 +1315,7 @@ class ResourceRecord uint32_t GetTtl(void) const { return HostSwap32(mTtl); } /** - * This method sets the time to live field of the resource record. + * Sets the time to live field of the resource record. * * @param[in] aTtl The time to live field of the resource record. * @@ -1323,7 +1323,7 @@ class ResourceRecord void SetTtl(uint32_t aTtl) { mTtl = HostSwap32(aTtl); } /** - * This method returns the length of the resource record data. + * Returns the length of the resource record data. * * @returns The length of the resource record data. * @@ -1331,7 +1331,7 @@ class ResourceRecord uint16_t GetLength(void) const { return HostSwap16(mLength); } /** - * This method sets the length of the resource record data. + * Sets the length of the resource record data. * * @param[in] aLength The length of the resource record data. * @@ -1339,7 +1339,7 @@ class ResourceRecord void SetLength(uint16_t aLength) { mLength = HostSwap16(aLength); } /** - * This method returns the size of (number of bytes) in resource record and its data RDATA section (excluding the + * Returns the size of (number of bytes) in resource record and its data RDATA section (excluding the * name field). * * @returns Size (number of bytes) of resource record and its data section (excluding the name field) @@ -1348,7 +1348,7 @@ class ResourceRecord uint32_t GetSize(void) const { return sizeof(ResourceRecord) + GetLength(); } /** - * This static method parses and skips over a given number of resource records in a message from a given offset. + * Parses and skips over a given number of resource records in a message from a given offset. * * @param[in] aMessage The message from which to parse/read the resource records. `aMessage.GetOffset()` * MUST point to the start of DNS header. @@ -1364,7 +1364,7 @@ class ResourceRecord static Error ParseRecords(const Message &aMessage, uint16_t &aOffset, uint16_t aNumRecords); /** - * This static method searches in a given message to find the first resource record matching a given record name. + * Searches in a given message to find the first resource record matching a given record name. * * @param[in] aMessage The message in which to search for a matching resource record. * `aMessage.GetOffset()` MUST point to the start of DNS header. @@ -1389,7 +1389,7 @@ class ResourceRecord * This template static method searches in a message to find the i-th occurrence of resource records of specific * type with a given record name and if found, reads the record from the message. * - * This method searches in @p aMessage starting from @p aOffset up to maximum of @p aNumRecords, for the + * Searches in @p aMessage starting from @p aOffset up to maximum of @p aNumRecords, for the * `(aIndex+1)`th occurrence of a resource record of `RecordType` with record name @p aName. * * On success (i.e., when a matching record is found and read from the message), @p aOffset is updated to point @@ -1433,10 +1433,10 @@ class ResourceRecord * This template static method tries to read a resource record of a given type from a message. If the record type * does not matches the type, it skips over the record. * - * This method requires the record name to be already parsed/read from the message. On input, @p aOffset should + * Requires the record name to be already parsed/read from the message. On input, @p aOffset should * point to the start of the `ResourceRecord` fields (type, class, TTL, data length) in @p aMessage. * - * This method verifies that the record is well-formed in the message. It then reads the record type and compares + * Verifies that the record is well-formed in the message. It then reads the record type and compares * it with `RecordType::kType` and ensures that the record size is at least `sizeof(RecordType)`. If it all matches, * the record is read into @p aRecord. * @@ -1506,7 +1506,7 @@ class ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of A type. + * Implements Resource Record body format of A type. * */ OT_TOOL_PACKED_BEGIN @@ -1516,7 +1516,7 @@ class ARecord : public ResourceRecord static constexpr uint16_t kType = kTypeA; ///< The A record type. /** - * This method initializes the A Resource Record by setting its type, class, and length. + * Initializes the A Resource Record by setting its type, class, and length. * * Other record fields (TTL, address) remain unchanged/uninitialized. * @@ -1528,7 +1528,7 @@ class ARecord : public ResourceRecord } /** - * This method sets the IPv4 address of the resource record. + * Sets the IPv4 address of the resource record. * * @param[in] aAddress The IPv4 address of the resource record. * @@ -1536,7 +1536,7 @@ class ARecord : public ResourceRecord void SetAddress(const Ip4::Address &aAddress) { mAddress = aAddress; } /** - * This method returns the reference to IPv4 address of the resource record. + * Returns the reference to IPv4 address of the resource record. * * @returns The reference to IPv4 address of the resource record. * @@ -1548,7 +1548,7 @@ class ARecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of CNAME type. + * Implements Resource Record body format of CNAME type. * */ OT_TOOL_PACKED_BEGIN @@ -1558,7 +1558,7 @@ class CnameRecord : public ResourceRecord static constexpr uint16_t kType = kTypeCname; ///< The CNAME record type. /** - * This method initializes the CNAME Resource Record by setting its type and class. + * Initializes the CNAME Resource Record by setting its type and class. * * Other record fields (TTL, length) remain unchanged/uninitialized. * @@ -1568,9 +1568,9 @@ class CnameRecord : public ResourceRecord void Init(uint16_t aClass = kClassInternet) { ResourceRecord::Init(kTypeCname, aClass); } /** - * This method parses and reads the CNAME alias name from a message. + * Parses and reads the CNAME alias name from a message. * - * This method also verifies that the CNAME record is well-formed (e.g., the record data length `GetLength()` + * Also verifies that the CNAME record is well-formed (e.g., the record data length `GetLength()` * matches the CNAME encoded name). * * @param[in] aMessage The message to read from. `aMessage.GetOffset()` MUST point to the start of @@ -1599,7 +1599,7 @@ class CnameRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of PTR type. + * Implements Resource Record body format of PTR type. * */ OT_TOOL_PACKED_BEGIN @@ -1609,7 +1609,7 @@ class PtrRecord : public ResourceRecord static constexpr uint16_t kType = kTypePtr; ///< The PTR record type. /** - * This method initializes the PTR Resource Record by setting its type and class. + * Initializes the PTR Resource Record by setting its type and class. * * Other record fields (TTL, length) remain unchanged/uninitialized. * @@ -1619,9 +1619,9 @@ class PtrRecord : public ResourceRecord void Init(uint16_t aClass = kClassInternet) { ResourceRecord::Init(kTypePtr, aClass); } /** - * This method parses and reads the PTR name from a message. + * Parses and reads the PTR name from a message. * - * This method also verifies that the PTR record is well-formed (e.g., the record data length `GetLength()` matches + * Also verifies that the PTR record is well-formed (e.g., the record data length `GetLength()` matches * the PTR encoded name). * * @param[in] aMessage The message to read from. `aMessage.GetOffset()` MUST point to the start of @@ -1646,9 +1646,9 @@ class PtrRecord : public ResourceRecord } /** - * This method parses and reads the PTR name from a message. + * Parses and reads the PTR name from a message. * - * This method also verifies that the PTR record is well-formed (e.g., the record data length `GetLength()` matches + * Also verifies that the PTR record is well-formed (e.g., the record data length `GetLength()` matches * the PTR encoded name). * * Unlike the previous method which reads the entire PTR name into a single char buffer, this method reads the @@ -1684,7 +1684,7 @@ class PtrRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of TXT type. + * Implements Resource Record body format of TXT type. * */ OT_TOOL_PACKED_BEGIN @@ -1694,7 +1694,7 @@ class TxtRecord : public ResourceRecord static constexpr uint16_t kType = kTypeTxt; ///< The TXT record type. /** - * This method initializes the TXT Resource Record by setting its type and class. + * Initializes the TXT Resource Record by setting its type and class. * * Other record fields (TTL, length) remain unchanged/uninitialized. * @@ -1704,9 +1704,9 @@ class TxtRecord : public ResourceRecord void Init(uint16_t aClass = kClassInternet) { ResourceRecord::Init(kTypeTxt, aClass); } /** - * This method parses and reads the TXT record data from a message. + * Parses and reads the TXT record data from a message. * - * This method also checks if the TXT data is well-formed by calling `VerifyTxtData()` when it is successfully + * Also checks if the TXT data is well-formed by calling `VerifyTxtData()` when it is successfully * read. * * @param[in] aMessage The message to read from. @@ -1728,7 +1728,7 @@ class TxtRecord : public ResourceRecord Error ReadTxtData(const Message &aMessage, uint16_t &aOffset, uint8_t *aTxtBuffer, uint16_t &aTxtBufferSize) const; /** - * This static method tests if a buffer contains valid encoded TXT data. + * Tests if a buffer contains valid encoded TXT data. * * @param[in] aTxtData The TXT data buffer. * @param[in] aTxtLength The length of the TXT data buffer. @@ -1742,7 +1742,7 @@ class TxtRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of AAAA type. + * Implements Resource Record body format of AAAA type. * */ OT_TOOL_PACKED_BEGIN @@ -1752,7 +1752,7 @@ class AaaaRecord : public ResourceRecord static constexpr uint16_t kType = kTypeAaaa; ///< The AAAA record type. /** - * This method initializes the AAAA Resource Record by setting its type, class, and length. + * Initializes the AAAA Resource Record by setting its type, class, and length. * * Other record fields (TTL, address) remain unchanged/uninitialized. * @@ -1764,7 +1764,7 @@ class AaaaRecord : public ResourceRecord } /** - * This method tells whether this is a valid AAAA record. + * Tells whether this is a valid AAAA record. * * @returns A boolean indicates whether this is a valid AAAA record. * @@ -1772,7 +1772,7 @@ class AaaaRecord : public ResourceRecord bool IsValid(void) const; /** - * This method sets the IPv6 address of the resource record. + * Sets the IPv6 address of the resource record. * * @param[in] aAddress The IPv6 address of the resource record. * @@ -1780,7 +1780,7 @@ class AaaaRecord : public ResourceRecord void SetAddress(const Ip6::Address &aAddress) { mAddress = aAddress; } /** - * This method returns the reference to IPv6 address of the resource record. + * Returns the reference to IPv6 address of the resource record. * * @returns The reference to IPv6 address of the resource record. * @@ -1792,7 +1792,7 @@ class AaaaRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of SRV type (RFC 2782). + * Implements Resource Record body format of SRV type (RFC 2782). * */ OT_TOOL_PACKED_BEGIN @@ -1802,7 +1802,7 @@ class SrvRecord : public ResourceRecord static constexpr uint16_t kType = kTypeSrv; ///< The SRV record type. /** - * This method initializes the SRV Resource Record by settings its type and class. + * Initializes the SRV Resource Record by settings its type and class. * * Other record fields (TTL, length, propriety, weight, port, ...) remain unchanged/uninitialized. * @@ -1812,7 +1812,7 @@ class SrvRecord : public ResourceRecord void Init(uint16_t aClass = kClassInternet) { ResourceRecord::Init(kTypeSrv, aClass); } /** - * This method returns the SRV record's priority value. + * Returns the SRV record's priority value. * * @returns The priority value. * @@ -1820,7 +1820,7 @@ class SrvRecord : public ResourceRecord uint16_t GetPriority(void) const { return HostSwap16(mPriority); } /** - * This method sets the SRV record's priority value. + * Sets the SRV record's priority value. * * @param[in] aPriority The priority value. * @@ -1828,7 +1828,7 @@ class SrvRecord : public ResourceRecord void SetPriority(uint16_t aPriority) { mPriority = HostSwap16(aPriority); } /** - * This method returns the SRV record's weight value. + * Returns the SRV record's weight value. * * @returns The weight value. * @@ -1836,7 +1836,7 @@ class SrvRecord : public ResourceRecord uint16_t GetWeight(void) const { return HostSwap16(mWeight); } /** - * This method sets the SRV record's weight value. + * Sets the SRV record's weight value. * * @param[in] aWeight The weight value. * @@ -1844,7 +1844,7 @@ class SrvRecord : public ResourceRecord void SetWeight(uint16_t aWeight) { mWeight = HostSwap16(aWeight); } /** - * This method returns the SRV record's port number on the target host for this service. + * Returns the SRV record's port number on the target host for this service. * * @returns The port number. * @@ -1852,7 +1852,7 @@ class SrvRecord : public ResourceRecord uint16_t GetPort(void) const { return HostSwap16(mPort); } /** - * This method sets the SRV record's port number on the target host for this service. + * Sets the SRV record's port number on the target host for this service. * * @param[in] aPort The port number. * @@ -1860,9 +1860,9 @@ class SrvRecord : public ResourceRecord void SetPort(uint16_t aPort) { mPort = HostSwap16(aPort); } /** - * This method parses and reads the SRV target host name from a message. + * Parses and reads the SRV target host name from a message. * - * This method also verifies that the SRV record is well-formed (e.g., the record data length `GetLength()` matches + * Also verifies that the SRV record is well-formed (e.g., the record data length `GetLength()` matches * the SRV encoded name). * * @param[in] aMessage The message to read from. `aMessage.GetOffset()` MUST point to the start of @@ -1898,7 +1898,7 @@ class SrvRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements Resource Record body format of KEY type (RFC 2535). + * Implements Resource Record body format of KEY type (RFC 2535). * */ OT_TOOL_PACKED_BEGIN @@ -1918,7 +1918,7 @@ class KeyRecord : public ResourceRecord static constexpr uint8_t kAlgorithmEd448 = 16; ///< ED448 algorithm. /** - * This enumeration type represents the use (or key type) flags (RFC 2535 - section 3.1.2). + * Type represents the use (or key type) flags (RFC 2535 - section 3.1.2). * */ enum UseFlags : uint8_t @@ -1930,7 +1930,7 @@ class KeyRecord : public ResourceRecord }; /** - * This enumeration type represents key owner (or name type) flags (RFC 2535 - section 3.1.2). + * Type represents key owner (or name type) flags (RFC 2535 - section 3.1.2). * */ enum OwnerFlags : uint8_t @@ -1970,7 +1970,7 @@ class KeyRecord : public ResourceRecord static constexpr uint8_t kSignatoryFlagGeneral = 1 << 0; /** - * This method initializes the KEY Resource Record by setting its type and class. + * Initializes the KEY Resource Record by setting its type and class. * * Other record fields (TTL, length, flags, protocol, algorithm) remain unchanged/uninitialized. * @@ -1980,7 +1980,7 @@ class KeyRecord : public ResourceRecord void Init(uint16_t aClass = kClassInternet) { ResourceRecord::Init(kTypeKey, aClass); } /** - * This method tells whether the KEY record is valid. + * Tells whether the KEY record is valid. * * @returns TRUE if this is a valid KEY record, FALSE if an invalid KEY record. * @@ -1988,7 +1988,7 @@ class KeyRecord : public ResourceRecord bool IsValid(void) const; /** - * This method gets the key use (or key type) flags. + * Gets the key use (or key type) flags. * * @returns The key use flags. * @@ -1996,7 +1996,7 @@ class KeyRecord : public ResourceRecord UseFlags GetUseFlags(void) const { return static_cast(mFlags[0] & kUseFlagsMask); } /** - * This method gets the owner (or name type) flags. + * Gets the owner (or name type) flags. * * @returns The key owner flags. * @@ -2004,7 +2004,7 @@ class KeyRecord : public ResourceRecord OwnerFlags GetOwnerFlags(void) const { return static_cast(mFlags[0] & kOwnerFlagsMask); } /** - * This method gets the signatory flags. + * Gets the signatory flags. * * @returns The signatory flags. * @@ -2012,7 +2012,7 @@ class KeyRecord : public ResourceRecord uint8_t GetSignatoryFlags(void) const { return (mFlags[1] & kSignatoryFlagsMask); } /** - * This method sets the flags field. + * Sets the flags field. * * @param[in] aUseFlags The `UseFlags` value. * @param[in] aOwnerFlags The `OwnerFlags` value. @@ -2026,7 +2026,7 @@ class KeyRecord : public ResourceRecord } /** - * This method returns the KEY record's protocol value. + * Returns the KEY record's protocol value. * * @returns The protocol value. * @@ -2034,7 +2034,7 @@ class KeyRecord : public ResourceRecord uint8_t GetProtocol(void) const { return mProtocol; } /** - * This method sets the KEY record's protocol value. + * Sets the KEY record's protocol value. * * @param[in] aProtocol The protocol value. * @@ -2042,7 +2042,7 @@ class KeyRecord : public ResourceRecord void SetProtocol(uint8_t aProtocol) { mProtocol = aProtocol; } /** - * This method returns the KEY record's algorithm value. + * Returns the KEY record's algorithm value. * * @returns The algorithm value. * @@ -2050,7 +2050,7 @@ class KeyRecord : public ResourceRecord uint8_t GetAlgorithm(void) const { return mAlgorithm; } /** - * This method sets the KEY record's algorithm value. + * Sets the KEY record's algorithm value. * * @param[in] aAlgorithm The algorithm value. * @@ -2084,7 +2084,7 @@ class Ecdsa256KeyRecord : public KeyRecord, public Clearable, { public: /** - * This method initializes the KEY Resource Record to ECDSA with curve P-256. + * Initializes the KEY Resource Record to ECDSA with curve P-256. * * Other record fields (TTL, length, flags, protocol) remain unchanged/uninitialized. * @@ -2092,7 +2092,7 @@ class Ecdsa256KeyRecord : public KeyRecord, public Clearable, void Init(void); /** - * This method tells whether this is a valid ECDSA DNSKEY with curve P-256. + * Tells whether this is a valid ECDSA DNSKEY with curve P-256. * * @returns A boolean that indicates whether this is a valid ECDSA DNSKEY RR with curve P-256. * @@ -2100,7 +2100,7 @@ class Ecdsa256KeyRecord : public KeyRecord, public Clearable, bool IsValid(void) const; /** - * This method returns the ECDSA P-256 public kek. + * Returns the ECDSA P-256 public kek. * * @returns A reference to the public key. * @@ -2113,7 +2113,7 @@ class Ecdsa256KeyRecord : public KeyRecord, public Clearable, #endif // OPENTHREAD_CONFIG_SRP_SERVER_ENABLE /** - * This class implements Resource Record body format of SIG type (RFC 2535 - section-4.1). + * Implements Resource Record body format of SIG type (RFC 2535 - section-4.1). * * */ @@ -2124,7 +2124,7 @@ class SigRecord : public ResourceRecord, public Clearable static constexpr uint16_t kType = kTypeSig; ///< The SIG record type. /** - * This method initializes the SIG Resource Record by setting its type and class. + * Initializes the SIG Resource Record by setting its type and class. * * Other record fields (TTL, length, ...) remain unchanged/uninitialized. * @@ -2136,7 +2136,7 @@ class SigRecord : public ResourceRecord, public Clearable void Init(uint16_t aClass) { ResourceRecord::Init(kTypeSig, aClass); } /** - * This method tells whether the SIG record is valid. + * Tells whether the SIG record is valid. * * @returns TRUE if this is a valid SIG record, FALSE if not a valid SIG record. * @@ -2144,7 +2144,7 @@ class SigRecord : public ResourceRecord, public Clearable bool IsValid(void) const; /** - * This method returns the SIG record's type-covered value. + * Returns the SIG record's type-covered value. * * @returns The type-covered value. * @@ -2152,7 +2152,7 @@ class SigRecord : public ResourceRecord, public Clearable uint16_t GetTypeCovered(void) const { return HostSwap16(mTypeCovered); } /** - * This method sets the SIG record's type-covered value. + * Sets the SIG record's type-covered value. * * @param[in] aTypeCovered The type-covered value. * @@ -2160,7 +2160,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetTypeCovered(uint8_t aTypeCovered) { mTypeCovered = HostSwap16(aTypeCovered); } /** - * This method returns the SIG record's algorithm value. + * Returns the SIG record's algorithm value. * * @returns The algorithm value. * @@ -2168,7 +2168,7 @@ class SigRecord : public ResourceRecord, public Clearable uint8_t GetAlgorithm(void) const { return mAlgorithm; } /** - * This method sets the SIG record's algorithm value. + * Sets the SIG record's algorithm value. * * @param[in] aAlgorithm The algorithm value. * @@ -2176,7 +2176,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetAlgorithm(uint8_t aAlgorithm) { mAlgorithm = aAlgorithm; } /** - * This method returns the SIG record's labels-count (number of labels, not counting null label, in the original + * Returns the SIG record's labels-count (number of labels, not counting null label, in the original * name of the owner). * * @returns The labels-count value. @@ -2185,7 +2185,7 @@ class SigRecord : public ResourceRecord, public Clearable uint8_t GetLabels(void) const { return mLabels; } /** - * This method sets the SIG record's labels-count (number of labels, not counting null label, in the original + * Sets the SIG record's labels-count (number of labels, not counting null label, in the original * name of the owner). * * @param[in] aLabels The labels-count value. @@ -2194,7 +2194,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetLabels(uint8_t aLabels) { mLabels = aLabels; } /** - * This method returns the SIG record's original TTL value. + * Returns the SIG record's original TTL value. * * @returns The original TTL value. * @@ -2202,7 +2202,7 @@ class SigRecord : public ResourceRecord, public Clearable uint32_t GetOriginalTtl(void) const { return HostSwap32(mOriginalTtl); } /** - * This method sets the SIG record's original TTL value. + * Sets the SIG record's original TTL value. * * @param[in] aOriginalTtl The original TTL value. * @@ -2210,7 +2210,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetOriginalTtl(uint32_t aOriginalTtl) { mOriginalTtl = HostSwap32(aOriginalTtl); } /** - * This method returns the SIG record's expiration time value. + * Returns the SIG record's expiration time value. * * @returns The expiration time value (seconds since Jan 1, 1970). * @@ -2218,7 +2218,7 @@ class SigRecord : public ResourceRecord, public Clearable uint32_t GetExpiration(void) const { return HostSwap32(mExpiration); } /** - * This method sets the SIG record's expiration time value. + * Sets the SIG record's expiration time value. * * @param[in] aExpiration The expiration time value (seconds since Jan 1, 1970). * @@ -2226,7 +2226,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetExpiration(uint32_t aExpiration) { mExpiration = HostSwap32(aExpiration); } /** - * This method returns the SIG record's inception time value. + * Returns the SIG record's inception time value. * * @returns The inception time value (seconds since Jan 1, 1970). * @@ -2234,7 +2234,7 @@ class SigRecord : public ResourceRecord, public Clearable uint32_t GetInception(void) const { return HostSwap32(mInception); } /** - * This method sets the SIG record's inception time value. + * Sets the SIG record's inception time value. * * @param[in] aInception The inception time value (seconds since Jan 1, 1970). * @@ -2242,7 +2242,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetInception(uint32_t aInception) { mInception = HostSwap32(aInception); } /** - * This method returns the SIG record's key tag value. + * Returns the SIG record's key tag value. * * @returns The key tag value. * @@ -2250,7 +2250,7 @@ class SigRecord : public ResourceRecord, public Clearable uint16_t GetKeyTag(void) const { return HostSwap16(mKeyTag); } /** - * This method sets the SIG record's key tag value. + * Sets the SIG record's key tag value. * * @param[in] aKeyTag The key tag value. * @@ -2258,7 +2258,7 @@ class SigRecord : public ResourceRecord, public Clearable void SetKeyTag(uint16_t aKeyTag) { mKeyTag = HostSwap16(aKeyTag); } /** - * This method returns a pointer to the start of the record data fields. + * Returns a pointer to the start of the record data fields. * * @returns A pointer to the start of the record data fields. * @@ -2266,7 +2266,7 @@ class SigRecord : public ResourceRecord, public Clearable const uint8_t *GetRecordData(void) const { return reinterpret_cast(&mTypeCovered); } /** - * This method parses and reads the SIG signer name from a message. + * Parses and reads the SIG signer name from a message. * * @param[in] aMessage The message to read from. `aMessage.GetOffset()` MUST point to the start of DNS * header. @@ -2301,7 +2301,7 @@ class SigRecord : public ResourceRecord, public Clearable } OT_TOOL_PACKED_END; /** - * This class implements DNS OPT Pseudo Resource Record header for EDNS(0) (RFC 6891 - Section 6.1). + * Implements DNS OPT Pseudo Resource Record header for EDNS(0) (RFC 6891 - Section 6.1). * */ OT_TOOL_PACKED_BEGIN @@ -2311,7 +2311,7 @@ class OptRecord : public ResourceRecord static constexpr uint16_t kType = kTypeOpt; ///< The OPT record type. /** - * This method initializes the OPT Resource Record by setting its type and clearing extended Response Code, version + * Initializes the OPT Resource Record by setting its type and clearing extended Response Code, version * and all flags. * * Other record fields (UDP payload size, length) remain unchanged/uninitialized. @@ -2324,7 +2324,7 @@ class OptRecord : public ResourceRecord } /** - * This method gets the requester's UDP payload size (the number of bytes of the largest UDP payload that can be + * Gets the requester's UDP payload size (the number of bytes of the largest UDP payload that can be * delivered in the requester's network). * * The field is encoded in the CLASS field. @@ -2335,7 +2335,7 @@ class OptRecord : public ResourceRecord uint16_t GetUdpPayloadSize(void) const { return GetClass(); } /** - * This method gets the requester's UDP payload size (the number of bytes of the largest UDP payload that can be + * Gets the requester's UDP payload size (the number of bytes of the largest UDP payload that can be * delivered in the requester's network). * * @param[in] aPayloadSize The UDP payload size. @@ -2344,7 +2344,7 @@ class OptRecord : public ResourceRecord void SetUdpPayloadSize(uint16_t aPayloadSize) { SetClass(aPayloadSize); } /** - * This method gets the upper 8-bit of the extended 12-bit Response Code. + * Gets the upper 8-bit of the extended 12-bit Response Code. * * Value of 0 indicates that an unextended Response code is in use. * @@ -2354,7 +2354,7 @@ class OptRecord : public ResourceRecord uint8_t GetExtendedResponseCode(void) const { return GetTtlByteAt(kExtRCodeByteIndex); } /** - * This method sets the upper 8-bit of the extended 12-bit Response Code. + * Sets the upper 8-bit of the extended 12-bit Response Code. * * Value of 0 indicates that an unextended Response code is in use. * @@ -2364,7 +2364,7 @@ class OptRecord : public ResourceRecord void SetExtendedResponseCode(uint8_t aExtendedResponse) { GetTtlByteAt(kExtRCodeByteIndex) = aExtendedResponse; } /** - * This method gets the Version field. + * Gets the Version field. * * @returns The version. * @@ -2372,7 +2372,7 @@ class OptRecord : public ResourceRecord uint8_t GetVersion(void) const { return GetTtlByteAt(kVersionByteIndex); } /** - * This method set the Version field. + * Set the Version field. * * @param[in] aVersion The version. * @@ -2380,7 +2380,7 @@ class OptRecord : public ResourceRecord void SetVersion(uint8_t aVersion) { GetTtlByteAt(kVersionByteIndex) = aVersion; } /** - * This method indicates whether the DNSSEC OK flag is set or not. + * Indicates whether the DNSSEC OK flag is set or not. * * @returns True if DNSSEC OK flag is set in the header, false otherwise. * @@ -2388,13 +2388,13 @@ class OptRecord : public ResourceRecord bool IsDnsSecurityFlagSet(void) const { return (GetTtlByteAt(kFlagByteIndex) & kDnsSecFlag) != 0; } /** - * This method clears the DNSSEC OK bit flag. + * Clears the DNSSEC OK bit flag. * */ void ClearDnsSecurityFlag(void) { GetTtlByteAt(kFlagByteIndex) &= ~kDnsSecFlag; } /** - * This method sets the DNSSEC OK bit flag. + * Sets the DNSSEC OK bit flag. * */ void SetDnsSecurityFlag(void) { GetTtlByteAt(kFlagByteIndex) |= kDnsSecFlag; } @@ -2425,7 +2425,7 @@ class OptRecord : public ResourceRecord } OT_TOOL_PACKED_END; /** - * This class implements the body of an Option in OPT Pseudo Resource Record (RFC 6981 - Section 6.1). + * Implements the body of an Option in OPT Pseudo Resource Record (RFC 6981 - Section 6.1). * */ OT_TOOL_PACKED_BEGIN @@ -2435,7 +2435,7 @@ class Option static constexpr uint16_t kUpdateLease = 2; ///< Update lease option code. /** - * This method returns the option code value. + * Returns the option code value. * * @returns The option code value. * @@ -2443,7 +2443,7 @@ class Option uint16_t GetOptionCode(void) const { return HostSwap16(mOptionCode); } /** - * This method sets the option code value. + * Sets the option code value. * * @param[in] aOptionCode The option code value. * @@ -2451,7 +2451,7 @@ class Option void SetOptionCode(uint16_t aOptionCode) { mOptionCode = HostSwap16(aOptionCode); } /** - * This method returns the option length value. + * Returns the option length value. * * @returns The option length (size of option data in bytes). * @@ -2459,7 +2459,7 @@ class Option uint16_t GetOptionLength(void) const { return HostSwap16(mOptionLength); } /** - * This method sets the option length value. + * Sets the option length value. * * @param[in] aOptionLength The option length (size of option data in bytes). * @@ -2467,7 +2467,7 @@ class Option void SetOptionLength(uint16_t aOptionLength) { mOptionLength = HostSwap16(aOptionLength); } /** - * This method returns the size of (number of bytes) in the Option and its data. + * Returns the size of (number of bytes) in the Option and its data. * * @returns Size (number of bytes) of the Option its data section. * @@ -2482,7 +2482,7 @@ class Option } OT_TOOL_PACKED_END; /** - * This class implements an Update Lease Option body. + * Implements an Update Lease Option body. * * This implementation is intended for use in Dynamic DNS Update Lease Requests and Responses as specified in * https://tools.ietf.org/html/draft-sekar-dns-ul-02. @@ -2493,7 +2493,7 @@ class LeaseOption : public Option { public: /** - * This method initializes the Update Lease Option using the short variant format which contains lease interval + * Initializes the Update Lease Option using the short variant format which contains lease interval * only. * * @param[in] aLeaseInterval The lease interval in seconds. @@ -2502,7 +2502,7 @@ class LeaseOption : public Option void InitAsShortVariant(uint32_t aLeaseInterval); /** - * This method initializes the Update Lease Option using the long variant format which contains both lease and + * Initializes the Update Lease Option using the long variant format which contains both lease and * key lease intervals. * * @param[in] aLeaseInterval The lease interval in seconds. @@ -2512,7 +2512,7 @@ class LeaseOption : public Option void InitAsLongVariant(uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval); /** - * This method indicates whether or not the Update Lease Option follows the short variant format which contains + * Indicates whether or not the Update Lease Option follows the short variant format which contains * only the lease interval. * * @retval TRUE The Update Lease Option follows the short variant format. @@ -2522,9 +2522,9 @@ class LeaseOption : public Option bool IsShortVariant(void) const { return (GetOptionLength() == kShortLength); } /** - * This method tells whether this is a valid Lease Option. + * Tells whether this is a valid Lease Option. * - * This method validates that option follows either short or long variant format. + * Validates that option follows either short or long variant format. * * @returns TRUE if this is a valid Lease Option, FALSE if not a valid Lease Option. * @@ -2532,7 +2532,7 @@ class LeaseOption : public Option bool IsValid(void) const; /** - * This method returns the Update Lease OPT record's lease interval value. + * Returns the Update Lease OPT record's lease interval value. * * @returns The lease interval value (in seconds). * @@ -2540,7 +2540,7 @@ class LeaseOption : public Option uint32_t GetLeaseInterval(void) const { return HostSwap32(mLeaseInterval); } /** - * This method returns the Update Lease OPT record's key lease interval value. + * Returns the Update Lease OPT record's key lease interval value. * * If the Update Lease Option follows the short variant format the lease interval is returned as key lease interval. * @@ -2553,10 +2553,10 @@ class LeaseOption : public Option } /** - * This method searches among the Options is a given message and reads and validates the Update Lease Option if + * Searches among the Options is a given message and reads and validates the Update Lease Option if * found. * - * This method reads the Update Lease Option whether it follows the short or long variant formats. + * Reads the Update Lease Option whether it follows the short or long variant formats. * * @param[in] aMessage The message to read the Option from. * @param[in] aOffset Offset in @p aMessage to the start of Options (start of OPT Record data). @@ -2581,7 +2581,7 @@ class LeaseOption : public Option } OT_TOOL_PACKED_END; /** - * This class implements Question format. + * Implements Question format. * */ OT_TOOL_PACKED_BEGIN @@ -2605,7 +2605,7 @@ class Question } /** - * This method returns the type of the question. + * Returns the type of the question. * * @returns The type of the question. * @@ -2613,7 +2613,7 @@ class Question uint16_t GetType(void) const { return HostSwap16(mType); } /** - * This method sets the type of the question. + * Sets the type of the question. * * @param[in] aType The type of the question. * @@ -2621,7 +2621,7 @@ class Question void SetType(uint16_t aType) { mType = HostSwap16(aType); } /** - * This method returns the class of the question. + * Returns the class of the question. * * @returns The class of the question. * @@ -2629,7 +2629,7 @@ class Question uint16_t GetClass(void) const { return HostSwap16(mClass); } /** - * This method sets the class of the question. + * Sets the class of the question. * * @param[in] aClass The class of the question. * @@ -2642,7 +2642,7 @@ class Question } OT_TOOL_PACKED_END; /** - * This class implements Zone section body for DNS Update (RFC 2136 - section 2.3). + * Implements Zone section body for DNS Update (RFC 2136 - section 2.3). * */ OT_TOOL_PACKED_BEGIN diff --git a/src/core/net/dnssd_server.cpp b/src/core/net/dnssd_server.cpp index 8f93096ae42..478e4d8bf4f 100644 --- a/src/core/net/dnssd_server.cpp +++ b/src/core/net/dnssd_server.cpp @@ -204,13 +204,9 @@ void Server::ProcessQuery(const Header &aRequestHeader, Message &aRequestMessage VerifyOrExit(!aRequestHeader.IsTruncationFlagSet(), response = Header::kResponseFormatError); VerifyOrExit(aRequestHeader.GetQuestionCount() > 0, response = Header::kResponseFormatError); - switch (mTestMode) + if (mTestMode & kTestModeSingleQuestionOnly) { - case kTestModeDisabled: - break; - case kTestModeSingleQuestionOnly: VerifyOrExit(aRequestHeader.GetQuestionCount() == 1, response = Header::kResponseFormatError); - break; } response = AddQuestions(aRequestHeader, aRequestMessage, responseHeader, *responseMessage, compressInfo); @@ -729,6 +725,8 @@ Header::Response Server::ResolveBySrp(Header &aResponseHeader, // Answer the questions with additional RRs if required if (aResponseHeader.GetAnswerCount() > 0) { + VerifyOrExit(!(mTestMode & kTestModeEmptyAdditionalSection)); + readOffset = sizeof(Header); for (uint16_t i = 0; i < aResponseHeader.GetQuestionCount(); i++) { @@ -1046,6 +1044,11 @@ void Server::AnswerQuery(QueryTransaction &aQuery, for (uint8_t additional = 0; additional <= 1; additional++) { + if (additional == 1) + { + VerifyOrExit(!(mTestMode & kTestModeEmptyAdditionalSection)); + } + if (HasQuestion(aQuery.GetResponseHeader(), aQuery.GetResponseMessage(), aInstanceInfo.mFullName, ResourceRecord::kTypeSrv) == !additional) { diff --git a/src/core/net/dnssd_server.hpp b/src/core/net/dnssd_server.hpp index bebcf41c503..88c737626da 100644 --- a/src/core/net/dnssd_server.hpp +++ b/src/core/net/dnssd_server.hpp @@ -63,7 +63,7 @@ namespace Dns { namespace ServiceDiscovery { /** - * This class implements DNS-SD server. + * Implements DNS-SD server. * */ class Server : public InstanceLocator, private NonCopyable @@ -72,7 +72,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This class contains the counters of the DNS-SD server. + * Contains the counters of the DNS-SD server. * */ class Counters : public otDnssdCounters, public Clearable @@ -81,7 +81,7 @@ class Server : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE /** - * This class represents an upstream query transaction. The methods should only be used by + * Represents an upstream query transaction. The methods should only be used by * `Dns::ServiceDiscovery::Server`. * */ @@ -89,7 +89,7 @@ class Server : public InstanceLocator, private NonCopyable { public: /** - * This method returns whether the transaction is valid. + * Returns whether the transaction is valid. * * @retval TRUE The transaction is valid. * @retval FALSE The transaction is not valid. @@ -98,7 +98,7 @@ class Server : public InstanceLocator, private NonCopyable bool IsValid(void) const { return mValid; } /** - * This method returns the time when the transaction expires. + * Returns the time when the transaction expires. * * @returns The expire time of the transaction. * @@ -106,14 +106,14 @@ class Server : public InstanceLocator, private NonCopyable TimeMilli GetExpireTime(void) const { return mExpireTime; } /** - * This method resets the transaction with a reason. The transaction will be invalid and can be reused for + * Resets the transaction with a reason. The transaction will be invalid and can be reused for * another upstream query after this call. * */ void Reset(void) { mValid = false; } /** - * This method initializes the transaction. + * Initializes the transaction. * * @param[in] aMessageInfo The IP message info of the query. * @@ -121,7 +121,7 @@ class Server : public InstanceLocator, private NonCopyable void Init(const Ip6::MessageInfo &aMessageInfo); /** - * This method returns the message info of the query. + * Returns the message info of the query. * * @returns The message info of the query. * @@ -136,7 +136,7 @@ class Server : public InstanceLocator, private NonCopyable #endif /** - * This enumeration specifies a DNS-SD query type. + * Specifies a DNS-SD query type. * */ enum DnsQueryType : uint8_t @@ -150,7 +150,7 @@ class Server : public InstanceLocator, private NonCopyable static constexpr uint16_t kPort = OPENTHREAD_CONFIG_DNSSD_SERVER_PORT; ///< The DNS-SD server port. /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -158,7 +158,7 @@ class Server : public InstanceLocator, private NonCopyable explicit Server(Instance &aInstance); /** - * This method starts the DNS-SD server. + * Starts the DNS-SD server. * * @retval kErrorNone Successfully started the DNS-SD server. * @retval kErrorFailed If failed to open or bind the UDP socket. @@ -167,13 +167,13 @@ class Server : public InstanceLocator, private NonCopyable Error Start(void); /** - * This method stops the DNS-SD server. + * Stops the DNS-SD server. * */ void Stop(void); /** - * This method sets DNS-SD query callbacks. + * Sets DNS-SD query callbacks. * * @param[in] aSubscribe A pointer to the callback function to subscribe a service or service instance. * @param[in] aUnsubscribe A pointer to the callback function to unsubscribe a service or service instance. @@ -185,7 +185,7 @@ class Server : public InstanceLocator, private NonCopyable void *aContext); /** - * This method notifies a discovered service instance. + * Notifies a discovered service instance. * * @param[in] aServiceFullName The null-terminated full service name. * @param[in] aInstanceInfo A reference to the discovered service instance information. @@ -195,7 +195,7 @@ class Server : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE /** - * This method notifies an answer of an upstream DNS query. + * Notifies an answer of an upstream DNS query. * * The Transaction will be released. * @@ -207,7 +207,7 @@ class Server : public InstanceLocator, private NonCopyable void OnUpstreamQueryDone(UpstreamQueryTransaction &aQueryTransaction, Message *aResponseMessage); /** - * This method indicates whether the server will forward DNS queries to platform DNS upstream API. + * Indicates whether the server will forward DNS queries to platform DNS upstream API. * * @retval TRUE If the server will forward DNS queries. * @retval FALSE If the server will not forward DNS queries. @@ -216,7 +216,7 @@ class Server : public InstanceLocator, private NonCopyable bool IsUpstreamQueryEnabled(void) const { return mEnableUpstreamQuery; } /** - * This method enables or disables forwarding DNS queries to platform DNS upstream API. + * Enables or disables forwarding DNS queries to platform DNS upstream API. * * @param[in] aEnabled A boolean to enable/disable forwarding DNS queries to upstream. * @@ -225,7 +225,7 @@ class Server : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE /** - * This method notifies a discovered host. + * Notifies a discovered host. * * @param[in] aHostFullName The null-terminated full host name. * @param[in] aHostInfo A reference to the discovered host information. @@ -234,7 +234,7 @@ class Server : public InstanceLocator, private NonCopyable void HandleDiscoveredHost(const char *aHostFullName, const otDnssdHostInfo &aHostInfo); /** - * This method acquires the next query in the server. + * Acquires the next query in the server. * * @param[in] aQuery The query pointer. Pass `nullptr` to get the first query. * @@ -244,7 +244,7 @@ class Server : public InstanceLocator, private NonCopyable const otDnssdQuery *GetNextQuery(const otDnssdQuery *aQuery) const; /** - * This method acquires the DNS-SD query type and name for a specific query. + * Acquires the DNS-SD query type and name for a specific query. * * @param[in] aQuery The query pointer. * @param[out] aName The name output buffer. @@ -255,7 +255,7 @@ class Server : public InstanceLocator, private NonCopyable static DnsQueryType GetQueryTypeAndName(const otDnssdQuery *aQuery, char (&aName)[Name::kMaxNameSize]); /** - * This method returns the counters of the DNS-SD server. + * Returns the counters of the DNS-SD server. * * @returns A reference to the `Counters` instance. * @@ -263,25 +263,27 @@ class Server : public InstanceLocator, private NonCopyable const Counters &GetCounters(void) const { return mCounters; }; /** - * This enumeration represents different test modes. - * - * The test mode is intended for testing the client by having server behave in certain ways, e.g., reject messages - * with certain format (e.g., more than one question in query). + * Represents different test mode flags for use in `SetTestMode()`. * */ - enum TestMode : uint8_t + enum TestModeFlags : uint8_t { - kTestModeDisabled, ///< Test mode is disabled. - kTestModeSingleQuestionOnly, ///< Allow single question in query message, send `FormatError` for two or more. + kTestModeSingleQuestionOnly = 1 << 0, ///< Allow single question in query, send `FormatError` otherwise. + kTestModeEmptyAdditionalSection = 1 << 1, ///< Do not include any RR in additional section. }; + static constexpr uint8_t kTestModeDisabled = 0; ///< Test mode is disabled (no flags). + /** - * This method sets the test mode for `Server`. + * Sets the test mode for `Server`. + * + * The test mode flags are intended for testing the client by having server behave in certain ways, e.g., reject + * messages with certain format (e.g., more than one question in query). * - * @param[in] aTestMode The new test mode. + * @param[in] aTestMode The new test mode (combination of `TestModeFlags`). * */ - void SetTestMode(TestMode aTestMode) { mTestMode = aTestMode; } + void SetTestMode(uint8_t aTestMode) { mTestMode = aTestMode; } private: class NameCompressInfo : public Clearable @@ -399,7 +401,7 @@ class Server : public InstanceLocator, private NonCopyable }; /** - * This class contains the compress information for a dns packet. + * Contains the compress information for a dns packet. * */ class QueryTransaction : public InstanceLocatorInit @@ -553,7 +555,7 @@ class Server : public InstanceLocator, private NonCopyable ServerTimer mTimer; Counters mCounters; - TestMode mTestMode; + uint8_t mTestMode; }; } // namespace ServiceDiscovery diff --git a/src/core/net/icmp6.hpp b/src/core/net/icmp6.hpp index b054b569256..e24b9445ce5 100644 --- a/src/core/net/icmp6.hpp +++ b/src/core/net/icmp6.hpp @@ -64,14 +64,14 @@ using ot::Encoding::BigEndian::HostSwap16; class Headers; /** - * This class implements ICMPv6. + * Implements ICMPv6. * */ class Icmp : public InstanceLocator, private NonCopyable { public: /* - * This class implements ICMPv6 header generation and parsing. + * Implements ICMPv6 header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -112,7 +112,7 @@ class Icmp : public InstanceLocator, private NonCopyable static constexpr uint8_t kDataFieldOffset = 4; ///< The byte offset of Data field in ICMP6 header. /** - * This method indicates whether the ICMPv6 message is an error message. + * Indicates whether the ICMPv6 message is an error message. * * @retval TRUE if the ICMPv6 message is an error message. * @retval FALSE if the ICMPv6 message is an informational message. @@ -121,7 +121,7 @@ class Icmp : public InstanceLocator, private NonCopyable bool IsError(void) const { return mType < OT_ICMP6_TYPE_ECHO_REQUEST; } /** - * This method returns the ICMPv6 message type. + * Returns the ICMPv6 message type. * * @returns The ICMPv6 message type. * @@ -129,7 +129,7 @@ class Icmp : public InstanceLocator, private NonCopyable Type GetType(void) const { return static_cast(mType); } /** - * This method sets the ICMPv6 message type. + * Sets the ICMPv6 message type. * * @param[in] aType The ICMPv6 message type. * @@ -137,7 +137,7 @@ class Icmp : public InstanceLocator, private NonCopyable void SetType(Type aType) { mType = static_cast(aType); } /** - * This method returns the ICMPv6 message code. + * Returns the ICMPv6 message code. * * @returns The ICMPv6 message code. * @@ -145,7 +145,7 @@ class Icmp : public InstanceLocator, private NonCopyable Code GetCode(void) const { return static_cast(mCode); } /** - * This method sets the ICMPv6 message code. + * Sets the ICMPv6 message code. * * @param[in] aCode The ICMPv6 message code. * @@ -153,7 +153,7 @@ class Icmp : public InstanceLocator, private NonCopyable void SetCode(Code aCode) { mCode = static_cast(aCode); } /** - * This method returns the ICMPv6 message checksum. + * Returns the ICMPv6 message checksum. * * @returns The ICMPv6 message checksum. * @@ -161,7 +161,7 @@ class Icmp : public InstanceLocator, private NonCopyable uint16_t GetChecksum(void) const { return HostSwap16(mChecksum); } /** - * This method sets the ICMPv6 message checksum. + * Sets the ICMPv6 message checksum. * * @param[in] aChecksum The ICMPv6 message checksum. * @@ -169,7 +169,7 @@ class Icmp : public InstanceLocator, private NonCopyable void SetChecksum(uint16_t aChecksum) { mChecksum = HostSwap16(aChecksum); } /** - * This method returns the ICMPv6 message ID for Echo Requests and Replies. + * Returns the ICMPv6 message ID for Echo Requests and Replies. * * @returns The ICMPv6 message ID. * @@ -177,7 +177,7 @@ class Icmp : public InstanceLocator, private NonCopyable uint16_t GetId(void) const { return HostSwap16(mData.m16[0]); } /** - * This method sets the ICMPv6 message ID for Echo Requests and Replies. + * Sets the ICMPv6 message ID for Echo Requests and Replies. * * @param[in] aId The ICMPv6 message ID. * @@ -185,7 +185,7 @@ class Icmp : public InstanceLocator, private NonCopyable void SetId(uint16_t aId) { mData.m16[0] = HostSwap16(aId); } /** - * This method returns the ICMPv6 message sequence for Echo Requests and Replies. + * Returns the ICMPv6 message sequence for Echo Requests and Replies. * * @returns The ICMPv6 message sequence. * @@ -193,7 +193,7 @@ class Icmp : public InstanceLocator, private NonCopyable uint16_t GetSequence(void) const { return HostSwap16(mData.m16[1]); } /** - * This method sets the ICMPv6 message sequence for Echo Requests and Replies. + * Sets the ICMPv6 message sequence for Echo Requests and Replies. * * @param[in] aSequence The ICMPv6 message sequence. * @@ -202,7 +202,7 @@ class Icmp : public InstanceLocator, private NonCopyable } OT_TOOL_PACKED_END; /** - * This class implements ICMPv6 message handlers. + * Implements ICMPv6 message handlers. * */ class Handler : public otIcmp6Handler, public LinkedListEntry @@ -211,7 +211,7 @@ class Icmp : public InstanceLocator, private NonCopyable public: /** - * This constructor creates an ICMPv6 message handler. + * Creates an ICMPv6 message handler. * * @param[in] aCallback A pointer to the function that is called when receiving an ICMPv6 message. * @param[in] aContext A pointer to arbitrary context information. @@ -232,7 +232,7 @@ class Icmp : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -240,7 +240,7 @@ class Icmp : public InstanceLocator, private NonCopyable explicit Icmp(Instance &aInstance); /** - * This method returns a new ICMP message with sufficient header space reserved. + * Returns a new ICMP message with sufficient header space reserved. * * @returns A pointer to the message or `nullptr` if no buffers are available. * @@ -248,7 +248,7 @@ class Icmp : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method registers ICMPv6 handler. + * Registers ICMPv6 handler. * * @param[in] aHandler A reference to the ICMPv6 handler. * @@ -259,7 +259,7 @@ class Icmp : public InstanceLocator, private NonCopyable Error RegisterHandler(Handler &aHandler); /** - * This method sends an ICMPv6 Echo Request message. + * Sends an ICMPv6 Echo Request message. * * @param[in] aMessage A reference to the Echo Request payload. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -273,7 +273,7 @@ class Icmp : public InstanceLocator, private NonCopyable Error SendEchoRequest(Message &aMessage, const MessageInfo &aMessageInfo, uint16_t aIdentifier); /** - * This method sends an ICMPv6 error message. + * Sends an ICMPv6 error message. * * @param[in] aType The ICMPv6 message type. * @param[in] aCode The ICMPv6 message code. @@ -287,7 +287,7 @@ class Icmp : public InstanceLocator, private NonCopyable Error SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Message &aMessage); /** - * This method sends an ICMPv6 error message. + * Sends an ICMPv6 error message. * * @param[in] aType The ICMPv6 message type. * @param[in] aCode The ICMPv6 message code. @@ -301,7 +301,7 @@ class Icmp : public InstanceLocator, private NonCopyable Error SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Headers &aHeaders); /** - * This method handles an ICMPv6 message. + * Handles an ICMPv6 message. * * @param[in] aMessage A reference to the ICMPv6 message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -314,7 +314,7 @@ class Icmp : public InstanceLocator, private NonCopyable Error HandleMessage(Message &aMessage, MessageInfo &aMessageInfo); /** - * This method indicates whether or not ICMPv6 Echo processing is enabled. + * Indicates whether or not ICMPv6 Echo processing is enabled. * * @retval TRUE ICMPv6 Echo processing is enabled. * @retval FALSE ICMPv6 Echo processing is disabled. @@ -331,7 +331,7 @@ class Icmp : public InstanceLocator, private NonCopyable void SetEchoMode(otIcmp6EchoMode aMode) { mEchoMode = aMode; } /** - * This method indicates whether or not the ICMPv6 Echo Request should be handled. + * Indicates whether or not the ICMPv6 Echo Request should be handled. * * @retval TRUE if OpenThread should respond with an ICMPv6 Echo Reply. * @retval FALSE if OpenThread should not respond with an ICMPv6 Echo Reply. @@ -340,7 +340,7 @@ class Icmp : public InstanceLocator, private NonCopyable bool ShouldHandleEchoRequest(const MessageInfo &aMessageInfo); /** - * This method returns the ICMPv6 Echo sequence number. + * Returns the ICMPv6 Echo sequence number. * * @returns The sequence number of the next ICMPv6 Echo request. * diff --git a/src/core/net/ip4_types.hpp b/src/core/net/ip4_types.hpp index 6d2ba0c3922..86d908f409d 100644 --- a/src/core/net/ip4_types.hpp +++ b/src/core/net/ip4_types.hpp @@ -92,7 +92,7 @@ using Ecn = Ip6::Ecn; class Cidr; /** - * This class represents an IPv4 address. + * Represents an IPv4 address. * */ OT_TOOL_PACKED_BEGIN @@ -103,13 +103,13 @@ class Address : public otIp4Address, public Equatable
, public Clearable static constexpr uint16_t kAddressStringSize = 17; ///< String size used by `ToString()`. /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method gets the IPv4 address as a pointer to a byte array. + * Gets the IPv4 address as a pointer to a byte array. * * @returns A pointer to a byte array containing the IPv4 address. * @@ -117,7 +117,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable const uint8_t *GetBytes(void) const { return mFields.m8; } /** - * This method sets the IPv4 address from a given byte array. + * Sets the IPv4 address from a given byte array. * * @param[in] aBuffer Pointer to an array containing the IPv4 address. `kSize` bytes from the buffer * are copied to form the IPv4 address. @@ -126,7 +126,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable void SetBytes(const uint8_t *aBuffer) { memcpy(mFields.m8, aBuffer, kSize); } /** - * This method sets the IPv4 address by performing NAT64 address translation from a given IPv6 address as specified + * Sets the IPv4 address by performing NAT64 address translation from a given IPv6 address 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 @@ -139,7 +139,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable void ExtractFromIp6Address(uint8_t aPrefixLength, const Ip6::Address &aIp6Address); /** - * This method sets the IPv4 address from the given CIDR and the host field. + * Sets the IPv4 address from the given CIDR and the host field. * * @param[in] aCidr The CIDR for the IPv4 address. * @param[in] aHost The host bits of the IPv4 address in host byte order. The aHost will be masked by host mask. @@ -148,7 +148,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable void SynthesizeFromCidrAndHost(const Cidr &aCidr, uint32_t aHost); /** - * This method parses an IPv4 address string terminated by `aTerminatorChar`. + * Parses an IPv4 address string terminated by `aTerminatorChar`. * * The string MUST follow the quad-dotted notation of four decimal values (ranging from 0 to 255 each). For * example, "127.0.0.1" @@ -162,7 +162,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable Error FromString(const char *aString, char aTerminatorChar = kNullChar); /** - * This method converts the address to a string. + * 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"). * @@ -176,7 +176,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable void ToString(char *aBuffer, uint16_t aSize) const; /** - * This method converts the IPv4 address to a string. + * Converts the IPv4 address to a string. * * The string format uses quad-dotted notation of four bytes in the address (e.g., "127.0.0.1"). * @@ -190,7 +190,7 @@ class Address : public otIp4Address, public Equatable
, public Clearable } OT_TOOL_PACKED_END; /** - * This class represents an IPv4 CIDR block. + * Represents an IPv4 CIDR block. * */ class Cidr : public otIp4Cidr, public Unequatable, public Clearable
@@ -201,13 +201,13 @@ class Cidr : public otIp4Cidr, public Unequatable, public Clearable InfoString; /** - * This method converts the IPv4 CIDR string to binary. + * Converts the IPv4 CIDR string to binary. * * 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"). @@ -221,7 +221,7 @@ class Cidr : public otIp4Cidr, public Unequatable, public Clearable, public Clearable, public Clearable, public Clearable, public Clearable, public Clearable static constexpr uint8_t kDestinationAddressOffset = 16; /** - * This method indicates whether or not the header appears to be well-formed. + * Indicates whether or not the header appears to be well-formed. * * @retval TRUE If the header appears to be well-formed. * @retval FALSE If the header does not appear to be well-formed. @@ -316,7 +316,7 @@ class Header : public Clearable
bool IsValid(void) const { return IsVersion4(); } /** - * This method initializes the Version to 4 and sets Traffic Class and Flow fields to zero. + * Initializes the Version to 4 and sets Traffic Class and Flow fields to zero. * * The other fields in the IPv4 header remain unchanged. * @@ -324,7 +324,7 @@ class Header : public Clearable
void InitVersionIhl(void) { SetVersionIhl(kVersIhlInit); } /** - * This method sets the version and Ihl of the IPv4 header. + * Sets the version and Ihl of the IPv4 header. * * @param[in] aVersionIhl The octet for the version and Ihl field. * @@ -332,7 +332,7 @@ class Header : public Clearable
void SetVersionIhl(uint8_t aVersionIhl) { mVersIhl = aVersionIhl; } /** - * This method indicates whether or not the IPv4 Version is set to 6. + * Indicates whether or not the IPv4 Version is set to 6. * * @retval TRUE If the IPv4 Version is set to 4. * @retval FALSE If the IPv4 Version is not set to 4. @@ -341,7 +341,7 @@ class Header : public Clearable
bool IsVersion4(void) const { return (mVersIhl & kVersionMask) == kVersion4; } /** - * This method returns the octet for DSCP + ECN. + * Returns the octet for DSCP + ECN. * * @retval The octet for DSCP and ECN. * @@ -349,7 +349,7 @@ class Header : public Clearable
uint8_t GetDscpEcn(void) const { return mDscpEcn; } /** - * This method gets the 6-bit Differentiated Services Code Point (DSCP) from Traffic Class field. + * Gets the 6-bit Differentiated Services Code Point (DSCP) from Traffic Class field. * * @returns The DSCP value. * @@ -357,7 +357,7 @@ class Header : public Clearable
uint8_t GetDscp(void) const { return (mDscpEcn & kDscpMask) >> kDscpOffset; } /** - * This method sets 6-bit Differentiated Services Code Point (DSCP) in IPv4 header. + * Sets 6-bit Differentiated Services Code Point (DSCP) in IPv4 header. * * @param[in] aDscp The DSCP value. * @@ -365,7 +365,7 @@ class Header : public Clearable
void SetDscp(uint8_t aDscp) { mDscpEcn = static_cast((mDscpEcn & ~kDscpMask) | (aDscp << kDscpOffset)); } /** - * This method gets the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field. + * Gets the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field. * * @returns The ECN value. * @@ -373,7 +373,7 @@ class Header : public Clearable
Ecn GetEcn(void) const { return static_cast(mDscpEcn & kEcnMask); } /** - * This method sets the 2-bit Explicit Congestion Notification (ECN) in IPv4 header.. + * Sets the 2-bit Explicit Congestion Notification (ECN) in IPv4 header.. * * @param[in] aEcn The ECN value. * @@ -381,7 +381,7 @@ class Header : public Clearable
void SetEcn(Ecn aEcn) { mDscpEcn = ((mDscpEcn & ~kEcnMask) | aEcn); } /** - * This method returns the IPv4 Payload Length value. + * Returns the IPv4 Payload Length value. * * @returns The IPv4 Payload Length value. * @@ -389,7 +389,7 @@ class Header : public Clearable
uint16_t GetTotalLength(void) const { return HostSwap16(mTotalLength); } /** - * This method sets the IPv4 Payload Length value. + * Sets the IPv4 Payload Length value. * * @param[in] aLength The IPv4 Payload Length value. * @@ -397,7 +397,7 @@ class Header : public Clearable
void SetTotalLength(uint16_t aLength) { mTotalLength = HostSwap16(aLength); } /** - * This method returns the IPv4 payload protocol. + * Returns the IPv4 payload protocol. * * @returns The IPv4 payload protocol value. * @@ -405,7 +405,7 @@ class Header : public Clearable
uint8_t GetProtocol(void) const { return mProtocol; } /** - * This method sets the IPv4 payload protocol. + * Sets the IPv4 payload protocol. * * @param[in] aProtocol The IPv4 payload protocol. * @@ -413,7 +413,7 @@ class Header : public Clearable
void SetProtocol(uint8_t aProtocol) { mProtocol = aProtocol; } /** - * This method returns the IPv4 header checksum, the checksum is in host endian. + * Returns the IPv4 header checksum, the checksum is in host endian. * * @returns The checksum field in the IPv4 header. * @@ -421,7 +421,7 @@ class Header : public Clearable
uint16_t GetChecksum(void) const { return HostSwap16(mHeaderChecksum); } /** - * This method sets the IPv4 header checksum, the checksum is in host endian. + * Sets the IPv4 header checksum, the checksum is in host endian. * * @param[in] aChecksum The checksum for the IPv4 header. * @@ -429,7 +429,7 @@ class Header : public Clearable
void SetChecksum(uint16_t aChecksum) { mHeaderChecksum = HostSwap16(aChecksum); } /** - * This method returns the IPv4 Identification value. + * Returns the IPv4 Identification value. * * @returns The IPv4 Identification value. * @@ -437,7 +437,7 @@ class Header : public Clearable
uint16_t GetIdentification(void) const { return HostSwap16(mIdentification); } /** - * This method sets the IPv4 Identification value. + * Sets the IPv4 Identification value. * * @param[in] aIdentification The IPv4 Identification value. * @@ -445,7 +445,7 @@ class Header : public Clearable
void SetIdentification(uint16_t aIdentification) { mIdentification = HostSwap16(aIdentification); } /** - * This method returns the IPv4 Time-to-Live value. + * Returns the IPv4 Time-to-Live value. * * @returns The IPv4 Time-to-Live value. * @@ -453,7 +453,7 @@ class Header : public Clearable
uint8_t GetTtl(void) const { return mTtl; } /** - * This method sets the IPv4 Time-to-Live value. + * Sets the IPv4 Time-to-Live value. * * @param[in] aTtl The IPv4 Time-to-Live value. * @@ -461,7 +461,7 @@ class Header : public Clearable
void SetTtl(uint8_t aTtl) { mTtl = aTtl; } /** - * This method returns the IPv4 Source address. + * Returns the IPv4 Source address. * * @returns A reference to the IPv4 Source address. * @@ -469,7 +469,7 @@ class Header : public Clearable
Address &GetSource(void) { return mSource; } /** - * This method returns the IPv4 Source address. + * Returns the IPv4 Source address. * * @returns A reference to the IPv4 Source address. * @@ -477,7 +477,7 @@ class Header : public Clearable
const Address &GetSource(void) const { return mSource; } /** - * This method sets the IPv4 Source address. + * Sets the IPv4 Source address. * * @param[in] aSource A reference to the IPv4 Source address. * @@ -485,7 +485,7 @@ class Header : public Clearable
void SetSource(const Address &aSource) { mSource = aSource; } /** - * This method returns the IPv4 Destination address. + * Returns the IPv4 Destination address. * * @returns A reference to the IPv4 Destination address. * @@ -493,7 +493,7 @@ class Header : public Clearable
Address &GetDestination(void) { return mDestination; } /** - * This method returns the IPv4 Destination address. + * Returns the IPv4 Destination address. * * @returns A reference to the IPv4 Destination address. * @@ -501,7 +501,7 @@ class Header : public Clearable
const Address &GetDestination(void) const { return mDestination; } /** - * This method sets the IPv4 Destination address. + * Sets the IPv4 Destination address. * * @param[in] aDestination A reference to the IPv4 Destination address. * @@ -509,7 +509,7 @@ class Header : public Clearable
void SetDestination(const Address &aDestination) { mDestination = aDestination; } /** - * This method parses and validates the IPv4 header from a given message. + * Parses and validates the IPv4 header from a given message. * * The header is read from @p aMessage at offset zero. * @@ -522,7 +522,7 @@ class Header : public Clearable
Error ParseFrom(const Message &aMessage); /** - * This method returns the Df flag in the IPv4 header. + * Returns the Df flag in the IPv4 header. * * @returns Whether don't fragment flag is set. * @@ -530,7 +530,7 @@ class Header : public Clearable
bool GetDf(void) const { return HostSwap16(mFlagsFragmentOffset) & kFlagsDf; } /** - * This method returns the Mf flag in the IPv4 header. + * Returns the Mf flag in the IPv4 header. * * @returns Whether more fragments flag is set. * @@ -538,7 +538,7 @@ class Header : public Clearable
bool GetMf(void) const { return HostSwap16(mFlagsFragmentOffset) & kFlagsMf; } /** - * This method returns the fragment offset in the IPv4 header. + * Returns the fragment offset in the IPv4 header. * * @returns The fragment offset of the IPv4 packet. * @@ -584,7 +584,7 @@ class Header : public Clearable
} OT_TOOL_PACKED_END; /** - * This class implements ICMP(v4). + * Implements ICMP(v4). * Note: ICMP(v4) messages will only be generated / handled by NAT64. So only header definition is required. * */ @@ -592,7 +592,7 @@ class Icmp { public: /** - * This class represents an IPv4 ICMP header. + * Represents an IPv4 ICMP header. * */ OT_TOOL_PACKED_BEGIN @@ -623,7 +623,7 @@ class Icmp }; /** - * This method returns the type of the ICMP message. + * Returns the type of the ICMP message. * * @returns The type field of the ICMP message. * @@ -631,7 +631,7 @@ class Icmp uint8_t GetType(void) const { return mType; } /** - * This method sets the type of the ICMP message. + * Sets the type of the ICMP message. * * @param[in] aType The type of the ICMP message. * @@ -639,7 +639,7 @@ class Icmp void SetType(uint8_t aType) { mType = aType; } /** - * This method returns the code of the ICMP message. + * Returns the code of the ICMP message. * * @returns The code field of the ICMP message. * @@ -647,7 +647,7 @@ class Icmp uint8_t GetCode(void) const { return mCode; } /** - * This method sets the code of the ICMP message. + * Sets the code of the ICMP message. * * @param[in] aCode The code of the ICMP message. * @@ -655,7 +655,7 @@ class Icmp void SetCode(uint8_t aCode) { mCode = aCode; } /** - * This method sets the checksum field in the ICMP message. + * Sets the checksum field in the ICMP message. * * @returns The checksum of the ICMP message. * @@ -663,7 +663,7 @@ class Icmp uint16_t GetChecksum(void) const { return HostSwap16(mChecksum); } /** - * This method sets the checksum field in the ICMP message. + * Sets the checksum field in the ICMP message. * * @param[in] aChecksum The checksum of the ICMP message. * @@ -671,7 +671,7 @@ class Icmp void SetChecksum(uint16_t aChecksum) { mChecksum = HostSwap16(aChecksum); } /** - * This method returns the rest of header field in the ICMP message. + * Returns the rest of header field in the ICMP message. * * @returns The rest of header field in the ICMP message. The returned buffer has 4 octets. * @@ -679,7 +679,7 @@ class Icmp const uint8_t *GetRestOfHeader(void) const { return mRestOfHeader; } /** - * This method sets the rest of header field in the ICMP message. + * Sets the rest of header field in the ICMP message. * * @param[in] aRestOfHeader The rest of header field in the ICMP message. The buffer should have 4 octets. * diff --git a/src/core/net/ip6.hpp b/src/core/net/ip6.hpp index aafb09ce856..f3e14a8ef8b 100644 --- a/src/core/net/ip6.hpp +++ b/src/core/net/ip6.hpp @@ -103,7 +103,7 @@ using ot::Encoding::BigEndian::HostSwap32; */ /** - * This class implements the core IPv6 message processing. + * Implements the core IPv6 message processing. * */ class Ip6 : public InstanceLocator, private NonCopyable @@ -114,7 +114,7 @@ class Ip6 : public InstanceLocator, private NonCopyable public: /** - * This enumeration represents an IPv6 message origin. + * Represents an IPv6 message origin. * * In case the message is originating from host, it also indicates whether or not it is allowed to passed back the * message to the host. @@ -128,7 +128,7 @@ class Ip6 : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the otInstance object. * @@ -136,7 +136,7 @@ class Ip6 : public InstanceLocator, private NonCopyable explicit Ip6(Instance &aInstance); /** - * This method allocates a new message buffer from the buffer pool with default settings (link security + * Allocates a new message buffer from the buffer pool with default settings (link security * enabled and `kPriorityMedium`). * * @returns A pointer to the message or `nullptr` if insufficient message buffers are available. @@ -145,7 +145,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method allocates a new message buffer from the buffer pool with default settings (link security + * Allocates a new message buffer from the buffer pool with default settings (link security * enabled and `kPriorityMedium`). * * @param[in] aReserved The number of header bytes to reserve following the IPv6 header. @@ -156,7 +156,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved); /** - * This method allocates a new message buffer from the buffer pool. + * Allocates a new message buffer from the buffer pool. * * @param[in] aReserved The number of header bytes to reserve following the IPv6 header. * @param[in] aSettings The message settings. @@ -167,7 +167,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved, const Message::Settings &aSettings); /** - * This method allocates a new message buffer from the buffer pool and writes the IPv6 datagram to the message. + * Allocates a new message buffer from the buffer pool and writes the IPv6 datagram to the message. * * The message priority is always determined from IPv6 message itself (@p aData) and the priority included in * @p aSetting is ignored. @@ -183,7 +183,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Message *NewMessageFromData(const uint8_t *aData, uint16_t aDataLength, const Message::Settings &aSettings); /** - * This method converts the IPv6 DSCP value to message priority level. + * Converts the IPv6 DSCP value to message priority level. * * @param[in] aDscp The IPv6 DSCP value. * @@ -193,7 +193,7 @@ class Ip6 : public InstanceLocator, private NonCopyable static Message::Priority DscpToPriority(uint8_t aDscp); /** - * This method sends an IPv6 datagram. + * Sends an IPv6 datagram. * * @param[in] aMessage A reference to the message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -206,7 +206,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Error SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aIpProto); /** - * This method sends a raw IPv6 datagram with a fully formed IPv6 header. + * Sends a raw IPv6 datagram with a fully formed IPv6 header. * * 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 `kErrorNone` is returned. @@ -224,7 +224,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Error SendRaw(Message &aMessage, bool aAllowLoopBackToHost); /** - * This method processes a received IPv6 datagram. + * Processes a received IPv6 datagram. * * @param[in] aMessage A reference to the message. * @param[in] aOrigin The message oirgin. @@ -243,7 +243,7 @@ class Ip6 : public InstanceLocator, private NonCopyable bool aIsReassembled = false); /** - * This method registers a callback to provide received raw IPv6 datagrams. + * Registers a callback to provide received raw IPv6 datagrams. * * By default, this callback does not pass Thread control traffic. See SetReceiveIp6FilterEnabled() to change * the Thread control traffic filter setting. @@ -263,7 +263,7 @@ class Ip6 : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE /** - * This method registers a callback to provide received translated IPv4 datagrams. + * Registers a callback to provide received translated IPv4 datagrams. * * @param[in] aCallback A pointer to a function that is called when a translated IPv4 datagram is received * or `nullptr` to disable the callback. @@ -279,7 +279,7 @@ class Ip6 : public InstanceLocator, private NonCopyable #endif /** - * This method indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + * Indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams * via the callback specified in SetReceiveIp6DatagramCallback(). * * @returns TRUE if Thread control traffic is filtered out, FALSE otherwise. @@ -291,7 +291,7 @@ class Ip6 : public InstanceLocator, private NonCopyable bool IsReceiveIp6FilterEnabled(void) const { return mIsReceiveIp6FilterEnabled; } /** - * This method sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams + * Sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams * via the callback specified in SetReceiveIp6DatagramCallback(). * * @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise. @@ -303,7 +303,7 @@ class Ip6 : public InstanceLocator, private NonCopyable void SetReceiveIp6FilterEnabled(bool aEnabled) { mIsReceiveIp6FilterEnabled = aEnabled; } /** - * This method performs default source address selection. + * Performs default source address selection. * * @param[in,out] aMessageInfo A reference to the message information. * @@ -314,7 +314,7 @@ class Ip6 : public InstanceLocator, private NonCopyable Error SelectSourceAddress(MessageInfo &aMessageInfo) const; /** - * This method performs default source address selection. + * Performs default source address selection. * * @param[in] aDestination The destination address. * @@ -324,7 +324,7 @@ class Ip6 : public InstanceLocator, private NonCopyable const Address *SelectSourceAddress(const Address &aDestination) const; /** - * This method returns a reference to the send queue. + * Returns a reference to the send queue. * * @returns A reference to the send queue. * @@ -332,7 +332,7 @@ class Ip6 : public InstanceLocator, private NonCopyable const PriorityQueue &GetSendQueue(void) const { return mSendQueue; } /** - * This static method converts an IP protocol number to a string. + * Converts an IP protocol number to a string. * * @param[in] aIpProto An IP protocol number. * @@ -342,7 +342,7 @@ class Ip6 : public InstanceLocator, private NonCopyable static const char *IpProtoToString(uint8_t aIpProto); /** - * This static method converts an IP header ECN value to a string. + * Converts an IP header ECN value to a string. * * @param[in] aEcn The 2-bit ECN value. * @@ -353,7 +353,7 @@ class Ip6 : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE /** - * This method returns a reference to the Border Routing counters. + * Returns a reference to the Border Routing counters. * * @returns A reference to the Border Routing counters. * @@ -361,7 +361,7 @@ class Ip6 : public InstanceLocator, private NonCopyable const otBorderRoutingCounters &GetBorderRoutingCounters(void) const { return mBorderRoutingCounters; } /** - * This method returns a reference to the Border Routing counters. + * Returns a reference to the Border Routing counters. * * @returns A reference to the Border Routing counters. * @@ -369,7 +369,7 @@ class Ip6 : public InstanceLocator, private NonCopyable otBorderRoutingCounters &GetBorderRoutingCounters(void) { return mBorderRoutingCounters; } /** - * This method resets the Border Routing counters. + * Resets the Border Routing counters. * */ void ResetBorderRoutingCounters(void) { memset(&mBorderRoutingCounters, 0, sizeof(mBorderRoutingCounters)); } @@ -453,7 +453,7 @@ class Ip6 : public InstanceLocator, private NonCopyable }; /** - * This class represents parsed IPv6 header along with UDP/TCP/ICMP6 headers from a received message/frame. + * Represents parsed IPv6 header along with UDP/TCP/ICMP6 headers from a received message/frame. * */ class Headers : private Clearable @@ -462,7 +462,7 @@ class Headers : private Clearable public: /** - * This method parses the IPv6 and UDP/TCP/ICMP6 headers from a given message. + * Parses the IPv6 and UDP/TCP/ICMP6 headers from a given message. * * @param[in] aMessage The message to parse the headers from. * @@ -473,7 +473,7 @@ class Headers : private Clearable Error ParseFrom(const Message &aMessage); /** - * This method decompresses lowpan frame and parses the IPv6 and UDP/TCP/ICMP6 headers. + * Decompresses lowpan frame and parses the IPv6 and UDP/TCP/ICMP6 headers. * * @param[in] aMessage The message from which to read the lowpan frame. * @param[in] aOffset The offset in @p aMessage to start reading the frame. @@ -487,7 +487,7 @@ class Headers : private Clearable Error DecompressFrom(const Message &aMessage, uint16_t aOffset, const Mac::Addresses &aMacAddrs); /** - * This method decompresses lowpan frame and parses the IPv6 and UDP/TCP/ICMP6 headers. + * Decompresses lowpan frame and parses the IPv6 and UDP/TCP/ICMP6 headers. * * @param[in] aFrameData The lowpan frame data. * @param[in] aMacAddrs The MAC source and destination addresses. @@ -501,7 +501,7 @@ class Headers : private Clearable Error DecompressFrom(const FrameData &aFrameData, const Mac::Addresses &aMacAddrs, Instance &aInstance); /** - * This method returns the IPv6 header. + * Returns the IPv6 header. * * @returns The IPv6 header. * @@ -509,7 +509,7 @@ class Headers : private Clearable const Header &GetIp6Header(void) const { return mIp6Header; } /** - * This method returns the IP protocol number from IPv6 Next Header field. + * Returns the IP protocol number from IPv6 Next Header field. * * @returns The IP protocol number. * @@ -517,7 +517,7 @@ class Headers : private Clearable uint8_t GetIpProto(void) const { return mIp6Header.GetNextHeader(); } /** - * This method returns the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field from IPv6 header. + * Returns the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field from IPv6 header. * * @returns The ECN value. * @@ -525,7 +525,7 @@ class Headers : private Clearable Ecn GetEcn(void) const { return mIp6Header.GetEcn(); } /** - * This method indicates if the protocol number from IPv6 header is UDP. + * Indicates if the protocol number from IPv6 header is UDP. * * @retval TRUE If the protocol number in IPv6 header is UDP. * @retval FALSE If the protocol number in IPv6 header is not UDP. @@ -534,7 +534,7 @@ class Headers : private Clearable bool IsUdp(void) const { return GetIpProto() == kProtoUdp; } /** - * This method indicates if the protocol number from IPv6 header is TCP. + * Indicates if the protocol number from IPv6 header is TCP. * * @retval TRUE If the protocol number in IPv6 header is TCP. * @retval FALSE If the protocol number in IPv6 header is not TCP. @@ -543,7 +543,7 @@ class Headers : private Clearable bool IsTcp(void) const { return GetIpProto() == kProtoTcp; } /** - * This method indicates if the protocol number from IPv6 header is ICMPv6. + * Indicates if the protocol number from IPv6 header is ICMPv6. * * @retval TRUE If the protocol number in IPv6 header is ICMPv6. * @retval FALSE If the protocol number in IPv6 header is not ICMPv6. @@ -552,7 +552,7 @@ class Headers : private Clearable bool IsIcmp6(void) const { return GetIpProto() == kProtoIcmp6; } /** - * This method returns the source IPv6 address from IPv6 header. + * Returns the source IPv6 address from IPv6 header. * * @returns The source IPv6 address. * @@ -560,7 +560,7 @@ class Headers : private Clearable const Address &GetSourceAddress(void) const { return mIp6Header.GetSource(); } /** - * This method returns the destination IPv6 address from IPv6 header. + * Returns the destination IPv6 address from IPv6 header. * * @returns The destination IPv6 address. * @@ -568,9 +568,9 @@ class Headers : private Clearable const Address &GetDestinationAddress(void) const { return mIp6Header.GetDestination(); } /** - * This method returns the UDP header. + * Returns the UDP header. * - * This method MUST be used when `IsUdp() == true`. Otherwise its behavior is undefined + * MUST be used when `IsUdp() == true`. Otherwise its behavior is undefined * * @returns The UDP header. * @@ -578,9 +578,9 @@ class Headers : private Clearable const Udp::Header &GetUdpHeader(void) const { return mHeader.mUdp; } /** - * This method returns the TCP header. + * Returns the TCP header. * - * This method MUST be used when `IsTcp() == true`. Otherwise its behavior is undefined + * MUST be used when `IsTcp() == true`. Otherwise its behavior is undefined * * @returns The TCP header. * @@ -588,9 +588,9 @@ class Headers : private Clearable const Tcp::Header &GetTcpHeader(void) const { return mHeader.mTcp; } /** - * This method returns the ICMPv6 header. + * Returns the ICMPv6 header. * - * This method MUST be used when `IsIcmp6() == true`. Otherwise its behavior is undefined + * MUST be used when `IsIcmp6() == true`. Otherwise its behavior is undefined * * @returns The ICMPv6 header. * @@ -598,7 +598,7 @@ class Headers : private Clearable const Icmp::Header &GetIcmpHeader(void) const { return mHeader.mIcmp; } /** - * This method returns the source port number if header is UDP or TCP, or zero otherwise + * Returns the source port number if header is UDP or TCP, or zero otherwise * * @returns The source port number under UDP / TCP or zero. * @@ -606,7 +606,7 @@ class Headers : private Clearable uint16_t GetSourcePort(void) const; /** - * This method returns the destination port number if header is UDP or TCP, or zero otherwise. + * Returns the destination port number if header is UDP or TCP, or zero otherwise. * * @returns The destination port number under UDP / TCP or zero. * @@ -614,7 +614,7 @@ class Headers : private Clearable uint16_t GetDestinationPort(void) const; /** - * This method returns the checksum values from corresponding UDP, TCP, or ICMPv6 header. + * Returns the checksum values from corresponding UDP, TCP, or ICMPv6 header. * * @returns The checksum value. * diff --git a/src/core/net/ip6_address.cpp b/src/core/net/ip6_address.cpp index 58ac92d7c51..e6d924296a6 100644 --- a/src/core/net/ip6_address.cpp +++ b/src/core/net/ip6_address.cpp @@ -96,6 +96,22 @@ bool Prefix::ContainsPrefix(const NetworkPrefix &aSubPrefix) const (MatchLength(GetBytes(), aSubPrefix.m8, NetworkPrefix::kSize) >= NetworkPrefix::kLength); } +void Prefix::Tidy(void) +{ + uint8_t byteLength = GetBytesSize(); + uint8_t lastByteBitMask = ~(static_cast(1 << (byteLength * 8 - mLength)) - 1); + + if (byteLength != 0) + { + mPrefix.mFields.m8[byteLength - 1] &= lastByteBitMask; + } + + for (uint16_t i = byteLength; i < GetArrayLength(mPrefix.mFields.m8); i++) + { + mPrefix.mFields.m8[i] = 0; + } +} + bool Prefix::operator==(const Prefix &aOther) const { return (mLength == aOther.mLength) && (MatchLength(GetBytes(), aOther.GetBytes(), GetBytesSize()) >= GetLength()); @@ -201,8 +217,10 @@ void Prefix::ToString(char *aBuffer, uint16_t aSize) const void Prefix::ToString(StringWriter &aWriter) const { uint8_t sizeInUint16 = (GetBytesSize() + sizeof(uint16_t) - 1) / sizeof(uint16_t); + Prefix tidyPrefix = *this; - AsCoreType(&mPrefix).AppendHexWords(aWriter, sizeInUint16); + tidyPrefix.Tidy(); + AsCoreType(&tidyPrefix.mPrefix).AppendHexWords(aWriter, sizeInUint16); if (GetBytesSize() < Address::kSize - 1) { @@ -237,7 +255,7 @@ bool InterfaceIdentifier::IsReservedSubnetAnycast(void) const mFields.m8[7] >= 0x80); } -void InterfaceIdentifier::GenerateRandom(void) { SuccessOrAssert(Random::Crypto::FillBuffer(mFields.m8, kSize)); } +void InterfaceIdentifier::GenerateRandom(void) { SuccessOrAssert(Random::Crypto::Fill(*this)); } void InterfaceIdentifier::SetBytes(const uint8_t *aBuffer) { memcpy(mFields.m8, aBuffer, kSize); } diff --git a/src/core/net/ip6_address.hpp b/src/core/net/ip6_address.hpp index 3323690fba0..3e91551a5b1 100644 --- a/src/core/net/ip6_address.hpp +++ b/src/core/net/ip6_address.hpp @@ -66,7 +66,7 @@ namespace Ip6 { */ /** - * This class represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). + * Represents the Network Prefix of an IPv6 address (most significant 64 bits of the address). * */ OT_TOOL_PACKED_BEGIN @@ -77,7 +77,7 @@ class NetworkPrefix : public otIp6NetworkPrefix, public Equatable static constexpr uint8_t kLength = OT_IP6_PREFIX_SIZE * CHAR_BIT; ///< Length of Network Prefix in bits. /** - * This method generates and sets the Network Prefix to a crypto-secure random Unique Local Address (ULA) based + * Generates and sets the Network Prefix to a crypto-secure random Unique Local Address (ULA) based * on the pattern `fdxx:xxxx:xxxx:` (RFC 4193). * * @retval kErrorNone Successfully generated a random ULA Network Prefix @@ -89,7 +89,7 @@ class NetworkPrefix : public otIp6NetworkPrefix, public Equatable } OT_TOOL_PACKED_END; /** - * This class represents an IPv6 Prefix. + * Represents an IPv6 Prefix. * */ OT_TOOL_PACKED_BEGIN @@ -102,13 +102,13 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< static constexpr uint16_t kInfoStringSize = OT_IP6_PREFIX_STRING_SIZE; ///< Info string size (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method gets the prefix as a pointer to a byte array. + * Gets the prefix as a pointer to a byte array. * * @returns A pointer to a byte array containing the Prefix. * @@ -116,7 +116,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< const uint8_t *GetBytes(void) const { return mPrefix.mFields.m8; } /** - * This method gets the subnet ID of the prefix. + * Gets the subnet ID of the prefix. * * @returns The 16-bit subnet ID. * @@ -124,7 +124,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< uint16_t GetSubnetId(void) const { return HostSwap16(mPrefix.mFields.m16[3]); } /** - * This method gets the prefix length (in bits). + * Gets the prefix length (in bits). * * @returns The prefix length (in bits). * @@ -132,7 +132,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< uint8_t GetLength(void) const { return mLength; } /** - * This method returns the size (in bytes) of the prefix. + * Returns the size (in bytes) of the prefix. * * @returns The size (in bytes) of the prefix array. * @@ -140,7 +140,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< uint8_t GetBytesSize(void) const { return SizeForLength(mLength); } /** - * This method sets the prefix. + * Sets the prefix. * * @param[in] aPrefix A pointer to buffer containing the prefix bytes. * @param[in] aLength The length or prefix in bits. @@ -149,7 +149,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< void Set(const uint8_t *aPrefix, uint8_t aLength); /** - * This method sets the prefix from a given Network Prefix. + * Sets the prefix from a given Network Prefix. * * @param[in] aNetworkPrefix A Network Prefix. * @@ -157,7 +157,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< void Set(const NetworkPrefix &aNetworkPrefix) { Set(aNetworkPrefix.m8, NetworkPrefix::kLength); } /** - * This method sets the subnet ID of the prefix. + * Sets the subnet ID of the prefix. * * @param[in] aSubnetId A 16-bit subnet ID. * @@ -165,7 +165,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< void SetSubnetId(uint16_t aSubnetId) { mPrefix.mFields.m16[3] = HostSwap16(aSubnetId); } /** - * This method set the prefix length. + * Set the prefix length. * * @param[in] aLength The new prefix length (in bits). * @@ -173,7 +173,13 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< void SetLength(uint8_t aLength) { mLength = aLength; } /** - * This method indicates whether prefix length is valid (smaller or equal to max length). + * Sets the bits after the prefix length to 0. + * + */ + void Tidy(void); + + /** + * Indicates whether prefix length is valid (smaller or equal to max length). * * @retval TRUE The prefix length is valid. * @retval FALSE The prefix length is not valid. @@ -182,7 +188,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsValid(void) const { return (mLength <= kMaxLength); } /** - * This method indicates whether the prefix is a Link-Local prefix. + * Indicates whether the prefix is a Link-Local prefix. * * @retval TRUE The prefix is a Link-Local prefix. * @retval FALSE The prefix is not a Link-Local prefix. @@ -191,7 +197,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsLinkLocal(void) const; /** - * This method indicates whether the prefix is a Multicast prefix. + * Indicates whether the prefix is a Multicast prefix. * * @retval TRUE The prefix is a Multicast prefix. * @retval FALSE The prefix is not a Multicast prefix. @@ -200,7 +206,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsMulticast(void) const; /** - * This method indicates whether the prefix is a Unique-Local prefix. + * Indicates whether the prefix is a Unique-Local prefix. * * @retval TRUE The prefix is a Unique-Local prefix. * @retval FALSE The prefix is not a Unique-Local prefix. @@ -209,7 +215,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsUniqueLocal(void) const; /** - * This method indicates whether the prefix is equal to a given prefix. + * Indicates whether the prefix is equal to a given prefix. * * @param[in] aPrefixBytes A pointer to buffer containing the prefix bytes to compare with. * @param[in] aPrefixLength The length of prefix (in bits) specified by @p aPrefixBytes. @@ -221,7 +227,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsEqual(const uint8_t *aPrefixBytes, uint8_t aPrefixLength) const; /** - * This method indicates whether the prefix contains a sub-prefix. + * Indicates whether the prefix contains a sub-prefix. * * @param[in] aSubPrefix A sub-prefix. * @@ -232,7 +238,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool ContainsPrefix(const Prefix &aSubPrefix) const; /** - * This method indicates whether the prefix contains a sub-prefix (given as a `NetworkPrefix`). + * Indicates whether the prefix contains a sub-prefix (given as a `NetworkPrefix`). * * @param[in] aSubPrefix A sub-prefix (as a `NetworkPrefix`). * @@ -243,7 +249,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool ContainsPrefix(const NetworkPrefix &aSubPrefix) const; /** - * This method overloads operator `==` to evaluate whether or not two prefixes are equal. + * Overloads operator `==` to evaluate whether or not two prefixes are equal. * * @param[in] aOther The other prefix to compare with. * @@ -254,7 +260,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool operator==(const Prefix &aOther) const; /** - * This method overloads operator `<` to compare two prefixes. + * Overloads operator `<` to compare two prefixes. * * If the two prefixes have the same length N, then the bytes are compared directly (as two big-endian N-bit * numbers). If the two prefix have different lengths, the shorter prefix is padded by `0` bit up to the longer @@ -270,7 +276,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool operator<(const Prefix &aOther) const; /** - * This static method converts a prefix length (in bits) to size (number of bytes). + * Converts a prefix length (in bits) to size (number of bytes). * * @param[in] aLength A prefix length (in bits). * @@ -280,7 +286,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< static uint8_t SizeForLength(uint8_t aLength) { return BitVectorBytes(aLength); } /** - * This static method returns the number of IPv6 prefix bits that match. + * Returns the number of IPv6 prefix bits that match. * * @param[in] aPrefixA A pointer to a byte array containing a first prefix. * @param[in] aPrefixB A pointer to a byte array containing a second prefix. @@ -292,7 +298,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< static uint8_t MatchLength(const uint8_t *aPrefixA, const uint8_t *aPrefixB, uint8_t aMaxSize); /** - * This method indicates whether or not a given prefix length is valid for use as a NAT64 prefix. + * Indicates whether or not a given prefix length is valid for use as a NAT64 prefix. * * A NAT64 prefix must have one of the following lengths: 32, 40, 48, 56, 64, or 96 (per RFC 6052). * @@ -305,7 +311,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< static bool IsValidNat64PrefixLength(uint8_t aLength); /** - * This method indicates whether or not the prefix has a valid length for use as a NAT64 prefix. + * Indicates whether or not the prefix has a valid length for use as a NAT64 prefix. * * A NAT64 prefix must have one of the following lengths: 32, 40, 48, 56, 64, or 96 (per RFC 6052). * @@ -316,7 +322,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< bool IsValidNat64(void) const { return IsValidNat64PrefixLength(mLength); } /** - * This method parses a given IPv6 prefix string and sets the prefix. + * Parses a given IPv6 prefix string and sets the prefix. * * @param[in] aString A null-terminated string, with format "/" * @@ -327,7 +333,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< Error FromString(const char *aString); /** - * This method converts the prefix to a string. + * Converts the prefix to a string. * * The IPv6 prefix string is formatted as "%x:%x:%x:...[::]/plen". * @@ -337,7 +343,7 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< InfoString ToString(void) const; /** - * This method converts the prefix to a string. + * Converts the prefix to a string. * * The IPv6 prefix string is formatted as "%x:%x:%x:...[::]/plen". * @@ -351,11 +357,12 @@ class Prefix : public otIp6Prefix, public Clearable, public Unequatable< void ToString(char *aBuffer, uint16_t aSize) const; private: - void ToString(StringWriter &aWriter) const; + uint8_t ByteAfterTidy(uint8_t aIndex); + void ToString(StringWriter &aWriter) const; } OT_TOOL_PACKED_END; /** - * This class represents the Interface Identifier of an IPv6 address. + * Represents the Interface Identifier of an IPv6 address. * */ OT_TOOL_PACKED_BEGIN @@ -371,13 +378,13 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, static constexpr uint16_t kInfoStringSize = 17; ///< Max chars for the info string (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method indicates whether or not the Interface Identifier is unspecified. + * Indicates whether or not the Interface Identifier is unspecified. * * @retval true If the Interface Identifier is unspecified. * @retval false If the Interface Identifier is not unspecified. @@ -386,7 +393,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsUnspecified(void) const; /** - * This method indicates whether or not the Interface Identifier is reserved (RFC 5453). + * Indicates whether or not the Interface Identifier is reserved (RFC 5453). * * @retval true If the Interface Identifier is reserved. * @retval false If the Interface Identifier is not reserved. @@ -395,7 +402,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsReserved(void) const; /** - * This method indicates whether or not the Interface Identifier is Subnet-Router Anycast (RFC 4291). + * Indicates whether or not the Interface Identifier is Subnet-Router Anycast (RFC 4291). * * @retval TRUE If the Interface Identifier is a Subnet-Router Anycast address. * @retval FALSE If the Interface Identifier is not a Subnet-Router Anycast address. @@ -404,7 +411,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsSubnetRouterAnycast(void) const; /** - * This method indicates whether or not the Interface Identifier is Reserved Subnet Anycast (RFC 2526). + * Indicates whether or not the Interface Identifier is Reserved Subnet Anycast (RFC 2526). * * @retval TRUE If the Interface Identifier is a Reserved Subnet Anycast address. * @retval FALSE If the Interface Identifier is not a Reserved Subnet Anycast address. @@ -413,13 +420,13 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsReservedSubnetAnycast(void) const; /** - * This method generates and sets the Interface Identifier to a crypto-secure random byte sequence. + * Generates and sets the Interface Identifier to a crypto-secure random byte sequence. * */ void GenerateRandom(void); /** - * This method gets the Interface Identifier as a pointer to a byte array. + * Gets the Interface Identifier as a pointer to a byte array. * * @returns A pointer to a byte array (of size `kSize`) containing the Interface Identifier. * @@ -427,7 +434,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, const uint8_t *GetBytes(void) const { return mFields.m8; } /** - * This method sets the Interface Identifier from a given byte array. + * Sets the Interface Identifier from a given byte array. * * @param[in] aBuffer Pointer to an array containing the Interface Identifier. `kSize` bytes from the buffer * are copied to form the Interface Identifier. @@ -436,7 +443,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void SetBytes(const uint8_t *aBuffer); /** - * This method sets the Interface Identifier from a given IEEE 802.15.4 Extended Address. + * Sets the Interface Identifier from a given IEEE 802.15.4 Extended Address. * * @param[in] aExtAddress An Extended Address. * @@ -444,7 +451,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void SetFromExtAddress(const Mac::ExtAddress &aExtAddress); /** - * This method converts the Interface Identifier to an IEEE 802.15.4 Extended Address. + * Converts the Interface Identifier to an IEEE 802.15.4 Extended Address. * * @param[out] aExtAddress A reference to an Extended Address where the converted address is placed. * @@ -452,7 +459,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void ConvertToExtAddress(Mac::ExtAddress &aExtAddress) const; /** - * This method converts the Interface Identifier to an IEEE 802.15.4 MAC Address. + * Converts the Interface Identifier to an IEEE 802.15.4 MAC Address. * * @param[out] aMacAddress A reference to a MAC Address where the converted address is placed. * @@ -460,7 +467,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void ConvertToMacAddress(Mac::Address &aMacAddress) const; /** - * This method sets the Interface Identifier to Routing/Anycast Locator pattern `0000:00ff:fe00:xxxx` with a given + * Sets the Interface Identifier to Routing/Anycast Locator pattern `0000:00ff:fe00:xxxx` with a given * locator (RLOC16 or ALOC16) value. * * @param[in] aLocator RLOC16 or ALOC16. @@ -469,7 +476,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void SetToLocator(uint16_t aLocator); /** - * This method indicates whether or not the Interface Identifier matches the locator pattern `0000:00ff:fe00:xxxx`. + * Indicates whether or not the Interface Identifier matches the locator pattern `0000:00ff:fe00:xxxx`. * * @retval TRUE If the IID matches the locator pattern. * @retval FALSE If the IID does not match the locator pattern. @@ -478,7 +485,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsLocator(void) const; /** - * This method indicates whether or not the Interface Identifier (IID) matches a Routing Locator (RLOC). + * Indicates whether or not the Interface Identifier (IID) matches a Routing Locator (RLOC). * * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also * checks that the locator value is a valid RLOC16. @@ -490,7 +497,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsRoutingLocator(void) const; /** - * This method indicates whether or not the Interface Identifier (IID) matches an Anycast Locator (ALOC). + * Indicates whether or not the Interface Identifier (IID) matches an Anycast Locator (ALOC). * * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also * checks that the locator value is any valid ALOC16 (0xfc00 - 0xfcff). @@ -502,7 +509,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsAnycastLocator(void) const; /** - * This method indicates whether or not the Interface Identifier (IID) matches a Service Anycast Locator (ALOC). + * Indicates whether or not the Interface Identifier (IID) matches a Service Anycast Locator (ALOC). * * In addition to checking that the IID matches the locator pattern (`0000:00ff:fe00:xxxx`), this method also * checks that the locator value is a valid Service ALOC16 (0xfc10 – 0xfc2f). @@ -514,9 +521,9 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, bool IsAnycastServiceLocator(void) const; /** - * This method gets the Interface Identifier (IID) address locator fields. + * Gets the Interface Identifier (IID) address locator fields. * - * This method assumes the IID to match the locator pattern `0000:00ff:fe00:xxxx` (does not explicitly check this) + * Assumes the IID to match the locator pattern `0000:00ff:fe00:xxxx` (does not explicitly check this) * and returns the last `uint16` portion of the IID. * * @returns The RLOC16 or ALOC16. @@ -525,7 +532,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, uint16_t GetLocator(void) const { return HostSwap16(mFields.m16[3]); } /** - * This method sets the Interface Identifier (IID) address locator field. + * Sets the Interface Identifier (IID) address locator field. * * Unlike `SetToLocator()`, this method only changes the last 2 bytes of the IID and keeps the rest of the address * as before. @@ -536,7 +543,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void SetLocator(uint16_t aLocator) { mFields.m16[3] = HostSwap16(aLocator); } /** - * This method applies a prefix to IID. + * Applies a prefix to IID. * * If the prefix length is longer than 64 bits, the prefix bits after 64 are written into the IID. This method only * changes the bits in IID up the prefix length and keeps the rest of the bits in IID as before. @@ -547,7 +554,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, void ApplyPrefix(const Prefix &aPrefix); /** - * This method converts an Interface Identifier to a string. + * Converts an Interface Identifier to a string. * * @returns An `InfoString` containing the string representation of the Interface Identifier. * @@ -561,7 +568,7 @@ class InterfaceIdentifier : public otIp6InterfaceIdentifier, } OT_TOOL_PACKED_END; /** - * This class implements an IPv6 address object. + * Implements an IPv6 address object. * */ OT_TOOL_PACKED_BEGIN @@ -588,7 +595,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable static constexpr uint8_t kGlobalScope = 14; ///< Global scope /** - * This enumeration defines IPv6 address type filter. + * Defines IPv6 address type filter. * */ enum TypeFilter : uint8_t @@ -600,13 +607,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable }; /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method gets the IPv6 address as a pointer to a byte array. + * Gets the IPv6 address as a pointer to a byte array. * * @returns A pointer to a byte array containing the IPv6 address. * @@ -614,7 +621,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable const uint8_t *GetBytes(void) const { return mFields.m8; } /** - * This method sets the IPv6 address from a given byte array. + * Sets the IPv6 address from a given byte array. * * @param[in] aBuffer Pointer to an array containing the IPv6 address. `kSize` bytes from the buffer * are copied to form the IPv6 address. @@ -623,7 +630,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetBytes(const uint8_t *aBuffer) { memcpy(mFields.m8, aBuffer, kSize); } /** - * This method indicates whether or not the IPv6 address is the Unspecified Address. + * Indicates whether or not the IPv6 address is the Unspecified Address. * * @retval TRUE If the IPv6 address is the Unspecified Address. * @retval FALSE If the IPv6 address is not the Unspecified Address. @@ -632,7 +639,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsUnspecified(void) const; /** - * This method indicates whether or not the IPv6 address is the Loopback Address. + * Indicates whether or not the IPv6 address is the Loopback Address. * * @retval TRUE If the IPv6 address is the Loopback Address. * @retval FALSE If the IPv6 address is not the Loopback Address. @@ -641,7 +648,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsLoopback(void) const; /** - * This method indicates whether or not the IPv6 address scope is Link-Local. + * Indicates whether or not the IPv6 address scope is Link-Local. * * @retval TRUE If the IPv6 address scope is Link-Local. * @retval FALSE If the IPv6 address scope is not Link-Local. @@ -650,7 +657,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsLinkLocal(void) const; /** - * This methods sets the IPv6 address to a Link-Local address with Interface Identifier generated from a given + * Sets the IPv6 address to a Link-Local address with Interface Identifier generated from a given * MAC Extended Address. * * @param[in] aExtAddress A MAC Extended Address (used to generate the IID). @@ -659,7 +666,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetToLinkLocalAddress(const Mac::ExtAddress &aExtAddress); /** - * This methods sets the IPv6 address to a Link-Local address with a given Interface Identifier. + * Sets the IPv6 address to a Link-Local address with a given Interface Identifier. * * @param[in] aIid An Interface Identifier. * @@ -667,7 +674,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetToLinkLocalAddress(const InterfaceIdentifier &aIid); /** - * This method indicates whether or not the IPv6 address is multicast address. + * Indicates whether or not the IPv6 address is multicast address. * * @retval TRUE If the IPv6 address is a multicast address. * @retval FALSE If the IPv6 address scope is not a multicast address. @@ -676,7 +683,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsMulticast(void) const { return mFields.m8[0] == 0xff; } /** - * This method indicates whether or not the IPv6 address is a link-local multicast address. + * Indicates whether or not the IPv6 address is a link-local multicast address. * * @retval TRUE If the IPv6 address is a link-local multicast address. * @retval FALSE If the IPv6 address scope is not a link-local multicast address. @@ -685,7 +692,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsLinkLocalMulticast(void) const; /** - * This method indicates whether or not the IPv6 address is a link-local all nodes multicast address (ff02::01). + * Indicates whether or not the IPv6 address is a link-local all nodes multicast address (ff02::01). * * @retval TRUE If the IPv6 address is a link-local all nodes multicast address. * @retval FALSE If the IPv6 address is not a link-local all nodes multicast address. @@ -694,13 +701,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsLinkLocalAllNodesMulticast(void) const; /** - * This method sets the IPv6 address to the link-local all nodes multicast address (ff02::01). + * Sets the IPv6 address to the link-local all nodes multicast address (ff02::01). * */ void SetToLinkLocalAllNodesMulticast(void); /** - * This method indicates whether or not the IPv6 address is a link-local all routers multicast address (ff02::02). + * Indicates whether or not the IPv6 address is a link-local all routers multicast address (ff02::02). * * @retval TRUE If the IPv6 address is a link-local all routers multicast address. * @retval FALSE If the IPv6 address is not a link-local all routers multicast address. @@ -709,13 +716,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsLinkLocalAllRoutersMulticast(void) const; /** - * This method sets the IPv6 address to the link-local all routers multicast address (ff02::02). + * Sets the IPv6 address to the link-local all routers multicast address (ff02::02). * */ void SetToLinkLocalAllRoutersMulticast(void); /** - * This method indicates whether or not the IPv6 address is a realm-local multicast address. + * Indicates whether or not the IPv6 address is a realm-local multicast address. * * @retval TRUE If the IPv6 address is a realm-local multicast address. * @retval FALSE If the IPv6 address scope is not a realm-local multicast address. @@ -724,7 +731,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsRealmLocalMulticast(void) const; /** - * This method indicates whether or not the IPv6 address is a realm-local all nodes multicast address (ff03::01). + * Indicates whether or not the IPv6 address is a realm-local all nodes multicast address (ff03::01). * * @retval TRUE If the IPv6 address is a realm-local all nodes multicast address. * @retval FALSE If the IPv6 address is not a realm-local all nodes multicast address. @@ -733,13 +740,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsRealmLocalAllNodesMulticast(void) const; /** - * This method sets the IPv6 address to the realm-local all nodes multicast address (ff03::01) + * Sets the IPv6 address to the realm-local all nodes multicast address (ff03::01) * */ void SetToRealmLocalAllNodesMulticast(void); /** - * This method indicates whether or not the IPv6 address is a realm-local all routers multicast address (ff03::02). + * Indicates whether or not the IPv6 address is a realm-local all routers multicast address (ff03::02). * * @retval TRUE If the IPv6 address is a realm-local all routers multicast address. * @retval FALSE If the IPv6 address is not a realm-local all routers multicast address. @@ -748,13 +755,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsRealmLocalAllRoutersMulticast(void) const; /** - * This method sets the IPv6 address to the realm-local all routers multicast address (ff03::02). + * Sets the IPv6 address to the realm-local all routers multicast address (ff03::02). * */ void SetToRealmLocalAllRoutersMulticast(void); /** - * This method indicates whether or not the IPv6 address is a realm-local all MPL forwarders address (ff03::fc). + * Indicates whether or not the IPv6 address is a realm-local all MPL forwarders address (ff03::fc). * * @retval TRUE If the IPv6 address is a realm-local all MPL forwarders address. * @retval FALSE If the IPv6 address is not a realm-local all MPL forwarders address. @@ -763,13 +770,13 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsRealmLocalAllMplForwarders(void) const; /** - * This method sets the the IPv6 address to the realm-local all MPL forwarders address (ff03::fc). + * Sets the the IPv6 address to the realm-local all MPL forwarders address (ff03::fc). * */ void SetToRealmLocalAllMplForwarders(void); /** - * This method indicates whether or not the IPv6 address is multicast larger than realm local. + * Indicates whether or not the IPv6 address is multicast larger than realm local. * * @retval TRUE If the IPv6 address is multicast larger than realm local. * @retval FALSE If the IPv6 address is not multicast or the scope is not larger than realm local. @@ -778,7 +785,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool IsMulticastLargerThanRealmLocal(void) const; /** - * This method sets the IPv6 address to a Routing Locator (RLOC) IPv6 address with a given Network Prefix and + * Sets the IPv6 address to a Routing Locator (RLOC) IPv6 address with a given Network Prefix and * RLOC16 value. * * @param[in] aNetworkPrefix A Network Prefix. @@ -791,7 +798,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method sets the IPv6 address to a Anycast Locator (ALOC) IPv6 address with a given Network Prefix and + * Sets the IPv6 address to a Anycast Locator (ALOC) IPv6 address with a given Network Prefix and * ALOC16 value. * * @param[in] aNetworkPrefix A Network Prefix. @@ -804,7 +811,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method returns the Network Prefix of the IPv6 address (most significant 64 bits of the address). + * Returns the Network Prefix of the IPv6 address (most significant 64 bits of the address). * * @returns A reference to the Network Prefix. * @@ -815,7 +822,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method gets a prefix of the IPv6 address with a given length. + * Gets a prefix of the IPv6 address with a given length. * * @param[in] aLength The length of prefix in bits. * @param[out] aPrefix A reference to a prefix to output the fetched prefix. @@ -824,7 +831,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void GetPrefix(uint8_t aLength, Prefix &aPrefix) const { aPrefix.Set(mFields.m8, aLength); } /** - * This method indicates whether the IPv6 address matches a given prefix. + * Indicates whether the IPv6 address matches a given prefix. * * @param[in] aPrefix An IPv6 prefix to match with. * @@ -835,7 +842,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool MatchesPrefix(const Prefix &aPrefix) const; /** - * This method indicates whether the IPv6 address matches a given prefix. + * Indicates whether the IPv6 address matches a given prefix. * * @param[in] aPrefix A buffer containing the prefix. * @param[in] aPrefixLength The prefix length (in bits). @@ -847,9 +854,9 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool MatchesPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength) const; /** - * This method sets the IPv6 address prefix. + * Sets the IPv6 address prefix. * - * This method only changes the first @p aPrefixLength bits of the address and keeps the rest of the bits in the + * Only changes the first @p aPrefixLength bits of the address and keeps the rest of the bits in the * address as before. * * @param[in] aPrefix A buffer containing the prefix. @@ -859,7 +866,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength) { CopyBits(mFields.m8, aPrefix, aPrefixLength); } /** - * This method sets the IPv6 address prefix to the given Network Prefix. + * Sets the IPv6 address prefix to the given Network Prefix. * * @param[in] aNetworkPrefix A Network Prefix. * @@ -867,9 +874,9 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetPrefix(const NetworkPrefix &aNetworkPrefix); /** - * This method sets the IPv6 address prefix. + * Sets the IPv6 address prefix. * - * This method only changes the initial prefix length bits of the IPv6 address and keeps the rest of the bits in + * Only changes the initial prefix length bits of the IPv6 address and keeps the rest of the bits in * the address as before. * * @param[in] aPrefix An IPv6 prefix. @@ -878,7 +885,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetPrefix(const Prefix &aPrefix); /** - * This method sets the prefix content of the Prefix-Based Multicast Address. + * Sets the prefix content of the Prefix-Based Multicast Address. * * @param[in] aPrefix A buffer containing the prefix. * @param[in] aPrefixLength The prefix length (in bits). @@ -887,7 +894,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetMulticastNetworkPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength); /** - * This method sets the prefix content of Prefix-Based Multicast Address. + * Sets the prefix content of Prefix-Based Multicast Address. * * @param[in] aNetworkPrefix A reference to a Network Prefix. * @@ -898,7 +905,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method sets the prefix content of Prefix-Based Multicast Address. + * Sets the prefix content of Prefix-Based Multicast Address. * * @param[in] aPrefix An IPv6 Prefix. * @@ -909,7 +916,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method returns the Interface Identifier of the IPv6 address. + * Returns the Interface Identifier of the IPv6 address. * * @returns A reference to the Interface Identifier. * @@ -920,7 +927,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable } /** - * This method returns the Interface Identifier of the IPv6 address. + * Returns the Interface Identifier of the IPv6 address. * * @returns A reference to the Interface Identifier. * @@ -928,7 +935,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable InterfaceIdentifier &GetIid(void) { return static_cast(mFields.mComponents.mIid); } /** - * This method sets the Interface Identifier. + * Sets the Interface Identifier. * * @param[in] aIid An Interface Identifier. * @@ -936,7 +943,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SetIid(const InterfaceIdentifier &aIid) { GetIid() = aIid; } /** - * This method returns the IPv6 address scope. + * Returns the IPv6 address scope. * * @returns The IPv6 address scope. * @@ -944,7 +951,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable uint8_t GetScope(void) const; /** - * This method returns the number of IPv6 prefix bits that match. + * Returns the number of IPv6 prefix bits that match. * * @param[in] aOther The IPv6 address to match against. * @@ -954,7 +961,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable uint8_t PrefixMatch(const Address &aOther) const; /** - * This method indicates whether address matches a given type filter. + * Indicates whether address matches a given type filter. * * @param[in] aFilter An address type filter. * @@ -965,7 +972,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable bool MatchesFilter(TypeFilter aFilter) const; /** - * This method sets the IPv6 address by performing NAT64 address translation from a given IPv4 address as specified + * Sets the IPv6 address by performing NAT64 address translation from a given IPv4 address as specified * in RFC 6052. * * The NAT64 @p aPrefix MUST have one of the following lengths: 32, 40, 48, 56, 64, or 96, otherwise the behavior @@ -978,7 +985,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void SynthesizeFromIp4Address(const Prefix &aPrefix, const Ip4::Address &aIp4Address); /** - * This method converts an IPv6 address string to binary. + * Converts an IPv6 address string to binary. * * @param[in] aString A pointer to the null-terminated string. * @@ -989,7 +996,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable Error FromString(const char *aString); /** - * This method converts the IPv6 address to a string. + * Converts the IPv6 address to a string. * * The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x"). * @@ -999,7 +1006,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable InfoString ToString(void) const; /** - * This method convert the IPv6 address to a C string. + * Convert the IPv6 address to a C string. * * The IPv6 address string is formatted as 16 hex values separated by ':' (i.e., "%x:%x:%x:...:%x"). * @@ -1013,7 +1020,7 @@ class Address : public otIp6Address, public Equatable
, public Clearable void ToString(char *aBuffer, uint16_t aSize) const; /** - * This method overloads operator `<` to compare two IPv6 addresses. + * Overloads operator `<` to compare two IPv6 addresses. * * @param[in] aOther The other IPv6 address to compare with. * diff --git a/src/core/net/ip6_filter.hpp b/src/core/net/ip6_filter.hpp index 664aa0ed1e3..b2ef3c29ce0 100644 --- a/src/core/net/ip6_filter.hpp +++ b/src/core/net/ip6_filter.hpp @@ -55,14 +55,14 @@ namespace Ip6 { */ /** - * This class implements an IPv6 datagram filter. + * Implements an IPv6 datagram filter. * */ class Filter : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the Filter object. + * Initializes the Filter object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -73,7 +73,7 @@ class Filter : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the IPv6 datagram passes the filter. + * Indicates whether or not the IPv6 datagram passes the filter. * * @param[in] aMessage The IPv6 datagram to process. * @@ -84,7 +84,7 @@ class Filter : public InstanceLocator, private NonCopyable bool Accept(Message &aMessage) const; /** - * This method adds a port to the allowed unsecured port list. + * Adds a port to the allowed unsecured port list. * * @param[in] aPort The port value. * @@ -96,7 +96,7 @@ class Filter : public InstanceLocator, private NonCopyable Error AddUnsecurePort(uint16_t aPort) { return UpdateUnsecurePorts(kAdd, aPort); } /** - * This method removes a port from the allowed unsecure port list. + * Removes a port from the allowed unsecure port list. * * @param[in] aPort The port value. * @@ -108,7 +108,7 @@ class Filter : public InstanceLocator, private NonCopyable Error RemoveUnsecurePort(uint16_t aPort) { return UpdateUnsecurePorts(kRemove, aPort); } /** - * This method checks whether a port is in the unsecure port list. + * Checks whether a port is in the unsecure port list. * * @param[in] aPort The port value. * @@ -118,13 +118,13 @@ class Filter : public InstanceLocator, private NonCopyable bool IsUnsecurePort(uint16_t aPort) { return mUnsecurePorts.Contains(aPort); } /** - * This method removes all ports from the allowed unsecure port list. + * Removes all ports from the allowed unsecure port list. * */ void RemoveAllUnsecurePorts(void) { mUnsecurePorts.Clear(); } /** - * This method returns a pointer to the unsecure port list. + * Returns a pointer to the unsecure port list. * * @note Port value 0 is used to indicate an invalid entry. * diff --git a/src/core/net/ip6_headers.hpp b/src/core/net/ip6_headers.hpp index bb2ba1065c9..2fc55c5aa33 100644 --- a/src/core/net/ip6_headers.hpp +++ b/src/core/net/ip6_headers.hpp @@ -88,7 +88,7 @@ using ot::Encoding::BigEndian::HostSwap32; */ /** - * This class implements IPv6 header generation and parsing. + * Implements IPv6 header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -102,7 +102,7 @@ class Header : public Clearable
static constexpr uint8_t kDestinationFieldOffset = 24; ///< Offset of Destination Address field in IPv6 header. /** - * This method initializes the Version to 6 and sets Traffic Class and Flow fields to zero. + * Initializes the Version to 6 and sets Traffic Class and Flow fields to zero. * * The other fields in the IPv6 header remain unchanged. * @@ -110,7 +110,7 @@ class Header : public Clearable
void InitVersionTrafficClassFlow(void) { SetVerionTrafficClassFlow(kVersTcFlowInit); } /** - * This method indicates whether or not the header appears to be well-formed. + * Indicates whether or not the header appears to be well-formed. * * @retval TRUE If the header appears to be well-formed. * @retval FALSE If the header does not appear to be well-formed. @@ -119,7 +119,7 @@ class Header : public Clearable
bool IsValid(void) const; /** - * This method indicates whether or not the IPv6 Version is set to 6. + * Indicates whether or not the IPv6 Version is set to 6. * * @retval TRUE If the IPv6 Version is set to 6. * @retval FALSE If the IPv6 Version is not set to 6. @@ -128,7 +128,7 @@ class Header : public Clearable
bool IsVersion6(void) const { return (mVerTcFlow.m8[0] & kVersionMask) == kVersion6; } /** - * This method gets the combination of Version, Traffic Class, and Flow fields as a 32-bit value. + * Gets the combination of Version, Traffic Class, and Flow fields as a 32-bit value. * * @returns The Version, Traffic Class, and Flow fields as a 32-bit value. * @@ -136,7 +136,7 @@ class Header : public Clearable
uint32_t GetVerionTrafficClassFlow(void) const { return HostSwap32(mVerTcFlow.m32); } /** - * This method sets the combination of Version, Traffic Class, and Flow fields as a 32-bit value. + * Sets the combination of Version, Traffic Class, and Flow fields as a 32-bit value. * * @param[in] aVerTcFlow The Version, Traffic Class, and Flow fields as a 32-bit value. * @@ -144,7 +144,7 @@ class Header : public Clearable
void SetVerionTrafficClassFlow(uint32_t aVerTcFlow) { mVerTcFlow.m32 = HostSwap32(aVerTcFlow); } /** - * This method gets the Traffic Class field. + * Gets the Traffic Class field. * * @returns The Traffic Class field. * @@ -155,7 +155,7 @@ class Header : public Clearable
} /** - * This method sets the Traffic Class filed. + * Sets the Traffic Class filed. * * @param[in] aTc The Traffic Class value. * @@ -167,7 +167,7 @@ class Header : public Clearable
} /** - * This method gets the 6-bit Differentiated Services Code Point (DSCP) from Traffic Class field. + * Gets the 6-bit Differentiated Services Code Point (DSCP) from Traffic Class field. * * @returns The DSCP value. * @@ -178,7 +178,7 @@ class Header : public Clearable
} /** - * This method sets 6-bit Differentiated Services Code Point (DSCP) in IPv6 header. + * Sets 6-bit Differentiated Services Code Point (DSCP) in IPv6 header. * * @param[in] aDscp The DSCP value. * @@ -190,7 +190,7 @@ class Header : public Clearable
} /** - * This method gets the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field. + * Gets the 2-bit Explicit Congestion Notification (ECN) from Traffic Class field. * * @returns The ECN value. * @@ -198,7 +198,7 @@ class Header : public Clearable
Ecn GetEcn(void) const { return static_cast((mVerTcFlow.m8[1] & kEcnMask) >> kEcnOffset); } /** - * This method sets the 2-bit Explicit Congestion Notification (ECN) in IPv6 header.. + * Sets the 2-bit Explicit Congestion Notification (ECN) in IPv6 header.. * * @param[in] aEcn The ECN value. * @@ -206,7 +206,7 @@ class Header : public Clearable
void SetEcn(Ecn aEcn) { mVerTcFlow.m8[1] = (mVerTcFlow.m8[1] & ~kEcnMask) | ((aEcn << kEcnOffset) & kEcnMask); } /** - * This method gets the 20-bit Flow field. + * Gets the 20-bit Flow field. * * @returns The Flow value. * @@ -214,7 +214,7 @@ class Header : public Clearable
uint32_t GetFlow(void) const { return HostSwap32(mVerTcFlow.m32) & kFlowMask; } /** - * This method sets the 20-bit Flow field in IPv6 header. + * Sets the 20-bit Flow field in IPv6 header. * * @param[in] aFlow The Flow value. * @@ -225,7 +225,7 @@ class Header : public Clearable
} /** - * This method returns the IPv6 Payload Length value. + * Returns the IPv6 Payload Length value. * * @returns The IPv6 Payload Length value. * @@ -233,7 +233,7 @@ class Header : public Clearable
uint16_t GetPayloadLength(void) const { return HostSwap16(mPayloadLength); } /** - * This method sets the IPv6 Payload Length value. + * Sets the IPv6 Payload Length value. * * @param[in] aLength The IPv6 Payload Length value. * @@ -241,7 +241,7 @@ class Header : public Clearable
void SetPayloadLength(uint16_t aLength) { mPayloadLength = HostSwap16(aLength); } /** - * This method returns the IPv6 Next Header value. + * Returns the IPv6 Next Header value. * * @returns The IPv6 Next Header value. * @@ -249,7 +249,7 @@ class Header : public Clearable
uint8_t GetNextHeader(void) const { return mNextHeader; } /** - * This method sets the IPv6 Next Header value. + * Sets the IPv6 Next Header value. * * @param[in] aNextHeader The IPv6 Next Header value. * @@ -257,7 +257,7 @@ class Header : public Clearable
void SetNextHeader(uint8_t aNextHeader) { mNextHeader = aNextHeader; } /** - * This method returns the IPv6 Hop Limit value. + * Returns the IPv6 Hop Limit value. * * @returns The IPv6 Hop Limit value. * @@ -265,7 +265,7 @@ class Header : public Clearable
uint8_t GetHopLimit(void) const { return mHopLimit; } /** - * This method sets the IPv6 Hop Limit value. + * Sets the IPv6 Hop Limit value. * * @param[in] aHopLimit The IPv6 Hop Limit value. * @@ -273,7 +273,7 @@ class Header : public Clearable
void SetHopLimit(uint8_t aHopLimit) { mHopLimit = aHopLimit; } /** - * This method returns the IPv6 Source address. + * Returns the IPv6 Source address. * * @returns A reference to the IPv6 Source address. * @@ -281,7 +281,7 @@ class Header : public Clearable
Address &GetSource(void) { return mSource; } /** - * This method returns the IPv6 Source address. + * Returns the IPv6 Source address. * * @returns A reference to the IPv6 Source address. * @@ -289,7 +289,7 @@ class Header : public Clearable
const Address &GetSource(void) const { return mSource; } /** - * This method sets the IPv6 Source address. + * Sets the IPv6 Source address. * * @param[in] aSource A reference to the IPv6 Source address. * @@ -297,7 +297,7 @@ class Header : public Clearable
void SetSource(const Address &aSource) { mSource = aSource; } /** - * This method returns the IPv6 Destination address. + * Returns the IPv6 Destination address. * * @returns A reference to the IPv6 Destination address. * @@ -305,7 +305,7 @@ class Header : public Clearable
Address &GetDestination(void) { return mDestination; } /** - * This method returns the IPv6 Destination address. + * Returns the IPv6 Destination address. * * @returns A reference to the IPv6 Destination address. * @@ -313,7 +313,7 @@ class Header : public Clearable
const Address &GetDestination(void) const { return mDestination; } /** - * This method sets the IPv6 Destination address. + * Sets the IPv6 Destination address. * * @param[in] aDestination A reference to the IPv6 Destination address. * @@ -321,7 +321,7 @@ class Header : public Clearable
void SetDestination(const Address &aDestination) { mDestination = aDestination; } /** - * This method parses and validates the IPv6 header from a given message. + * Parses and validates the IPv6 header from a given message. * * The header is read from @p aMessage at offset zero. * @@ -370,7 +370,7 @@ class Header : public Clearable
} OT_TOOL_PACKED_END; /** - * This class implements IPv6 Extension Header generation and processing. + * Implements IPv6 Extension Header generation and processing. * */ OT_TOOL_PACKED_BEGIN @@ -386,7 +386,7 @@ class ExtensionHeader static constexpr uint16_t kLengthUnitSize = 8; /** - * This method returns the IPv6 Next Header value. + * Returns the IPv6 Next Header value. * * @returns The IPv6 Next Header value. * @@ -394,7 +394,7 @@ class ExtensionHeader uint8_t GetNextHeader(void) const { return mNextHeader; } /** - * This method sets the IPv6 Next Header value. + * Sets the IPv6 Next Header value. * * @param[in] aNextHeader The IPv6 Next Header value. * @@ -402,7 +402,7 @@ class ExtensionHeader void SetNextHeader(uint8_t aNextHeader) { mNextHeader = aNextHeader; } /** - * This method returns the IPv6 Header Extension Length value. + * Returns the IPv6 Header Extension Length value. * * The Length is in 8-byte units and does not include the first 8 bytes. * @@ -412,7 +412,7 @@ class ExtensionHeader uint8_t GetLength(void) const { return mLength; } /** - * This method sets the IPv6 Header Extension Length value. + * Sets the IPv6 Header Extension Length value. * * The Length is in 8-byte units and does not include the first 8 bytes. * @@ -422,7 +422,7 @@ class ExtensionHeader void SetLength(uint8_t aLength) { mLength = aLength; } /** - * This method returns the size (number of bytes) of the Extension Header including Next Header and Length fields. + * Returns the size (number of bytes) of the Extension Header including Next Header and Length fields. * * @returns The size (number of bytes) of the Extension Header. * @@ -440,7 +440,7 @@ class ExtensionHeader } OT_TOOL_PACKED_END; /** - * This class implements IPv6 Hop-by-Hop Options Header generation and parsing. + * Implements IPv6 Hop-by-Hop Options Header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -449,7 +449,7 @@ class HopByHopHeader : public ExtensionHeader } OT_TOOL_PACKED_END; /** - * This class implements IPv6 Options generation and parsing. + * Implements IPv6 Options generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -469,7 +469,7 @@ class Option }; /** - * This method returns the IPv6 Option Type value. + * Returns the IPv6 Option Type value. * * @returns The IPv6 Option Type value. * @@ -477,7 +477,7 @@ class Option uint8_t GetType(void) const { return mType; } /** - * This method indicates whether IPv6 Option is padding (either Pad1 or PadN). + * Indicates whether IPv6 Option is padding (either Pad1 or PadN). * * @retval TRUE The Option is padding. * @retval FALSE The Option is not padding. @@ -486,7 +486,7 @@ class Option bool IsPadding(void) const { return (mType == kTypePad1) || (mType == kTypePadN); } /** - * This method returns the IPv6 Option action for unrecognized IPv6 Options. + * Returns the IPv6 Option action for unrecognized IPv6 Options. * * @returns The IPv6 Option action for unrecognized IPv6 Options. * @@ -494,7 +494,7 @@ class Option Action GetAction(void) const { return static_cast(mType & kActionMask); } /** - * This method returns the IPv6 Option Length value. + * Returns the IPv6 Option Length value. * * @returns The IPv6 Option Length value. * @@ -502,9 +502,9 @@ class Option uint8_t GetLength(void) const { return mLength; } /** - * This method returns the size (number of bytes) of the IPv6 Option. + * Returns the size (number of bytes) of the IPv6 Option. * - * This method returns the proper size of the Option independent of its type, particularly if Option is Pad1 (which + * Returns the proper size of the Option independent of its type, particularly if Option is Pad1 (which * does not follow the common Option header structure and has only Type field with no Length field). For other * Option types, the returned size includes the Type and Length fields. * @@ -514,7 +514,7 @@ class Option uint16_t GetSize(void) const; /** - * This method parses and validates the IPv6 Option from a given message. + * Parses and validates the IPv6 Option from a given message. * * The Option is read from @p aOffset in @p aMessage. This method then checks that the entire Option is present * in @p aMessage before the @p aEndOffset. @@ -534,7 +534,7 @@ class Option static constexpr uint8_t kTypePadN = 0x01; ///< PanN Option Type. /** - * This method sets the IPv6 Option Type value. + * Sets the IPv6 Option Type value. * * @param[in] aType The IPv6 Option Type value. * @@ -542,7 +542,7 @@ class Option void SetType(uint8_t aType) { mType = aType; } /** - * This method sets the IPv6 Option Length value. + * Sets the IPv6 Option Length value. * * @param[in] aLength The IPv6 Option Length value. * @@ -557,7 +557,7 @@ class Option } OT_TOOL_PACKED_END; /** - * This class implements IPv6 Pad Options (Pad1 or PadN) generation. + * Implements IPv6 Pad Options (Pad1 or PadN) generation. * */ OT_TOOL_PACKED_BEGIN @@ -567,7 +567,7 @@ class PadOption : public Option, private Clearable public: /** - * This method initializes the Pad Option for a given total Pad size. + * Initializes the Pad Option for a given total Pad size. * * The @p aPadSize MUST be from range 1-7. Otherwise the behavior of this method is undefined. * @@ -577,7 +577,7 @@ class PadOption : public Option, private Clearable void InitForPadSize(uint8_t aPadSize); /** - * This method initializes the Pad Option for padding an IPv6 Extension header with a given current size. + * Initializes the Pad Option for padding an IPv6 Extension header with a given current size. * * The Extension Header Length is in 8-bytes unit, so the total size should be a multiple of 8. This method * determines the Pad Option size needed for appending to Extension Header based on it current size @p aHeaderSize @@ -599,7 +599,7 @@ class PadOption : public Option, private Clearable } OT_TOOL_PACKED_END; /** - * This class implements IPv6 Fragment Header generation and parsing. + * Implements IPv6 Fragment Header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -607,7 +607,7 @@ class FragmentHeader { public: /** - * This method initializes the IPv6 Fragment header. + * Initializes the IPv6 Fragment header. * */ void Init(void) @@ -618,7 +618,7 @@ class FragmentHeader } /** - * This method returns the IPv6 Next Header value. + * Returns the IPv6 Next Header value. * * @returns The IPv6 Next Header value. * @@ -626,7 +626,7 @@ class FragmentHeader uint8_t GetNextHeader(void) const { return mNextHeader; } /** - * This method sets the IPv6 Next Header value. + * Sets the IPv6 Next Header value. * * @param[in] aNextHeader The IPv6 Next Header value. * @@ -634,7 +634,7 @@ class FragmentHeader void SetNextHeader(uint8_t aNextHeader) { mNextHeader = aNextHeader; } /** - * This method returns the Fragment Offset value. + * Returns the Fragment Offset value. * * @returns The Fragment Offset value. * @@ -642,7 +642,7 @@ class FragmentHeader uint16_t GetOffset(void) const { return (HostSwap16(mOffsetMore) & kOffsetMask) >> kOffsetOffset; } /** - * This method sets the Fragment Offset value. + * Sets the Fragment Offset value. * * @param[in] aOffset The Fragment Offset value. */ @@ -654,7 +654,7 @@ class FragmentHeader } /** - * This method returns the M flag value. + * Returns the M flag value. * * @returns The M flag value. * @@ -662,19 +662,19 @@ class FragmentHeader bool IsMoreFlagSet(void) const { return HostSwap16(mOffsetMore) & kMoreFlag; } /** - * This method clears the M flag value. + * Clears the M flag value. * */ void ClearMoreFlag(void) { mOffsetMore = HostSwap16(HostSwap16(mOffsetMore) & ~kMoreFlag); } /** - * This method sets the M flag value. + * Sets the M flag value. * */ void SetMoreFlag(void) { mOffsetMore = HostSwap16(HostSwap16(mOffsetMore) | kMoreFlag); } /** - * This method returns the frame identification. + * Returns the frame identification. * * @returns The frame identification. * @@ -682,14 +682,14 @@ class FragmentHeader uint32_t GetIdentification(void) const { return mIdentification; } /** - * This method sets the frame identification. + * Sets the frame identification. * * @param[in] aIdentification The fragment identification value. */ void SetIdentification(uint32_t aIdentification) { mIdentification = aIdentification; } /** - * This method returns the next valid payload length for a fragment. + * Returns the next valid payload length for a fragment. * * @param[in] aLength The payload length to be validated for a fragment. * @@ -699,7 +699,7 @@ class FragmentHeader static inline uint16_t MakeDivisibleByEight(uint16_t aLength) { return aLength & 0xfff8; } /** - * This method converts the fragment offset of 8-octet units into bytes. + * Converts the fragment offset of 8-octet units into bytes. * * @param[in] aOffset The fragment offset in 8-octet units. * @@ -709,7 +709,7 @@ class FragmentHeader static inline uint16_t FragmentOffsetToBytes(uint16_t aOffset) { return static_cast(aOffset << 3); } /** - * This method converts a fragment offset in bytes into a fragment offset in 8-octet units. + * Converts a fragment offset in bytes into a fragment offset in 8-octet units. * * @param[in] aOffset The fragment offset in bytes. * diff --git a/src/core/net/ip6_mpl.hpp b/src/core/net/ip6_mpl.hpp index 60fd6686f31..65f5be40dba 100644 --- a/src/core/net/ip6_mpl.hpp +++ b/src/core/net/ip6_mpl.hpp @@ -57,7 +57,7 @@ namespace Ip6 { */ /** - * This class implements MPL header generation and parsing. + * Implements MPL header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -80,7 +80,7 @@ class MplOption : public Option }; /** - * This method initializes the MPL Option. + * Initializes the MPL Option. * * The @p aSeedIdLength MUST be either `kSeedIdLength0` or `kSeedIdLength2`. Other values are not supported. * @@ -90,7 +90,7 @@ class MplOption : public Option void Init(SeedIdLength aSeedIdLength); /** - * This method returns the MPL Seed Id Length value. + * Returns the MPL Seed Id Length value. * * @returns The MPL Seed Id Length value. * @@ -98,7 +98,7 @@ class MplOption : public Option SeedIdLength GetSeedIdLength(void) const { return static_cast(mControl & kSeedIdLengthMask); } /** - * This method indicates whether or not the MPL M flag is set. + * Indicates whether or not the MPL M flag is set. * * @retval TRUE If the MPL M flag is set. * @retval FALSE If the MPL M flag is not set. @@ -107,19 +107,19 @@ class MplOption : public Option bool IsMaxFlagSet(void) const { return (mControl & kMaxFlag) != 0; } /** - * This method clears the MPL M flag. + * Clears the MPL M flag. * */ void ClearMaxFlag(void) { mControl &= ~kMaxFlag; } /** - * This method sets the MPL M flag. + * Sets the MPL M flag. * */ void SetMaxFlag(void) { mControl |= kMaxFlag; } /** - * This method returns the MPL Sequence value. + * Returns the MPL Sequence value. * * @returns The MPL Sequence value. * @@ -127,7 +127,7 @@ class MplOption : public Option uint8_t GetSequence(void) const { return mSequence; } /** - * This method sets the MPL Sequence value. + * Sets the MPL Sequence value. * * @param[in] aSequence The MPL Sequence value. * @@ -135,7 +135,7 @@ class MplOption : public Option void SetSequence(uint8_t aSequence) { mSequence = aSequence; } /** - * This method returns the MPL Seed Id value. + * Returns the MPL Seed Id value. * * @returns The MPL Seed Id value. * @@ -143,7 +143,7 @@ class MplOption : public Option uint16_t GetSeedId(void) const { return HostSwap16(mSeedId); } /** - * This method sets the MPL Seed Id value. + * Sets the MPL Seed Id value. * * @param[in] aSeedId The MPL Seed Id value. * @@ -160,7 +160,7 @@ class MplOption : public Option } OT_TOOL_PACKED_END; /** - * This class implements MPL message processing. + * Implements MPL message processing. * */ class Mpl : public InstanceLocator, private NonCopyable @@ -169,7 +169,7 @@ class Mpl : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the MPL object. + * Initializes the MPL object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -177,7 +177,7 @@ class Mpl : public InstanceLocator, private NonCopyable explicit Mpl(Instance &aInstance); /** - * This method initializes the MPL option. + * Initializes the MPL option. * * @param[in] aOption A reference to the MPL header to initialize. * @param[in] aAddress A reference to the IPv6 Source Address. @@ -186,7 +186,7 @@ class Mpl : public InstanceLocator, private NonCopyable void InitOption(MplOption &aOption, const Address &aAddress); /** - * This method processes an MPL option. When the MPL module acts as an MPL Forwarder + * Processes an MPL option. When the MPL module acts as an MPL Forwarder * it disseminates MPL Data Message using Trickle timer expirations. When acts as an * MPL Seed it allows to send the first MPL Data Message directly, then sets up Trickle * timer expirations for subsequent retransmissions. @@ -206,7 +206,7 @@ class Mpl : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method returns a reference to the buffered message set. + * Returns a reference to the buffered message set. * * @returns A reference to the buffered message set. * diff --git a/src/core/net/ip6_types.hpp b/src/core/net/ip6_types.hpp index 8e1f9c34137..5d70e919215 100644 --- a/src/core/net/ip6_types.hpp +++ b/src/core/net/ip6_types.hpp @@ -99,7 +99,7 @@ enum IpDscpCs : uint8_t }; /** - * This enumeration represents the 2-bit Explicit Congestion Notification (ECN) values. + * Represents the 2-bit Explicit Congestion Notification (ECN) values. * */ enum Ecn : uint8_t diff --git a/src/core/net/nat64_translator.cpp b/src/core/net/nat64_translator.cpp index ee9cd2d70cd..bdee98ee614 100644 --- a/src/core/net/nat64_translator.cpp +++ b/src/core/net/nat64_translator.cpp @@ -36,6 +36,8 @@ #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE +#include + #include "common/code_utils.hpp" #include "common/locator_getters.hpp" #include "common/log.hpp" @@ -70,7 +72,7 @@ Translator::Translator(Instance &aInstance) , mState(State::kStateDisabled) , mMappingExpirerTimer(aInstance) { - Random::NonCrypto::FillBuffer(reinterpret_cast(&mNextMappingId), sizeof(mNextMappingId)); + Random::NonCrypto::Fill(mNextMappingId); mNat64Prefix.Clear(); mIp4Cidr.Clear(); @@ -507,7 +509,8 @@ Error Translator::SetIp4Cidr(const Ip4::Cidr &aCidr) numberOfHosts); mIp4Cidr = aCidr; - UpdateState(); + // Always notify the platform when the CIDR is changed. + UpdateState(true /* aAlwaysNotify */); exit: return err; @@ -631,7 +634,7 @@ void Translator::ProtocolCounters::Count4To6Packet(uint8_t aProtocol, uint64_t a mTotal.m4To6Bytes += aPacketSize; } -void Translator::UpdateState(void) +void Translator::UpdateState(bool aAlwaysNotify) { State newState; @@ -651,7 +654,14 @@ void Translator::UpdateState(void) newState = kStateDisabled; } - SuccessOrExit(Get().Update(mState, newState, kEventNat64TranslatorStateChanged)); + if (aAlwaysNotify) + { + Get().Signal(kEventNat64TranslatorStateChanged); + } + else + { + SuccessOrExit(Get().Update(mState, newState, kEventNat64TranslatorStateChanged)); + } LogInfo("NAT64 translator is now %s", StateToString(mState)); exit: diff --git a/src/core/net/nat64_translator.hpp b/src/core/net/nat64_translator.hpp index 1ec16a4a6a4..bd29ff690e7 100644 --- a/src/core/net/nat64_translator.hpp +++ b/src/core/net/nat64_translator.hpp @@ -57,7 +57,7 @@ enum State : uint8_t }; /** - * This function converts a `State` into a string. + * Converts a `State` into a string. * * @param[in] aState A state. * @@ -69,7 +69,7 @@ const char *StateToString(State aState); #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE /** - * This class implements the NAT64 translator. + * Implements the NAT64 translator. * */ class Translator : public InstanceLocator, private NonCopyable @@ -153,7 +153,7 @@ class Translator : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the NAT64 translator. + * Initializes the NAT64 translator. * */ explicit Translator(Instance &aInstance); @@ -179,7 +179,7 @@ class Translator : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method translates an IPv4 datagram to an IPv6 datagram and sends it via Thread interface. + * Translates an IPv4 datagram to an IPv6 datagram and sends it via 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 `kErrorNone` is returned. @@ -253,7 +253,7 @@ class Translator : public InstanceLocator, private NonCopyable /** * Sets the prefix of NAT64-mapped addresses in the thread network. The address mapping table will not be cleared. - * This function equals to `ClearNat64Prefix` when an empty prefix is provided. + * Equals to `ClearNat64Prefix` when an empty prefix is provided. * * @param[in] aNat64Prefix The prefix of the NAT64-mapped addresses. * @@ -380,7 +380,7 @@ class Translator : public InstanceLocator, private NonCopyable using MappingTimer = TimerMilliIn; - void UpdateState(void); + void UpdateState(bool aAlwaysNotify = false); bool mEnabled; State mState; diff --git a/src/core/net/nd6.hpp b/src/core/net/nd6.hpp index 8a084a917b5..9cf5c08039e 100644 --- a/src/core/net/nd6.hpp +++ b/src/core/net/nd6.hpp @@ -61,7 +61,7 @@ namespace Nd { typedef NetworkData::RoutePreference RoutePreference; ///< Route Preference /** - * This class represents the variable length options in Neighbor Discovery messages. + * Represents the variable length options in Neighbor Discovery messages. * * @sa PrefixInfoOption * @sa RouteInfoOption @@ -82,7 +82,7 @@ class Option static constexpr uint16_t kLengthUnit = 8; ///< The unit of length in octets. /** - * This method gets the option type. + * Gets the option type. * * @returns The option type. * @@ -90,7 +90,7 @@ class Option uint8_t GetType(void) const { return mType; } /** - * This method sets the option type. + * Sets the option type. * * @param[in] aType The option type. * @@ -99,7 +99,7 @@ class Option void SetType(Type aType) { mType = aType; } /** - * This method sets the length based on a given total option size in bytes. + * Sets the length based on a given total option size in bytes. * * Th option must end on a 64-bit boundary, so the length is derived as `(aSize + 7) / 8 * 8`. * @@ -109,7 +109,7 @@ class Option void SetSize(uint16_t aSize) { mLength = static_cast((aSize + kLengthUnit - 1) / kLengthUnit); } /** - * This method returns the size of the option in bytes. + * Returns the size of the option in bytes. * * @returns The size of the option in bytes. * @@ -117,7 +117,7 @@ class Option uint16_t GetSize(void) const { return mLength * kLengthUnit; } /** - * This method sets the length of the option (in unit of 8 bytes). + * Sets the length of the option (in unit of 8 bytes). * * @param[in] aLength The length of the option in unit of 8 bytes. * @@ -125,7 +125,7 @@ class Option void SetLength(uint8_t aLength) { mLength = aLength; } /** - * This method returns the length of the option (in unit of 8 bytes). + * Returns the length of the option (in unit of 8 bytes). * * @returns The length of the option in unit of 8 bytes. * @@ -133,7 +133,7 @@ class Option uint16_t GetLength(void) const { return mLength; } /** - * This method indicates whether or not this option is valid. + * Indicates whether or not this option is valid. * * @retval TRUE The option is valid. * @retval FALSE The option is not valid. @@ -167,7 +167,7 @@ class Option } OT_TOOL_PACKED_END; /** - * This class represents the Prefix Information Option. + * Represents the Prefix Information Option. * * See section 4.6.2 of RFC 4861 for definition of this option [https://tools.ietf.org/html/rfc4861#section-4.6.2] * @@ -181,13 +181,13 @@ class PrefixInfoOption : public Option, private Clearable static constexpr Type kType = kTypePrefixInfo; ///< Prefix Information Option Type. /** - * This method initializes the Prefix Info option with proper type and length and sets all other fields to zero. + * Initializes the Prefix Info option with proper type and length and sets all other fields to zero. * */ void Init(void); /** - * This method indicates whether or not the on-link flag is set. + * Indicates whether or not the on-link flag is set. * * @retval TRUE The on-link flag is set. * @retval FALSE The on-link flag is not set. @@ -196,19 +196,19 @@ class PrefixInfoOption : public Option, private Clearable bool IsOnLinkFlagSet(void) const { return (mFlags & kOnLinkFlagMask) != 0; } /** - * This method sets the on-link (L) flag. + * Sets the on-link (L) flag. * */ void SetOnLinkFlag(void) { mFlags |= kOnLinkFlagMask; } /** - * This method clears the on-link (L) flag. + * Clears the on-link (L) flag. * */ void ClearOnLinkFlag(void) { mFlags &= ~kOnLinkFlagMask; } /** - * This method indicates whether or not the autonomous address-configuration (A) flag is set. + * Indicates whether or not the autonomous address-configuration (A) flag is set. * * @retval TRUE The auto address-config flag is set. * @retval FALSE The auto address-config flag is not set. @@ -217,19 +217,19 @@ class PrefixInfoOption : public Option, private Clearable bool IsAutoAddrConfigFlagSet(void) const { return (mFlags & kAutoConfigFlagMask) != 0; } /** - * This method sets the autonomous address-configuration (A) flag. + * Sets the autonomous address-configuration (A) flag. * */ void SetAutoAddrConfigFlag(void) { mFlags |= kAutoConfigFlagMask; } /** - * This method clears the autonomous address-configuration (A) flag. + * Clears the autonomous address-configuration (A) flag. * */ void ClearAutoAddrConfigFlag(void) { mFlags &= ~kAutoConfigFlagMask; } /** - * This method sets the valid lifetime of the prefix in seconds. + * Sets the valid lifetime of the prefix in seconds. * * @param[in] aValidLifetime The valid lifetime in seconds. * @@ -245,7 +245,7 @@ class PrefixInfoOption : public Option, private Clearable uint32_t GetValidLifetime(void) const { return HostSwap32(mValidLifetime); } /** - * This method sets the preferred lifetime of the prefix in seconds. + * Sets the preferred lifetime of the prefix in seconds. * * @param[in] aPreferredLifetime The preferred lifetime in seconds. * @@ -261,7 +261,7 @@ class PrefixInfoOption : public Option, private Clearable uint32_t GetPreferredLifetime(void) const { return HostSwap32(mPreferredLifetime); } /** - * This method sets the prefix. + * Sets the prefix. * * @param[in] aPrefix The prefix contained in this option. * @@ -269,7 +269,7 @@ class PrefixInfoOption : public Option, private Clearable void SetPrefix(const Prefix &aPrefix); /** - * This method gets the prefix in this option. + * Gets the prefix in this option. * * @param[out] aPrefix Reference to a `Prefix` to return the prefix. * @@ -277,7 +277,7 @@ class PrefixInfoOption : public Option, private Clearable void GetPrefix(Prefix &aPrefix) const; /** - * This method indicates whether or not the option is valid. + * Indicates whether or not the option is valid. * * @retval TRUE The option is valid * @retval FALSE The option is not valid. @@ -324,7 +324,7 @@ class PrefixInfoOption : public Option, private Clearable static_assert(sizeof(PrefixInfoOption) == 32, "invalid PrefixInfoOption structure"); /** - * This class represents the Route Information Option. + * Represents the Route Information Option. * * See section 2.3 of RFC 4191 for definition of this option. [https://tools.ietf.org/html/rfc4191#section-2.3] * @@ -339,13 +339,13 @@ class RouteInfoOption : public Option, private Clearable static constexpr Type kType = kTypeRouteInfo; ///< Route Information Option Type. /** - * This method initializes the option setting the type and clearing (setting to zero) all other fields. + * Initializes the option setting the type and clearing (setting to zero) all other fields. * */ void Init(void); /** - * This method sets the route preference. + * Sets the route preference. * * @param[in] aPreference The route preference. * @@ -353,7 +353,7 @@ class RouteInfoOption : public Option, private Clearable void SetPreference(RoutePreference aPreference); /** - * This method gets the route preference. + * Gets the route preference. * * @returns The route preference. * @@ -361,7 +361,7 @@ class RouteInfoOption : public Option, private Clearable RoutePreference GetPreference(void) const; /** - * This method sets the lifetime of the route in seconds. + * Sets the lifetime of the route in seconds. * * @param[in] aLifetime The lifetime of the route in seconds. * @@ -369,7 +369,7 @@ class RouteInfoOption : public Option, private Clearable void SetRouteLifetime(uint32_t aLifetime) { mRouteLifetime = HostSwap32(aLifetime); } /** - * This method gets Route Lifetime in seconds. + * Gets Route Lifetime in seconds. * * @returns The Route Lifetime in seconds. * @@ -377,7 +377,7 @@ class RouteInfoOption : public Option, private Clearable uint32_t GetRouteLifetime(void) const { return HostSwap32(mRouteLifetime); } /** - * This method sets the prefix and adjusts the option length based on the prefix length. + * Sets the prefix and adjusts the option length based on the prefix length. * * @param[in] aPrefix The prefix contained in this option. * @@ -385,7 +385,7 @@ class RouteInfoOption : public Option, private Clearable void SetPrefix(const Prefix &aPrefix); /** - * This method gets the prefix in this option. + * Gets the prefix in this option. * * @param[out] aPrefix Reference to a `Prefix` to return the prefix. * @@ -393,7 +393,7 @@ class RouteInfoOption : public Option, private Clearable void GetPrefix(Prefix &aPrefix) const; /** - * This method tells whether this option is valid. + * Tells whether this option is valid. * * @returns A boolean indicates whether this option is valid. * @@ -401,7 +401,7 @@ class RouteInfoOption : public Option, private Clearable bool IsValid(void) const; /** - * This static method calculates the minimum option length for a given prefix length. + * Calculates the minimum option length for a given prefix length. * * The option length (which is in unit of 8 octets) can be 1, 2, or 3 depending on the prefix length. It can be 1 * for a zero prefix length, 2 if the prefix length is not greater than 64, and 3 otherwise. @@ -414,7 +414,7 @@ class RouteInfoOption : public Option, private Clearable static uint8_t OptionLengthForPrefix(uint8_t aPrefixLength); /** - * This static method calculates the minimum option size (in bytes) for a given prefix length. + * Calculates the minimum option size (in bytes) for a given prefix length. * * @param[in] aPrefixLength The prefix length (in bits). * @@ -459,14 +459,14 @@ class RouteInfoOption : public Option, private Clearable static_assert(sizeof(RouteInfoOption) == 8, "invalid RouteInfoOption structure"); /** - * This class represents a Router Advertisement message. + * Represents a Router Advertisement message. * */ class RouterAdvertMessage { public: /** - * This class implements the RA message header. + * Implements the RA message header. * * See section 2.2 of RFC 4191 [https://datatracker.ietf.org/doc/html/rfc4191] * @@ -478,20 +478,20 @@ class RouterAdvertMessage public: /** - * This constructor initializes the Router Advertisement message with + * Initializes the Router Advertisement message with * zero router lifetime, reachable time and retransmission timer. * */ Header(void) { SetToDefault(); } /** - * This method sets the RA message to default values. + * Sets the RA message to default values. * */ void SetToDefault(void); /** - * This method sets the checksum value. + * Sets the checksum value. * * @param[in] aChecksum The checksum value. * @@ -499,7 +499,7 @@ class RouterAdvertMessage void SetChecksum(uint16_t aChecksum) { mChecksum = HostSwap16(aChecksum); } /** - * This method sets the Router Lifetime in seconds. + * Sets the Router Lifetime in seconds. * * @param[in] aRouterLifetime The router lifetime in seconds. * @@ -507,7 +507,7 @@ class RouterAdvertMessage void SetRouterLifetime(uint16_t aRouterLifetime) { mRouterLifetime = HostSwap16(aRouterLifetime); } /** - * This method gets the Router Lifetime (in seconds). + * Gets the Router Lifetime (in seconds). * * Router Lifetime set to zero indicates that the sender is not a default router. * @@ -517,7 +517,7 @@ class RouterAdvertMessage uint16_t GetRouterLifetime(void) const { return HostSwap16(mRouterLifetime); } /** - * This method sets the default router preference. + * Sets the default router preference. * * @param[in] aPreference The router preference. * @@ -525,13 +525,21 @@ class RouterAdvertMessage void SetDefaultRouterPreference(RoutePreference aPreference); /** - * This method gets the default router preference. + * Gets the default router preference. * * @returns The router preference. * */ RoutePreference GetDefaultRouterPreference(void) const; + /** + * This method returns the ICMPv6 message type. + * + * @returns The ICMPv6 message type. + * + */ + Icmp::Header::Type GetType(void) const { return static_cast(mType); } + private: // Router Advertisement Message // @@ -567,7 +575,7 @@ class RouterAdvertMessage typedef Data Icmp6Packet; ///< A data buffer containing an ICMPv6 packet. /** - * This constructor initializes the RA message from a received packet data buffer. + * Initializes the RA message from a received packet data buffer. * * @param[in] aPacket A received packet data. * @@ -599,7 +607,7 @@ class RouterAdvertMessage } /** - * This method gets the RA message as an `Icmp6Packet`. + * Gets the RA message as an `Icmp6Packet`. * * @returns The RA message as an `Icmp6Packet`. * @@ -607,16 +615,20 @@ class RouterAdvertMessage const Icmp6Packet &GetAsPacket(void) const { return mData; } /** - * This method indicates whether or not the RA message is valid. + * Indicates whether or not the RA message is valid. * * @retval TRUE If the RA message is valid. * @retval FALSE If the RA message is not valid. * */ - bool IsValid(void) const { return (mData.GetBytes() != nullptr) && (mData.GetLength() >= sizeof(Header)); } + bool IsValid(void) const + { + return (mData.GetBytes() != nullptr) && (mData.GetLength() >= sizeof(Header)) && + (GetHeader().GetType() == Icmp::Header::kTypeRouterAdvert); + } /** - * This method gets the RA message's header. + * Gets the RA message's header. * * @returns The RA message's header. * @@ -624,7 +636,7 @@ class RouterAdvertMessage const Header &GetHeader(void) const { return *reinterpret_cast(mData.GetBytes()); } /** - * This method appends a Prefix Info Option to the RA message. + * Appends a Prefix Info Option to the RA message. * * The appended Prefix Info Option will have both on-link (L) and autonomous address-configuration (A) flags set. * @@ -639,7 +651,7 @@ class RouterAdvertMessage Error AppendPrefixInfoOption(const Prefix &aPrefix, uint32_t aValidLifetime, uint32_t aPreferredLifetime); /** - * This method appends a Route Info Option to the RA message. + * Appends a Route Info Option to the RA message. * * @param[in] aPrefix The prefix. * @param[in] aRouteLifetime The route lifetime in seconds. @@ -652,7 +664,7 @@ class RouterAdvertMessage Error AppendRouteInfoOption(const Prefix &aPrefix, uint32_t aRouteLifetime, RoutePreference aPreference); /** - * This method indicates whether or not the RA message contains any options. + * Indicates whether or not the RA message contains any options. * * @retval TRUE If the RA message contains at least one option. * @retval FALSE If the RA message contains no options. @@ -676,7 +688,7 @@ class RouterAdvertMessage }; /** - * This class implements the Router Solicitation message. + * Implements the Router Solicitation message. * * See section 4.1 of RFC 4861 for definition of this message. * https://tools.ietf.org/html/rfc4861#section-4.1 @@ -687,7 +699,7 @@ class RouterSolicitMessage { public: /** - * This constructor initializes the Router Solicitation message. + * Initializes the Router Solicitation message. * */ RouterSolicitMessage(void); @@ -699,7 +711,7 @@ class RouterSolicitMessage static_assert(sizeof(RouterSolicitMessage) == 8, "invalid RouterSolicitMessage structure"); /** - * This class represents a Neighbor Solicitation (NS) message. + * Represents a Neighbor Solicitation (NS) message. * */ OT_TOOL_PACKED_BEGIN @@ -707,13 +719,13 @@ class NeighborSolicitMessage : public Clearable { public: /** - * This constructor initializes the Neighbor Solicitation message. + * Initializes the Neighbor Solicitation message. * */ NeighborSolicitMessage(void); /** - * This method indicates whether the Neighbor Solicitation message is valid (proper Type and Code). + * Indicates whether the Neighbor Solicitation message is valid (proper Type and Code). * * @retval TRUE If the message is valid. * @retval FALSE If the message is not valid. @@ -722,7 +734,7 @@ class NeighborSolicitMessage : public Clearable bool IsValid(void) const { return (mType == Icmp::Header::kTypeNeighborSolicit) && (mCode == 0); } /** - * This method gets the Target Address field. + * Gets the Target Address field. * * @returns The Target Address. * @@ -730,7 +742,7 @@ class NeighborSolicitMessage : public Clearable const Address &GetTargetAddress(void) const { return mTargetAddress; } /** - * This method sets the Target Address field. + * Sets the Target Address field. * * @param[in] aTargetAddress The Target Address. * @@ -768,7 +780,7 @@ class NeighborSolicitMessage : public Clearable static_assert(sizeof(NeighborSolicitMessage) == 24, "Invalid NeighborSolicitMessage definition"); /** - * This class represents a Neighbor Advertisement (NA) message. + * Represents a Neighbor Advertisement (NA) message. * */ OT_TOOL_PACKED_BEGIN @@ -778,7 +790,7 @@ class NeighborAdvertMessage : public Clearable NeighborAdvertMessage(void); /** - * This method indicates whether the Neighbor Advertisement message is valid (proper Type and Code). + * Indicates whether the Neighbor Advertisement message is valid (proper Type and Code). * * @retval TRUE If the message is valid. * @retval FALSE If the message is not valid. @@ -787,7 +799,7 @@ class NeighborAdvertMessage : public Clearable bool IsValid(void) const { return (mType == Icmp::Header::kTypeNeighborAdvert) && (mCode == 0); } /** - * This method indicates whether or not the Router Flag is set in the NA message. + * Indicates whether or not the Router Flag is set in the NA message. * * @retval TRUE The Router Flag is set. * @retval FALSE The Router Flag is not set. @@ -796,13 +808,13 @@ class NeighborAdvertMessage : public Clearable bool IsRouterFlagSet(void) const { return (mFlags & kRouterFlag) != 0; } /** - * This method sets the Router Flag in the NA message. + * Sets the Router Flag in the NA message. * */ void SetRouterFlag(void) { mFlags |= kRouterFlag; } /** - * This method indicates whether or not the Solicited Flag is set in the NA message. + * Indicates whether or not the Solicited Flag is set in the NA message. * * @retval TRUE The Solicited Flag is set. * @retval FALSE The Solicited Flag is not set. @@ -811,13 +823,13 @@ class NeighborAdvertMessage : public Clearable bool IsSolicitedFlagSet(void) const { return (mFlags & kSolicitedFlag) != 0; } /** - * This method sets the Solicited Flag in the NA message. + * Sets the Solicited Flag in the NA message. * */ void SetSolicitedFlag(void) { mFlags |= kSolicitedFlag; } /** - * This method indicates whether or not the Override Flag is set in the NA message. + * Indicates whether or not the Override Flag is set in the NA message. * * @retval TRUE The Override Flag is set. * @retval FALSE The Override Flag is not set. @@ -826,13 +838,13 @@ class NeighborAdvertMessage : public Clearable bool IsOverrideFlagSet(void) const { return (mFlags & kOverrideFlag) != 0; } /** - * This method sets the Override Flag in the NA message. + * Sets the Override Flag in the NA message. * */ void SetOverrideFlag(void) { mFlags |= kOverrideFlag; } /** - * This method gets the Target Address field. + * Gets the Target Address field. * * @returns The Target Address. * @@ -840,7 +852,7 @@ class NeighborAdvertMessage : public Clearable const Address &GetTargetAddress(void) const { return mTargetAddress; } /** - * This method sets the Target Address field. + * Sets the Target Address field. * * @param[in] aTargetAddress The Target Address. * diff --git a/src/core/net/nd_agent.hpp b/src/core/net/nd_agent.hpp index ae04c9714a1..62125b6787f 100644 --- a/src/core/net/nd_agent.hpp +++ b/src/core/net/nd_agent.hpp @@ -49,7 +49,7 @@ class Agent : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -61,13 +61,13 @@ class Agent : public InstanceLocator, private NonCopyable } /** - * This method updates the Neighbor Discovery Agents using current Thread Network Data. + * Updates the Neighbor Discovery Agents using current Thread Network Data. * */ void UpdateService(void); /** - * This method updates the prefix of the Neighbor Discovery Agent Anycast Locator. + * Updates the prefix of the Neighbor Discovery Agent Anycast Locator. * */ void ApplyMeshLocalPrefix(void); diff --git a/src/core/net/netif.cpp b/src/core/net/netif.cpp index 009feaa9a39..b8a99a15309 100644 --- a/src/core/net/netif.cpp +++ b/src/core/net/netif.cpp @@ -43,30 +43,6 @@ namespace ot { namespace Ip6 { -class AddressInfo : public otIp6AddressInfo -{ -public: - explicit AddressInfo(const Netif::UnicastAddress &aAddress) - { - mAddress = &aAddress.mAddress; - mPrefixLength = aAddress.mPrefixLength; - mScope = aAddress.GetScope(); - mPreferred = aAddress.mPreferred; - } - - explicit AddressInfo(const Netif::MulticastAddress &aAddress) - { - mAddress = &aAddress.GetAddress(); - mPrefixLength = kMulticastPrefixLength; - mScope = aAddress.GetAddress().GetScope(); - mPreferred = false; - } - -private: - static constexpr uint8_t kMulticastPrefixLength = - 128; ///< Multicast prefix length used to notify internal address changes. -}; - /* * Certain fixed multicast addresses are defined as a set of chained (linked-list) constant `otNetifMulticastAddress` * entries: @@ -141,7 +117,7 @@ void Netif::SubscribeAllNodesMulticast(void) tail->SetNext(&linkLocalAllNodesAddress); } - SignalMulticastAddressChange(kAddressAdded, &linkLocalAllNodesAddress, nullptr); + SignalMulticastAddressesChange(kAddressAdded, &linkLocalAllNodesAddress, nullptr); exit: return; @@ -179,7 +155,7 @@ void Netif::UnsubscribeAllNodesMulticast(void) prev->SetNext(nullptr); } - SignalMulticastAddressChange(kAddressRemoved, &linkLocalAllNodesAddress, nullptr); + SignalMulticastAddressesChange(kAddressRemoved, &linkLocalAllNodesAddress, nullptr); exit: return; @@ -222,7 +198,7 @@ void Netif::SubscribeAllRoutersMulticast(void) prev->SetNext(&linkLocalAllRoutersAddress); } - SignalMulticastAddressChange(kAddressAdded, &linkLocalAllRoutersAddress, &linkLocalAllNodesAddress); + SignalMulticastAddressesChange(kAddressAdded, &linkLocalAllRoutersAddress, &linkLocalAllNodesAddress); exit: return; @@ -255,45 +231,44 @@ void Netif::UnsubscribeAllRoutersMulticast(void) prev->SetNext(&linkLocalAllNodesAddress); } - SignalMulticastAddressChange(kAddressRemoved, &linkLocalAllRoutersAddress, &linkLocalAllNodesAddress); + SignalMulticastAddressesChange(kAddressRemoved, &linkLocalAllRoutersAddress, &linkLocalAllNodesAddress); exit: return; } -void Netif::SignalMulticastAddressChange(AddressEvent aAddressEvent, - const MulticastAddress *aStart, - const MulticastAddress *aEnd) +void Netif::SignalMulticastAddressChange(AddressEvent aEvent, const MulticastAddress &aAddress, AddressOrigin aOrigin) { - // Signal changes to fixed multicast addresses from `aStart` up to - // (not including) `aEnd`. `aAddressEvent` indicates whether - // addresses were subscribed or unsubscribed. - - Get().Signal(aAddressEvent == kAddressAdded ? kEventIp6MulticastSubscribed - : kEventIp6MulticastUnsubscribed); + Get().Signal(aEvent == kAddressAdded ? kEventIp6MulticastSubscribed : kEventIp6MulticastUnsubscribed); -#if !OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - VerifyOrExit(mAddressCallback.IsSet()); +#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE + Get().RecordAddressEvent(aEvent, aAddress, aOrigin); #endif - for (const MulticastAddress *entry = aStart; entry != aEnd; entry = entry->GetNext()) + if ((aOrigin == kOriginThread) && mAddressCallback.IsSet()) { -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(aAddressEvent, *entry, kOriginThread); + AddressInfo info; - if (mAddressCallback.IsSet()) -#endif - { - AddressInfo addressInfo(*entry); + info.mAddress = &aAddress.GetAddress(); + info.mPrefixLength = kMulticastPrefixLength; + info.mScope = aAddress.GetAddress().GetScope(); + info.mPreferred = false; - mAddressCallback.Invoke(&addressInfo, aAddressEvent); - } + mAddressCallback.Invoke(&info, aEvent); } +} - ExitNow(); +void Netif::SignalMulticastAddressesChange(AddressEvent aEvent, + const MulticastAddress *aStart, + const MulticastAddress *aEnd) +{ + // Signal changes to fixed multicast addresses from `aStart` up to + // (not including) `aEnd`. -exit: - return; + for (const MulticastAddress *entry = aStart; entry != aEnd; entry = entry->GetNext()) + { + SignalMulticastAddressChange(aEvent, *entry, kOriginThread); + } } bool Netif::IsMulticastAddressExternal(const MulticastAddress &aAddress) const @@ -304,19 +279,7 @@ bool Netif::IsMulticastAddressExternal(const MulticastAddress &aAddress) const void Netif::SubscribeMulticast(MulticastAddress &aAddress) { SuccessOrExit(mMulticastAddresses.Add(aAddress)); - - Get().Signal(kEventIp6MulticastSubscribed); - -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressAdded, aAddress, kOriginThread); -#endif - - if (mAddressCallback.IsSet()) - { - AddressInfo addressInfo(aAddress); - - mAddressCallback.Invoke(&addressInfo, kAddressAdded); - } + SignalMulticastAddressChange(kAddressAdded, aAddress, kOriginThread); exit: return; @@ -325,19 +288,7 @@ void Netif::SubscribeMulticast(MulticastAddress &aAddress) void Netif::UnsubscribeMulticast(const MulticastAddress &aAddress) { SuccessOrExit(mMulticastAddresses.Remove(aAddress)); - - Get().Signal(kEventIp6MulticastUnsubscribed); - -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressRemoved, aAddress, kOriginThread); -#endif - - if (mAddressCallback.IsSet()) - { - AddressInfo addressInfo(aAddress); - - mAddressCallback.Invoke(&addressInfo, kAddressRemoved); - } + SignalMulticastAddressChange(kAddressRemoved, aAddress, kOriginThread); exit: return; @@ -370,11 +321,7 @@ Error Netif::SubscribeExternalMulticast(const Address &aAddress) #endif mMulticastAddresses.Push(*entry); -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressAdded, *entry, kOriginManual); -#endif - - Get().Signal(kEventIp6MulticastSubscribed); + SignalMulticastAddressChange(kAddressAdded, *entry, kOriginManual); exit: return error; @@ -393,14 +340,10 @@ Error Netif::UnsubscribeExternalMulticast(const Address &aAddress) mMulticastAddresses.PopAfter(prev); -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressRemoved, *entry, kOriginManual); -#endif + SignalMulticastAddressChange(kAddressRemoved, *entry, kOriginManual); mExtMulticastAddressPool.Free(static_cast(*entry)); - Get().Signal(kEventIp6MulticastUnsubscribed); - exit: return error; } @@ -423,19 +366,7 @@ void Netif::UnsubscribeAllExternalMulticastAddresses(void) void Netif::AddUnicastAddress(UnicastAddress &aAddress) { SuccessOrExit(mUnicastAddresses.Add(aAddress)); - - Get().Signal(aAddress.mRloc ? kEventThreadRlocAdded : kEventIp6AddressAdded); - -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressAdded, aAddress); -#endif - - if (mAddressCallback.IsSet()) - { - AddressInfo addressInfo(aAddress); - - mAddressCallback.Invoke(&addressInfo, kAddressAdded); - } + SignalUnicastAddressChange(kAddressAdded, aAddress); exit: return; @@ -444,22 +375,42 @@ void Netif::AddUnicastAddress(UnicastAddress &aAddress) void Netif::RemoveUnicastAddress(const UnicastAddress &aAddress) { SuccessOrExit(mUnicastAddresses.Remove(aAddress)); + SignalUnicastAddressChange(kAddressRemoved, aAddress); + +exit: + return; +} + +void Netif::SignalUnicastAddressChange(AddressEvent aEvent, const UnicastAddress &aAddress) +{ + Event event; + + if (aAddress.mRloc) + { + event = (aEvent == kAddressAdded) ? kEventThreadRlocAdded : kEventThreadRlocRemoved; + } + else + { + event = (aEvent == kAddressAdded) ? kEventIp6AddressAdded : kEventIp6AddressRemoved; + } - Get().Signal(aAddress.mRloc ? kEventThreadRlocRemoved : kEventIp6AddressRemoved); + Get().Signal(event); #if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressRemoved, aAddress); + Get().RecordAddressEvent(aEvent, aAddress); #endif - if (mAddressCallback.IsSet()) + if (!IsUnicastAddressExternal(aAddress) && mAddressCallback.IsSet()) { - AddressInfo addressInfo(aAddress); + AddressInfo info; - mAddressCallback.Invoke(&addressInfo, kAddressRemoved); - } + info.mAddress = &aAddress.mAddress; + info.mPrefixLength = aAddress.mPrefixLength; + info.mScope = aAddress.GetScope(); + info.mPreferred = aAddress.mPreferred; -exit: - return; + mAddressCallback.Invoke(&info, aEvent); + } } Error Netif::AddExternalUnicastAddress(const UnicastAddress &aAddress) @@ -487,14 +438,10 @@ Error Netif::AddExternalUnicastAddress(const UnicastAddress &aAddress) entry = mExtUnicastAddressPool.Allocate(); VerifyOrExit(entry != nullptr, error = kErrorNoBufs); - *entry = aAddress; + *entry = aAddress; + entry->mRloc = false; mUnicastAddresses.Push(*entry); - -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressAdded, *entry); -#endif - - Get().Signal(kEventIp6AddressAdded); + SignalUnicastAddressChange(kAddressAdded, *entry); exit: return error; @@ -513,12 +460,9 @@ Error Netif::RemoveExternalUnicastAddress(const Address &aAddress) mUnicastAddresses.PopAfter(prev); -#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE - Get().RecordAddressEvent(kAddressRemoved, *entry); -#endif + SignalUnicastAddressChange(kAddressRemoved, *entry); mExtUnicastAddressPool.Free(*entry); - Get().Signal(kEventIp6AddressRemoved); exit: return error; diff --git a/src/core/net/netif.hpp b/src/core/net/netif.hpp index 29f3b61240b..be186b54351 100644 --- a/src/core/net/netif.hpp +++ b/src/core/net/netif.hpp @@ -68,7 +68,7 @@ class Ip6; */ /** - * This class implements an IPv6 network interface. + * Implements an IPv6 network interface. * */ class Netif : public InstanceLocator, private NonCopyable @@ -78,7 +78,7 @@ class Netif : public InstanceLocator, private NonCopyable public: /** - * This enumeration represent an address event (added or removed) + * Represent an address event (added or removed) * * The boolean values are used for `aIsAdded` parameter in the call of `otIp6AddressCallback`. * @@ -90,7 +90,7 @@ class Netif : public InstanceLocator, private NonCopyable }; /** - * This enumeration represents the address origin. + * Represents the address origin. * */ enum AddressOrigin : uint8_t @@ -102,7 +102,7 @@ class Netif : public InstanceLocator, private NonCopyable }; /** - * This class implements an IPv6 network interface unicast address. + * Implements an IPv6 network interface unicast address. * */ class UnicastAddress : public otNetifAddress, @@ -113,7 +113,7 @@ class Netif : public InstanceLocator, private NonCopyable public: /** - * This method clears and initializes the unicast address as a preferred, valid, thread-origin address with + * Clears and initializes the unicast address as a preferred, valid, thread-origin address with * 64-bit prefix length. * * @param[in] aPreferred Whether to initialize as a preferred address. @@ -122,21 +122,21 @@ class Netif : public InstanceLocator, private NonCopyable void InitAsThreadOrigin(bool aPreferred = false); /** - * This method clears and initializes the unicast address as a valid (but not preferred), thread-origin, + * Clears and initializes the unicast address as a valid (but not preferred), thread-origin, * realm-local scope (overridden) address with 64-bit prefix length. * */ void InitAsThreadOriginRealmLocalScope(void); /** - * This method clears and initializes the unicast address as a valid (but not preferred), thread-origin, global + * Clears and initializes the unicast address as a valid (but not preferred), thread-origin, global * scope address. * */ void InitAsThreadOriginGlobalScope(void); /** - * This method clears and initializes the unicast address as a valid, SLAAC-origin address with a given + * Clears and initializes the unicast address as a valid, SLAAC-origin address with a given * preferred flag and a given prefix length. * * @param[in] aPrefixLength The prefix length (in bits). @@ -146,7 +146,7 @@ class Netif : public InstanceLocator, private NonCopyable void InitAsSlaacOrigin(uint8_t aPrefixLength, bool aPreferred); /** - * This method returns the unicast address. + * Returns the unicast address. * * @returns The unicast address. * @@ -154,7 +154,7 @@ class Netif : public InstanceLocator, private NonCopyable const Address &GetAddress(void) const { return AsCoreType(&mAddress); } /** - * This method returns the unicast address. + * Returns the unicast address. * * @returns The unicast address. * @@ -162,7 +162,7 @@ class Netif : public InstanceLocator, private NonCopyable Address &GetAddress(void) { return AsCoreType(&mAddress); } /** - * This method returns the address's prefix length (in bits). + * Returns the address's prefix length (in bits). * * @returns The prefix length (in bits). * @@ -170,7 +170,7 @@ class Netif : public InstanceLocator, private NonCopyable uint8_t GetPrefixLength(void) const { return mPrefixLength; } /** - * This method indicates whether the address has a given prefix (i.e. same prefix length and matches the + * Indicates whether the address has a given prefix (i.e. same prefix length and matches the * prefix). * * @param[in] aPrefix A prefix to check against. @@ -185,7 +185,7 @@ class Netif : public InstanceLocator, private NonCopyable } /** - * This method returns the IPv6 scope value. + * Returns the IPv6 scope value. * * @returns The IPv6 scope value. * @@ -196,7 +196,7 @@ class Netif : public InstanceLocator, private NonCopyable } /** - * This method sets the IPv6 scope override value. + * Sets the IPv6 scope override value. * * @param[in] aScope The IPv6 scope value. * @@ -208,7 +208,7 @@ class Netif : public InstanceLocator, private NonCopyable } /** - * This method gets the IPv6 address origin. + * Gets the IPv6 address origin. * * @returns The address origin. * @@ -220,7 +220,7 @@ class Netif : public InstanceLocator, private NonCopyable }; /** - * This class implements an IPv6 network interface multicast address. + * Implements an IPv6 network interface multicast address. * */ class MulticastAddress : public otNetifMulticastAddress, @@ -231,7 +231,7 @@ class Netif : public InstanceLocator, private NonCopyable public: /** - * This method returns the multicast address. + * Returns the multicast address. * * @returns The multicast address. * @@ -239,7 +239,7 @@ class Netif : public InstanceLocator, private NonCopyable const Address &GetAddress(void) const { return AsCoreType(&mAddress); } /** - * This method returns the multicast address. + * Returns the multicast address. * * @returns The multicast address. * @@ -247,7 +247,7 @@ class Netif : public InstanceLocator, private NonCopyable Address &GetAddress(void) { return AsCoreType(&mAddress); } /** - * This method returns the next multicast address subscribed to the interface. + * Returns the next multicast address subscribed to the interface. * * @returns A pointer to the next multicast address. * @@ -255,7 +255,7 @@ class Netif : public InstanceLocator, private NonCopyable const MulticastAddress *GetNext(void) const { return static_cast(mNext); } /** - * This method returns the next multicast address subscribed to the interface. + * Returns the next multicast address subscribed to the interface. * * @returns A pointer to the next multicast address. * @@ -273,7 +273,7 @@ class Netif : public InstanceLocator, private NonCopyable public: /** - * This class represents an iterator for iterating external multicast addresses in a `Netif` instance. + * Represents an iterator for iterating external multicast addresses in a `Netif` instance. * */ class Iterator : public ItemPtrIterator @@ -283,7 +283,7 @@ class Netif : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes an `Iterator` instance to start from the first external multicast address + * Initializes an `Iterator` instance to start from the first external multicast address * that matches a given IPv6 address type filter. * * @param[in] aNetif A reference to the `Netif` instance. @@ -329,7 +329,7 @@ class Netif : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MLR_ENABLE /** - * This method returns the current Multicast Listener Registration (MLR) state. + * Returns the current Multicast Listener Registration (MLR) state. * * @returns The current Multicast Listener Registration state. * @@ -337,7 +337,7 @@ class Netif : public InstanceLocator, private NonCopyable MlrState GetMlrState(void) const { return mMlrState; } /** - * This method sets the Multicast Listener Registration (MLR) state. + * Sets the Multicast Listener Registration (MLR) state. * * @param[in] aState The new Multicast Listener Registration state. * @@ -354,7 +354,7 @@ class Netif : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the network interface. + * Initializes the network interface. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -362,7 +362,7 @@ class Netif : public InstanceLocator, private NonCopyable explicit Netif(Instance &aInstance); /** - * This method registers a callback to notify internal IPv6 address changes. + * Registers a callback to notify internal IPv6 address changes. * * @param[in] aCallback A pointer to a function that is called when an IPv6 address is added or removed. * @param[in] aCallbackContext A pointer to application-specific context. @@ -374,7 +374,7 @@ class Netif : public InstanceLocator, private NonCopyable } /** - * This method returns the linked list of unicast addresses. + * Returns the linked list of unicast addresses. * * @returns The linked list of unicast addresses. * @@ -382,9 +382,9 @@ class Netif : public InstanceLocator, private NonCopyable const LinkedList &GetUnicastAddresses(void) const { return mUnicastAddresses; } /** - * This method adds a unicast address to the network interface. + * Adds a unicast address to the network interface. * - * This method is intended for addresses internal to OpenThread. The @p aAddress instance is directly added in the + * Is intended for addresses internal to OpenThread. The @p aAddress instance is directly added in the * unicast address linked list. * * If @p aAddress is already added, the call to `AddUnicastAddress()` with the same address will perform no action. @@ -395,9 +395,9 @@ class Netif : public InstanceLocator, private NonCopyable void AddUnicastAddress(UnicastAddress &aAddress); /** - * This method removes a unicast address from the network interface. + * Removes a unicast address from the network interface. * - * This method is intended for addresses internal to OpenThread. The @p aAddress instance is removed from the + * Is intended for addresses internal to OpenThread. The @p aAddress instance is removed from the * unicast address linked list. * * If @p aAddress is not in the list, the call to `RemoveUnicastAddress()` will perform no action. @@ -408,7 +408,7 @@ class Netif : public InstanceLocator, private NonCopyable void RemoveUnicastAddress(const UnicastAddress &aAddress); /** - * This method indicates whether or not an address is assigned to the interface. + * Indicates whether or not an address is assigned to the interface. * * @param[in] aAddress A reference to the unicast address. * @@ -419,7 +419,7 @@ class Netif : public InstanceLocator, private NonCopyable bool HasUnicastAddress(const Address &aAddress) const; /** - * This method indicates whether or not a unicast address is assigned to the network interface. + * Indicates whether or not a unicast address is assigned to the network interface. * * @param[in] aAddress A reference to the unicast address. * @@ -430,7 +430,7 @@ class Netif : public InstanceLocator, private NonCopyable bool HasUnicastAddress(const UnicastAddress &aAddress) const { return mUnicastAddresses.Contains(aAddress); } /** - * This method indicates whether a unicast address is an external or internal address. + * Indicates whether a unicast address is an external or internal address. * * @param[in] aAddress A reference to the unicast address. * @@ -441,7 +441,7 @@ class Netif : public InstanceLocator, private NonCopyable bool IsUnicastAddressExternal(const UnicastAddress &aAddress) const; /** - * This method adds an external (to OpenThread) unicast address to the network interface. + * Adds an external (to OpenThread) unicast address to the network interface. * * For external address, the @p aAddress instance is not directly used (i.e., it can be temporary). It is copied * into a local entry (allocated from an internal pool) before being added in the unicast address linked list. @@ -457,7 +457,7 @@ class Netif : public InstanceLocator, private NonCopyable Error AddExternalUnicastAddress(const UnicastAddress &aAddress); /** - * This method removes a external (to OpenThread) unicast address from the network interface. + * Removes a external (to OpenThread) unicast address from the network interface. * * @param[in] aAddress A reference to the unicast address. * @@ -469,14 +469,14 @@ class Netif : public InstanceLocator, private NonCopyable Error RemoveExternalUnicastAddress(const Address &aAddress); /** - * This method removes all the previously added external (to OpenThread) unicast addresses from the + * Removes all the previously added external (to OpenThread) unicast addresses from the * network interface. * */ void RemoveAllExternalUnicastAddresses(void); /** - * This method indicates whether or not the network interface is subscribed to a multicast address. + * Indicates whether or not the network interface is subscribed to a multicast address. * * @param[in] aAddress The multicast address to check. * @@ -487,7 +487,7 @@ class Netif : public InstanceLocator, private NonCopyable bool IsMulticastSubscribed(const Address &aAddress) const; /** - * This method subscribes the network interface to the link-local and realm-local all routers addresses. + * Subscribes the network interface to the link-local and realm-local all routers addresses. * * @note This method MUST be called after `SubscribeAllNodesMulticast()` or its behavior is undefined. * @@ -495,13 +495,13 @@ class Netif : public InstanceLocator, private NonCopyable void SubscribeAllRoutersMulticast(void); /** - * This method unsubscribes the network interface to the link-local and realm-local all routers address. + * Unsubscribes the network interface to the link-local and realm-local all routers address. * */ void UnsubscribeAllRoutersMulticast(void); /** - * This method returns the linked list of multicast addresses. + * Returns the linked list of multicast addresses. * * @returns The linked list of multicast addresses. * @@ -509,7 +509,7 @@ class Netif : public InstanceLocator, private NonCopyable const LinkedList &GetMulticastAddresses(void) const { return mMulticastAddresses; } /** - * This method indicates whether a multicast address is an external or internal address. + * Indicates whether a multicast address is an external or internal address. * * @param[in] aAddress A reference to the multicast address. * @@ -520,9 +520,9 @@ class Netif : public InstanceLocator, private NonCopyable bool IsMulticastAddressExternal(const MulticastAddress &aAddress) const; /** - * This method subscribes the network interface to a multicast address. + * Subscribes the network interface to a multicast address. * - * This method is intended for addresses internal to OpenThread. The @p aAddress instance is directly added in the + * Is intended for addresses internal to OpenThread. The @p aAddress instance is directly added in the * multicast address linked list. * * @param[in] aAddress A reference to the multicast address. @@ -531,9 +531,9 @@ class Netif : public InstanceLocator, private NonCopyable void SubscribeMulticast(MulticastAddress &aAddress); /** - * This method unsubscribes the network interface to a multicast address. + * Unsubscribes the network interface to a multicast address. * - * This method is intended for addresses internal to OpenThread. The @p aAddress instance is directly removed from + * Is intended for addresses internal to OpenThread. The @p aAddress instance is directly removed from * the multicast address linked list. * * @param[in] aAddress A reference to the multicast address. @@ -542,7 +542,7 @@ class Netif : public InstanceLocator, private NonCopyable void UnsubscribeMulticast(const MulticastAddress &aAddress); /** - * This method subscribes the network interface to the external (to OpenThread) multicast address. + * Subscribes the network interface to the external (to OpenThread) multicast address. * * For external address, the @p aAddress instance is not directly used (i.e., it can be temporary). It is copied * into a local entry (allocated from an internal pool) before being added in the multicast address linked list. @@ -560,7 +560,7 @@ class Netif : public InstanceLocator, private NonCopyable Error SubscribeExternalMulticast(const Address &aAddress); /** - * This method unsubscribes the network interface to the external (to OpenThread) multicast address. + * Unsubscribes the network interface to the external (to OpenThread) multicast address. * * @param[in] aAddress A reference to the multicast address. * @@ -572,14 +572,14 @@ class Netif : public InstanceLocator, private NonCopyable Error UnsubscribeExternalMulticast(const Address &aAddress); /** - * This method unsubscribes the network interface from all previously added external (to OpenThread) multicast + * Unsubscribes the network interface from all previously added external (to OpenThread) multicast * addresses. * */ void UnsubscribeAllExternalMulticastAddresses(void); /** - * This method checks if multicast promiscuous mode is enabled on the network interface. + * Checks if multicast promiscuous mode is enabled on the network interface. * * @retval TRUE If the multicast promiscuous mode is enabled. * @retval FALSE If the multicast promiscuous mode is disabled. @@ -588,7 +588,7 @@ class Netif : public InstanceLocator, private NonCopyable bool IsMulticastPromiscuousEnabled(void) const { return mMulticastPromiscuous; } /** - * This method enables multicast promiscuous mode on the network interface. + * Enables multicast promiscuous mode on the network interface. * * @param[in] aEnabled TRUE if Multicast Promiscuous mode is enabled, FALSE otherwise. * @@ -596,10 +596,10 @@ class Netif : public InstanceLocator, private NonCopyable void SetMulticastPromiscuous(bool aEnabled) { mMulticastPromiscuous = aEnabled; } /** - * This method enables range-based `for` loop iteration over external multicast addresses on the Netif that matches + * Enables range-based `for` loop iteration over external multicast addresses on the Netif that matches * a given IPv6 address type filter. * - * This method should be used like follows: to iterate over all external multicast addresses + * Should be used like follows: to iterate over all external multicast addresses * * for (Ip6::Netif::ExternalMulticastAddress &addr : Get().IterateExternalMulticastAddresses()) * { ... } @@ -622,7 +622,7 @@ class Netif : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not the network interfaces is subscribed to any external multicast address. + * Indicates whether or not the network interfaces is subscribed to any external multicast address. * * @retval TRUE The network interface is subscribed to at least one external multicast address. * @retval FALSE The network interface is not subscribed to any external multicast address. @@ -632,14 +632,14 @@ class Netif : public InstanceLocator, private NonCopyable protected: /** - * This method subscribes the network interface to the realm-local all MPL forwarders, link-local, and realm-local + * Subscribes the network interface to the realm-local all MPL forwarders, link-local, and realm-local * all nodes address. * */ void SubscribeAllNodesMulticast(void); /** - * This method unsubscribes the network interface from the realm-local all MPL forwarders, link-local and + * Unsubscribes the network interface from the realm-local all MPL forwarders, link-local and * realm-local all nodes address. * * @note This method MUST be called after `UnsubscribeAllRoutersMulticast()` or its behavior is undefined @@ -648,9 +648,15 @@ class Netif : public InstanceLocator, private NonCopyable void UnsubscribeAllNodesMulticast(void); private: - void SignalMulticastAddressChange(AddressEvent aAddressEvent, - const MulticastAddress *aStart, - const MulticastAddress *aEnd); + typedef otIp6AddressInfo AddressInfo; + + static constexpr uint8_t kMulticastPrefixLength = 128; // Multicast prefix length used in `AdressInfo`. + + void SignalUnicastAddressChange(AddressEvent aEvent, const UnicastAddress &aAddress); + void SignalMulticastAddressChange(AddressEvent aEvent, const MulticastAddress &aAddress, AddressOrigin aOrigin); + void SignalMulticastAddressesChange(AddressEvent aEvent, + const MulticastAddress *aStart, + const MulticastAddress *aEnd); LinkedList mUnicastAddresses; LinkedList mMulticastAddresses; diff --git a/src/core/net/sntp_client.cpp b/src/core/net/sntp_client.cpp index e93effa7c2f..bc79e3d9be1 100644 --- a/src/core/net/sntp_client.cpp +++ b/src/core/net/sntp_client.cpp @@ -50,49 +50,6 @@ namespace Sntp { RegisterLogModule("SntpClnt"); -Header::Header(void) - : mFlags(kNtpVersion << kVersionOffset | kModeClient << kModeOffset) - , mStratum(0) - , mPoll(0) - , mPrecision(0) - , mRootDelay(0) - , mRootDispersion(0) - , mReferenceId(0) - , mReferenceTimestampSeconds(0) - , mReferenceTimestampFraction(0) - , mOriginateTimestampSeconds(0) - , mOriginateTimestampFraction(0) - , mReceiveTimestampSeconds(0) - , mReceiveTimestampFraction(0) - , mTransmitTimestampSeconds(0) - , mTransmitTimestampFraction(0) -{ -} - -QueryMetadata::QueryMetadata(void) - : mTransmitTimestamp(0) - , mResponseHandler(nullptr) - , mResponseContext(nullptr) - , mTransmissionTime(0) - , mDestinationPort(0) - , mRetransmissionCount(0) -{ - mSourceAddress.Clear(); - mDestinationAddress.Clear(); -} - -QueryMetadata::QueryMetadata(otSntpResponseHandler aHandler, void *aContext) - : mTransmitTimestamp(0) - , mResponseHandler(aHandler) - , mResponseContext(aContext) - , mTransmissionTime(0) - , mDestinationPort(0) - , mRetransmissionCount(0) -{ - mSourceAddress.Clear(); - mDestinationAddress.Clear(); -} - Client::Client(Instance &aInstance) : mSocket(aInstance) , mRetransmissionTimer(aInstance) @@ -127,7 +84,7 @@ Error Client::Stop(void) Error Client::Query(const otSntpQuery *aQuery, otSntpResponseHandler aHandler, void *aContext) { Error error; - QueryMetadata queryMetadata(aHandler, aContext); + QueryMetadata queryMetadata; Message *message = nullptr; Message *messageCopy = nullptr; Header header; @@ -135,6 +92,8 @@ Error Client::Query(const otSntpQuery *aQuery, otSntpResponseHandler aHandler, v VerifyOrExit(aQuery->mMessageInfo != nullptr, error = kErrorInvalidArgs); + header.Init(); + // Originate timestamp is used only as a unique token. header.SetTransmitTimestampSeconds(TimerMilli::GetNow().GetValue() / 1000 + kTimeAt1970); @@ -142,6 +101,7 @@ Error Client::Query(const otSntpQuery *aQuery, otSntpResponseHandler aHandler, v messageInfo = AsCoreTypePtr(aQuery->mMessageInfo); + queryMetadata.mResponseHandler.Set(aHandler, aContext); queryMetadata.mTransmitTimestamp = header.GetTransmitTimestampSeconds(); queryMetadata.mTransmissionTime = TimerMilli::GetNow() + kResponseTimeout; queryMetadata.mSourceAddress = messageInfo->GetSockAddr(); @@ -262,11 +222,7 @@ void Client::FinalizeSntpTransaction(Message &aQuery, Error aResult) { DequeueMessage(aQuery); - - if (aQueryMetadata.mResponseHandler != nullptr) - { - aQueryMetadata.mResponseHandler(aQueryMetadata.mResponseContext, aTime, aResult); - } + aQueryMetadata.mResponseHandler.InvokeIfSet(aTime, aResult); } void Client::HandleRetransmissionTimer(void) diff --git a/src/core/net/sntp_client.hpp b/src/core/net/sntp_client.hpp index f8338d58cba..3a513aa4e09 100644 --- a/src/core/net/sntp_client.hpp +++ b/src/core/net/sntp_client.hpp @@ -35,6 +35,7 @@ #include +#include "common/clearable.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" #include "common/timer.hpp" @@ -52,468 +53,186 @@ namespace Sntp { using ot::Encoding::BigEndian::HostSwap32; /** - * This class implements SNTP header generation and parsing. + * Implements SNTP client. * */ -OT_TOOL_PACKED_BEGIN -class Header +class Client : private NonCopyable { public: - /** - * Default constructor for SNTP Header. - * - */ - Header(void); - - /** - * Defines supported SNTP modes. - * - */ - enum Mode : uint8_t - { - kModeClient = 3, - kModeServer = 4, - }; - - static constexpr uint8_t kKissCodeLength = 4; ///< Length of the kiss code in ASCII format - - /** - * This method returns the flags field value. - * - * @returns Value of the flags field (LI, VN and Mode). - * - */ - uint8_t GetFlags(void) const { return mFlags; } - - /** - * This method sets the flags field. - * - * @param[in] aFlags The value of the flags field. - * - */ - void SetFlags(uint8_t aFlags) { mFlags = aFlags; } - - /** - * This method returns the SNTP operational mode. - * - * @returns SNTP operational mode. - * - */ - Mode GetMode(void) const { return static_cast((mFlags & kModeMask) >> kModeOffset); } - - /** - * This method returns the packet stratum field value. - * - * @returns Value of the packet stratum. - * - */ - uint8_t GetStratum(void) const { return mStratum; } - - /** - * This method sets the packet stratum field value. - * - * @param[in] aStratum The value of the packet stratum field. - * - */ - void SetStratum(uint8_t aStratum) { mStratum = aStratum; } - - /** - * This method returns the poll field value. - * - * @returns Value of the poll field. - * - */ - uint8_t GetPoll(void) const { return mPoll; } - - /** - * This method sets the poll field. - * - * @param[in] aPoll The value of the poll field. - * - */ - void SetPoll(uint8_t aPoll) { mPoll = aPoll; } - - /** - * This method returns the precision field value. - * - * @returns Value of the precision field. - * - */ - uint8_t GetPrecision(void) const { return mPrecision; } - - /** - * This method sets the precision field. - * - * @param[in] aPrecision The value of the precision field. - * - */ - void SetPrecision(uint8_t aPrecision) { mPrecision = aPrecision; } - - /** - * This method returns the root delay field value. - * - * @returns Value of the root delay field. - * - */ - uint32_t GetRootDelay(void) const { return HostSwap32(mRootDelay); } + typedef otSntpResponseHandler ResponseHandler; ///< Response handler callback. /** - * This method sets the root delay field. + * Initializes the object. * - * @param[in] aRootDelay The value of the root delay field. - * - */ - void SetRootDelay(uint32_t aRootDelay) { mRootDelay = HostSwap32(aRootDelay); } - - /** - * This method returns the root dispersion field value. - * - * @returns Value of the root dispersion field. - * - */ - uint32_t GetRootDispersion(void) const { return HostSwap32(mRootDispersion); } - - /** - * This method sets the root dispersion field. - * - * @param[in] aRootDispersion The value of the root dispersion field. - * - */ - void SetRootDispersion(uint32_t aRootDispersion) { mRootDispersion = HostSwap32(aRootDispersion); } - - /** - * This method returns the reference identifier field value. - * - * @returns Value of the reference identifier field. - * - */ - uint32_t GetReferenceId(void) const { return HostSwap32(mReferenceId); } - - /** - * This method sets the reference identifier field. - * - * @param[in] aReferenceId The value of the reference identifier field. - * - */ - void SetReferenceId(uint32_t aReferenceId) { mReferenceId = HostSwap32(aReferenceId); } - - /** - * This method returns the kiss code in ASCII format. - * - * @returns Value of the reference identifier field in ASCII format. - * - */ - char *GetKissCode(void) { return reinterpret_cast(&mReferenceId); } - - /** - * This method returns the reference timestamp seconds field. - * - * @returns Value of the reference timestamp seconds field. + * @param[in] aInstance A reference to the OpenThread instance. * */ - uint32_t GetReferenceTimestampSeconds(void) const { return HostSwap32(mReferenceTimestampSeconds); } + explicit Client(Instance &aInstance); /** - * This method sets the reference timestamp seconds field. - * - * @param[in] aReferenceTimestampSeconds Value of the reference timestamp seconds field. + * Starts the SNTP client. * + * @retval kErrorNone Successfully started the SNTP client. + * @retval kErrorAlready The socket is already open. */ - void SetReferenceTimestampSeconds(uint32_t aReferenceTimestampSeconds) - { - mReferenceTimestampSeconds = HostSwap32(aReferenceTimestampSeconds); - } + Error Start(void); /** - * This method returns the reference timestamp fraction field. + * Stops the SNTP client. * - * @returns Value of the reference timestamp fraction field. + * @retval kErrorNone Successfully stopped the SNTP client. * */ - uint32_t GetReferenceTimestampFraction(void) const { return HostSwap32(mReferenceTimestampFraction); } + Error Stop(void); /** - * This method sets the reference timestamp fraction field. + * Returns the unix era number. * - * @param[in] aReferenceTimestampFraction Value of the reference timestamp fraction field. + * @returns The unix era number. * */ - void SetReferenceTimestampFraction(uint32_t aReferenceTimestampFraction) - { - mReferenceTimestampFraction = HostSwap32(aReferenceTimestampFraction); - } + uint32_t GetUnixEra(void) const { return mUnixEra; } /** - * This method returns the originate timestamp seconds field. + * Sets the unix era number. * - * @returns Value of the originate timestamp seconds field. + * @param[in] aUnixEra The unix era number. * */ - uint32_t GetOriginateTimestampSeconds(void) const { return HostSwap32(mOriginateTimestampSeconds); } + void SetUnixEra(uint32_t aUnixEra) { mUnixEra = aUnixEra; } /** - * This method sets the originate timestamp seconds field. - * - * @param[in] aOriginateTimestampSeconds Value of the originate timestamp seconds field. + * Sends an SNTP query. * - */ - void SetOriginateTimestampSeconds(uint32_t aOriginateTimestampSeconds) - { - mOriginateTimestampSeconds = HostSwap32(aOriginateTimestampSeconds); - } - - /** - * This method returns the originate timestamp fraction field. + * @param[in] aQuery A pointer to specify SNTP query parameters. + * @param[in] aHandler A function pointer that shall be called on response reception or time-out. + * @param[in] aContext A pointer to arbitrary context information. * - * @returns Value of the originate timestamp fraction field. + * @retval kErrorNone Successfully sent SNTP query. + * @retval kErrorNoBufs Failed to allocate retransmission data. + * @retval kErrorInvalidArgs Invalid arguments supplied. * */ - uint32_t GetOriginateTimestampFraction(void) const { return HostSwap32(mOriginateTimestampFraction); } + Error Query(const otSntpQuery *aQuery, ResponseHandler aHandler, void *aContext); - /** - * This method sets the originate timestamp fraction field. - * - * @param[in] aOriginateTimestampFraction Value of the originate timestamp fraction field. - * - */ - void SetOriginateTimestampFraction(uint32_t aOriginateTimestampFraction) - { - mOriginateTimestampFraction = HostSwap32(aOriginateTimestampFraction); - } +private: + static constexpr uint32_t kTimeAt1970 = 2208988800UL; // num seconds between 1st Jan 1900 and 1st Jan 1970. - /** - * This method returns the receive timestamp seconds field. - * - * @returns Value of the receive timestamp seconds field. - * - */ - uint32_t GetReceiveTimestampSeconds(void) const { return HostSwap32(mReceiveTimestampSeconds); } + static constexpr uint32_t kResponseTimeout = OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT; + static constexpr uint8_t kMaxRetransmit = OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT; - /** - * This method sets the receive timestamp seconds field. - * - * @param[in] aReceiveTimestampSeconds Value of the receive timestamp seconds field. - * - */ - void SetReceiveTimestampSeconds(uint32_t aReceiveTimestampSeconds) + OT_TOOL_PACKED_BEGIN + class Header : public Clearable
{ - mReceiveTimestampSeconds = HostSwap32(aReceiveTimestampSeconds); - } + public: + enum Mode : uint8_t + { + kModeClient = 3, + kModeServer = 4, + }; - /** - * This method returns the receive timestamp fraction field. - * - * @returns Value of the receive timestamp fraction field. - * - */ - uint32_t GetReceiveTimestampFraction(void) const { return HostSwap32(mReceiveTimestampFraction); } + static constexpr uint8_t kKissCodeLength = 4; - /** - * This method sets the receive timestamp fraction field. - * - * @param[in] aReceiveTimestampFraction Value of the receive timestamp fraction field. - * - */ - void SetReceiveTimestampFraction(uint32_t aReceiveTimestampFraction) - { - mReceiveTimestampFraction = HostSwap32(aReceiveTimestampFraction); - } + void Init(void) + { + Clear(); + mFlags = (kNtpVersion << kVersionOffset | kModeClient << kModeOffset); + } - /** - * This method returns the transmit timestamp seconds field. - * - * @returns Value of the transmit timestamp seconds field. - * - */ - uint32_t GetTransmitTimestampSeconds(void) const { return HostSwap32(mTransmitTimestampSeconds); } + uint8_t GetFlags(void) const { return mFlags; } + void SetFlags(uint8_t aFlags) { mFlags = aFlags; } - /** - * This method sets the transmit timestamp seconds field. - * - * @param[in] aTransmitTimestampSeconds Value of the transmit timestamp seconds field. - * - */ - void SetTransmitTimestampSeconds(uint32_t aTransmitTimestampSeconds) - { - mTransmitTimestampSeconds = HostSwap32(aTransmitTimestampSeconds); - } + Mode GetMode(void) const { return static_cast((mFlags & kModeMask) >> kModeOffset); } - /** - * This method returns the transmit timestamp fraction field. - * - * @returns Value of the transmit timestamp fraction field. - * - */ - uint32_t GetTransmitTimestampFraction(void) const { return HostSwap32(mTransmitTimestampFraction); } + uint8_t GetStratum(void) const { return mStratum; } + void SetStratum(uint8_t aStratum) { mStratum = aStratum; } - /** - * This method sets the transmit timestamp fraction field. - * - * @param[in] aTransmitTimestampFraction Value of the transmit timestamp fraction field. - * - */ - void SetTransmitTimestampFraction(uint32_t aTransmitTimestampFraction) - { - mTransmitTimestampFraction = HostSwap32(aTransmitTimestampFraction); - } + uint8_t GetPoll(void) const { return mPoll; } + void SetPoll(uint8_t aPoll) { mPoll = aPoll; } -private: - static constexpr uint8_t kNtpVersion = 4; // Current NTP version. - static constexpr uint8_t kLeapOffset = 6; // Leap Indicator field offset. - static constexpr uint8_t kLeapMask = 0x03 << kLeapOffset; // Leap Indicator field mask. - static constexpr uint8_t kVersionOffset = 3; // Version field offset. - static constexpr uint8_t kVersionMask = 0x07 << kVersionOffset; // Version field mask. - static constexpr uint8_t kModeOffset = 0; // Mode field offset. - static constexpr uint8_t kModeMask = 0x07 << kModeOffset; // Mode filed mask. - - uint8_t mFlags; // SNTP flags: LI Leap Indicator, VN Version Number and Mode. - uint8_t mStratum; // Packet Stratum. - uint8_t mPoll; // Maximum interval between successive messages, in log2 seconds. - uint8_t mPrecision; // The precision of the system clock, in log2 seconds. - uint32_t mRootDelay; // Total round-trip delay to the reference clock, in NTP short format. - uint32_t mRootDispersion; // Total dispersion to the reference clock. - uint32_t mReferenceId; // ID identifying the particular server or reference clock. - uint32_t mReferenceTimestampSeconds; // Time the system clock was last set or corrected (NTP format). - uint32_t mReferenceTimestampFraction; // Fraction part of above value. - uint32_t mOriginateTimestampSeconds; // Time at the client when the request departed for the server (NTP format). - uint32_t mOriginateTimestampFraction; // Fraction part of above value. - uint32_t mReceiveTimestampSeconds; // Time at the server when the request arrived from the client (NTP format). - uint32_t mReceiveTimestampFraction; // Fraction part of above value. - uint32_t mTransmitTimestampSeconds; // Time at the server when the response left for the client (NTP format). - uint32_t mTransmitTimestampFraction; // Fraction part of above value. -} OT_TOOL_PACKED_END; + uint8_t GetPrecision(void) const { return mPrecision; } + void SetPrecision(uint8_t aPrecision) { mPrecision = aPrecision; } -/** - * This class implements metadata required for SNTP retransmission. - * - */ -class QueryMetadata -{ - friend class Client; + uint32_t GetRootDelay(void) const { return HostSwap32(mRootDelay); } + void SetRootDelay(uint32_t aRootDelay) { mRootDelay = HostSwap32(aRootDelay); } -public: - /** - * Default constructor for the object. - * - */ - QueryMetadata(void); + uint32_t GetRootDispersion(void) const { return HostSwap32(mRootDispersion); } + void SetRootDispersion(uint32_t aRootDispersion) { mRootDispersion = HostSwap32(aRootDispersion); } - /** - * This constructor initializes the object with specific values. - * - * @param[in] aHandler Pointer to a handler function for the response. - * @param[in] aContext Context for the handler function. - * - */ - QueryMetadata(otSntpResponseHandler aHandler, void *aContext); + uint32_t GetReferenceId(void) const { return HostSwap32(mReferenceId); } + void SetReferenceId(uint32_t aReferenceId) { mReferenceId = HostSwap32(aReferenceId); } - /** - * This method appends request data to the message. - * - * @param[in] aMessage A reference to the message. - * - * @retval kErrorNone Successfully appended the bytes. - * @retval kErrorNoBufs Insufficient available buffers to grow the message. - * - */ - Error AppendTo(Message &aMessage) const { return aMessage.Append(*this); } + char *GetKissCode(void) { return reinterpret_cast(&mReferenceId); } - /** - * This method reads request data from the message. - * - * @param[in] aMessage A reference to the message. - * - */ - void ReadFrom(const Message &aMessage) - { - SuccessOrAssert(aMessage.Read(aMessage.GetLength() - sizeof(*this), *this)); - } + uint32_t GetReferenceTimestampSeconds(void) const { return HostSwap32(mReferenceTimestampSeconds); } + void SetReferenceTimestampSeconds(uint32_t aTimestamp) { mReferenceTimestampSeconds = HostSwap32(aTimestamp); } - /** - * This method updates request data in the message. - * - * @param[in] aMessage A reference to the message. - * - */ - void UpdateIn(Message &aMessage) const { aMessage.Write(aMessage.GetLength() - sizeof(*this), *this); } + uint32_t GetReferenceTimestampFraction(void) const { return HostSwap32(mReferenceTimestampFraction); } + void SetReferenceTimestampFraction(uint32_t aFraction) { mReferenceTimestampFraction = HostSwap32(aFraction); } -private: - uint32_t mTransmitTimestamp; ///< Time at the client when the request departed for the server. - otSntpResponseHandler mResponseHandler; ///< A function pointer that is called on response reception. - void *mResponseContext; ///< A pointer to arbitrary context information. - TimeMilli mTransmissionTime; ///< Time when the timer should shoot for this message. - Ip6::Address mSourceAddress; ///< IPv6 address of the message source. - Ip6::Address mDestinationAddress; ///< IPv6 address of the message destination. - uint16_t mDestinationPort; ///< UDP port of the message destination. - uint8_t mRetransmissionCount; ///< Number of retransmissions. -}; + uint32_t GetOriginateTimestampSeconds(void) const { return HostSwap32(mOriginateTimestampSeconds); } + void SetOriginateTimestampSeconds(uint32_t aTimestamp) { mOriginateTimestampSeconds = HostSwap32(aTimestamp); } -/** - * This class implements SNTP client. - * - */ -class Client : private NonCopyable -{ -public: - /** - * This constructor initializes the object. - * - * @param[in] aInstance A reference to the OpenThread instance. - * - */ - explicit Client(Instance &aInstance); + uint32_t GetOriginateTimestampFraction(void) const { return HostSwap32(mOriginateTimestampFraction); } + void SetOriginateTimestampFraction(uint32_t aFraction) { mOriginateTimestampFraction = HostSwap32(aFraction); } - /** - * This method starts the SNTP client. - * - * @retval kErrorNone Successfully started the SNTP client. - * @retval kErrorAlready The socket is already open. - */ - Error Start(void); + uint32_t GetReceiveTimestampSeconds(void) const { return HostSwap32(mReceiveTimestampSeconds); } + void SetReceiveTimestampSeconds(uint32_t aTimestamp) { mReceiveTimestampSeconds = HostSwap32(aTimestamp); } - /** - * This method stops the SNTP client. - * - * @retval kErrorNone Successfully stopped the SNTP client. - * - */ - Error Stop(void); + uint32_t GetReceiveTimestampFraction(void) const { return HostSwap32(mReceiveTimestampFraction); } + void SetReceiveTimestampFraction(uint32_t aFraction) { mReceiveTimestampFraction = HostSwap32(aFraction); } - /** - * This method returns the unix era number. - * - * @returns The unix era number. - * - */ - uint32_t GetUnixEra(void) const { return mUnixEra; } + uint32_t GetTransmitTimestampSeconds(void) const { return HostSwap32(mTransmitTimestampSeconds); } + void SetTransmitTimestampSeconds(uint32_t aTimestamp) { mTransmitTimestampSeconds = HostSwap32(aTimestamp); } - /** - * This method sets the unix era number. - * - * @param[in] aUnixEra The unix era number. - * - */ - void SetUnixEra(uint32_t aUnixEra) { mUnixEra = aUnixEra; } + uint32_t GetTransmitTimestampFraction(void) const { return HostSwap32(mTransmitTimestampFraction); } + void SetTransmitTimestampFraction(uint32_t aFraction) { mTransmitTimestampFraction = HostSwap32(aFraction); } - /** - * This method sends an SNTP query. - * - * @param[in] aQuery A pointer to specify SNTP query parameters. - * @param[in] aHandler A function pointer that shall be called on response reception or time-out. - * @param[in] aContext A pointer to arbitrary context information. - * - * @retval kErrorNone Successfully sent SNTP query. - * @retval kErrorNoBufs Failed to allocate retransmission data. - * @retval kErrorInvalidArgs Invalid arguments supplied. - * - */ - Error Query(const otSntpQuery *aQuery, otSntpResponseHandler aHandler, void *aContext); + private: + static constexpr uint8_t kNtpVersion = 4; // Current NTP version. + static constexpr uint8_t kLeapOffset = 6; // Leap Indicator field offset. + static constexpr uint8_t kLeapMask = 0x03 << kLeapOffset; // Leap Indicator field mask. + static constexpr uint8_t kVersionOffset = 3; // Version field offset. + static constexpr uint8_t kVersionMask = 0x07 << kVersionOffset; // Version field mask. + static constexpr uint8_t kModeOffset = 0; // Mode field offset. + static constexpr uint8_t kModeMask = 0x07 << kModeOffset; // Mode filed mask. -private: - static constexpr uint32_t kTimeAt1970 = 2208988800UL; // num seconds between 1st Jan 1900 and 1st Jan 1970. + uint8_t mFlags; // SNTP flags: LI Leap Indicator, VN Version Number and Mode. + uint8_t mStratum; // Packet Stratum. + uint8_t mPoll; // Maximum interval between successive messages, in log2 seconds. + uint8_t mPrecision; // The precision of the system clock, in log2 seconds. + uint32_t mRootDelay; // Total round-trip delay to the reference clock, in NTP short format. + uint32_t mRootDispersion; // Total dispersion to the reference clock. + uint32_t mReferenceId; // ID identifying the particular server or reference clock. + uint32_t mReferenceTimestampSeconds; // Time the system clock was last set or corrected (NTP format). + uint32_t mReferenceTimestampFraction; // Fraction part of above value. + uint32_t mOriginateTimestampSeconds; // Time at client when request departed for the server (NTP format). + uint32_t mOriginateTimestampFraction; // Fraction part of above value. + uint32_t mReceiveTimestampSeconds; // Time at server when request arrived from the client (NTP format). + uint32_t mReceiveTimestampFraction; // Fraction part of above value. + uint32_t mTransmitTimestampSeconds; // Time at server when the response left for the client (NTP format). + uint32_t mTransmitTimestampFraction; // Fraction part of above value. + } OT_TOOL_PACKED_END; - static constexpr uint32_t kResponseTimeout = OPENTHREAD_CONFIG_SNTP_CLIENT_RESPONSE_TIMEOUT; - static constexpr uint8_t kMaxRetransmit = OPENTHREAD_CONFIG_SNTP_CLIENT_MAX_RETRANSMIT; + class QueryMetadata + { + public: + Error AppendTo(Message &aMessage) const { return aMessage.Append(*this); } + void ReadFrom(const Message &aMessage) + { + IgnoreError(aMessage.Read(aMessage.GetLength() - sizeof(*this), *this)); + } + + void UpdateIn(Message &aMessage) const { aMessage.Write(aMessage.GetLength() - sizeof(*this), *this); } + + uint32_t mTransmitTimestamp; // Time at client when request departed for server + Callback mResponseHandler; // Response handler callback + TimeMilli mTransmissionTime; // Time when the timer should shoot for this message + Ip6::Address mSourceAddress; // Source IPv6 address + Ip6::Address mDestinationAddress; // Destination IPv6 address + uint16_t mDestinationPort; // Destination UDP port + uint8_t mRetransmissionCount; // Number of retransmissions + }; Message *NewMessage(const Header &aHeader); Message *CopyAndEnqueueMessage(const Message &aMessage, const QueryMetadata &aQueryMetadata); diff --git a/src/core/net/socket.hpp b/src/core/net/socket.hpp index fed22d19822..fb4e928ff43 100644 --- a/src/core/net/socket.hpp +++ b/src/core/net/socket.hpp @@ -55,20 +55,20 @@ namespace Ip6 { */ /** - * This class implements message information for an IPv6 message. + * Implements message information for an IPv6 message. * */ class MessageInfo : public otMessageInfo, public Clearable { public: /** - * This constructor initializes the object. + * Initializes the object. * */ MessageInfo(void) { Clear(); } /** - * This method returns a reference to the local socket address. + * Returns a reference to the local socket address. * * @returns A reference to the local socket address. * @@ -76,7 +76,7 @@ class MessageInfo : public otMessageInfo, public Clearable Address &GetSockAddr(void) { return AsCoreType(&mSockAddr); } /** - * This method returns a reference to the local socket address. + * Returns a reference to the local socket address. * * @returns A reference to the local socket address. * @@ -84,7 +84,7 @@ class MessageInfo : public otMessageInfo, public Clearable const Address &GetSockAddr(void) const { return AsCoreType(&mSockAddr); } /** - * This method sets the local socket address. + * Sets the local socket address. * * @param[in] aAddress The IPv6 address. * @@ -92,7 +92,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetSockAddr(const Address &aAddress) { mSockAddr = aAddress; } /** - * This method gets the local socket port. + * Gets the local socket port. * * @returns The local socket port. * @@ -100,7 +100,7 @@ class MessageInfo : public otMessageInfo, public Clearable uint16_t GetSockPort(void) const { return mSockPort; } /** - * This method gets the local socket port. + * Gets the local socket port. * * @param[in] aPort The port value. * @@ -108,7 +108,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetSockPort(uint16_t aPort) { mSockPort = aPort; } /** - * This method returns a reference to the peer socket address. + * Returns a reference to the peer socket address. * * @returns A reference to the peer socket address. * @@ -116,7 +116,7 @@ class MessageInfo : public otMessageInfo, public Clearable Address &GetPeerAddr(void) { return AsCoreType(&mPeerAddr); } /** - * This method returns a reference to the peer socket address. + * Returns a reference to the peer socket address. * * @returns A reference to the peer socket address. * @@ -124,7 +124,7 @@ class MessageInfo : public otMessageInfo, public Clearable const Address &GetPeerAddr(void) const { return AsCoreType(&mPeerAddr); } /** - * This method sets the peer's socket address. + * Sets the peer's socket address. * * @param[in] aAddress The IPv6 address. * @@ -132,7 +132,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetPeerAddr(const Address &aAddress) { mPeerAddr = aAddress; } /** - * This method gets the peer socket port. + * Gets the peer socket port. * * @returns The peer socket port. * @@ -140,7 +140,7 @@ class MessageInfo : public otMessageInfo, public Clearable uint16_t GetPeerPort(void) const { return mPeerPort; } /** - * This method gets the peer socket port. + * Gets the peer socket port. * * @param[in] aPort The port value. * @@ -148,7 +148,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetPeerPort(uint16_t aPort) { mPeerPort = aPort; } /** - * This method gets the Hop Limit. + * Gets the Hop Limit. * * @returns The Hop Limit. * @@ -156,7 +156,7 @@ class MessageInfo : public otMessageInfo, public Clearable uint8_t GetHopLimit(void) const { return mHopLimit; } /** - * This method sets the Hop Limit. + * Sets the Hop Limit. * * @param[in] aHopLimit The Hop Limit. * @@ -164,7 +164,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetHopLimit(uint8_t aHopLimit) { mHopLimit = aHopLimit; } /** - * This method returns whether multicast may be looped back. + * Returns whether multicast may be looped back. * * @retval TRUE If message may be looped back. * @retval FALSE If message must not be looped back. @@ -173,7 +173,7 @@ class MessageInfo : public otMessageInfo, public Clearable bool GetMulticastLoop(void) const { return mMulticastLoop; } /** - * This method sets whether multicast may be looped back. + * Sets whether multicast may be looped back. * * @param[in] aMulticastLoop Whether allow looping back multicast. * @@ -181,7 +181,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetMulticastLoop(bool aMulticastLoop) { mMulticastLoop = aMulticastLoop; } /** - * This method returns a pointer to the link-specific information object. + * Returns a pointer to the link-specific information object. * * @returns A pointer to the link-specific information object. * @@ -189,7 +189,7 @@ class MessageInfo : public otMessageInfo, public Clearable const void *GetLinkInfo(void) const { return mLinkInfo; } /** - * This method sets the pointer to the link-specific information object. + * Sets the pointer to the link-specific information object. * * @param[in] aLinkInfo A pointer to the link-specific information object. * @@ -197,7 +197,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetLinkInfo(const void *aLinkInfo) { mLinkInfo = aLinkInfo; } /** - * This method returns a pointer to the link-specific information as a `ThreadLinkInfo`. + * Returns a pointer to the link-specific information as a `ThreadLinkInfo`. * * @returns A pointer to to the link-specific information object as `ThreadLinkInfo`. * @@ -205,7 +205,7 @@ class MessageInfo : public otMessageInfo, public Clearable const ThreadLinkInfo *GetThreadLinkInfo(void) const { return reinterpret_cast(mLinkInfo); } /** - * This method gets the ECN status. + * Gets the ECN status. * * @returns The ECN status, as represented in the IP header. * @@ -213,7 +213,7 @@ class MessageInfo : public otMessageInfo, public Clearable Ecn GetEcn(void) const { return static_cast(mEcn); } /** - * This method sets the ECN status. + * Sets the ECN status. * * @param[in] aEcn The ECN status, as represented in the IP header. * @@ -221,7 +221,7 @@ class MessageInfo : public otMessageInfo, public Clearable void SetEcn(Ecn aEcn) { mEcn = aEcn; } /** - * This method indicates whether peer is via the host interface. + * Indicates whether peer is via the host interface. * * @retval TRUE if the peer is via the host interface. * @retval FALSE if the peer is via the Thread interface. @@ -230,7 +230,7 @@ class MessageInfo : public otMessageInfo, public Clearable bool IsHostInterface(void) const { return mIsHostInterface; } /** - * This method indicates whether or not to apply hop limit 0. + * Indicates whether or not to apply hop limit 0. * * @retval TRUE if applying hop limit 0 when `mHopLimit` field is 0. * @retval FALSE if applying default `OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT` when `mHopLimit` field is 0. @@ -239,7 +239,7 @@ class MessageInfo : public otMessageInfo, public Clearable bool ShouldAllowZeroHopLimit(void) const { return mAllowZeroHopLimit; } /** - * This method sets whether the peer is via the host interface. + * Sets whether the peer is via the host interface. * * @param[in] aIsHost TRUE if the peer is via the host interface, FALSE otherwise. * @@ -248,7 +248,7 @@ class MessageInfo : public otMessageInfo, public Clearable }; /** - * This class implements a socket address. + * Implements a socket address. * */ class SockAddr : public otSockAddr, public Clearable, public Unequatable @@ -257,19 +257,19 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab static constexpr uint16_t kInfoStringSize = OT_IP6_SOCK_ADDR_STRING_SIZE; ///< Info string size (`ToString()`). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This constructor initializes the socket address (all fields are set to zero). + * Initializes the socket address (all fields are set to zero). * */ SockAddr(void) { Clear(); } /** - * This constructor initializes the socket address with a given port number. + * Initializes the socket address with a given port number. * * @param[in] aPort A port number. * @@ -281,7 +281,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab } /** - * This constructor initializes the socket address with a given address and port number. + * Initializes the socket address with a given address and port number. * * @param[in] aAddress An IPv6 address. * @param[in] aPort A port number. @@ -294,7 +294,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab } /** - * This method returns a reference to the IPv6 address. + * Returns a reference to the IPv6 address. * * @returns A reference to the IPv6 address. * @@ -302,7 +302,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab Address &GetAddress(void) { return AsCoreType(&mAddress); } /** - * This method returns a reference to the IPv6 address. + * Returns a reference to the IPv6 address. * * @returns A reference to the IPv6 address. * @@ -310,7 +310,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab const Address &GetAddress(void) const { return AsCoreType(&mAddress); } /** - * This method sets the IPv6 address. + * Sets the IPv6 address. * * @param[in] aAddress The IPv6 address. * @@ -318,7 +318,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab void SetAddress(const Address &aAddress) { mAddress = aAddress; } /** - * This method returns the socket address port number. + * Returns the socket address port number. * * @returns The port number * @@ -326,7 +326,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab uint16_t GetPort(void) const { return mPort; } /** - * This method sets the socket address port number. + * Sets the socket address port number. * * @param[in] aPort The port number. * @@ -334,7 +334,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab void SetPort(uint16_t aPort) { mPort = aPort; } /** - * This method overloads operator `==` to evaluate whether or not two `SockAddr` instances are equal (same address + * Overloads operator `==` to evaluate whether or not two `SockAddr` instances are equal (same address * and port number). * * @param[in] aOther The other `SockAddr` instance to compare with. @@ -349,7 +349,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab } /** - * This method converts the socket address to a string. + * Converts the socket address to a string. * * The string is formatted as "[]:". * @@ -359,7 +359,7 @@ class SockAddr : public otSockAddr, public Clearable, public Unequatab InfoString ToString(void) const; /** - * This method converts a given IPv6 socket address to a human-readable string. + * Converts a given IPv6 socket address to a human-readable string. * * The IPv6 socket address string is formatted as "[]:". * diff --git a/src/core/net/srp_client.cpp b/src/core/net/srp_client.cpp index d9647319dc3..eae23025c78 100644 --- a/src/core/net/srp_client.cpp +++ b/src/core/net/srp_client.cpp @@ -1054,10 +1054,7 @@ Error Client::AppendServiceInstructions(Message &aMessage, Info &aInfo) // In such a case, we end up using `mDefaultLease` but then we need // to make sure it is not greater than the selected `mKeyLease`. - if (mLease > mKeyLease) - { - mLease = mKeyLease; - } + mLease = Min(mLease, mKeyLease); exit: return error; @@ -1844,11 +1841,7 @@ void Client::GrowRetryWaitInterval(void) { mRetryWaitInterval = mRetryWaitInterval / kRetryIntervalGrowthFactorDenominator * kRetryIntervalGrowthFactorNumerator; - - if (mRetryWaitInterval > kMaxRetryWaitInterval) - { - mRetryWaitInterval = kMaxRetryWaitInterval; - } + mRetryWaitInterval = Min(mRetryWaitInterval, kMaxRetryWaitInterval); } uint32_t Client::DetermineLeaseInterval(uint32_t aInterval, uint32_t aDefaultInterval) const diff --git a/src/core/net/srp_client.hpp b/src/core/net/srp_client.hpp index 992940cfd40..5260ea6ac78 100644 --- a/src/core/net/srp_client.hpp +++ b/src/core/net/srp_client.hpp @@ -65,7 +65,7 @@ namespace Srp { #endif /** - * This class implements SRP client. + * Implements SRP client. * */ class Client : public InstanceLocator, private NonCopyable @@ -77,7 +77,7 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This enumeration types represents an SRP client item (service or host info) state. + * Types represents an SRP client item (service or host info) state. * */ enum ItemState : uint8_t @@ -93,7 +93,7 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This function pointer type defines the callback used by SRP client to notify user of a changes/events/errors. + * Pointer type defines the callback used by SRP client to notify user of a changes/events/errors. * * Please see `otSrpClientCallback` for more details. * @@ -101,7 +101,7 @@ class Client : public InstanceLocator, private NonCopyable typedef otSrpClientCallback ClientCallback; /** - * This type represents an SRP client host info. + * Represents an SRP client host info. * */ class HostInfo : public otSrpClientHostInfo, private Clearable @@ -111,19 +111,19 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This method initializes the `HostInfo` object. + * Initializes the `HostInfo` object. * */ void Init(void); /** - * This method clears the `HostInfo` object. + * Clears the `HostInfo` object. * */ void Clear(void); /** - * This method gets the host name (label) string. + * Gets the host name (label) string. * * @returns The host name (label) string, or `nullptr` if not yet set. * @@ -131,7 +131,7 @@ class Client : public InstanceLocator, private NonCopyable const char *GetName(void) const { return mName; } /** - * This method indicates whether or not the host auto address mode is enabled. + * Indicates whether or not the host auto address mode is enabled. * * @retval TRUE If the auto address mode is enabled. * @retval FALSE If the auto address mode is disabled. @@ -140,7 +140,7 @@ class Client : public InstanceLocator, private NonCopyable bool IsAutoAddressEnabled(void) const { return mAutoAddress; } /** - * This method gets the number of host IPv6 addresses. + * Gets the number of host IPv6 addresses. * * @returns The number of host IPv6 addresses. * @@ -148,7 +148,7 @@ class Client : public InstanceLocator, private NonCopyable uint8_t GetNumAddresses(void) const { return mNumAddresses; } /** - * This method gets the host IPv6 address at a given index. + * Gets the host IPv6 address at a given index. * * @param[in] aIndex The index to get (MUST be smaller than `GetNumAddresses()`). * @@ -158,7 +158,7 @@ class Client : public InstanceLocator, private NonCopyable const Ip6::Address &GetAddress(uint8_t aIndex) const { return AsCoreType(&mAddresses[aIndex]); } /** - * This method gets the state of `HostInfo`. + * Gets the state of `HostInfo`. * * @returns The `HostInfo` state. * @@ -173,7 +173,7 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This type represents an SRP client service. + * Represents an SRP client service. * */ class Service : public otSrpClientService, public LinkedListEntry @@ -183,7 +183,7 @@ class Client : public InstanceLocator, private NonCopyable public: /** - * This method initializes and validates the `Service` object and its fields. + * Initializes and validates the `Service` object and its fields. * * @retval kErrorNone Successfully initialized and validated the `Service` object. * @retval kErrorInvalidArgs The info in `Service` object is not valid (e.g. null name or bad `TxtEntry`). @@ -192,7 +192,7 @@ class Client : public InstanceLocator, private NonCopyable Error Init(void); /** - * This method gets the service name labels string. + * Gets the service name labels string. * * @returns The service name label string (e.g., "_chip._udp", not the full domain name). * @@ -200,7 +200,7 @@ class Client : public InstanceLocator, private NonCopyable const char *GetName(void) const { return mName; } /** - * This method gets the service instance name label (not the full name). + * Gets the service instance name label (not the full name). * * @returns The service instance name label string. * @@ -208,7 +208,7 @@ class Client : public InstanceLocator, private NonCopyable const char *GetInstanceName(void) const { return mInstanceName; } /** - * This method indicates whether or not the service has any subtypes. + * Indicates whether or not the service has any subtypes. * * @retval TRUE The service has at least one subtype. * @retval FALSE The service does not have any subtype. @@ -217,9 +217,9 @@ class Client : public InstanceLocator, private NonCopyable bool HasSubType(void) const { return (mSubTypeLabels != nullptr); } /** - * This method gets the subtype label at a given index. + * Gets the subtype label at a given index. * - * This method MUST be used only after `HasSubType()` indicates that service has a subtype. + * MUST be used only after `HasSubType()` indicates that service has a subtype. * * @param[in] aIndex The index into list of subtype labels. * @@ -230,7 +230,7 @@ class Client : public InstanceLocator, private NonCopyable const char *GetSubTypeLabelAt(uint16_t aIndex) const { return mSubTypeLabels[aIndex]; } /** - * This method gets the service port number. + * Gets the service port number. * * @returns The service port number. * @@ -238,7 +238,7 @@ class Client : public InstanceLocator, private NonCopyable uint16_t GetPort(void) const { return mPort; } /** - * This method gets the service priority. + * Gets the service priority. * * @returns The service priority. * @@ -246,7 +246,7 @@ class Client : public InstanceLocator, private NonCopyable uint16_t GetPriority(void) const { return mPriority; } /** - * This method gets the service weight. + * Gets the service weight. * * @returns The service weight. * @@ -254,7 +254,7 @@ class Client : public InstanceLocator, private NonCopyable uint16_t GetWeight(void) const { return mWeight; } /** - * This method gets the array of service TXT entries. + * Gets the array of service TXT entries. * * @returns A pointer to an array of service TXT entries. * @@ -262,7 +262,7 @@ class Client : public InstanceLocator, private NonCopyable const Dns::TxtEntry *GetTxtEntries(void) const { return AsCoreTypePtr(mTxtEntries); } /** - * This method gets the number of entries in the service TXT entry array. + * Gets the number of entries in the service TXT entry array. * * @returns The number of entries in the service TXT entry array. * @@ -270,7 +270,7 @@ class Client : public InstanceLocator, private NonCopyable uint8_t GetNumTxtEntries(void) const { return mNumTxtEntries; } /** - * This method gets the state of service. + * Gets the state of service. * * @returns The service state. * @@ -278,7 +278,7 @@ class Client : public InstanceLocator, private NonCopyable ItemState GetState(void) const { return static_cast(mState); } /** - * This method gets the desired lease interval to request when registering this service. + * Gets the desired lease interval to request when registering this service. * * @returns The desired lease interval in sec. Zero indicates to use default. * @@ -286,7 +286,7 @@ class Client : public InstanceLocator, private NonCopyable uint32_t GetLease(void) const { return (mLease & kLeaseMask); } /** - * This method gets the desired key lease interval to request when registering this service. + * Gets the desired key lease interval to request when registering this service. * * @returns The desired lease interval in sec. Zero indicates to use default. * @@ -314,7 +314,7 @@ class Client : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the SRP `Client` object. + * Initializes the SRP `Client` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -322,7 +322,7 @@ class Client : public InstanceLocator, private NonCopyable explicit Client(Instance &aInstance); /** - * This method starts the SRP client operation. + * Starts the SRP client operation. * * SRP client will prepare and send "SRP Update" message to the SRP server once all the following conditions are * met: @@ -348,9 +348,9 @@ class Client : public InstanceLocator, private NonCopyable Error Start(const Ip6::SockAddr &aServerSockAddr) { return Start(aServerSockAddr, kRequesterUser); } /** - * This method stops the SRP client operation. + * Stops the SRP client operation. * - * This method stops any further interactions with the SRP server. Note that it does not remove or clear host info + * Stops any further interactions with the SRP server. Note that it does not remove or clear host info * and/or list of services. It marks all services to be added/removed again once the client is started again. * * If `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE` (auto-start feature) is enabled, a call to this method @@ -361,14 +361,14 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE /** - * This function pointer type defines the callback used by SRP client to notify user when it is auto-started or + * Pointer type defines the callback used by SRP client to notify user when it is auto-started or * stopped. * */ typedef otSrpClientAutoStartCallback AutoStartCallback; /** - * This method enables the auto-start mode. + * Enables the auto-start mode. * * 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). @@ -406,7 +406,7 @@ class Client : public InstanceLocator, private NonCopyable void EnableAutoStartMode(AutoStartCallback aCallback, void *aContext); /** - * This method disables the auto-start mode. + * Disables the auto-start mode. * * Disabling the auto-start mode will not stop the client if it is already running but the client stops monitoring * the Thread Network Data to verify that the selected SRP server is still present in it. @@ -417,7 +417,7 @@ class Client : public InstanceLocator, private NonCopyable void DisableAutoStartMode(void) { mAutoStart.SetState(AutoStart::kDisabled); } /** - * This method indicates the current state of auto-start mode (enabled or disabled). + * Indicates the current state of auto-start mode (enabled or disabled). * * @returns TRUE if the auto-start mode is enabled, FALSE otherwise. * @@ -425,7 +425,7 @@ class Client : public InstanceLocator, private NonCopyable bool IsAutoStartModeEnabled(void) const { return mAutoStart.GetState() != AutoStart::kDisabled; } /** - * This method indicates whether or not the current SRP server's address is selected by auto-start. + * Indicates whether or not the current SRP server's address is selected by auto-start. * * @returns TRUE if the SRP server's address is selected by auto-start, FALSE otherwise. * @@ -434,7 +434,7 @@ class Client : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE /** - * This method indicates whether the SRP client is running or not. + * Indicates whether the SRP client is running or not. * * @returns TRUE if the SRP client is running, FALSE otherwise. * @@ -442,7 +442,7 @@ class Client : public InstanceLocator, private NonCopyable bool IsRunning(void) const { return (mState != kStateStopped); } /** - * This method gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP + * Gets the socket address (IPv6 address and port number) of the SRP server which is being used by SRP * client. * * If the client is not running, the address is unspecified (all zero) with zero port number. @@ -453,7 +453,7 @@ class Client : public InstanceLocator, private NonCopyable const Ip6::SockAddr &GetServerAddress(void) const { return mSocket.GetPeerName(); } /** - * This method sets the callback used to notify caller of events/changes. + * Sets the callback used to notify caller of events/changes. * * The SRP client allows a single callback to be registered. So consecutive calls to this method will overwrite any * previously set callback functions. @@ -465,7 +465,7 @@ class Client : public InstanceLocator, private NonCopyable void SetCallback(ClientCallback aCallback, void *aContext) { mCallback.Set(aCallback, aContext); } /** - * This method gets the TTL used in SRP update requests. + * Gets the TTL used in SRP update requests. * * Note that this is the TTL requested by the SRP client. The server may choose to accept a different TTL. * @@ -478,7 +478,7 @@ class Client : public InstanceLocator, private NonCopyable uint32_t GetTtl(void) const { return mTtl; } /** - * This method sets the TTL used in SRP update requests. + * Sets the TTL used in SRP update requests. * * Changing the TTL does not impact the TTL of already registered services/host-info. * It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services). @@ -490,7 +490,7 @@ class Client : public InstanceLocator, private NonCopyable void SetTtl(uint32_t aTtl) { mTtl = aTtl; } /** - * This method gets the lease interval used in SRP update requests. + * Gets the lease interval used in SRP update requests. * * Note that this is lease duration that would be requested by the SRP client. Server may choose to accept a * different lease interval. @@ -501,7 +501,7 @@ class Client : public InstanceLocator, private NonCopyable uint32_t GetLeaseInterval(void) const { return mDefaultLease; } /** - * This method sets the lease interval used in SRP update requests. + * Sets the lease interval used in SRP update requests. * * Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. * It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services). @@ -512,7 +512,7 @@ class Client : public InstanceLocator, private NonCopyable void SetLeaseInterval(uint32_t aInterval) { mDefaultLease = DetermineLeaseInterval(aInterval, kDefaultLease); } /** - * This method gets the key lease interval used in SRP update requests. + * Gets the key lease interval used in SRP update requests. * * @returns The key lease interval (in seconds). * @@ -520,7 +520,7 @@ class Client : public InstanceLocator, private NonCopyable uint32_t GetKeyLeaseInterval(void) const { return mDefaultKeyLease; } /** - * This method sets the key lease interval used in SRP update requests. + * Sets the key lease interval used in SRP update requests. * * Changing the lease interval does not impact the accepted lease interval of already registered services/host-info. * It only changes any future SRP update messages (i.e adding new services and/or refreshes of existing services). @@ -535,7 +535,7 @@ class Client : public InstanceLocator, private NonCopyable } /** - * This method gets the host info. + * Gets the host info. * * @returns A reference to host info structure. * @@ -543,7 +543,7 @@ class Client : public InstanceLocator, private NonCopyable const HostInfo &GetHostInfo(void) const { return mHostInfo; } /** - * This method sets the host name label. + * Sets the host name label. * * After a successful call to this method, `Callback` will be called to report the status of host info * registration with SRP server. @@ -562,7 +562,7 @@ class Client : public InstanceLocator, private NonCopyable Error SetHostName(const char *aName); /** - * This method enables auto host address mode. + * Enables auto host address mode. * * When enabled host IPv6 addresses are automatically set by SRP client using all the unicast addresses on Thread * netif excluding the link-local and mesh-local addresses. If there is no valid address, then Mesh Local EID @@ -583,7 +583,7 @@ class Client : public InstanceLocator, private NonCopyable Error EnableAutoHostAddress(void); /** - * This method sets/updates the list of host IPv6 address. + * Sets/updates the list of host IPv6 address. * * Host IPv6 addresses can be set/changed before start or even during operation of SRP client (e.g. to add/remove * or change a previously registered host address), except when the host info is being removed (client is busy @@ -608,7 +608,7 @@ class Client : public InstanceLocator, private NonCopyable Error SetHostAddresses(const Ip6::Address *aAddresses, uint8_t aNumAddresses); /** - * This method adds a service to be registered with server. + * Adds a service to be registered with server. * * After a successful call to this method, `Callback` will be called to report the status of the service * addition/registration with SRP server. @@ -625,7 +625,7 @@ class Client : public InstanceLocator, private NonCopyable Error AddService(Service &aService); /** - * This method removes a service to be unregistered with server. + * Removes a service to be unregistered with server. * * @param[in] aService A `Service` to remove (the instance must persist and remain unchanged after * successful return from this method). @@ -639,7 +639,7 @@ class Client : public InstanceLocator, private NonCopyable Error RemoveService(Service &aService); /** - * This method clears a service, immediately removing it from the client service list. + * Clears a service, immediately removing it from the client service list. * * Unlike `RemoveService()` which sends an update message to the server to remove the service, this method clears * the service from the client's service list without any interaction with the server. On a successful call @@ -655,7 +655,7 @@ class Client : public InstanceLocator, private NonCopyable Error ClearService(Service &aService); /** - * This method gets the list of services being managed by client. + * Gets the list of services being managed by client. * * @returns The list of services. * @@ -663,7 +663,7 @@ class Client : public InstanceLocator, private NonCopyable const LinkedList &GetServices(void) const { return mServices; } /** - * This method starts the remove process of the host info and all services. + * Starts the remove process of the host info and all services. * * After returning from this method, `Callback` will be called to report the status of remove request with * SRP server. @@ -697,7 +697,7 @@ class Client : public InstanceLocator, private NonCopyable Error RemoveHostAndServices(bool aShouldRemoveKeyLease, bool aSendUnregToServer = false); /** - * This method clears all host info and all the services. + * Clears all host info and all the services. * * Unlike `RemoveHostAndServices()` which sends an update message to the server to remove all the info, this method * clears all the info immediately without any interaction with the server. @@ -707,7 +707,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE /** - * This method gets the domain name being used by SRP client. + * Gets the domain name being used by SRP client. * * If domain name is not set, "default.service.arpa" will be used. * @@ -717,7 +717,7 @@ class Client : public InstanceLocator, private NonCopyable const char *GetDomainName(void) const { return mDomainName; } /** - * This method sets the domain name to be used by SRP client. + * Sets the domain name to be used by SRP client. * * This is an optional method. If not set "default.service.arpa" will be used. * @@ -734,7 +734,7 @@ class Client : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_SRP_CLIENT_DOMAIN_NAME_API_ENABLE /** - * This static method converts a `ItemState` to a string. + * Converts a `ItemState` to a string. * * @param[in] aState An `ItemState`. * @@ -745,7 +745,7 @@ class Client : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method enables/disables "service key record inclusion" mode. + * Enables/disables "service key record inclusion" mode. * * When enabled, SRP client will include KEY record in Service Description Instructions in the SRP update messages * that it sends. @@ -760,7 +760,7 @@ class Client : public InstanceLocator, private NonCopyable void SetServiceKeyRecordEnabled(bool aEnabled) { mServiceKeyRecordEnabled = aEnabled; } /** - * This method indicates whether the "service key record inclusion" mode is enabled or disabled. + * Indicates whether the "service key record inclusion" mode is enabled or disabled. * * @returns TRUE if "service key record inclusion" mode is enabled, FALSE otherwise. * @@ -768,12 +768,12 @@ class Client : public InstanceLocator, private NonCopyable bool IsServiceKeyRecordEnabled(void) const { return mServiceKeyRecordEnabled; } /** - * This method enables/disables "use short Update Lease Option" behavior. + * Enables/disables "use short Update Lease Option" behavior. * * When enabled, the SRP client will use the short variant format of Update Lease Option in its message. The short * format only includes the lease interval. * - * This method is added under `REFERENCE_DEVICE` config and is intended to override the default behavior for + * Is added under `REFERENCE_DEVICE` config and is intended to override the default behavior for * testing only. * * @param[in] aUseShort TRUE to enable, FALSE to disable the "use short Update Lease Option" mode. @@ -782,7 +782,7 @@ class Client : public InstanceLocator, private NonCopyable void SetUseShortLeaseOption(bool aUseShort) { mUseShortLeaseOption = aUseShort; } /** - * This method gets the current "use short Update Lease Option" mode. + * Gets the current "use short Update Lease Option" mode. * * @returns TRUE if "use short Update Lease Option" mode is enabled, FALSE otherwise. * @@ -858,7 +858,7 @@ class Client : public InstanceLocator, private NonCopyable // will retry after a short interval `kTxFailureRetryInterval` // up to `kMaxTxFailureRetries` attempts. After this, the retry // wait interval will be used (which keeps growing on each failure - // - please see bellow). + // - please see below). // // If the update message is sent successfully but there is no // response from server or if server rejects the update, the diff --git a/src/core/net/srp_server.cpp b/src/core/net/srp_server.cpp index 7125238fae4..9699d84aece 100644 --- a/src/core/net/srp_server.cpp +++ b/src/core/net/srp_server.cpp @@ -43,6 +43,7 @@ #include "common/new.hpp" #include "common/num_utils.hpp" #include "common/random.hpp" +#include "common/string.hpp" #include "net/dns_types.hpp" #include "thread/thread_netif.hpp" @@ -915,12 +916,14 @@ Error Server::ProcessServiceDiscoveryInstructions(Host &aHost, for (uint16_t numRecords = aMetadata.mDnsHeader.GetUpdateRecordCount(); numRecords > 0; numRecords--) { - char serviceName[Dns::Name::kMaxNameSize]; - char instanceName[Dns::Name::kMaxNameSize]; - Dns::PtrRecord ptrRecord; - const char *subServiceName; - Service *service; - bool isSubType; + char serviceName[Dns::Name::kMaxNameSize]; + char instanceLabel[Dns::Name::kMaxLabelSize]; + char instanceServiceName[Dns::Name::kMaxNameSize]; + String instanceName; + Dns::PtrRecord ptrRecord; + const char *subServiceName; + Service *service; + bool isSubType; SuccessOrExit(error = Dns::Name::ReadName(aMessage, offset, serviceName, sizeof(serviceName))); VerifyOrExit(Dns::Name::IsSubDomainOf(serviceName, GetDomain()), error = kErrorSecurity); @@ -937,7 +940,9 @@ Error Server::ProcessServiceDiscoveryInstructions(Host &aHost, SuccessOrExit(error); - SuccessOrExit(error = Dns::Name::ReadName(aMessage, offset, instanceName, sizeof(instanceName))); + SuccessOrExit(error = ptrRecord.ReadPtrName(aMessage, offset, instanceLabel, sizeof(instanceLabel), + instanceServiceName, sizeof(instanceServiceName))); + instanceName.Append("%s.%s", instanceLabel, instanceServiceName); VerifyOrExit(ptrRecord.GetClass() == Dns::ResourceRecord::kClassNone || ptrRecord.GetClass() == aMetadata.mDnsZone.GetClass(), @@ -957,13 +962,14 @@ Error Server::ProcessServiceDiscoveryInstructions(Host &aHost, } // Verify that instance name and service name are related. - VerifyOrExit(Dns::Name::IsSubDomainOf(instanceName, isSubType ? subServiceName : serviceName), + VerifyOrExit(Dns::Name::IsSubDomainOf(instanceName.AsCString(), isSubType ? subServiceName : serviceName), error = kErrorFailed); // Ensure the same service does not exist already. - VerifyOrExit(aHost.FindService(serviceName, instanceName) == nullptr, error = kErrorFailed); + VerifyOrExit(aHost.FindService(serviceName, instanceName.AsCString()) == nullptr, error = kErrorFailed); - service = aHost.AddNewService(serviceName, instanceName, isSubType, aMetadata.mRxTime); + service = + aHost.AddNewService(serviceName, instanceName.AsCString(), instanceLabel, isSubType, aMetadata.mRxTime); VerifyOrExit(service != nullptr, error = kErrorNoBufs); // This RR is a "Delete an RR from an RRset" update when the CLASS is NONE. @@ -1854,8 +1860,10 @@ void Server::Service::Log(Action) const {} //--------------------------------------------------------------------------------------------------------------------- // Server::Service::Description -Error Server::Service::Description::Init(const char *aInstanceName, Host &aHost) +Error Server::Service::Description::Init(const char *aInstanceName, const char *aInstanceLabel, Host &aHost) { + Error error; + mNext = nullptr; mHost = &aHost; mPriority = 0; @@ -1867,7 +1875,11 @@ Error Server::Service::Description::Init(const char *aInstanceName, Host &aHost) mUpdateTime = TimerMilli::GetNow().GetDistantPast(); mTxtData.Free(); - return mInstanceName.Set(aInstanceName); + SuccessOrExit(error = mInstanceLabel.Set(aInstanceLabel)); + error = mInstanceName.Set(aInstanceName); + +exit: + return error; } bool Server::Service::Description::Matches(const char *aInstanceName) const @@ -1994,7 +2006,7 @@ Error Server::Host::ProcessTtl(uint32_t aTtl) { // This method processes the TTL value received in a resource record. // - // If no TTL value is stored, this method wil set the stored value to @p aTtl and return `kErrorNone`. + // If no TTL value is stored, this method will set the stored value to @p aTtl and return `kErrorNone`. // If a TTL value is stored and @p aTtl equals the stored value, this method returns `kErrorNone`. // Otherwise, this method returns `kErrorRejected`. @@ -2042,6 +2054,7 @@ const Server::Service *Server::Host::FindNextService(const Service *aPrevService Server::Service *Server::Host::AddNewService(const char *aServiceName, const char *aInstanceName, + const char *aInstanceLabel, bool aIsSubType, TimeMilli aUpdateTime) { @@ -2050,7 +2063,7 @@ Server::Service *Server::Host::AddNewService(const char *aServiceName, if (desc == nullptr) { - desc.Reset(Service::Description::AllocateAndInit(aInstanceName, *this)); + desc.Reset(Service::Description::AllocateAndInit(aInstanceName, aInstanceLabel, *this)); VerifyOrExit(desc != nullptr); } @@ -2063,6 +2076,12 @@ Server::Service *Server::Host::AddNewService(const char *aServiceName, return service; } +Server::Service *Server::Host::AddNewService(const Service &aService, TimeMilli aUpdateTime) +{ + return AddNewService(aService.GetServiceName(), aService.GetInstanceName(), aService.GetInstanceLabel(), + aService.IsSubType(), aUpdateTime); +} + void Server::Host::RemoveService(Service *aService, RetainName aRetainName, NotifyMode aNotifyServiceHandler) { Server &server = Get(); @@ -2103,8 +2122,7 @@ Error Server::Host::AddCopyOfServiceAsDeletedIfNotPresent(const Service &aServic VerifyOrExit(FindService(aService.GetServiceName(), aService.GetInstanceName()) == nullptr); - newService = - AddNewService(aService.GetServiceName(), aService.GetInstanceName(), aService.IsSubType(), aUpdateTime); + newService = AddNewService(aService, aUpdateTime); VerifyOrExit(newService != nullptr, error = kErrorNoBufs); @@ -2156,9 +2174,7 @@ Error Server::Host::MergeServicesAndResourcesFrom(Host &aHost) // Add/Merge `service` into the existing service or a allocate a new one - newService = (existingService != nullptr) ? existingService - : AddNewService(service.GetServiceName(), service.GetInstanceName(), - service.IsSubType(), service.GetUpdateTime()); + newService = (existingService != nullptr) ? existingService : AddNewService(service, service.GetUpdateTime()); VerifyOrExit(newService != nullptr, error = kErrorNoBufs); diff --git a/src/core/net/srp_server.hpp b/src/core/net/srp_server.hpp index b88b136568c..ba5665b0cca 100644 --- a/src/core/net/srp_server.hpp +++ b/src/core/net/srp_server.hpp @@ -102,7 +102,7 @@ class RoutingManager; namespace Srp { /** - * This class implements the SRP server. + * Implements the SRP server. * */ class Server : public InstanceLocator, private NonCopyable @@ -147,7 +147,7 @@ class Server : public InstanceLocator, private NonCopyable typedef otSrpServerLeaseInfo LeaseInfo; /** - * This enumeration represents the address mode used by the SRP server. + * Represents the address mode used by the SRP server. * * Address mode specifies how the address and port number are determined by the SRP server and how this info ins * published in the Thread Network Data. @@ -162,7 +162,7 @@ class Server : public InstanceLocator, private NonCopyable class Host; /** - * This enumeration represents the state of SRP server. + * Represents the state of SRP server. * */ enum State : uint8_t @@ -173,7 +173,7 @@ class Server : public InstanceLocator, private NonCopyable }; /** - * This class implements a server-side SRP service. + * Implements a server-side SRP service. * */ class Service : public otSrpServerService, @@ -188,7 +188,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This type represents the flags which indicates which services to include or exclude when searching in (or + * Represents the flags which indicates which services to include or exclude when searching in (or * iterating over) the list of SRP services. * */ @@ -219,7 +219,7 @@ class Server : public InstanceLocator, private NonCopyable static constexpr Flags kFlagDeleted = OT_SRP_SERVER_SERVICE_FLAG_DELETED; /** - * This method tells if the SRP service has been deleted. + * Tells if the SRP service has been deleted. * * A SRP service can be deleted but retains its name for future uses. * In this case, the service instance is not removed from the SRP server/registry. @@ -231,7 +231,7 @@ class Server : public InstanceLocator, private NonCopyable bool IsDeleted(void) const { return mIsDeleted; } /** - * This method indicates whether the SRP service is a sub-type. + * Indicates whether the SRP service is a sub-type. * * @retval TRUE If the service is a sub-type. * @retval FALSE If the service is not a sub-type. @@ -240,15 +240,23 @@ class Server : public InstanceLocator, private NonCopyable bool IsSubType(void) const { return mIsSubType; } /** - * This method gets the full service instance name of the service. + * Gets the full service instance name of the service. * * @returns A pointer service instance name (as a null-terminated C string). * */ - const char *GetInstanceName(void) const { return mDescription->mInstanceName.AsCString(); } + const char *GetInstanceName(void) const { return mDescription->GetInstanceName(); } /** - * This method gets the full service name of the service. + * Gets the service instance label of the service. + * + * @returns A pointer service instance label (as a null-terminated C string). + * + */ + const char *GetInstanceLabel(void) const { return mDescription->GetInstanceLabel(); } + + /** + * Gets the full service name of the service. * * @returns A pointer service name (as a null-terminated C string). * @@ -256,7 +264,7 @@ class Server : public InstanceLocator, private NonCopyable const char *GetServiceName(void) const { return mServiceName.AsCString(); } /** - * This method gets the sub-type label from service name. + * Gets the sub-type label from service name. * * The full service name for a sub-type service follows "._sub...". This * method copies the `` into the @p aLabel buffer. @@ -275,7 +283,7 @@ class Server : public InstanceLocator, private NonCopyable Error GetServiceSubTypeLabel(char *aLabel, uint8_t aMaxSize) const; /** - * This method returns the TTL of the service instance. + * Returns the TTL of the service instance. * * @returns The TTL of the service instance. * @@ -283,7 +291,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetTtl(void) const { return mDescription->mTtl; } /** - * This method returns the port of the service instance. + * Returns the port of the service instance. * * @returns The port of the service. * @@ -291,7 +299,7 @@ class Server : public InstanceLocator, private NonCopyable uint16_t GetPort(void) const { return mDescription->mPort; } /** - * This method returns the weight of the service instance. + * Returns the weight of the service instance. * * @returns The weight of the service. * @@ -299,7 +307,7 @@ class Server : public InstanceLocator, private NonCopyable uint16_t GetWeight(void) const { return mDescription->mWeight; } /** - * This method returns the priority of the service instance. + * Returns the priority of the service instance. * * @returns The priority of the service. * @@ -307,7 +315,7 @@ class Server : public InstanceLocator, private NonCopyable uint16_t GetPriority(void) const { return mDescription->mPriority; } /** - * This method returns the TXT record data of the service instance. + * Returns the TXT record data of the service instance. * * @returns A pointer to the buffer containing the TXT record data. * @@ -315,7 +323,7 @@ class Server : public InstanceLocator, private NonCopyable const uint8_t *GetTxtData(void) const { return mDescription->mTxtData.GetBytes(); } /** - * This method returns the TXT record data length of the service instance. + * Returns the TXT record data length of the service instance. * * @return The TXT record data length (number of bytes in buffer returned from `GetTxtData()`). * @@ -323,7 +331,7 @@ class Server : public InstanceLocator, private NonCopyable uint16_t GetTxtDataLength(void) const { return mDescription->mTxtData.GetLength(); } /** - * This method returns the host which the service instance reside on. + * Returns the host which the service instance reside on. * * @returns A reference to the host instance. * @@ -331,7 +339,7 @@ class Server : public InstanceLocator, private NonCopyable const Host &GetHost(void) const { return *mDescription->mHost; } /** - * This method returns the LEASE time of the service. + * Returns the LEASE time of the service. * * @returns The LEASE time in seconds. * @@ -339,7 +347,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetLease(void) const { return mDescription->mLease; } /** - * This method returns the KEY-LEASE time of the key of the service. + * Returns the KEY-LEASE time of the key of the service. * * @returns The KEY-LEASE time in seconds. * @@ -347,7 +355,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetKeyLease(void) const { return mDescription->mKeyLease; } /** - * This method returns the expire time (in milliseconds) of the service. + * Returns the expire time (in milliseconds) of the service. * * @returns The service expire time in milliseconds. * @@ -355,7 +363,7 @@ class Server : public InstanceLocator, private NonCopyable TimeMilli GetExpireTime(void) const; /** - * This method returns the key expire time (in milliseconds) of the service. + * Returns the key expire time (in milliseconds) of the service. * * @returns The service key expire time in milliseconds. * @@ -363,7 +371,7 @@ class Server : public InstanceLocator, private NonCopyable TimeMilli GetKeyExpireTime(void) const; /** - * This method gets the LEASE and KEY-LEASE information of a given service. + * Gets the LEASE and KEY-LEASE information of a given service. * * @param[out] aLeaseInfo A reference to a LeaseInfo instance. It contains the LEASE time, KEY-LEASE time, * remaining LEASE time and the remaining KEY-LEASE time. @@ -372,7 +380,7 @@ class Server : public InstanceLocator, private NonCopyable void GetLeaseInfo(LeaseInfo &aLeaseInfo) const; /** - * This method indicates whether this service matches a given service instance name. + * Indicates whether this service matches a given service instance name. * * @param[in] aInstanceName The service instance name. * @@ -383,7 +391,7 @@ class Server : public InstanceLocator, private NonCopyable bool MatchesInstanceName(const char *aInstanceName) const; /** - * This method tells whether this service matches a given service name. + * Tells whether this service matches a given service name. * * @param[in] aServiceName The full service name to match. * @@ -399,8 +407,9 @@ class Server : public InstanceLocator, private NonCopyable public RetainCountable, private NonCopyable { - Error Init(const char *aInstanceName, Host &aHost); + Error Init(const char *aInstanceName, const char *aInstanceLabel, Host &aHost); const char *GetInstanceName(void) const { return mInstanceName.AsCString(); } + const char *GetInstanceLabel(void) const { return mInstanceLabel.AsCString(); } bool Matches(const char *aInstanceName) const; void ClearResources(void); void TakeResourcesFrom(Description &aDescription); @@ -408,6 +417,7 @@ class Server : public InstanceLocator, private NonCopyable Description *mNext; Heap::String mInstanceName; + Heap::String mInstanceLabel; Host *mHost; Heap::Data mTxtData; uint16_t mPriority; @@ -444,7 +454,7 @@ class Server : public InstanceLocator, private NonCopyable }; /** - * This class implements the Host which registers services on the SRP server. + * Implements the Host which registers services on the SRP server. * */ class Host : public otSrpServerHost, @@ -459,7 +469,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This method tells whether the Host object has been deleted. + * Tells whether the Host object has been deleted. * * The Host object retains event if the host has been deleted by the SRP client, * because the host name may retain. @@ -470,7 +480,7 @@ class Server : public InstanceLocator, private NonCopyable bool IsDeleted(void) const { return (mLease == 0); } /** - * This method returns the full name of the host. + * Returns the full name of the host. * * @returns A pointer to the null-terminated full host name. * @@ -478,7 +488,7 @@ class Server : public InstanceLocator, private NonCopyable const char *GetFullName(void) const { return mFullName.AsCString(); } /** - * This method returns addresses of the host. + * Returns addresses of the host. * * @param[out] aAddressesNum The number of the addresses. * @@ -493,7 +503,7 @@ class Server : public InstanceLocator, private NonCopyable } /** - * This method returns the TTL of the host. + * Returns the TTL of the host. * * @returns The TTL of the host. * @@ -501,7 +511,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetTtl(void) const { return mTtl; } /** - * This method returns the LEASE time of the host. + * Returns the LEASE time of the host. * * @returns The LEASE time in seconds. * @@ -509,7 +519,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetLease(void) const { return mLease; } /** - * This method returns the KEY-LEASE time of the key of the host. + * Returns the KEY-LEASE time of the key of the host. * * @returns The KEY-LEASE time in seconds. * @@ -517,7 +527,7 @@ class Server : public InstanceLocator, private NonCopyable uint32_t GetKeyLease(void) const { return mKeyLease; } /** - * This method gets the LEASE and KEY-LEASE information of a given host. + * Gets the LEASE and KEY-LEASE information of a given host. * * @param[out] aLeaseInfo A reference to a LeaseInfo instance. It contains the LEASE time, KEY-LEASE time, * remaining LEASE time and the remaining KEY-LEASE time. @@ -526,7 +536,7 @@ class Server : public InstanceLocator, private NonCopyable void GetLeaseInfo(LeaseInfo &aLeaseInfo) const; /** - * This method returns the KEY resource record of the host. + * Returns the KEY resource record of the host. * * @returns A pointer to the ECDSA P 256 public key resource record * if there is valid one. `nullptr` if no valid key exists. @@ -535,7 +545,7 @@ class Server : public InstanceLocator, private NonCopyable const Dns::Ecdsa256KeyRecord *GetKeyRecord(void) const { return mKeyRecord.IsValid() ? &mKeyRecord : nullptr; } /** - * This method returns the expire time (in milliseconds) of the host. + * Returns the expire time (in milliseconds) of the host. * * @returns The expire time in milliseconds. * @@ -543,7 +553,7 @@ class Server : public InstanceLocator, private NonCopyable TimeMilli GetExpireTime(void) const; /** - * This method returns the expire time (in milliseconds) of the key of the host. + * Returns the expire time (in milliseconds) of the key of the host. * * @returns The expire time of the key in milliseconds. * @@ -551,7 +561,7 @@ class Server : public InstanceLocator, private NonCopyable TimeMilli GetKeyExpireTime(void) const; /** - * This method returns the `Service` linked list associated with the host. + * Returns the `Service` linked list associated with the host. * * @returns The `Service` linked list. * @@ -559,7 +569,7 @@ class Server : public InstanceLocator, private NonCopyable const LinkedList &GetServices(void) const { return mServices; } /** - * This method finds the next matching service on the host. + * Finds the next matching service on the host. * * @param[in] aPrevService A pointer to the previous service or `nullptr` to start from beginning of the list. * @param[in] aFlags Flags indicating which services to include (base/sub-type, active/deleted). @@ -575,7 +585,7 @@ class Server : public InstanceLocator, private NonCopyable const char *aInstanceName = nullptr) const; /** - * This method tells whether the host matches a given full name. + * Tells whether the host matches a given full name. * * @param[in] aFullName The full name. * @@ -600,8 +610,10 @@ class Server : public InstanceLocator, private NonCopyable LinkedList &GetServices(void) { return mServices; } Service *AddNewService(const char *aServiceName, const char *aInstanceName, + const char *aInstanceLabel, bool aIsSubType, TimeMilli aUpdateTime); + Service *AddNewService(const Service &aService, TimeMilli aUpdateTime); void RemoveService(Service *aService, RetainName aRetainName, NotifyMode aNotifyServiceHandler); Error AddCopyOfServiceAsDeletedIfNotPresent(const Service &aService, TimeMilli aUpdateTime); void FreeAllServices(void); @@ -632,7 +644,7 @@ class Server : public InstanceLocator, private NonCopyable }; /** - * This class handles TTL configuration. + * Handles TTL configuration. * */ class TtlConfig : public otSrpServerTtlConfig @@ -641,7 +653,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes to default TTL configuration. + * Initializes to default TTL configuration. * */ TtlConfig(void); @@ -652,7 +664,7 @@ class Server : public InstanceLocator, private NonCopyable }; /** - * This class handles LEASE and KEY-LEASE configurations. + * Handles LEASE and KEY-LEASE configurations. * */ class LeaseConfig : public otSrpServerLeaseConfig @@ -661,7 +673,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This constructor initialize to default LEASE and KEY-LEASE configurations. + * Initialize to default LEASE and KEY-LEASE configurations. * */ LeaseConfig(void); @@ -703,7 +715,7 @@ class Server : public InstanceLocator, private NonCopyable static constexpr Service::Flags kFlagsAnyTypeDeletedService = OT_SRP_SERVER_FLAGS_ANY_TYPE_DELETED_SERVICE; /** - * This constructor initializes the SRP server object. + * Initializes the SRP server object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -711,7 +723,7 @@ class Server : public InstanceLocator, private NonCopyable explicit Server(Instance &aInstance); /** - * This method sets the SRP service events handler. + * Sets the SRP service events handler. * * @param[in] aServiceHandler A service events handler. * @param[in] aServiceHandlerContext A pointer to arbitrary context information. @@ -728,7 +740,7 @@ class Server : public InstanceLocator, private NonCopyable } /** - * This method returns the domain authorized to the SRP server. + * Returns the domain authorized to the SRP server. * * If the domain if not set by SetDomain, "default.service.arpa." will be returned. * A trailing dot is always appended even if the domain is set without it. @@ -739,10 +751,10 @@ class Server : public InstanceLocator, private NonCopyable const char *GetDomain(void) const { return mDomain.AsCString(); } /** - * This method sets the domain on the SRP server. + * Sets the domain on the SRP server. * * A trailing dot will be appended to @p aDomain if it is not already there. - * This method should only be called before the SRP server is enabled. + * Should only be called before the SRP server is enabled. * * @param[in] aDomain The domain to be set. MUST NOT be `nullptr`. * @@ -755,7 +767,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetDomain(const char *aDomain); /** - * This method returns the address mode being used by the SRP server. + * Returns the address mode being used by the SRP server. * * @returns The SRP server's address mode. * @@ -763,7 +775,7 @@ class Server : public InstanceLocator, private NonCopyable AddressMode GetAddressMode(void) const { return mAddressMode; } /** - * This method sets the address mode to be used by the SRP server. + * Sets the address mode to be used by the SRP server. * * @param[in] aMode The address mode to use. * @@ -774,7 +786,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetAddressMode(AddressMode aMode); /** - * This method gets the sequence number used with anycast address mode. + * Gets the sequence number used with anycast address mode. * * The sequence number is included in "DNS/SRP Service Anycast Address" entry published in the Network Data. * @@ -784,7 +796,7 @@ class Server : public InstanceLocator, private NonCopyable uint8_t GetAnycastModeSequenceNumber(void) const { return mAnycastSequenceNumber; } /** - * This method sets the sequence number used with anycast address mode. + * Sets the sequence number used with anycast address mode. * * @param[in] aSequenceNumber The sequence number to use. * @@ -795,7 +807,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetAnycastModeSequenceNumber(uint8_t aSequenceNumber); /** - * This method returns the state of the SRP server. + * Returns the state of the SRP server. * * @returns The state of the server. * @@ -803,7 +815,7 @@ class Server : public InstanceLocator, private NonCopyable State GetState(void) const { return mState; } /** - * This method tells the port the SRP server is listening to. + * Tells the port the SRP server is listening to. * * @returns The port of the server or 0 if the SRP server is not running. * @@ -811,7 +823,7 @@ class Server : public InstanceLocator, private NonCopyable uint16_t GetPort(void) const { return (mState == kStateRunning) ? mPort : 0; } /** - * This method enables/disables the SRP server. + * Enables/disables the SRP server. * * @param[in] aEnabled A boolean to enable/disable the SRP server. * @@ -820,7 +832,7 @@ class Server : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE /** - * This method enables/disables the auto-enable mode on SRP server. + * Enables/disables the auto-enable mode on SRP server. * * 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 it is done with the initial prefix and route @@ -838,7 +850,7 @@ class Server : public InstanceLocator, private NonCopyable void SetAutoEnableMode(bool aEnabled); /** - * This method indicates whether the auto-enable mode is enabled or disabled. + * Indicates whether the auto-enable mode is enabled or disabled. * * @retval TRUE The auto-enable mode is enabled. * @retval FALSE The auto-enable mode is disabled. @@ -848,7 +860,7 @@ class Server : public InstanceLocator, private NonCopyable #endif /** - * This method returns the TTL configuration. + * Returns the TTL configuration. * * @param[out] aTtlConfig A reference to the `TtlConfig` instance. * @@ -856,7 +868,7 @@ class Server : public InstanceLocator, private NonCopyable void GetTtlConfig(TtlConfig &aTtlConfig) const { aTtlConfig = mTtlConfig; } /** - * This method sets the TTL configuration. + * Sets the TTL configuration. * * @param[in] aTtlConfig A reference to the `TtlConfig` instance. * @@ -867,7 +879,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetTtlConfig(const TtlConfig &aTtlConfig); /** - * This method returns the LEASE and KEY-LEASE configurations. + * Returns the LEASE and KEY-LEASE configurations. * * @param[out] aLeaseConfig A reference to the `LeaseConfig` instance. * @@ -875,7 +887,7 @@ class Server : public InstanceLocator, private NonCopyable void GetLeaseConfig(LeaseConfig &aLeaseConfig) const { aLeaseConfig = mLeaseConfig; } /** - * This method sets the LEASE and KEY-LEASE configurations. + * Sets the LEASE and KEY-LEASE configurations. * * When a LEASE time is requested from a client, the granted value will be * limited in range [aMinLease, aMaxLease]; and a KEY-LEASE will be granted @@ -890,7 +902,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetLeaseConfig(const LeaseConfig &aLeaseConfig); /** - * This method returns the next registered SRP host. + * Returns the next registered SRP host. * * @param[in] aHost The current SRP host; use `nullptr` to get the first SRP host. * @@ -900,7 +912,7 @@ class Server : public InstanceLocator, private NonCopyable const Host *GetNextHost(const Host *aHost); /** - * This method returns the response counters of the SRP server. + * Returns the response counters of the SRP server. * * @returns A pointer to the response counters of the SRP server. * @@ -908,7 +920,7 @@ class Server : public InstanceLocator, private NonCopyable const otSrpServerResponseCounters *GetResponseCounters(void) const { return &mResponseCounters; } /** - * This method receives the service update result from service handler set by + * Receives the service update result from service handler set by * SetServiceHandler. * * @param[in] aId The ID of the service update transaction. diff --git a/src/core/net/tcp6.cpp b/src/core/net/tcp6.cpp index 47c50278ed8..7c9b1d3cccb 100644 --- a/src/core/net/tcp6.cpp +++ b/src/core/net/tcp6.cpp @@ -1114,7 +1114,7 @@ bool tcplp_sys_autobind(otInstance *aInstance, uint32_t tcplp_sys_generate_isn() { uint32_t isn; - IgnoreError(Random::Crypto::FillBuffer(reinterpret_cast(&isn), sizeof(isn))); + IgnoreError(Random::Crypto::Fill(isn)); return isn; } diff --git a/src/core/net/tcp6.hpp b/src/core/net/tcp6.hpp index ec407deaded..36812064557 100644 --- a/src/core/net/tcp6.hpp +++ b/src/core/net/tcp6.hpp @@ -82,14 +82,14 @@ namespace Ip6 { */ /** - * This class implements TCP message handling. + * Implements TCP message handling. * */ class Tcp : public InstanceLocator, private NonCopyable { public: /** - * This class represents an endpoint of a TCP/IPv6 connection. + * Represents an endpoint of a TCP/IPv6 connection. * */ class Endpoint : public otTcpEndpoint, public LinkedListEntry, public GetProvider @@ -408,7 +408,7 @@ class Tcp : public InstanceLocator, private NonCopyable }; /** - * This class represents a TCP/IPv6 listener. + * Represents a TCP/IPv6 listener. * */ class Listener : public otTcpListener, public LinkedListEntry, public GetProvider @@ -535,7 +535,7 @@ class Tcp : public InstanceLocator, private NonCopyable }; /** - * This class implements TCP header parsing. + * Implements TCP header parsing. * */ OT_TOOL_PACKED_BEGIN @@ -545,7 +545,7 @@ class Tcp : public InstanceLocator, private NonCopyable static constexpr uint8_t kChecksumFieldOffset = 16; ///< Byte offset of the Checksum field in the TCP header. /** - * This method returns the TCP Source Port. + * Returns the TCP Source Port. * * @returns The TCP Source Port. * @@ -553,7 +553,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint16_t GetSourcePort(void) const { return HostSwap16(mSource); } /** - * This method returns the TCP Destination Port. + * Returns the TCP Destination Port. * * @returns The TCP Destination Port. * @@ -561,7 +561,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint16_t GetDestinationPort(void) const { return HostSwap16(mDestination); } /** - * This method returns the TCP Sequence Number. + * Returns the TCP Sequence Number. * * @returns The TCP Sequence Number. * @@ -569,7 +569,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint32_t GetSequenceNumber(void) const { return HostSwap32(mSequenceNumber); } /** - * This method returns the TCP Acknowledgment Sequence Number. + * Returns the TCP Acknowledgment Sequence Number. * * @returns The TCP Acknowledgment Sequence Number. * @@ -577,7 +577,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint32_t GetAcknowledgmentNumber(void) const { return HostSwap32(mAckNumber); } /** - * This method returns the TCP Flags. + * Returns the TCP Flags. * * @returns The TCP Flags. * @@ -585,7 +585,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint16_t GetFlags(void) const { return HostSwap16(mFlags); } /** - * This method returns the TCP Window. + * Returns the TCP Window. * * @returns The TCP Window. * @@ -593,7 +593,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint16_t GetWindow(void) const { return HostSwap16(mWindow); } /** - * This method returns the TCP Checksum. + * Returns the TCP Checksum. * * @returns The TCP Checksum. * @@ -601,7 +601,7 @@ class Tcp : public InstanceLocator, private NonCopyable uint16_t GetChecksum(void) const { return HostSwap16(mChecksum); } /** - * This method returns the TCP Urgent Pointer. + * Returns the TCP Urgent Pointer. * * @returns The TCP Urgent Pointer. * @@ -620,7 +620,7 @@ class Tcp : public InstanceLocator, private NonCopyable } OT_TOOL_PACKED_END; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * diff --git a/src/core/net/tcp6_ext.hpp b/src/core/net/tcp6_ext.hpp index b40663aedb2..395576cbead 100644 --- a/src/core/net/tcp6_ext.hpp +++ b/src/core/net/tcp6_ext.hpp @@ -54,7 +54,7 @@ namespace Ip6 { */ /** - * This class represents a TCP circular send buffer. + * Represents a TCP circular send buffer. * */ class TcpCircularSendBuffer : public otTcpCircularSendBuffer diff --git a/src/core/net/udp6.hpp b/src/core/net/udp6.hpp index 6648f00728a..8f7460a50f7 100644 --- a/src/core/net/udp6.hpp +++ b/src/core/net/udp6.hpp @@ -67,7 +67,7 @@ class Udp; #endif /** - * This enumeration defines the network interface identifiers. + * Defines the network interface identifiers. * */ enum NetifIdentifier : uint8_t @@ -78,14 +78,14 @@ enum NetifIdentifier : uint8_t }; /** - * This class implements core UDP message handling. + * Implements core UDP message handling. * */ class Udp : public InstanceLocator, private NonCopyable { public: /** - * This class implements a UDP/IPv6 socket. + * Implements a UDP/IPv6 socket. * */ class SocketHandle : public otUdpSocket, public LinkedListEntry, public Clearable @@ -95,7 +95,7 @@ class Udp : public InstanceLocator, private NonCopyable public: /** - * This method indicates whether or not the socket is bound. + * Indicates whether or not the socket is bound. * * @retval TRUE if the socket is bound (i.e. source port is non-zero). * @retval FALSE if the socket is not bound (source port is zero). @@ -104,7 +104,7 @@ class Udp : public InstanceLocator, private NonCopyable bool IsBound(void) const { return mSockName.mPort != 0; } /** - * This method returns the local socket address. + * Returns the local socket address. * * @returns A reference to the local socket address. * @@ -112,7 +112,7 @@ class Udp : public InstanceLocator, private NonCopyable SockAddr &GetSockName(void) { return AsCoreType(&mSockName); } /** - * This method returns the local socket address. + * Returns the local socket address. * * @returns A reference to the local socket address. * @@ -120,7 +120,7 @@ class Udp : public InstanceLocator, private NonCopyable const SockAddr &GetSockName(void) const { return AsCoreType(&mSockName); } /** - * This method returns the peer's socket address. + * Returns the peer's socket address. * * @returns A reference to the peer's socket address. * @@ -128,7 +128,7 @@ class Udp : public InstanceLocator, private NonCopyable SockAddr &GetPeerName(void) { return AsCoreType(&mPeerName); } /** - * This method returns the peer's socket address. + * Returns the peer's socket address. * * @returns A reference to the peer's socket address. * @@ -145,7 +145,7 @@ class Udp : public InstanceLocator, private NonCopyable }; /** - * This class implements a UDP/IPv6 socket. + * Implements a UDP/IPv6 socket. * */ class Socket : public InstanceLocator, public SocketHandle @@ -154,7 +154,7 @@ class Udp : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to OpenThread instance. * @@ -162,7 +162,7 @@ class Udp : public InstanceLocator, private NonCopyable explicit Socket(Instance &aInstance); /** - * This method returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) + * Returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) * * @returns A pointer to the message or `nullptr` if no buffers are available. * @@ -170,7 +170,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) + * Returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) * * @param[in] aReserved The number of header bytes to reserve after the UDP header. * @@ -180,7 +180,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved); /** - * This method returns a new UDP message with sufficient header space reserved. + * Returns a new UDP message with sufficient header space reserved. * * @param[in] aReserved The number of header bytes to reserve after the UDP header. * @param[in] aSettings The message settings (default is used if not provided). @@ -191,7 +191,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved, const Message::Settings &aSettings); /** - * This method opens the UDP socket. + * Opens the UDP socket. * * @param[in] aHandler A pointer to a function that is called when receiving UDP messages. * @param[in] aContext A pointer to arbitrary context information. @@ -203,7 +203,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Open(otUdpReceive aHandler, void *aContext); /** - * This method returns if the UDP socket is open. + * Returns if the UDP socket is open. * * @returns If the UDP socket is open. * @@ -211,7 +211,7 @@ class Udp : public InstanceLocator, private NonCopyable bool IsOpen(void) const; /** - * This method binds the UDP socket. + * Binds the UDP socket. * * @param[in] aSockAddr A reference to the socket address. * @param[in] aNetifIdentifier The network interface identifier. @@ -224,7 +224,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Bind(const SockAddr &aSockAddr, NetifIdentifier aNetifIdentifier = kNetifThread); /** - * This method binds the UDP socket. + * Binds the UDP socket. * * @param[in] aPort A port number. * @param[in] aNetifIdentifier The network interface identifier. @@ -236,7 +236,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Bind(uint16_t aPort, NetifIdentifier aNetifIdentifier = kNetifThread); /** - * This method binds the UDP socket. + * Binds the UDP socket. * * @retval kErrorNone Successfully bound the socket. * @retval kErrorFailed Failed to bind UDP Socket. @@ -245,7 +245,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Bind(void) { return Bind(0); } /** - * This method connects the UDP socket. + * Connects the UDP socket. * * @param[in] aSockAddr A reference to the socket address. * @@ -256,7 +256,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Connect(const SockAddr &aSockAddr); /** - * This method connects the UDP socket. + * Connects the UDP socket. * * @param[in] aPort A port number. * @@ -267,7 +267,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Connect(uint16_t aPort); /** - * This method connects the UDP socket. + * Connects the UDP socket. * * @retval kErrorNone Successfully connected the socket. * @retval kErrorFailed Failed to connect UDP Socket. @@ -276,7 +276,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Connect(void) { return Connect(0); } /** - * This method closes the UDP socket. + * Closes the UDP socket. * * @retval kErrorNone Successfully closed the UDP socket. * @retval kErrorFailed Failed to close UDP Socket. @@ -285,7 +285,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Close(void); /** - * This method sends a UDP message. + * Sends a UDP message. * * @param[in] aMessage The message to send. * @param[in] aMessageInfo The message info associated with @p aMessage. @@ -299,7 +299,7 @@ class Udp : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE /** - * This method configures the UDP socket to join a multicast group on a Host network interface. + * Configures the UDP socket to join a multicast group on a Host network interface. * * @param[in] aNetifIdentifier The network interface identifier. * @param[in] aAddress The multicast group address. @@ -311,7 +311,7 @@ class Udp : public InstanceLocator, private NonCopyable Error JoinNetifMulticastGroup(NetifIdentifier aNetifIdentifier, const Address &aAddress); /** - * This method configures the UDP socket to leave a multicast group on a Host network interface. + * Configures the UDP socket to leave a multicast group on a Host network interface. * * @param[in] aNetifIdentifier The network interface identifier. * @param[in] aAddress The multicast group address. @@ -325,7 +325,7 @@ class Udp : public InstanceLocator, private NonCopyable }; /** - * This class implements a UDP receiver. + * Implements a UDP receiver. * */ class Receiver : public otUdpReceiver, public LinkedListEntry @@ -334,7 +334,7 @@ class Udp : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the UDP receiver. + * Initializes the UDP receiver. * * @param[in] aHandler A pointer to the function to handle UDP message. * @param[in] aContext A pointer to arbitrary context information. @@ -355,7 +355,7 @@ class Udp : public InstanceLocator, private NonCopyable }; /** - * This class implements UDP header generation and parsing. + * Implements UDP header generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -368,7 +368,7 @@ class Udp : public InstanceLocator, private NonCopyable static constexpr uint16_t kChecksumFieldOffset = 6; ///< Byte offset of Checksum field in UDP header. /** - * This method returns the UDP Source Port. + * Returns the UDP Source Port. * * @returns The UDP Source Port. * @@ -376,7 +376,7 @@ class Udp : public InstanceLocator, private NonCopyable uint16_t GetSourcePort(void) const { return HostSwap16(mSourcePort); } /** - * This method sets the UDP Source Port. + * Sets the UDP Source Port. * * @param[in] aPort The UDP Source Port. * @@ -384,7 +384,7 @@ class Udp : public InstanceLocator, private NonCopyable void SetSourcePort(uint16_t aPort) { mSourcePort = HostSwap16(aPort); } /** - * This method returns the UDP Destination Port. + * Returns the UDP Destination Port. * * @returns The UDP Destination Port. * @@ -392,7 +392,7 @@ class Udp : public InstanceLocator, private NonCopyable uint16_t GetDestinationPort(void) const { return HostSwap16(mDestinationPort); } /** - * This method sets the UDP Destination Port. + * Sets the UDP Destination Port. * * @param[in] aPort The UDP Destination Port. * @@ -400,7 +400,7 @@ class Udp : public InstanceLocator, private NonCopyable void SetDestinationPort(uint16_t aPort) { mDestinationPort = HostSwap16(aPort); } /** - * This method returns the UDP Length. + * Returns the UDP Length. * * @returns The UDP Length. * @@ -408,7 +408,7 @@ class Udp : public InstanceLocator, private NonCopyable uint16_t GetLength(void) const { return HostSwap16(mLength); } /** - * This method sets the UDP Length. + * Sets the UDP Length. * * @param[in] aLength The UDP Length. * @@ -416,7 +416,7 @@ class Udp : public InstanceLocator, private NonCopyable void SetLength(uint16_t aLength) { mLength = HostSwap16(aLength); } /** - * This method returns the UDP Checksum. + * Returns the UDP Checksum. * * @returns The UDP Checksum. * @@ -424,7 +424,7 @@ class Udp : public InstanceLocator, private NonCopyable uint16_t GetChecksum(void) const { return HostSwap16(mChecksum); } /** - * This method sets the UDP Checksum. + * Sets the UDP Checksum. * * @param[in] aChecksum The UDP Checksum. * @@ -440,7 +440,7 @@ class Udp : public InstanceLocator, private NonCopyable } OT_TOOL_PACKED_END; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to OpenThread instance. * @@ -448,7 +448,7 @@ class Udp : public InstanceLocator, private NonCopyable explicit Udp(Instance &aInstance); /** - * This method adds a UDP receiver. + * Adds a UDP receiver. * * @param[in] aReceiver A reference to the UDP receiver. * @@ -459,7 +459,7 @@ class Udp : public InstanceLocator, private NonCopyable Error AddReceiver(Receiver &aReceiver); /** - * This method removes a UDP receiver. + * Removes a UDP receiver. * * @param[in] aReceiver A reference to the UDP receiver. * @@ -470,7 +470,7 @@ class Udp : public InstanceLocator, private NonCopyable Error RemoveReceiver(Receiver &aReceiver); /** - * This method opens a UDP socket. + * Opens a UDP socket. * * @param[in] aSocket A reference to the socket. * @param[in] aHandler A pointer to a function that is called when receiving UDP messages. @@ -483,7 +483,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Open(SocketHandle &aSocket, otUdpReceive aHandler, void *aContext); /** - * This method returns if a UDP socket is open. + * Returns if a UDP socket is open. * * @param[in] aSocket A reference to the socket. * @@ -493,7 +493,7 @@ class Udp : public InstanceLocator, private NonCopyable bool IsOpen(const SocketHandle &aSocket) const { return mSockets.Contains(aSocket); } /** - * This method binds a UDP socket. + * Binds a UDP socket. * * @param[in] aSocket A reference to the socket. * @param[in] aSockAddr A reference to the socket address. @@ -507,7 +507,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Bind(SocketHandle &aSocket, const SockAddr &aSockAddr, NetifIdentifier aNetifIdentifier); /** - * This method connects a UDP socket. + * Connects a UDP socket. * * @param[in] aSocket A reference to the socket. * @param[in] aSockAddr A reference to the socket address. @@ -519,7 +519,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Connect(SocketHandle &aSocket, const SockAddr &aSockAddr); /** - * This method closes the UDP socket. + * Closes the UDP socket. * * @param[in] aSocket A reference to the socket. * @@ -530,7 +530,7 @@ class Udp : public InstanceLocator, private NonCopyable Error Close(SocketHandle &aSocket); /** - * This method sends a UDP message using a socket. + * Sends a UDP message using a socket. * * @param[in] aSocket A reference to the socket. * @param[in] aMessage The message to send. @@ -544,7 +544,7 @@ class Udp : public InstanceLocator, private NonCopyable Error SendTo(SocketHandle &aSocket, Message &aMessage, const MessageInfo &aMessageInfo); /** - * This method returns a new ephemeral port. + * Returns a new ephemeral port. * * @returns A new ephemeral port. * @@ -552,7 +552,7 @@ class Udp : public InstanceLocator, private NonCopyable uint16_t GetEphemeralPort(void); /** - * This method returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) + * Returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) * * @returns A pointer to the message or `nullptr` if no buffers are available. * @@ -560,7 +560,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(void); /** - * This method returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) + * Returns a new UDP message with default settings (link security enabled and `kPriorityNormal`) * * @param[in] aReserved The number of header bytes to reserve after the UDP header. * @@ -570,7 +570,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved); /** - * This method returns a new UDP message with sufficient header space reserved. + * Returns a new UDP message with sufficient header space reserved. * * @param[in] aReserved The number of header bytes to reserve after the UDP header. * @param[in] aSettings The message settings. @@ -581,7 +581,7 @@ class Udp : public InstanceLocator, private NonCopyable Message *NewMessage(uint16_t aReserved, const Message::Settings &aSettings); /** - * This method sends an IPv6 datagram. + * Sends an IPv6 datagram. * * @param[in] aMessage A reference to the message. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -594,7 +594,7 @@ class Udp : public InstanceLocator, private NonCopyable Error SendDatagram(Message &aMessage, MessageInfo &aMessageInfo, uint8_t aIpProto); /** - * This method handles a received UDP message. + * Handles a received UDP message. * * @param[in] aMessage A reference to the UDP message to process. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -606,7 +606,7 @@ class Udp : public InstanceLocator, private NonCopyable Error HandleMessage(Message &aMessage, MessageInfo &aMessageInfo); /** - * This method handles a received UDP message with offset set to the payload. + * Handles a received UDP message with offset set to the payload. * * @param[in] aMessage A reference to the UDP message to process. * @param[in] aMessageInfo A reference to the message info associated with @p aMessage. @@ -615,7 +615,7 @@ class Udp : public InstanceLocator, private NonCopyable void HandlePayload(Message &aMessage, MessageInfo &aMessageInfo); /** - * This method returns the head of UDP Sockets list. + * Returns the head of UDP Sockets list. * * @returns A pointer to the head of UDP Socket linked list. * @@ -624,7 +624,7 @@ class Udp : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE /** - * This method sets the forward sender. + * Sets the forward sender. * * @param[in] aForwarder A function pointer to forward UDP packets. * @param[in] aContext A pointer to arbitrary context information. @@ -634,7 +634,7 @@ class Udp : public InstanceLocator, private NonCopyable #endif /** - * This method returns whether a udp port is being used by OpenThread or any of it's optional + * Returns whether a udp port is being used by OpenThread or any of it's optional * features, e.g. CoAP API. * * @param[in] aPort The udp port @@ -646,7 +646,7 @@ class Udp : public InstanceLocator, private NonCopyable bool IsPortInUse(uint16_t aPort) const; /** - * This method returns whether a udp port belongs to the platform or the stack. + * Returns whether a udp port belongs to the platform or the stack. * * @param[in] aPort The udp port * diff --git a/src/core/openthread-core-config.h b/src/core/openthread-core-config.h index 2b4127dccbf..b7bff4ed187 100644 --- a/src/core/openthread-core-config.h +++ b/src/core/openthread-core-config.h @@ -84,6 +84,7 @@ #include "config/logging.h" #include "config/mac.h" #include "config/mesh_diag.h" +#include "config/mesh_forwarder.h" #include "config/misc.h" #include "config/mle.h" #include "config/nat64.h" diff --git a/src/core/radio/max_power_table.hpp b/src/core/radio/max_power_table.hpp index 7b38d9c21cf..4fe09f8f057 100644 --- a/src/core/radio/max_power_table.hpp +++ b/src/core/radio/max_power_table.hpp @@ -42,7 +42,7 @@ class MaxPowerTable MaxPowerTable(void) { memset(mPowerTable, kPowerDefault, sizeof(mPowerTable)); } /** - * This method gets the max allowed transmit power of channel @p aChannel. + * Gets the max allowed transmit power of channel @p aChannel. * * @param[in] aChannel The radio channel number. * @@ -52,7 +52,7 @@ class MaxPowerTable int8_t GetTransmitPower(uint8_t aChannel) const { return mPowerTable[aChannel - Radio::kChannelMin]; } /** - * This method sets the max allowed transmit power of channel @p aChannel. + * Sets the max allowed transmit power of channel @p aChannel. * * @param[in] aChannel The radio channel number. * @param[in] aPower The max supported transmit power in dBm. @@ -61,7 +61,7 @@ class MaxPowerTable void SetTransmitPower(uint8_t aChannel, int8_t aPower) { mPowerTable[aChannel - Radio::kChannelMin] = aPower; } /** - * This method gets the supported channel masks. + * Gets the supported channel masks. * */ uint32_t GetSupportedChannelMask(void) const diff --git a/src/core/radio/radio.cpp b/src/core/radio/radio.cpp index 918d838cdaf..9b3eb695e77 100644 --- a/src/core/radio/radio.cpp +++ b/src/core/radio/radio.cpp @@ -28,7 +28,10 @@ #include "radio.hpp" +#include "common/code_utils.hpp" #include "common/locator_getters.hpp" +#include "common/timer.hpp" +#include "mac/mac_frame.hpp" #include "utils/otns.hpp" namespace ot { @@ -92,4 +95,111 @@ Error Radio::Transmit(Mac::TxFrame &aFrame) } #endif // OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) +inline uint64_t UintSafeMinus(uint64_t aLhs, uint64_t aRhs) { return aLhs > aRhs ? (aLhs - aRhs) : 0; } + +RadioStatistics::RadioStatistics(void) + : mStatus(kDisabled) +{ + ResetTime(); +} + +void RadioStatistics::RecordStateChange(Status aStatus) +{ + UpdateTime(); + mStatus = aStatus; +} + +void RadioStatistics::HandleReceiveAt(uint32_t aDurationUs) +{ + // The actual rx time of ReceiveAt cannot be obtained from software level. This is a workaround. + if (mStatus == kSleep) + { + mTimeStats.mRxTime += aDurationUs; + } +} + +void RadioStatistics::RecordTxDone(otError aError, uint16_t aPsduLength) +{ + if (aError == kErrorNone || aError == kErrorNoAck) + { + uint32_t txTimeUs = (aPsduLength + Mac::Frame::kPhyHeaderSize) * Radio::kSymbolsPerOctet * Radio::kSymbolTime; + uint32_t rxAckTimeUs = (Mac::Frame::kImmAckLength + Mac::Frame::kPhyHeaderSize) * Radio::kPhyUsPerByte; + + UpdateTime(); + mTimeStats.mTxTime += txTimeUs; + + if (mStatus == kReceive) + { + mTimeStats.mRxTime = UintSafeMinus(mTimeStats.mRxTime, txTimeUs); + } + else if (mStatus == kSleep) + { + mTimeStats.mSleepTime = UintSafeMinus(mTimeStats.mSleepTime, txTimeUs); + if (aError == kErrorNone) + { + mTimeStats.mRxTime += rxAckTimeUs; + mTimeStats.mSleepTime = UintSafeMinus(mTimeStats.mSleepTime, rxAckTimeUs); + } + } + } +} + +void RadioStatistics::RecordRxDone(otError aError) +{ + uint32_t ackTimeUs; + + VerifyOrExit(aError == kErrorNone); + + UpdateTime(); + // Currently we cannot know the actual length of ACK. So assume the ACK is an immediate ACK. + ackTimeUs = (Mac::Frame::kImmAckLength + Mac::Frame::kPhyHeaderSize) * Radio::kPhyUsPerByte; + mTimeStats.mTxTime += ackTimeUs; + if (mStatus == kReceive) + { + mTimeStats.mRxTime = UintSafeMinus(mTimeStats.mRxTime, ackTimeUs); + } + +exit: + return; +} + +const otRadioTimeStats &RadioStatistics::GetStats(void) +{ + UpdateTime(); + + return mTimeStats; +} + +void RadioStatistics::ResetTime(void) +{ + mTimeStats.mDisabledTime = 0; + mTimeStats.mSleepTime = 0; + mTimeStats.mRxTime = 0; + mTimeStats.mTxTime = 0; + mLastUpdateTime = TimerMicro::GetNow(); +} + +void RadioStatistics::UpdateTime(void) +{ + TimeMicro nowTime = TimerMicro::GetNow(); + uint32_t timeElapsed = nowTime - mLastUpdateTime; + + switch (mStatus) + { + case kSleep: + mTimeStats.mSleepTime += timeElapsed; + break; + case kReceive: + mTimeStats.mRxTime += timeElapsed; + break; + case kDisabled: + mTimeStats.mDisabledTime += timeElapsed; + break; + } + mLastUpdateTime = nowTime; +} + +#endif // OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + } // namespace ot diff --git a/src/core/radio/radio.hpp b/src/core/radio/radio.hpp index bbe8544d5cb..a8d36a1a520 100644 --- a/src/core/radio/radio.hpp +++ b/src/core/radio/radio.hpp @@ -36,17 +36,20 @@ #include "openthread-core-config.h" +#include #include #include #include "common/locator.hpp" #include "common/non_copyable.hpp" +#include "common/time.hpp" #include "mac/mac_frame.hpp" namespace ot { static constexpr uint32_t kUsPerTenSymbols = OT_US_PER_TEN_SYMBOLS; ///< Time for 10 symbols in units of microseconds static constexpr uint32_t kRadioHeaderShrDuration = 160; ///< Duration of SHR in us +static constexpr uint32_t kRadioHeaderPhrDuration = 32; ///< Duration of PHR in us #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** @@ -68,7 +71,61 @@ static constexpr uint64_t kMaxCslTimeout = OPENTHREAD_CONFIG_MAC_CSL_MAX_TIMEOUT */ /** - * This class represents an OpenThread radio abstraction. + * Implements the radio statistics logic. + * + * The radio statistics are the time when the radio in TX/RX/radio state. + * Since this class collects these statistics from pure software level and no platform API is involved, a simplied + * model is used to calculate the time of different radio states. The data may not be very accurate, but it's + * sufficient to provide a general understanding of the proportion of time a device is in different radio states. + * + * The simplified model is: + * - The RadioStats is only aware of 2 states: RX and sleep. + * - Each time `Radio::Receive` or `Radio::Sleep` is called, it will check the current state and add the time since + * last time the methods were called. For example, `Sleep` is first called and `Receive` is called after 1 second, + * then 1 second will be added to SleepTime and the current state switches to `Receive`. + * - The time of TX will be calculated from the callback of TransmitDone. If TX returns OT_ERROR_NONE or + * OT_ERROR_NO_ACK, the tx time will be added according to the number of bytes sent. And the SleepTime or RxTime + * will be reduced accordingly. + * - When `GetStats` is called, an operation will be executed to calcute the time for the last state. And the result + * will be returned. + * + */ +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + +#if !OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE +#error "OPENTHREAD_CONFIG_RADIO_STATS_ENABLE requires OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE". +#endif + +class RadioStatistics +{ +public: + enum Status : uint8_t + { + kDisabled, + kSleep, + kReceive, + }; + + explicit RadioStatistics(void); + + void RecordStateChange(Status aStatus); + void HandleReceiveAt(uint32_t aDurationUs); + void RecordTxDone(otError aError, uint16_t aPsduLength); + void RecordRxDone(otError aError); + const otRadioTimeStats &GetStats(void); + void ResetTime(void); + +private: + void UpdateTime(void); + + Status mStatus; + otRadioTimeStats mTimeStats; + TimeMicro mLastUpdateTime; +}; +#endif // OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + +/** + * Represents an OpenThread radio abstraction. * */ class Radio : public InstanceLocator, private NonCopyable @@ -76,7 +133,9 @@ class Radio : public InstanceLocator, private NonCopyable friend class Instance; public: - static constexpr uint32_t kSymbolTime = OT_RADIO_SYMBOL_TIME; + static constexpr uint32_t kSymbolTime = OT_RADIO_SYMBOL_TIME; + static constexpr uint8_t kSymbolsPerOctet = OT_RADIO_SYMBOLS_PER_OCTET; + static constexpr uint32_t kPhyUsPerByte = kSymbolsPerOctet * kSymbolTime; #if (OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT && OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT) static constexpr uint16_t kNumChannelPages = 2; static constexpr uint32_t kSupportedChannels = @@ -116,7 +175,7 @@ class Radio : public InstanceLocator, private NonCopyable "must be set to 1 to specify the radio mode"); /** - * This class defines the callbacks from `Radio`. + * Defines the callbacks from `Radio`. * */ class Callbacks : public InstanceLocator @@ -159,7 +218,7 @@ class Radio : public InstanceLocator, private NonCopyable /** * This callback method handles "Energy Scan Done" event from radio platform. * - * This method is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. It is called from + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. It is called from * `otPlatRadioEnergyScanDone()`. * * @param[in] aMaxRssi The maximum RSSI encountered on the scanned channel. @@ -200,7 +259,7 @@ class Radio : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `Radio` object. + * Initializes the `Radio` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -212,7 +271,7 @@ class Radio : public InstanceLocator, private NonCopyable } /** - * This method gets the radio version string. + * Gets the radio version string. * * @returns A pointer to the OpenThread radio version. * @@ -220,7 +279,7 @@ class Radio : public InstanceLocator, private NonCopyable const char *GetVersionString(void); /** - * This method gets the factory-assigned IEEE EUI-64 for the device. + * Gets the factory-assigned IEEE EUI-64 for the device. * * @param[out] aIeeeEui64 A reference to `Mac::ExtAddress` to place the factory-assigned IEEE EUI-64. * @@ -228,7 +287,7 @@ class Radio : public InstanceLocator, private NonCopyable void GetIeeeEui64(Mac::ExtAddress &aIeeeEui64); /** - * This method gets the radio capabilities. + * Gets the radio capabilities. * * @returns The radio capability bit vector (see `OT_RADIO_CAP_*` definitions). * @@ -236,7 +295,7 @@ class Radio : public InstanceLocator, private NonCopyable otRadioCaps GetCaps(void); /** - * This method gets the radio receive sensitivity value. + * Gets the radio receive sensitivity value. * * @returns The radio receive sensitivity value in dBm. * @@ -245,14 +304,14 @@ class Radio : public InstanceLocator, private NonCopyable #if OPENTHREAD_RADIO /** - * This method initializes the states of the Thread radio. + * Initializes the states of the Thread radio. * */ void Init(void); #endif /** - * This method sets the PAN ID for address filtering. + * Sets the PAN ID for address filtering. * * @param[in] aPanId The IEEE 802.15.4 PAN ID. * @@ -260,7 +319,7 @@ class Radio : public InstanceLocator, private NonCopyable void SetPanId(Mac::PanId aPanId); /** - * This method sets the Extended Address for address filtering. + * Sets the Extended Address for address filtering. * * @param[in] aExtAddress The IEEE 802.15.4 Extended Address stored in little-endian byte order. * @@ -268,7 +327,7 @@ class Radio : public InstanceLocator, private NonCopyable void SetExtendedAddress(const Mac::ExtAddress &aExtAddress); /** - * This method sets the Short Address for address filtering. + * Sets the Short Address for address filtering. * * @param[in] aShortAddress The IEEE 802.15.4 Short Address. * @@ -276,7 +335,7 @@ class Radio : public InstanceLocator, private NonCopyable void SetShortAddress(Mac::ShortAddress aShortAddress); /** - * This method sets MAC key and key ID. + * Sets MAC key and key ID. * * @param[in] aKeyIdMode MAC key ID mode. * @param[in] aKeyId Current MAC key index. @@ -292,7 +351,7 @@ class Radio : public InstanceLocator, private NonCopyable const Mac::KeyMaterial &aNextKey); /** - * This method sets the current MAC Frame Counter value. + * Sets the current MAC Frame Counter value. * * @param[in] aMacFrameCounter The MAC Frame Counter value. * @@ -303,7 +362,7 @@ class Radio : public InstanceLocator, private NonCopyable } /** - * This method sets the current MAC Frame Counter value only if the new given value is larger than the current + * Sets the current MAC Frame Counter value only if the new given value is larger than the current * value. * * @param[in] aMacFrameCounter The MAC Frame Counter value. @@ -315,7 +374,7 @@ class Radio : public InstanceLocator, private NonCopyable } /** - * This method gets the radio's transmit power in dBm. + * Gets the radio's transmit power in dBm. * * @param[out] aPower A reference to output the transmit power in dBm. * @@ -326,7 +385,7 @@ class Radio : public InstanceLocator, private NonCopyable Error GetTransmitPower(int8_t &aPower); /** - * This method sets the radio's transmit power in dBm. + * Sets the radio's transmit power in dBm. * * @param[in] aPower The transmit power in dBm. * @@ -337,7 +396,7 @@ class Radio : public InstanceLocator, private NonCopyable Error SetTransmitPower(int8_t aPower); /** - * This method gets the radio's CCA ED threshold in dBm. + * Gets the radio's CCA ED threshold in dBm. * * @param[in] aThreshold The CCA ED threshold in dBm. * @@ -348,7 +407,7 @@ class Radio : public InstanceLocator, private NonCopyable Error GetCcaEnergyDetectThreshold(int8_t &aThreshold); /** - * This method sets the radio's CCA ED threshold in dBm. + * Sets the radio's CCA ED threshold in dBm. * * @param[in] aThreshold The CCA ED threshold in dBm. * @@ -359,7 +418,7 @@ class Radio : public InstanceLocator, private NonCopyable Error SetCcaEnergyDetectThreshold(int8_t aThreshold); /** - * This method gets the status of promiscuous mode. + * Gets the status of promiscuous mode. * * @retval TRUE Promiscuous mode is enabled. * @retval FALSE Promiscuous mode is disabled. @@ -368,7 +427,7 @@ class Radio : public InstanceLocator, private NonCopyable bool GetPromiscuous(void); /** - * This method enables or disables promiscuous mode. + * Enables or disables promiscuous mode. * * @param[in] aEnable TRUE to enable or FALSE to disable promiscuous mode. * @@ -376,9 +435,9 @@ class Radio : public InstanceLocator, private NonCopyable void SetPromiscuous(bool aEnable); /** - * This method returns the current state of the radio. + * Returns the current state of the radio. * - * This function is not required by OpenThread. It may be used for debugging and/or application-specific purposes. + * Is not required by OpenThread. It may be used for debugging and/or application-specific purposes. * * @note This function may be not implemented. In this case it always returns OT_RADIO_STATE_INVALID state. * @@ -388,7 +447,7 @@ class Radio : public InstanceLocator, private NonCopyable otRadioState GetState(void); /** - * This method enables the radio. + * Enables the radio. * * @retval kErrorNone Successfully enabled. * @retval kErrorFailed The radio could not be enabled. @@ -397,7 +456,7 @@ class Radio : public InstanceLocator, private NonCopyable Error Enable(void); /** - * This method disables the radio. + * Disables the radio. * * @retval kErrorNone Successfully transitioned to Disabled. * @retval kErrorInvalidState The radio was not in sleep state. @@ -406,7 +465,7 @@ class Radio : public InstanceLocator, private NonCopyable Error Disable(void); /** - * This method indicates whether radio is enabled or not. + * Indicates whether radio is enabled or not. * * @returns TRUE if the radio is enabled, FALSE otherwise. * @@ -414,7 +473,7 @@ class Radio : public InstanceLocator, private NonCopyable bool IsEnabled(void); /** - * This method transitions the radio from Receive to Sleep (turn off the radio). + * Transitions the radio from Receive to Sleep (turn off the radio). * * @retval kErrorNone Successfully transitioned to Sleep. * @retval kErrorBusy The radio was transmitting. @@ -424,7 +483,7 @@ class Radio : public InstanceLocator, private NonCopyable Error Sleep(void); /** - * This method transitions the radio from Sleep to Receive (turn on the radio). + * Transitions the radio from Sleep to Receive (turn on the radio). * * @param[in] aChannel The channel to use for receiving. * @@ -436,7 +495,7 @@ class Radio : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method updates the CSL sample time in radio. + * Updates the CSL sample time in radio. * * @param[in] aCslSampleTime The CSL sample time. * @@ -444,7 +503,7 @@ class Radio : public InstanceLocator, private NonCopyable void UpdateCslSampleTime(uint32_t aCslSampleTime); /** - * This method schedules a radio reception window at a specific time and duration. + * Schedules a radio reception window at a specific time and duration. * * @param[in] aChannel The radio channel on which to receive. * @param[in] aStart The receive window start time, in microseconds. @@ -456,7 +515,7 @@ class Radio : public InstanceLocator, private NonCopyable */ Error ReceiveAt(uint8_t aChannel, uint32_t aStart, uint32_t aDuration); - /** This method enables CSL sampling in radio. + /** Enables CSL sampling in radio. * * @param[in] aCslPeriod CSL period, 0 for disabling CSL. * @param[in] aShortAddr The short source address of CSL receiver's peer. @@ -493,7 +552,7 @@ class Radio : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE /** - * This method gets the radio transmit frame buffer. + * Gets the radio transmit frame buffer. * * OpenThread forms the IEEE 802.15.4 frame in this buffer then calls `Transmit()` to request transmission. * @@ -503,7 +562,7 @@ class Radio : public InstanceLocator, private NonCopyable Mac::TxFrame &GetTransmitBuffer(void); /** - * This method starts the transmit sequence on the radio. + * Starts the transmit sequence on the radio. * * The caller must form the IEEE 802.15.4 frame in the buffer provided by `GetTransmitBuffer()` before * requesting transmission. The channel and transmit power are also included in the frame. @@ -517,7 +576,7 @@ class Radio : public InstanceLocator, private NonCopyable Error Transmit(Mac::TxFrame &aFrame); /** - * This method gets the most recent RSSI measurement. + * Gets the most recent RSSI measurement. * * @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid. * @@ -525,9 +584,9 @@ class Radio : public InstanceLocator, private NonCopyable int8_t GetRssi(void); /** - * This method begins the energy scan sequence on the radio. + * Begins the energy scan sequence on the radio. * - * This function is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. * * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. @@ -540,7 +599,7 @@ class Radio : public InstanceLocator, private NonCopyable Error EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration); /** - * This method enables/disables source address match feature. + * Enables/disables source address match feature. * * The source address match feature controls how the radio layer decides the "frame pending" bit for acks sent in * response to data request commands from children. @@ -559,7 +618,7 @@ class Radio : public InstanceLocator, private NonCopyable void EnableSrcMatch(bool aEnable); /** - * This method adds a short address to the source address match table. + * Adds a short address to the source address match table. * * @param[in] aShortAddress The short address to be added. * @@ -570,7 +629,7 @@ class Radio : public InstanceLocator, private NonCopyable Error AddSrcMatchShortEntry(Mac::ShortAddress aShortAddress); /** - * This method adds an extended address to the source address match table. + * Adds an extended address to the source address match table. * * @param[in] aExtAddress The extended address to be added stored in little-endian byte order. * @@ -581,7 +640,7 @@ class Radio : public InstanceLocator, private NonCopyable Error AddSrcMatchExtEntry(const Mac::ExtAddress &aExtAddress); /** - * This method removes a short address from the source address match table. + * Removes a short address from the source address match table. * * @param[in] aShortAddress The short address to be removed. * @@ -592,7 +651,7 @@ class Radio : public InstanceLocator, private NonCopyable Error ClearSrcMatchShortEntry(Mac::ShortAddress aShortAddress); /** - * This method removes an extended address from the source address match table. + * Removes an extended address from the source address match table. * * @param[in] aExtAddress The extended address to be removed stored in little-endian byte order. * @@ -603,19 +662,19 @@ class Radio : public InstanceLocator, private NonCopyable Error ClearSrcMatchExtEntry(const Mac::ExtAddress &aExtAddress); /** - * This method clears all short addresses from the source address match table. + * Clears all short addresses from the source address match table. * */ void ClearSrcMatchShortEntries(void); /** - * This method clears all the extended/long addresses from source address match table. + * Clears all the extended/long addresses from source address match table. * */ void ClearSrcMatchExtEntries(void); /** - * This method gets the radio supported channel mask that the device is allowed to be on. + * Gets the radio supported channel mask that the device is allowed to be on. * * @returns The radio supported channel mask. * @@ -623,7 +682,7 @@ class Radio : public InstanceLocator, private NonCopyable uint32_t GetSupportedChannelMask(void); /** - * This method gets 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. * * @returns The radio preferred channel mask. * @@ -632,7 +691,7 @@ class Radio : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method enables/disables or updates Enhanced-ACK Based Probing in radio for a specific Initiator. + * Enables/disables or updates Enhanced-ACK Based Probing in radio for a specific Initiator. * * After Enhanced-ACK Based Probing is configured by a specific Probing Initiator, the Enhanced-ACK sent to that * node should include Vendor-Specific IE containing Link Metrics data. This method informs the radio to @@ -648,6 +707,8 @@ class Radio : public InstanceLocator, private NonCopyable * @retval kErrorNone Successfully enable/disable or update Enhanced-ACK Based Probing for a specific * Initiator. * @retval kErrorInvalidArgs @p aDataLength or @p aExtAddr is not valid. + * @retval kErrorNotFound The Initiator indicated by @p aShortAddress is not found when trying to clear. + * @retval kErrorNoBufs No more Initiator can be supported. * @retval kErrorNotImplemented Radio driver doesn't support Enhanced-ACK Probing. * */ @@ -660,7 +721,7 @@ class Radio : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method checks if a given channel is valid as a CSL channel. + * Checks if a given channel is valid as a CSL channel. * * @retval true The channel is valid. * @retval false The channel is invalid. @@ -676,6 +737,9 @@ class Radio : public InstanceLocator, private NonCopyable otInstance *GetInstancePtr(void) const { return reinterpret_cast(&InstanceLocator::GetInstance()); } Callbacks mCallbacks; +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + RadioStatistics mRadioStatistics; +#endif }; //--------------------------------------------------------------------------------------------------------------------- @@ -741,15 +805,39 @@ inline void Radio::SetPromiscuous(bool aEnable) { otPlatRadioSetPromiscuous(GetI inline otRadioState Radio::GetState(void) { return otPlatRadioGetState(GetInstancePtr()); } -inline Error Radio::Enable(void) { return otPlatRadioEnable(GetInstancePtr()); } +inline Error Radio::Enable(void) +{ +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + mRadioStatistics.RecordStateChange(RadioStatistics::kSleep); +#endif + return otPlatRadioEnable(GetInstancePtr()); +} -inline Error Radio::Disable(void) { return otPlatRadioDisable(GetInstancePtr()); } +inline Error Radio::Disable(void) +{ +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + mRadioStatistics.RecordStateChange(RadioStatistics::kDisabled); +#endif + return otPlatRadioDisable(GetInstancePtr()); +} inline bool Radio::IsEnabled(void) { return otPlatRadioIsEnabled(GetInstancePtr()); } -inline Error Radio::Sleep(void) { return otPlatRadioSleep(GetInstancePtr()); } +inline Error Radio::Sleep(void) +{ +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + mRadioStatistics.RecordStateChange(RadioStatistics::kSleep); +#endif + return otPlatRadioSleep(GetInstancePtr()); +} -inline Error Radio::Receive(uint8_t aChannel) { return otPlatRadioReceive(GetInstancePtr(), aChannel); } +inline Error Radio::Receive(uint8_t aChannel) +{ +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + mRadioStatistics.RecordStateChange(RadioStatistics::kReceive); +#endif + return otPlatRadioReceive(GetInstancePtr(), aChannel); +} #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE inline void Radio::UpdateCslSampleTime(uint32_t aCslSampleTime) @@ -759,7 +847,14 @@ inline void Radio::UpdateCslSampleTime(uint32_t aCslSampleTime) inline Error Radio::ReceiveAt(uint8_t aChannel, uint32_t aStart, uint32_t aDuration) { - return otPlatRadioReceiveAt(GetInstancePtr(), aChannel, aStart, aDuration); + Error error = otPlatRadioReceiveAt(GetInstancePtr(), aChannel, aStart, aDuration); +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + if (error == kErrorNone) + { + mRadioStatistics.HandleReceiveAt(aDuration); + } +#endif + return error; } inline Error Radio::EnableCsl(uint32_t aCslPeriod, otShortAddress aShortAddr, const otExtAddress *aExtAddr) diff --git a/src/core/radio/radio_callbacks.cpp b/src/core/radio/radio_callbacks.cpp index d23dddc2448..b66f82ac8e8 100644 --- a/src/core/radio/radio_callbacks.cpp +++ b/src/core/radio/radio_callbacks.cpp @@ -40,6 +40,9 @@ namespace ot { void Radio::Callbacks::HandleReceiveDone(Mac::RxFrame *aFrame, Error aError) { +#if OPENTHREAD_CONFIG_RADIO_STATS_ENABLE && (OPENTHREAD_FTD || OPENTHREAD_MTD) + Get().RecordRxDone(aError); +#endif Get().HandleReceiveDone(aFrame, aError); } @@ -47,6 +50,9 @@ void Radio::Callbacks::HandleTransmitStarted(Mac::TxFrame &aFrame) { Get().RecordTxDone(aError, aFrame.GetPsduLength()); +#endif Get().HandleTransmitDone(aFrame, aAckFrame, aError); } diff --git a/src/core/radio/trel_interface.hpp b/src/core/radio/trel_interface.hpp index 1822d4739b9..9ef09b2dd43 100644 --- a/src/core/radio/trel_interface.hpp +++ b/src/core/radio/trel_interface.hpp @@ -60,7 +60,7 @@ extern "C" void otPlatTrelHandleReceived(otInstance *aInstance, uint8_t *aBuffer extern "C" void otPlatTrelHandleDiscoveredPeerInfo(otInstance *aInstance, const otPlatTrelPeerInfo *aInfo); /** - * This class represents a TREL link interface. + * Represents a TREL link interface. * */ class Interface : public InstanceLocator @@ -71,7 +71,7 @@ class Interface : public InstanceLocator public: /** - * This class represents information about a discovered TREL peer. + * Represents information about a discovered TREL peer. * */ class Peer : public otTrelPeer @@ -81,7 +81,7 @@ class Interface : public InstanceLocator public: /** - * This method returns the Extended MAC Address of the discovered TREL peer. + * Returns the Extended MAC Address of the discovered TREL peer. * * @returns The Extended MAC Address of the TREL peer. * @@ -89,7 +89,7 @@ class Interface : public InstanceLocator const Mac::ExtAddress &GetExtAddress(void) const { return static_cast(mExtAddress); } /** - * This method returns the Extended PAN Identifier of the discovered TREL peer. + * Returns the Extended PAN Identifier of the discovered TREL peer. * * @returns The Extended PAN Identifier of the TREL peer. * @@ -100,7 +100,7 @@ class Interface : public InstanceLocator } /** - * This method returns the IPv6 socket address of the discovered TREL peer. + * Returns the IPv6 socket address of the discovered TREL peer. * * @returns The IPv6 socket address of the TREP peer. * @@ -108,7 +108,7 @@ class Interface : public InstanceLocator const Ip6::SockAddr &GetSockAddr(void) const { return static_cast(mSockAddr); } /** - * This method indicates whether the peer matches a given Extended Address. + * Indicates whether the peer matches a given Extended Address. * * @param[in] aExtAddress A Extended Address to match with. * @@ -119,7 +119,7 @@ class Interface : public InstanceLocator bool Matches(const Mac::ExtAddress &aExtAddress) const { return GetExtAddress() == aExtAddress; } /** - * This method indicates whether the peer matches a given Socket Address. + * Indicates whether the peer matches a given Socket Address. * * @param[in] aSockAddr A Socket Address to match with. * @@ -146,20 +146,20 @@ class Interface : public InstanceLocator }; /** - * This type represents an iterator for iterating over TREL peer table entries. + * Represents an iterator for iterating over TREL peer table entries. * */ typedef otTrelPeerIterator PeerIterator; /** - * This method enables or disables the TREL interface. + * Enables or disables the TREL interface. * * @param[in] aEnable A boolean to enable/disable the TREL interface. */ void SetEnabled(bool aEnable); /** - * This method enables the TREL interface. + * Enables the TREL interface. * * This call 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, @@ -170,7 +170,7 @@ class Interface : public InstanceLocator void Enable(void); /** - * This method disables the TREL interface. + * Disables the TREL interface. * * This call stops the DNS-SD browse on the service name "_trel._udp", stops advertising TREL DNS-SD service, and * clears the TREL peer table. @@ -179,7 +179,7 @@ class Interface : public InstanceLocator void Disable(void); /** - * This method indicates whether the TREL interface is enabled. + * Indicates whether the TREL interface is enabled. * * @retval TRUE if the TREL interface is enabled. * @retval FALSE if the TREL interface is disabled. @@ -188,7 +188,7 @@ class Interface : public InstanceLocator bool IsEnabled(void) const { return mEnabled; } /** - * This method initializes a peer table iterator. + * Initializes a peer table iterator. * * @param[in] aIterator The iterator to initialize. * @@ -196,7 +196,7 @@ class Interface : public InstanceLocator void InitIterator(PeerIterator &aIterator) const { aIterator = 0; } /** - * This method iterates over the peer table entries. + * Iterates over the peer table entries. * * @param[in] aIterator The iterator. MUST be initialized. * @@ -206,7 +206,7 @@ class Interface : public InstanceLocator const Peer *GetNextPeer(PeerIterator &aIterator) const; /** - * This method sets the filter mode (enables/disables filtering). + * Sets the filter mode (enables/disables filtering). * * When filtering is enabled, any rx and tx traffic through TREL interface is silently dropped. This is mainly * intended for use during testing. @@ -220,7 +220,7 @@ class Interface : public InstanceLocator void SetFilterEnabled(bool aEnable) { mFiltered = aEnable; } /** - * This method indicates whether or not the filter mode is enabled. + * Indicates whether or not the filter mode is enabled. * * @retval TRUE if the TREL filter mode is enabled. * @retval FALSE if the TREL filter mode is disabled. diff --git a/src/core/radio/trel_link.hpp b/src/core/radio/trel_link.hpp index f19b0bbaee3..4d538ad558a 100644 --- a/src/core/radio/trel_link.hpp +++ b/src/core/radio/trel_link.hpp @@ -65,7 +65,7 @@ namespace Trel { */ /** - * This class represents a Thread Radio Encapsulation Link (TREL). + * Represents a Thread Radio Encapsulation Link (TREL). * */ class Link : public InstanceLocator @@ -79,7 +79,7 @@ class Link : public InstanceLocator static constexpr uint8_t kFcsSize = 0; ///< FCS size for TREL frame. /** - * This constructor initializes the `Link` object. + * Initializes the `Link` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -87,7 +87,7 @@ class Link : public InstanceLocator explicit Link(Instance &aInstance); /** - * This method sets the PAN Identifier. + * Sets the PAN Identifier. * * @param[in] aPanId A PAN Identifier. * @@ -95,32 +95,32 @@ class Link : public InstanceLocator void SetPanId(Mac::PanId aPanId) { mPanId = aPanId; } /** - * This method notifies TREL radio link that device's extended MAC address has changed for it to update any + * Notifies TREL radio link that device's extended MAC address has changed for it to update any * internal address/state. * */ void HandleExtAddressChange(void) { mInterface.HandleExtAddressChange(); } /** - * This method enables the TREL radio link. + * Enables the TREL radio link. * */ void Enable(void); /** - * This method disables the TREL radio link. + * Disables the TREL radio link. * */ void Disable(void); /** - * This method requests TREL radio link to transition to Sleep mode + * Requests TREL radio link to transition to Sleep mode * */ void Sleep(void); /** - * This method requests TREL radio link to transition to Receive mode on a given channel. + * Requests TREL radio link to transition to Receive mode on a given channel. * * `Mac::HandleReceivedFrame()` is used to notify MAC layer upon receiving a frame. * @@ -130,7 +130,7 @@ class Link : public InstanceLocator void Receive(uint8_t aChannel); /** - * This method gets the radio transmit frame for TREL radio link. + * Gets the radio transmit frame for TREL radio link. * * @returns The transmit frame. * @@ -138,7 +138,7 @@ class Link : public InstanceLocator Mac::TxFrame &GetTransmitFrame(void) { return mTxFrame; } /** - * This method requests a frame to be sent over TREL radio link. + * Requests a frame to be sent over TREL radio link. * * The frame should be already placed in `GetTransmitFrame()` frame. * @@ -197,7 +197,7 @@ class Link : public InstanceLocator }; /** - * This class defines all the neighbor info required for TREL link. + * Defines all the neighbor info required for TREL link. * * `Neighbor` class publicly inherits from this class. * diff --git a/src/core/radio/trel_packet.hpp b/src/core/radio/trel_packet.hpp index 5b28cb784a2..5b4caace6e7 100644 --- a/src/core/radio/trel_packet.hpp +++ b/src/core/radio/trel_packet.hpp @@ -48,7 +48,7 @@ namespace ot { namespace Trel { /** - * This class represents a TREL radio link packet encapsulation header. + * Represents a TREL radio link packet encapsulation header. * */ OT_TOOL_PACKED_BEGIN @@ -56,7 +56,7 @@ class Header { public: /** - * This enumeration defines packet types. + * Defines packet types. * */ enum Type : uint8_t @@ -67,7 +67,7 @@ class Header }; /** - * This enumeration represents Ack Mode field in TREL header. + * Represents Ack Mode field in TREL header. * */ enum AckMode : uint8_t @@ -79,13 +79,13 @@ class Header static constexpr uint16_t kInfoStringSize = 128; ///< Max chars for the info string (@sa ToInfoString()). /** - * This type defines the fixed-length `String` object returned from `ToString()` method. + * Defines the fixed-length `String` object returned from `ToString()` method. * */ typedef String InfoString; /** - * This method initializes the header. + * Initializes the header. * * @param[in] aType The header type. * @@ -93,7 +93,7 @@ class Header void Init(Type aType) { mControl = aType + kVersion; } /** - * This method checks whether the version field in header is valid or not + * Checks whether the version field in header is valid or not * * @returns TRUE if the version field is valid, FALSE otherwise. * @@ -101,7 +101,7 @@ class Header bool IsVersionValid(void) const { return (mControl & kVersionMask) == kVersion; } /** - * This method gets the packet type. + * Gets the packet type. * * @returns The packet type. * @@ -109,7 +109,7 @@ class Header Type GetType(void) const { return static_cast(mControl & kTypeMask); } /** - * This method gets the header length based on its type. + * Gets the header length based on its type. * * @returns the header length (number of bytes). * @@ -117,7 +117,7 @@ class Header uint16_t GetLength(void) const { return GetSize(GetType()); } /** - * This method gets the Ack Mode field from the header. + * Gets the Ack Mode field from the header. * * @returns The Ack Mode field. * @@ -125,7 +125,7 @@ class Header AckMode GetAckMode(void) const { return (mControl & kAckModeFlag) ? kAckRequested : kNoAck; } /** - * This method sets the Ack Mode field in the header. + * Sets the Ack Mode field in the header. * * @param[in] aAckMode The Ack Mode field * @@ -133,7 +133,7 @@ class Header void SetAckMode(AckMode aAckMode); /** - * This method gets the channel field from the header. + * Gets the channel field from the header. * * @returns The channel field. * @@ -141,7 +141,7 @@ class Header uint8_t GetChannel(void) const { return mChannel; } /** - * This method sets the channel field in the header. + * Sets the channel field in the header. * * @param[in] aChannel A channel. * @@ -149,7 +149,7 @@ class Header void SetChannel(uint8_t aChannel) { mChannel = aChannel; } /** - * This method gets the PAN Identifier field from the header. + * Gets the PAN Identifier field from the header. * * @returns The PAN Identifier field. * @@ -157,7 +157,7 @@ class Header Mac::PanId GetPanId(void) const { return Encoding::BigEndian::HostSwap16(mPanId); } /** - * This method sets the PAN Identifier field in the header. + * Sets the PAN Identifier field in the header. * * @param[in] aPanId A PAN Identifier. * @@ -165,7 +165,7 @@ class Header void SetPanId(Mac::PanId aPanId) { mPanId = Encoding::BigEndian::HostSwap16(aPanId); } /** - * This method gets the packet number field from the header. + * Gets the packet number field from the header. * * @returns The packet number field. * @@ -173,7 +173,7 @@ class Header uint32_t GetPacketNumber(void) const { return Encoding::BigEndian::HostSwap32(mPacketNumber); } /** - * This method sets the packet number field in the header. + * Sets the packet number field in the header. * * @param[in] aPacketNumber The packet number. * @@ -181,7 +181,7 @@ class Header void SetPacketNumber(uint32_t aPacketNumber) { mPacketNumber = Encoding::BigEndian::HostSwap32(aPacketNumber); } /** - * This method gets the source MAC address field from the header. + * Gets the source MAC address field from the header. * * @returns The source MAC address field. * @@ -189,7 +189,7 @@ class Header const Mac::ExtAddress &GetSource(void) const { return mSource; } /** - * This method sets the source MAC address filed in the header. + * Sets the source MAC address filed in the header. * * @param[in] aSource A MAC extended address to set as source. * @@ -197,9 +197,9 @@ class Header void SetSource(const Mac::ExtAddress &aSource) { mSource = aSource; } /** - * This method gets the destination MAC address field from the header. + * Gets the destination MAC address field from the header. * - * This method MUST be used with a unicast of ack type packet, otherwise its behavior is undefined. + * MUST be used with a unicast of ack type packet, otherwise its behavior is undefined. * * @returns The destination MAC address field. * @@ -207,9 +207,9 @@ class Header const Mac::ExtAddress &GetDestination(void) const { return mDestination; } /** - * This method sets the destination MAC address field in the header. + * Sets the destination MAC address field in the header. * - * This method MUST be used with a unicast of ack type packet, otherwise its behavior is undefined. + * MUST be used with a unicast of ack type packet, otherwise its behavior is undefined. * * @param[in] aDest A MAC extended address to set as destination. * @@ -217,7 +217,7 @@ class Header void SetDestination(const Mac::ExtAddress &aDest) { mDestination = aDest; } /** - * This static method gets the size (number of bytes) in header of given packet type. + * Gets the size (number of bytes) in header of given packet type. * * @param[in] aType The packet type. * @@ -227,7 +227,7 @@ class Header static uint16_t GetSize(Type aType); /** - * This method returns a string representation of header. + * Returns a string representation of header. * * @returns An `InfoString` representation of header. * @@ -251,7 +251,7 @@ class Header } OT_TOOL_PACKED_END; /** - * This class represents a TREL radio link packet. + * Represents a TREL radio link packet. * */ class Packet : private MutableData @@ -260,7 +260,7 @@ class Packet : private MutableData public: /** - * This method initializes the `Packet` with a given buffer and length. + * Initializes the `Packet` with a given buffer and length. * * @param[in] aBuffer A pointer to a buffer containing the entire packet (header and payload). * @param[in] aLength Length (number of bytes) of the packet (including header and payload). @@ -269,10 +269,10 @@ class Packet : private MutableData void Init(uint8_t *aBuffer, uint16_t aLength) { Base::Init(aBuffer, aLength); } /** - * This method initializes the `Packet` with a specified header type and given a payload. + * Initializes the `Packet` with a specified header type and given a payload. * * The payload buffer @p aPayload should have space reserved before the start of payload for the packet header. - * This method will initialize the header with the given type @p aType. Rest of header fields can be updated after + * Will initialize the header with the given type @p aType. Rest of header fields can be updated after * initializing the packet. * * @param[in] aType The packet type. @@ -284,7 +284,7 @@ class Packet : private MutableData void Init(Header::Type aType, uint8_t *aPayload, uint16_t aPayloadLength); /** - * This method gets a pointer to buffer containing the packet. + * Gets a pointer to buffer containing the packet. * * @returns A pointer to buffer containing the packet. * @@ -292,7 +292,7 @@ class Packet : private MutableData uint8_t *GetBuffer(void) { return Base::GetBytes(); } /** - * This method gets a pointer to buffer containing the packet. + * Gets a pointer to buffer containing the packet. * * @returns A pointer to buffer containing the packet. * @@ -300,7 +300,7 @@ class Packet : private MutableData const uint8_t *GetBuffer(void) const { return Base::GetBytes(); } /** - * This method gets the length of packet. + * Gets the length of packet. * * @returns The length (number of bytes) of packet (header and payload). * @@ -308,7 +308,7 @@ class Packet : private MutableData uint16_t GetLength(void) const { return Base::GetLength(); } /** - * This method checks whether or not the packet header is valid. + * Checks whether or not the packet header is valid. * * @retval TRUE The packet header is valid and well-formed. * @retval FALSE The packet header is not valid. @@ -317,7 +317,7 @@ class Packet : private MutableData bool IsHeaderValid(void) const; /** - * This method gets the packet header. + * Gets the packet header. * * @returns A reference to the packet header as `Header`. * @@ -325,7 +325,7 @@ class Packet : private MutableData Header &GetHeader(void) { return *reinterpret_cast
(Base::GetBytes()); } /** - * This method gets the packet header. + * Gets the packet header. * * @returns A reference to the packet header as `Header`. * @@ -333,7 +333,7 @@ class Packet : private MutableData const Header &GetHeader(void) const { return *reinterpret_cast(Base::GetBytes()); } /** - * This method gets a pointer to start of packet payload. + * Gets a pointer to start of packet payload. * * @returns A pointer to start of packet payload (after header). * @@ -341,7 +341,7 @@ class Packet : private MutableData uint8_t *GetPayload(void) { return Base::GetBytes() + GetHeader().GetLength(); } /** - * This method gets a pointer to start of packet payload. + * Gets a pointer to start of packet payload. * * @returns A pointer to start of packet payload (after header). * @@ -349,7 +349,7 @@ class Packet : private MutableData const uint8_t *GetPayload(void) const { return Base::GetBytes() + GetHeader().GetLength(); } /** - * This method gets the payload length. + * Gets the payload length. * * @returns The packet payload length (number of bytes). * diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 16bf8e7a471..3fac7460601 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -959,11 +959,7 @@ void AddressResolver::HandleTimeTick(void) entry->SetTimeout(retryDelay); retryDelay <<= 1; - - if (retryDelay > kAddressQueryMaxRetryDelay) - { - retryDelay = kAddressQueryMaxRetryDelay; - } + retryDelay = Min(retryDelay, kAddressQueryMaxRetryDelay); entry->SetRetryDelay(retryDelay); entry->SetCanEvict(true); diff --git a/src/core/thread/address_resolver.hpp b/src/core/thread/address_resolver.hpp index 81ee36be57e..171fa14473f 100644 --- a/src/core/thread/address_resolver.hpp +++ b/src/core/thread/address_resolver.hpp @@ -61,7 +61,7 @@ namespace ot { */ /** - * This class implements the EID-to-RLOC mapping and caching. + * Implements the EID-to-RLOC mapping and caching. * */ class AddressResolver : public InstanceLocator, private NonCopyable @@ -74,7 +74,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable public: /** - * This type represents an iterator used for iterating through the EID cache table entries. + * Represents an iterator used for iterating through the EID cache table entries. * */ class Iterator : public otCacheEntryIterator, public Clearable @@ -91,7 +91,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable }; /** - * This type represents an EID cache entry. + * Represents an EID cache entry. * */ class EntryInfo : public otCacheEntryInfo, public Clearable @@ -107,20 +107,20 @@ class AddressResolver : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the object. + * Initializes the object. * */ explicit AddressResolver(Instance &aInstance); #if OPENTHREAD_FTD /** - * This method clears the EID-to-RLOC cache. + * Clears the EID-to-RLOC cache. * */ void Clear(void); /** - * This method gets the information about the next EID cache entry (using an iterator). + * Gets the information about the next EID cache entry (using an iterator). * * @param[out] aInfo An `EntryInfo` where the EID cache entry information is placed. * @param[in,out] aIterator An iterator. It will be updated to point to the next entry on success. @@ -134,7 +134,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable Error GetNextCacheEntry(EntryInfo &aInfo, Iterator &aIterator) const; /** - * This method removes the EID-to-RLOC cache entries corresponding to an RLOC16. + * Removes the EID-to-RLOC cache entries corresponding to an RLOC16. * * @param[in] aRloc16 The RLOC16 address. * @@ -142,7 +142,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void RemoveEntriesForRloc16(Mac::ShortAddress aRloc16); /** - * This method removes all EID-to-RLOC cache entries associated with a Router ID. + * Removes all EID-to-RLOC cache entries associated with a Router ID. * * @param[in] aRouterId The Router ID. * @@ -150,7 +150,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void RemoveEntriesForRouterId(uint8_t aRouterId); /** - * This method removes the cache entry for the EID. + * Removes the cache entry for the EID. * * @param[in] aEid A reference to the EID. * @@ -158,7 +158,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void RemoveEntryForAddress(const Ip6::Address &aEid); /** - * This method replaces all EID-to-RLOC cache entries corresponding to an old RLOC16 with a new RLOC16. + * Replaces all EID-to-RLOC cache entries corresponding to an old RLOC16 with a new RLOC16. * * @param[in] aOldRloc16 The old RLOC16. * @param[in] aNewRloc16 The new RLOC16. @@ -167,7 +167,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void ReplaceEntriesForRloc16(uint16_t aOldRloc16, uint16_t aNewRloc16); /** - * This method updates an existing entry or adds a snooped cache entry for a given EID. + * Updates an existing entry or adds a snooped cache entry for a given EID. * * The method is intended to add an entry for snoop optimization (inspection of a received message to create a * cache entry mapping an EID to a RLOC). @@ -180,7 +180,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void UpdateSnoopedCacheEntry(const Ip6::Address &aEid, Mac::ShortAddress aRloc16, Mac::ShortAddress aDest); /** - * This method returns the RLOC16 for a given EID, initiates an Address Query if the mapping is not known. + * Returns the RLOC16 for a given EID, initiates an Address Query if the mapping is not known. * * @param[in] aEid A reference to the EID. * @param[out] aRloc16 The RLOC16 corresponding to @p aEid. @@ -197,7 +197,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable } /** - * This method looks up the RLOC16 for a given EID in the address cache. + * Looks up the RLOC16 for a given EID in the address cache. * * @param[in] aEid A reference to the EID. * @@ -207,7 +207,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable Mac::ShortAddress LookUp(const Ip6::Address &aEid); /** - * This method restarts any ongoing address queries. + * Restarts any ongoing address queries. * * Any existing address queries will be restarted as if they are being sent for the first time. * @@ -215,7 +215,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable void RestartAddressQueries(void); /** - * This method sends an Address Notification (ADDR_NTF.ans) message. + * Sends an Address Notification (ADDR_NTF.ans) message. * * @param[in] aTarget The target address of the ADDR_NTF.ans message. * @param[in] aMeshLocalIid The ML-IID of the ADDR_NTF.ans message. @@ -230,7 +230,7 @@ class AddressResolver : public InstanceLocator, private NonCopyable const Ip6::Address &aDestination); /** - * This method sends an Address Error Notification (ADDR_ERR.ntf) message. + * Sends an Address Error Notification (ADDR_ERR.ntf) message. * * @param aTarget The target address of the ADDR_ERR.ntf message. * @param aMeshLocalIid The ML-IID of the ADDR_ERR.ntf message. diff --git a/src/core/thread/announce_begin_server.hpp b/src/core/thread/announce_begin_server.hpp index a5aafd1f3f6..5839f9c84f0 100644 --- a/src/core/thread/announce_begin_server.hpp +++ b/src/core/thread/announce_begin_server.hpp @@ -45,7 +45,7 @@ namespace ot { /** - * This class implements handling Announce Begin Requests. + * Implements handling Announce Begin Requests. * */ class AnnounceBeginServer : public AnnounceSenderBase @@ -54,13 +54,13 @@ class AnnounceBeginServer : public AnnounceSenderBase public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit AnnounceBeginServer(Instance &aInstance); /** - * This method begins the MLE Announce transmission process. + * Begins the MLE Announce transmission process. * * @param[in] aChannelMask The channels to use for transmission. * @param[in] aCount The number of transmissions per channel. diff --git a/src/core/thread/announce_sender.hpp b/src/core/thread/announce_sender.hpp index a3e533ed1aa..26927da258f 100644 --- a/src/core/thread/announce_sender.hpp +++ b/src/core/thread/announce_sender.hpp @@ -46,9 +46,9 @@ namespace ot { /** - * This class implements the base class for an `AnnounceSender` and `AnnounceBeginSever`. + * Implements the base class for an `AnnounceSender` and `AnnounceBeginSever`. * - * This class provides APIs to schedule periodic transmission of MLE Announcement messages for a given number + * Provides APIs to schedule periodic transmission of MLE Announcement messages for a given number * transmissions per channel. */ class AnnounceSenderBase : public InstanceLocator, private NonCopyable @@ -61,7 +61,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable static constexpr uint8_t kChannelIteratorFirst = Mac::ChannelMask::kChannelIteratorFirst; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aHandler A timer handler provided by sub-class. @@ -70,9 +70,9 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable AnnounceSenderBase(Instance &aInstance, Timer::Handler aHandler); /** - * This method schedules the MLE Announce transmissions. + * Schedules the MLE Announce transmissions. * - * This method requests @p aCount additional MLE transmission cycles to be scheduled. Each cycle covers all the + * Requests @p aCount additional MLE transmission cycles to be scheduled. Each cycle covers all the * channels in the specified channel mask from `GetChannelMask()`, with `GetPeriod()` as the time interval between * any two successive MLE Announcement transmissions (possibly) on different channels from the mask. The * `GetJitter()` value is used to add a random interval from `[-jitter, jitter]` to each period interval. @@ -93,13 +93,13 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable void SendAnnounce(uint8_t aCount); /** - * This method stops the ongoing MLE Announce transmissions. + * Stops the ongoing MLE Announce transmissions. * */ void Stop(void); /** - * This method indicates whether a previously scheduled MLE Announce transmission is currently in progress or is + * Indicates whether a previously scheduled MLE Announce transmission is currently in progress or is * finished. * * @returns TRUE if the MLE Announce transmission is in progress, FALSE otherwise. @@ -108,7 +108,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable bool IsRunning(void) const { return mTimer.IsRunning(); } /** - * This method gets the period interval. + * Gets the period interval. * * @returns The period interval (in milliseconds). * @@ -116,7 +116,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable uint32_t GetPeriod(void) const { return mPeriod; } /** - * This method sets the period interval. + * Sets the period interval. * * The period along with jitter value from (`Get/SetJitter()`) determines the interval between two successive MLE * Announcement transmissions (possibly) on different channels from the specified channel mask. @@ -127,7 +127,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable void SetPeriod(uint32_t aPeriod) { mPeriod = aPeriod; } /** - * This method gets the current jitter interval. + * Gets the current jitter interval. * * @returns The jitter interval (in milliseconds). * @@ -135,7 +135,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable uint16_t GetJitter(void) const { return mJitter; } /** - * This method sets the jitter interval. + * Sets the jitter interval. * * @param[in] aJitter The jitter interval (in milliseconds). * @@ -143,7 +143,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable void SetJitter(uint16_t aJitter) { mJitter = aJitter; } /** - * This method gets the channel mask. + * Gets the channel mask. * * @returns The channel mask. * @@ -151,7 +151,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable const Mac::ChannelMask GetChannelMask(void) const { return mChannelMask; } /** - * This method sets the channel mask. + * Sets the channel mask. * * @param[in] aChannelMask The channel mask. * @@ -159,7 +159,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable void SetChannelMask(Mac::ChannelMask aChannelMask); /** - * This method gets the starting channel, i.e., the first channel in a TX cycle to send MLE Announcement on. + * Gets the starting channel, i.e., the first channel in a TX cycle to send MLE Announcement on. * * @returns The current starting channel. * @@ -167,7 +167,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable uint8_t GetStartingChannel(void) const { return mStartingChannel; } /** - * This method sets the starting channel, i.e., the first channel in a TX cycle to send MLE Announcement on. + * Sets the starting channel, i.e., the first channel in a TX cycle to send MLE Announcement on. * * @p aStartingChannel MUST be present in the current channel mask (from `GetChannelMask()`), otherwise it is * ignored and an MLE transmission cycle starts with the first channel (with smallest channel number) in the channel @@ -179,7 +179,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable void SetStartingChannel(uint8_t aStartingChannel); /** - * This method is the timer handler and must be invoked by sub-class when the timer expires from the `aHandler` + * Is the timer handler and must be invoked by sub-class when the timer expires from the `aHandler` * callback function provided in the constructor. * */ @@ -200,7 +200,7 @@ class AnnounceSenderBase : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_ANNOUNCE_SENDER_ENABLE /** - * This class implements an AnnounceSender. + * Implements an AnnounceSender. * */ class AnnounceSender : public AnnounceSenderBase @@ -209,7 +209,7 @@ class AnnounceSender : public AnnounceSenderBase public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -217,7 +217,7 @@ class AnnounceSender : public AnnounceSenderBase explicit AnnounceSender(Instance &aInstance); /** - * This method notifies the `AnnounceSender` that a MLE Announcement message was received with a current timestamp + * Notifies the `AnnounceSender` that a MLE Announcement message was received with a current timestamp * to update its internal state (decide whether or not to skip transmission of MLE Announcement in this cycle). * */ diff --git a/src/core/thread/anycast_locator.hpp b/src/core/thread/anycast_locator.hpp index cba969d2e38..be983931f38 100644 --- a/src/core/thread/anycast_locator.hpp +++ b/src/core/thread/anycast_locator.hpp @@ -47,7 +47,7 @@ namespace ot { /** - * This class implements Anycast Locator functionality which allows caller to determine the mesh local EID and RLOC16 + * Implements Anycast Locator functionality which allows caller to determine the mesh local EID and RLOC16 * of the closest destination of an anycast address (if any). * * The closest destination is determined based on the current routing table and path costs within the Thread mesh. @@ -59,13 +59,13 @@ class AnycastLocator : public InstanceLocator, private NonCopyable public: /** - * This function pointer type defines the callback to notify the outcome of a request. + * Pointer type defines the callback to notify the outcome of a request. * */ typedef otThreadAnycastLocatorCallback LocatorCallback; /** - * This constructor initializes the `AnycastLocator` object. + * Initializes the `AnycastLocator` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -73,7 +73,7 @@ class AnycastLocator : public InstanceLocator, private NonCopyable explicit AnycastLocator(Instance &aInstance); /** - * This method requests the closest destination of a given anycast address to be located. + * Requests the closest destination of a given anycast address to be located. * * If a previous `Locate()` request is ongoing, a subsequent call to this method will cancel and replace the * earlier request. @@ -90,7 +90,7 @@ class AnycastLocator : public InstanceLocator, private NonCopyable Error Locate(const Ip6::Address &aAnycastAddress, LocatorCallback aCallback, void *aContext); /** - * This method indicates whether an earlier request is in progress. + * Indicates whether an earlier request is in progress. * * @returns TRUE if an earlier request is in progress, FALSE otherwise. * diff --git a/src/core/thread/child_mask.hpp b/src/core/thread/child_mask.hpp index ae18b2a526b..f7315c9220f 100644 --- a/src/core/thread/child_mask.hpp +++ b/src/core/thread/child_mask.hpp @@ -51,7 +51,7 @@ namespace ot { */ /** - * This class represents a bit-vector of child mask. + * Represents a bit-vector of child mask. * */ typedef BitVector ChildMask; diff --git a/src/core/thread/child_supervision.hpp b/src/core/thread/child_supervision.hpp index c56291f69c9..637e5ff8816 100644 --- a/src/core/thread/child_supervision.hpp +++ b/src/core/thread/child_supervision.hpp @@ -86,7 +86,7 @@ class Child; #if OPENTHREAD_FTD /** - * This class implements a child supervisor. + * Implements a child supervisor. * */ class ChildSupervisor : public InstanceLocator, private NonCopyable @@ -96,7 +96,7 @@ class ChildSupervisor : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -104,19 +104,19 @@ class ChildSupervisor : public InstanceLocator, private NonCopyable explicit ChildSupervisor(Instance &aInstance); /** - * This method starts the child supervision process on parent. + * Starts the child supervision process on parent. * */ void Start(void); /** - * This method stops the child supervision process on parent. + * Stops the child supervision process on parent. * */ void Stop(void); /** - * This method returns the destination for a supervision message. + * Returns the destination for a supervision message. * * @param[in] aMessage The message for which to get the destination. * @@ -127,7 +127,7 @@ class ChildSupervisor : public InstanceLocator, private NonCopyable Child *GetDestination(const Message &aMessage) const; /** - * This method updates the supervision state for a child. It informs the child supervisor that a message was + * Updates the supervision state for a child. It informs the child supervisor that a message was * successfully sent to the child. * * @param[in] aChild The child to which a message was successfully sent. @@ -147,14 +147,14 @@ class ChildSupervisor : public InstanceLocator, private NonCopyable #endif // #if OPENTHREAD_FTD /** - * This class implements a child supervision listener. + * Implements a child supervision listener. * */ class SupervisionListener : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -162,19 +162,19 @@ class SupervisionListener : public InstanceLocator, private NonCopyable explicit SupervisionListener(Instance &aInstance); /** - * This method starts the supervision listener operation. + * Starts the supervision listener operation. * */ void Start(void); /** - * This method stops the supervision listener operation. + * Stops the supervision listener operation. * */ void Stop(void); /** - * This method sets the supervision interval. + * Sets the supervision interval. * * @param[in] aInterval If non-zero, the desired supervision interval (in seconds), zero to disable supervision. * @@ -182,7 +182,7 @@ class SupervisionListener : public InstanceLocator, private NonCopyable void SetInterval(uint16_t aInterval); /** - * This method returns the supervision interval. + * Returns the supervision interval. * * @returns The current supervision interval (seconds), or zero if supervision is disabled. * @@ -190,7 +190,7 @@ class SupervisionListener : public InstanceLocator, private NonCopyable uint16_t GetInterval(void) const { return mInterval; } /** - * This method sets the supervision check timeout (in seconds). + * Sets the supervision check timeout (in seconds). * * If the child does not hear from its parent within the given check timeout interval, it initiates the re-attach * process (MLE Child Update Request/Response exchange with its parent). Setting the timeout to zero, disables the @@ -205,7 +205,7 @@ class SupervisionListener : public InstanceLocator, private NonCopyable void SetTimeout(uint16_t aTimeout); /** - * This method returns the supervision check timeout interval (in seconds). + * Returns the supervision check timeout interval (in seconds). * * @returns The check timeout interval (in seconds) or zero if the supervision check on the child is disabled. * @@ -213,7 +213,7 @@ class SupervisionListener : public InstanceLocator, private NonCopyable uint16_t GetTimeout(void) const { return mTimeout; } /** - * This method returns the value of supervision check timeout failure counter. + * Returns 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. @@ -222,13 +222,13 @@ class SupervisionListener : public InstanceLocator, private NonCopyable uint16_t GetCounter(void) const { return mCounter; } /** - * This method reset the supervision check timeout failure counter. + * Reset the supervision check timeout failure counter. * */ void ResetCounter(void) { mCounter = 0; } /** - * This method updates the supervision listener state. It informs the listener of a received frame. + * Updates the supervision listener state. It informs the listener of a received frame. * * @param[in] aSourceAddress The source MAC address of the received frame * @param[in] aIsSecure TRUE to indicate that the received frame is secure, FALSE otherwise. diff --git a/src/core/thread/child_table.hpp b/src/core/thread/child_table.hpp index 7df7dee3472..e023136615f 100644 --- a/src/core/thread/child_table.hpp +++ b/src/core/thread/child_table.hpp @@ -47,7 +47,7 @@ namespace ot { /** - * This class represents the Thread child table. + * Represents the Thread child table. * */ class ChildTable : public InstanceLocator, private NonCopyable @@ -57,7 +57,7 @@ class ChildTable : public InstanceLocator, private NonCopyable public: /** - * This class represents an iterator for iterating through the child entries in the child table. + * Represents an iterator for iterating through the child entries in the child table. * */ class Iterator : public InstanceLocator, public ItemPtrIterator @@ -67,7 +67,7 @@ class ChildTable : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes an `Iterator` instance. + * Initializes an `Iterator` instance. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aFilter A child state filter. @@ -76,13 +76,13 @@ class ChildTable : public InstanceLocator, private NonCopyable Iterator(Instance &aInstance, Child::StateFilter aFilter); /** - * This method resets the iterator to start over. + * Resets the iterator to start over. * */ void Reset(void); /** - * This method gets the `Child` entry to which the iterator is currently pointing. + * Gets the `Child` entry to which the iterator is currently pointing. * * @returns A pointer to the `Child` entry, or `nullptr` if the iterator is done and/or empty. * @@ -102,7 +102,7 @@ class ChildTable : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes a `ChildTable` instance. + * Initializes a `ChildTable` instance. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -110,13 +110,13 @@ class ChildTable : public InstanceLocator, private NonCopyable explicit ChildTable(Instance &aInstance); /** - * This method clears the child table. + * Clears the child table. * */ void Clear(void); /** - * This method returns the child table index for a given `Child` instance. + * Returns the child table index for a given `Child` instance. * * @param[in] aChild A reference to a `Child` * @@ -126,7 +126,7 @@ class ChildTable : public InstanceLocator, private NonCopyable uint16_t GetChildIndex(const Child &aChild) const { return static_cast(&aChild - mChildren); } /** - * This method returns a pointer to a `Child` entry at a given index, or `nullptr` if the index is out of bounds, + * Returns a pointer to a `Child` entry at a given index, or `nullptr` if the index is out of bounds, * i.e., index is larger or equal to maximum number of children allowed (@sa GetMaxChildrenAllowed()). * * @param[in] aChildIndex A child index. @@ -137,7 +137,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Child *GetChildAtIndex(uint16_t aChildIndex); /** - * This method gets a new/unused `Child` entry from the child table. + * Gets a new/unused `Child` entry from the child table. * * @note The returned child entry will be cleared (`memset` to zero). * @@ -147,7 +147,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Child *GetNewChild(void); /** - * This method searches the child table for a `Child` with a given RLOC16 also matching a given state filter. + * Searches the child table for a `Child` with a given RLOC16 also matching a given state filter. * * @param[in] aRloc16 A RLOC16 address. * @param[in] aFilter A child state filter. @@ -158,7 +158,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Child *FindChild(uint16_t aRloc16, Child::StateFilter aFilter); /** - * This method searches the child table for a `Child` with a given extended address also matching a given state + * Searches the child table for a `Child` with a given extended address also matching a given state * filter. * * @param[in] aExtAddress A reference to an extended address. @@ -170,7 +170,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Child *FindChild(const Mac::ExtAddress &aExtAddress, Child::StateFilter aFilter); /** - * This method searches the child table for a `Child` with a given address also matching a given state filter. + * Searches the child table for a `Child` with a given address also matching a given state filter. * * @param[in] aMacAddress A reference to a MAC address. * @param[in] aFilter A child state filter. @@ -181,7 +181,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Child *FindChild(const Mac::Address &aMacAddress, Child::StateFilter aFilter); /** - * This method indicates whether the child table contains any child matching a given state filter. + * Indicates whether the child table contains any child matching a given state filter. * * @param[in] aFilter A child state filter. * @@ -191,7 +191,7 @@ class ChildTable : public InstanceLocator, private NonCopyable bool HasChildren(Child::StateFilter aFilter) const; /** - * This method returns the number of children in the child table matching a given state filter. + * Returns the number of children in the child table matching a given state filter. * * @param[in] aFilter A child state filter. * @@ -201,7 +201,7 @@ class ChildTable : public InstanceLocator, private NonCopyable uint16_t GetNumChildren(Child::StateFilter aFilter) const; /** - * This method returns the maximum number of children that can be supported (build-time constant). + * Returns the maximum number of children that can be supported (build-time constant). * * @note Number of children allowed (from `GetMaxChildrenAllowed()`) can be less than maximum number of supported * children. @@ -212,7 +212,7 @@ class ChildTable : public InstanceLocator, private NonCopyable uint16_t GetMaxChildren(void) const { return kMaxChildren; } /** - * This method get the maximum number of children allowed. + * Get the maximum number of children allowed. * * @returns The maximum number of children allowed. * @@ -220,7 +220,7 @@ class ChildTable : public InstanceLocator, private NonCopyable uint16_t GetMaxChildrenAllowed(void) const { return mMaxChildrenAllowed; } /** - * This method sets the maximum number of children allowed. + * Sets the maximum number of children allowed. * * The number of children allowed must be at least one and at most same as maximum supported children (@sa * GetMaxChildren()). It can be changed only if the child table is empty. @@ -235,10 +235,10 @@ class ChildTable : public InstanceLocator, private NonCopyable Error SetMaxChildrenAllowed(uint16_t aMaxChildren); /** - * This method enables range-based `for` loop iteration over all child entries in the child table matching a given + * Enables range-based `for` loop iteration over all child entries in the child table matching a given * state filter. * - * This method should be used as follows: + * Should be used as follows: * * for (Child &child : aChildTable.Iterate(aFilter)) { ... } * @@ -250,7 +250,7 @@ class ChildTable : public InstanceLocator, private NonCopyable IteratorBuilder Iterate(Child::StateFilter aFilter) { return IteratorBuilder(GetInstance(), aFilter); } /** - * This method retains diagnostic information for an attached child by Child ID or RLOC16. + * Retains diagnostic information for an attached child by Child ID or RLOC16. * * @param[in] aChildId The Child ID or RLOC16 for an attached child. * @param[out] aChildInfo A reference to a `Child::Info` to populate with the child information. @@ -259,7 +259,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Error GetChildInfoById(uint16_t aChildId, Child::Info &aChildInfo); /** - * This method retains diagnostic information for an attached child by the internal table index. + * Retains diagnostic information for an attached child by the internal table index. * * @param[in] aChildIndex The table index. * @param[out] aChildInfo A reference to a `Child::Info` to populate with the child information. @@ -268,13 +268,13 @@ class ChildTable : public InstanceLocator, private NonCopyable Error GetChildInfoByIndex(uint16_t aChildIndex, Child::Info &aChildInfo); /** - * This method restores child table from non-volatile memory. + * Restores child table from non-volatile memory. * */ void Restore(void); /** - * This method removes a stored child information from non-volatile memory. + * Removes a stored child information from non-volatile memory. * * @param[in] aChild A reference to the child to remove from non-volatile memory. * @@ -282,7 +282,7 @@ class ChildTable : public InstanceLocator, private NonCopyable void RemoveStoredChild(const Child &aChild); /** - * This method store a child information into non-volatile memory. + * Store a child information into non-volatile memory. * * @param[in] aChild A reference to the child to store. * @@ -293,7 +293,7 @@ class ChildTable : public InstanceLocator, private NonCopyable Error StoreChild(const Child &aChild); /** - * This method indicates whether the child table contains any sleepy child (in states valid or restoring) with a + * Indicates whether the child table contains any sleepy child (in states valid or restoring) with a * given IPv6 address. * * @param[in] aIp6Address An IPv6 address. @@ -305,7 +305,7 @@ class ChildTable : public InstanceLocator, private NonCopyable bool HasSleepyChildWithAddress(const Ip6::Address &aIp6Address) const; /** - * This method indicates whether the child table contains a given `Neighbor` instance. + * Indicates whether the child table contains a given `Neighbor` instance. * * @param[in] aNeighbor A reference to a `Neighbor`. * diff --git a/src/core/thread/csl_tx_scheduler.cpp b/src/core/thread/csl_tx_scheduler.cpp index 9d86408cc76..45facec355a 100644 --- a/src/core/thread/csl_tx_scheduler.cpp +++ b/src/core/thread/csl_tx_scheduler.cpp @@ -115,7 +115,7 @@ void CslTxScheduler::Clear(void) } /** - * This method always finds the most recent CSL tx among all children, + * Always finds the most recent CSL tx among all children, * and requests `Mac` to do CSL tx at specific time. It shouldn't be called * when `Mac` is already starting to do the CSL tx (indicated by `mCslTxMessage`). * @@ -181,6 +181,7 @@ Mac::TxFrame *CslTxScheduler::HandleFrameRequest(Mac::TxFrames &aTxFrames) uint32_t delay; VerifyOrExit(mCslTxChild != nullptr); + VerifyOrExit(mCslTxChild->IsCslSynchronized()); #if OPENTHREAD_CONFIG_MULTI_RADIO frame = &aTxFrames.GetTxFrame(Mac::kRadioTypeIeee802154); @@ -227,7 +228,7 @@ Mac::TxFrame *CslTxScheduler::HandleFrameRequest(Mac::TxFrames &aTxFrames) // in `RescheduleCslTx()` when determining the next CSL delay to // schedule CSL tx with `Mac` but here we calculate the delay with // zero `aAheadUs`. All the timings are in usec but when passing - // delay to `Mac` we divide by `1000` (to covert to msec) which + // delay to `Mac` we divide by `1000` (to convert to msec) which // can round the value down and cause `Mac` to start operation a // bit (some usec) earlier. This is covered by adding the guard // time `kFramePreparationGuardInterval`. diff --git a/src/core/thread/csl_tx_scheduler.hpp b/src/core/thread/csl_tx_scheduler.hpp index e0378b22857..3f1bfec6e48 100644 --- a/src/core/thread/csl_tx_scheduler.hpp +++ b/src/core/thread/csl_tx_scheduler.hpp @@ -55,7 +55,7 @@ namespace ot { class Child; /** - * This class implements CSL tx scheduling functionality. + * Implements CSL tx scheduling functionality. * */ class CslTxScheduler : public InstanceLocator, private NonCopyable @@ -67,7 +67,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable static constexpr uint8_t kMaxCslTriggeredTxAttempts = OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS; /** - * This class defines all the child info required for scheduling CSL transmissions. + * Defines all the child info required for scheduling CSL transmissions. * * `Child` class publicly inherits from this class. * @@ -114,7 +114,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable }; /** - * This class defines the callbacks used by the `CslTxScheduler`. + * Defines the callbacks used by the `CslTxScheduler`. * */ class Callbacks : public InstanceLocator @@ -125,7 +125,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable typedef IndirectSenderBase::FrameContext FrameContext; /** - * This constructor initializes the callbacks object. + * Initializes the callbacks object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -163,7 +163,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable Child &aChild); }; /** - * This constructor initializes the CSL tx scheduler object. + * Initializes the CSL tx scheduler object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -171,7 +171,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable explicit CslTxScheduler(Instance &aInstance); /** - * This method updates the next CSL transmission (finds the nearest child). + * Updates the next CSL transmission (finds the nearest child). * * It would then request the `Mac` to do the CSL tx. If the last CSL tx has been fired at `Mac` but hasn't been * done yet, and it's aborted, this method would set `mCslTxChild` to `nullptr` to notify the `HandleTransmitDone` @@ -181,7 +181,7 @@ class CslTxScheduler : public InstanceLocator, private NonCopyable void Update(void); /** - * This method clears all the states inside `CslTxScheduler` and the related states in each child. + * Clears all the states inside `CslTxScheduler` and the related states in each child. * */ void Clear(void); diff --git a/src/core/thread/discover_scanner.cpp b/src/core/thread/discover_scanner.cpp index 288bbe7c98d..0fa311c906e 100644 --- a/src/core/thread/discover_scanner.cpp +++ b/src/core/thread/discover_scanner.cpp @@ -302,7 +302,6 @@ void DiscoverScanner::HandleDiscoveryResponse(Mle::RxInfo &aRxInfo) const MeshCoP::NetworkNameTlv networkName; ScanResult result; uint16_t offset; - uint16_t length; uint16_t end; bool didCheckSteeringData = false; @@ -311,8 +310,7 @@ void DiscoverScanner::HandleDiscoveryResponse(Mle::RxInfo &aRxInfo) const VerifyOrExit(mState == kStateScanning, error = kErrorDrop); // Find MLE Discovery TLV - SuccessOrExit(error = Tlv::FindTlvValueOffset(aRxInfo.mMessage, Tlv::kDiscovery, offset, length)); - end = offset + length; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aRxInfo.mMessage, Tlv::kDiscovery, offset, end)); memset(&result, 0, sizeof(result)); result.mDiscover = true; diff --git a/src/core/thread/discover_scanner.hpp b/src/core/thread/discover_scanner.hpp index ac5ac523ea0..d9bdd13aaf5 100644 --- a/src/core/thread/discover_scanner.hpp +++ b/src/core/thread/discover_scanner.hpp @@ -54,7 +54,7 @@ class MeshForwarder; namespace Mle { /** - * This class implements MLE Discover Scan. + * Implements MLE Discover Scan. * */ class DiscoverScanner : public InstanceLocator, private NonCopyable @@ -71,13 +71,13 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable static constexpr uint32_t kDefaultScanDuration = Mac::kScanDurationDefault; /** - * This type represents Discover Scan result. + * Represents Discover Scan result. * */ typedef otActiveScanResult ScanResult; /** - * This type represents the handler function pointer called with any Discover Scan result or when the scan + * Represents the handler function pointer called with any Discover Scan result or when the scan * completes. * * The handler function format is `void (*oHandler)(ScanResult *aResult, void *aContext);`. End of scan is @@ -87,7 +87,7 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable typedef otHandleActiveScanResult Handler; /** - * This type represents the filter indexes, i.e., hash bit index values for the bloom filter (calculated from a + * Represents the filter indexes, i.e., hash bit index values for the bloom filter (calculated from a * Joiner ID). * * This is used when filtering is enabled during Discover Scan, i.e., received MLE Discovery Responses with steering @@ -97,7 +97,7 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable typedef MeshCoP::SteeringData::HashBitIndexes FilterIndexes; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -105,7 +105,7 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable explicit DiscoverScanner(Instance &aInstance); /** - * This method starts a Thread Discovery Scan. + * Starts a Thread Discovery Scan. * * @param[in] aScanChannels Channel mask listing channels to scan (if empty, use all supported channels). * @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter). @@ -133,7 +133,7 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable void *aContext); /** - * This method indicates whether or not an MLE Thread Discovery Scan is currently in progress. + * Indicates whether or not an MLE Thread Discovery Scan is currently in progress. * * @returns true if an MLE Thread Discovery Scan is in progress, false otherwise. * @@ -141,7 +141,7 @@ class DiscoverScanner : public InstanceLocator, private NonCopyable bool IsInProgress(void) const { return (mState != kStateIdle); } /** - * This method sets Joiner Advertisement. + * Sets Joiner Advertisement. * * @param[in] aOui The Vendor OUI for Joiner Advertisement. * @param[in] aAdvData A pointer to AdvData for Joiner Advertisement. diff --git a/src/core/thread/dua_manager.cpp b/src/core/thread/dua_manager.cpp index 53faa17f8ea..591aacb30ff 100644 --- a/src/core/thread/dua_manager.cpp +++ b/src/core/thread/dua_manager.cpp @@ -78,10 +78,9 @@ DuaManager::DuaManager(Instance &aInstance) #endif } -void DuaManager::HandleDomainPrefixUpdate(BackboneRouter::Leader::DomainPrefixState aState) +void DuaManager::HandleDomainPrefixUpdate(BackboneRouter::DomainPrefixEvent aEvent) { - if ((aState == BackboneRouter::Leader::kDomainPrefixRemoved) || - (aState == BackboneRouter::Leader::kDomainPrefixRefreshed)) + if ((aEvent == BackboneRouter::kDomainPrefixRemoved) || (aEvent == BackboneRouter::kDomainPrefixRefreshed)) { if (mIsDuaPending) { @@ -102,16 +101,16 @@ void DuaManager::HandleDomainPrefixUpdate(BackboneRouter::Leader::DomainPrefixSt } #if OPENTHREAD_CONFIG_DUA_ENABLE - switch (aState) + switch (aEvent) { - case BackboneRouter::Leader::kDomainPrefixUnchanged: + case BackboneRouter::kDomainPrefixUnchanged: // In case removed for some reason e.g. the kDuaInvalid response from PBBR forcefully VerifyOrExit(!Get().HasUnicastAddress(GetDomainUnicastAddress())); OT_FALL_THROUGH; - case BackboneRouter::Leader::kDomainPrefixRefreshed: - case BackboneRouter::Leader::kDomainPrefixAdded: + case BackboneRouter::kDomainPrefixRefreshed: + case BackboneRouter::kDomainPrefixAdded: { const Ip6::Prefix *prefix = Get().GetDomainPrefix(); OT_ASSERT(prefix != nullptr); @@ -376,7 +375,7 @@ void DuaManager::HandleTimeTick(void) mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay); if ((mDuaState != kNotExist) && - (TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(Mle::kDuaDadPeriod)))) + (TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(kDuaDadPeriod)))) { mDomainUnicastAddress.mPreferred = true; } @@ -546,7 +545,7 @@ void DuaManager::PerformNextRegistration(void) exit: if (error == kErrorNoBufs) { - UpdateCheckDelay(Mle::kNoBufDelay); + UpdateCheckDelay(kNoBufDelay); } LogInfo("PerformNextRegistration: %s", ErrorToString(error)); @@ -574,7 +573,7 @@ void DuaManager::HandleDuaResponse(Coap::Message *aMessage, const Ip6::MessageIn if (aResult == kErrorResponseTimeout) { - UpdateCheckDelay(Mle::KResponseTimeoutDelay); + UpdateCheckDelay(KResponseTimeoutDelay); ExitNow(error = aResult); } @@ -758,12 +757,11 @@ void DuaManager::SendAddressNotification(Ip6::Address &aAddress, } } -void DuaManager::UpdateChildDomainUnicastAddress(const Child &aChild, Mle::ChildDuaState aState) +void DuaManager::HandleChildDuaAddressEvent(const Child &aChild, ChildDuaAddressEvent aEvent) { uint16_t childIndex = Get().GetChildIndex(aChild); - if ((aState == Mle::ChildDuaState::kRemoved || aState == Mle::ChildDuaState::kChanged) && - mChildDuaMask.Get(childIndex)) + if ((aEvent == kAddressRemoved || aEvent == kAddressChanged) && mChildDuaMask.Get(childIndex)) { // Abort on going proxy DUA.req for this child if (mChildIndexDuaRegistering == childIndex) @@ -775,12 +773,12 @@ void DuaManager::UpdateChildDomainUnicastAddress(const Child &aChild, Mle::Child mChildDuaRegisteredMask.Set(childIndex, false); } - if (aState == Mle::ChildDuaState::kAdded || aState == Mle::ChildDuaState::kChanged || - (aState == Mle::ChildDuaState::kUnchanged && !mChildDuaMask.Get(childIndex))) + if (aEvent == kAddressAdded || aEvent == kAddressChanged || + (aEvent == kAddressUnchanged && !mChildDuaMask.Get(childIndex))) { if (mChildDuaMask == mChildDuaRegisteredMask) { - UpdateCheckDelay(Random::NonCrypto::GetUint8InRange(1, Mle::kParentAggregateDelay)); + UpdateCheckDelay(Random::NonCrypto::GetUint8InRange(1, BackboneRouter::kParentAggregateDelay)); } mChildDuaMask.Set(childIndex, true); diff --git a/src/core/thread/dua_manager.hpp b/src/core/thread/dua_manager.hpp index d8df6c672be..383111566d8 100644 --- a/src/core/thread/dua_manager.hpp +++ b/src/core/thread/dua_manager.hpp @@ -77,7 +77,7 @@ namespace ot { */ /** - * This class implements managing DUA. + * Implements managing DUA. * */ class DuaManager : public InstanceLocator, private NonCopyable @@ -88,7 +88,7 @@ class DuaManager : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -96,15 +96,15 @@ class DuaManager : public InstanceLocator, private NonCopyable explicit DuaManager(Instance &aInstance); /** - * This method notifies Domain Prefix status. + * Notifies Domain Prefix changes. * - * @param[in] aState The Domain Prefix state or state change. + * @param[in] aEvent The Domain Prefix event. * */ - void HandleDomainPrefixUpdate(BackboneRouter::Leader::DomainPrefixState aState); + void HandleDomainPrefixUpdate(BackboneRouter::DomainPrefixEvent aEvent); /** - * This method notifies Primary Backbone Router status. + * Notifies Primary Backbone Router status. * * @param[in] aState The state or state change of Primary Backbone Router. * @param[in] aConfig The Primary Backbone Router service. @@ -115,7 +115,7 @@ class DuaManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_DUA_ENABLE /** - * This method returns a reference to the Domain Unicast Address. + * Returns a reference to the Domain Unicast Address. * * @returns A reference to the Domain Unicast Address. * @@ -123,7 +123,7 @@ class DuaManager : public InstanceLocator, private NonCopyable const Ip6::Address &GetDomainUnicastAddress(void) const { return mDomainUnicastAddress.GetAddress(); } /** - * This method sets the Interface Identifier manually specified for the Thread Domain Unicast Address. + * Sets the Interface Identifier manually specified for the Thread Domain Unicast Address. * * @param[in] aIid A reference to the Interface Identifier to set. * @@ -134,13 +134,13 @@ class DuaManager : public InstanceLocator, private NonCopyable Error SetFixedDuaInterfaceIdentifier(const Ip6::InterfaceIdentifier &aIid); /** - * This method clears the Interface Identifier manually specified for the Thread Domain Unicast Address. + * Clears the Interface Identifier manually specified for the Thread Domain Unicast Address. * */ void ClearFixedDuaInterfaceIdentifier(void); /** - * This method indicates whether or not there is Interface Identifier manually specified for the Thread + * Indicates whether or not there is Interface Identifier manually specified for the Thread * Domain Unicast Address. * * @retval true If there is Interface Identifier manually specified. @@ -150,7 +150,7 @@ class DuaManager : public InstanceLocator, private NonCopyable bool IsFixedDuaInterfaceIdentifierSet(void) { return !mFixedDuaInterfaceIdentifier.IsUnspecified(); } /** - * This method gets the Interface Identifier for the Thread Domain Unicast Address if manually specified. + * Gets the Interface Identifier for the Thread Domain Unicast Address if manually specified. * * @returns A reference to the Interface Identifier. * @@ -158,25 +158,47 @@ class DuaManager : public InstanceLocator, private NonCopyable const Ip6::InterfaceIdentifier &GetFixedDuaInterfaceIdentifier(void) const { return mFixedDuaInterfaceIdentifier; } /* - * This method restores duplicate address detection information from non-volatile memory. + * Restores duplicate address detection information from non-volatile memory. * */ void Restore(void); /** - * This method notifies duplicated Domain Unicast Address. + * Notifies duplicated Domain Unicast Address. * */ void NotifyDuplicateDomainUnicastAddress(void); #endif #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - void UpdateChildDomainUnicastAddress(const Child &aChild, Mle::ChildDuaState aState); + /** + * Events related to a Child DUA address. + * + */ + enum ChildDuaAddressEvent : uint8_t + { + kAddressAdded, ///< A new DUA registered by the Child via Address Registration. + kAddressChanged, ///< A different DUA registered by the Child via Address Registration. + kAddressRemoved, ///< DUA registered by the Child is removed and not in Address Registration. + kAddressUnchanged, ///< The Child registers the same DUA again. + }; + + /** + * Handles Child DUA address event. + * + * @param[in] aChild A child. + * @param[in] aEvent The DUA address event for @p aChild. + * + */ + void HandleChildDuaAddressEvent(const Child &aChild, ChildDuaAddressEvent aEvent); #endif private: - static constexpr uint8_t kNewRouterRegistrationDelay = 3; ///< Delay (in sec) to establish link for a new router. - static constexpr uint8_t kNewDuaRegistrationDelay = 1; ///< Delay (in sec) for newly added DUA. + static constexpr uint32_t kDuaDadPeriod = 100; // DAD wait time to become "Preferred" (in sec). + static constexpr uint8_t kNoBufDelay = 5; // In sec. + static constexpr uint8_t KResponseTimeoutDelay = 30; // In sec. + static constexpr uint8_t kNewRouterRegistrationDelay = 3; // Delay (in sec) to establish link for a new router. + static constexpr uint8_t kNewDuaRegistrationDelay = 1; // Delay (in sec) for newly added DUA. #if OPENTHREAD_CONFIG_DUA_ENABLE Error GenerateDomainUnicastAddressIid(void); diff --git a/src/core/thread/energy_scan_server.hpp b/src/core/thread/energy_scan_server.hpp index ca7c7a50675..99fe32e89f3 100644 --- a/src/core/thread/energy_scan_server.hpp +++ b/src/core/thread/energy_scan_server.hpp @@ -48,7 +48,7 @@ namespace ot { /** - * This class implements handling Energy Scan Requests. + * Implements handling Energy Scan Requests. * */ class EnergyScanServer : public InstanceLocator, private NonCopyable @@ -58,7 +58,7 @@ class EnergyScanServer : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit EnergyScanServer(Instance &aInstance); diff --git a/src/core/thread/indirect_sender.hpp b/src/core/thread/indirect_sender.hpp index f04b54f1ce4..b15c942e8d0 100644 --- a/src/core/thread/indirect_sender.hpp +++ b/src/core/thread/indirect_sender.hpp @@ -62,7 +62,7 @@ namespace ot { class Child; /** - * This class implements indirect transmission. + * Implements indirect transmission. * */ class IndirectSender : public InstanceLocator, public IndirectSenderBase, private NonCopyable @@ -75,7 +75,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat public: /** - * This class defines all the child info required for indirect transmission. + * Defines all the child info required for indirect transmission. * * `Child` class publicly inherits from this class. * @@ -89,7 +89,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat public: /** - * This method returns the number of queued messages for the child. + * Returns the number of queued messages for the child. * * @returns Number of queued messages for the child. * @@ -134,7 +134,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat }; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -142,13 +142,13 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat explicit IndirectSender(Instance &aInstance); /** - * This method enables indirect transmissions. + * Enables indirect transmissions. * */ void Start(void) { mEnabled = true; } /** - * This method disables indirect transmission. + * Disables indirect transmission. * * Any previously scheduled indirect transmission is canceled. * @@ -156,7 +156,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat void Stop(void); /** - * This method adds a message for indirect transmission to a sleepy child. + * Adds a message for indirect transmission to a sleepy child. * * @param[in] aMessage The message to add. * @param[in] aChild The (sleepy) child for indirect transmission. @@ -165,7 +165,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat void AddMessageForSleepyChild(Message &aMessage, Child &aChild); /** - * This method removes a message for indirect transmission to a sleepy child. + * Removes a message for indirect transmission to a sleepy child. * * @param[in] aMessage The message to update. * @param[in] aChild The (sleepy) child for indirect transmission. @@ -177,7 +177,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat Error RemoveMessageFromSleepyChild(Message &aMessage, Child &aChild); /** - * This method removes all added messages for a specific child and frees message (with no indirect/direct tx). + * Removes all added messages for a specific child and frees message (with no indirect/direct tx). * * @param[in] aChild A reference to a child whose messages shall be removed. * @@ -185,7 +185,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat void ClearAllMessagesForSleepyChild(Child &aChild); /** - * This method sets whether to use the extended or short address for a child. + * Sets whether to use the extended or short address for a child. * * @param[in] aChild A reference to the child. * @param[in] aUseShortAddress `true` to use short address, `false` to use extended address. @@ -194,7 +194,7 @@ class IndirectSender : public InstanceLocator, public IndirectSenderBase, privat void SetChildUseShortAddress(Child &aChild, bool aUseShortAddress); /** - * This method handles a child mode change and updates any queued messages for the child accordingly. + * Handles a child mode change and updates any queued messages for the child accordingly. * * @param[in] aChild The child whose device mode was changed. * @param[in] aOldMode The old device mode of the child. diff --git a/src/core/thread/indirect_sender_frame_context.hpp b/src/core/thread/indirect_sender_frame_context.hpp index 9e14348b3f8..b1d9c2ac97e 100644 --- a/src/core/thread/indirect_sender_frame_context.hpp +++ b/src/core/thread/indirect_sender_frame_context.hpp @@ -50,7 +50,7 @@ namespace ot { */ /** - * This class defines the `FrameContext` type. + * Defines the `FrameContext` type. * * This is the base class for `IndirectSender`. * @@ -59,9 +59,9 @@ class IndirectSenderBase { public: /** - * This type defines the frame context used by `IndirectSender`. + * Defines the frame context used by `IndirectSender`. * - * This type specifies all the info that `IndirectSender` requires to be saved along with a prepared frame for + * Specifies all the info that `IndirectSender` requires to be saved along with a prepared frame for * indirect transmission. `IndirectSender` is designed to contain the common code for handling of indirect * transmission to sleepy children and be able to interface to different lower-layer implementation of * `DataPollHandler`. While the `FrameContext` is defined by the `IndirectSender` itself, the lower-layer diff --git a/src/core/thread/key_manager.hpp b/src/core/thread/key_manager.hpp index 7428301c973..18f11f20b77 100644 --- a/src/core/thread/key_manager.hpp +++ b/src/core/thread/key_manager.hpp @@ -65,7 +65,7 @@ namespace ot { */ /** - * This class represents Security Policy Rotation and Flags. + * Represents Security Policy Rotation and Flags. * */ class SecurityPolicy : public otSecurityPolicy, public Equatable @@ -81,20 +81,20 @@ class SecurityPolicy : public otSecurityPolicy, public Equatable static constexpr uint16_t kDefaultKeyRotationTime = 672; ///< Default Key Rotation Time (in unit of hours). /** - * This constructor initializes the object with default Key Rotation Time + * Initializes the object with default Key Rotation Time * and Security Policy Flags. * */ SecurityPolicy(void) { SetToDefault(); } /** - * This method sets the Security Policy to default values. + * Sets the Security Policy to default values. * */ void SetToDefault(void); /** - * This method sets the Security Policy Flags. + * Sets the Security Policy Flags. * * @param[in] aFlags The Security Policy Flags. * @param[in] aFlagsLength The length of the Security Policy Flags, 1 byte for @@ -104,7 +104,7 @@ class SecurityPolicy : public otSecurityPolicy, public Equatable void SetFlags(const uint8_t *aFlags, uint8_t aFlagsLength); /** - * This method returns the Security Policy Flags. + * Returns the Security Policy Flags. * * @param[out] aFlags A pointer to the Security Policy Flags buffer. * @param[in] aFlagsLength The length of the Security Policy Flags buffer. @@ -131,7 +131,7 @@ class SecurityPolicy : public otSecurityPolicy, public Equatable }; /** - * This class represents a Thread Network Key. + * Represents a Thread Network Key. * */ OT_TOOL_PACKED_BEGIN @@ -142,13 +142,13 @@ class NetworkKey : public otNetworkKey, public Equatable, public Cle #if !OPENTHREAD_RADIO /** - * This method generates a cryptographically secure random sequence to populate the Thread Network Key. + * Generates a cryptographically secure random sequence to populate the Thread Network Key. * * @retval kErrorNone Successfully generated a random Thread Network Key. * @retval kErrorFailed Failed to generate random sequence. * */ - Error GenerateRandom(void) { return Random::Crypto::FillBuffer(m8, sizeof(m8)); } + Error GenerateRandom(void) { return Random::Crypto::Fill(*this); } #endif } OT_TOOL_PACKED_END; @@ -162,7 +162,7 @@ typedef otNetworkKeyRef NetworkKeyRef; #endif /** - * This class represents a Thread Pre-Shared Key for the Commissioner (PSKc). + * Represents a Thread Pre-Shared Key for the Commissioner (PSKc). * */ OT_TOOL_PACKED_BEGIN @@ -173,12 +173,12 @@ class Pskc : public otPskc, public Equatable, public Clearable #if !OPENTHREAD_RADIO /** - * This method generates a cryptographically secure random sequence to populate the Thread PSKc. + * Generates a cryptographically secure random sequence to populate the Thread PSKc. * * @retval kErrorNone Successfully generated a random Thread PSKc. * */ - Error GenerateRandom(void) { return Random::Crypto::FillBuffer(m8, sizeof(m8)); } + Error GenerateRandom(void) { return Random::Crypto::Fill(*this); } #endif } OT_TOOL_PACKED_END; @@ -192,27 +192,27 @@ typedef otPskcRef PskcRef; /** * - * This class represents a Key Encryption Key (KEK). + * Represents a Key Encryption Key (KEK). * */ typedef Mac::Key Kek; /** * - * This class represents a Key Material for Key Encryption Key (KEK). + * Represents a Key Material for Key Encryption Key (KEK). * */ typedef Mac::KeyMaterial KekKeyMaterial; /** - * This class defines Thread Key Manager. + * Defines Thread Key Manager. * */ class KeyManager : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -220,19 +220,19 @@ class KeyManager : public InstanceLocator, private NonCopyable explicit KeyManager(Instance &aInstance); /** - * This method starts KeyManager rotation timer and sets guard timer to initial value. + * Starts KeyManager rotation timer and sets guard timer to initial value. * */ void Start(void); /** - * This method stops KeyManager timers. + * Stops KeyManager timers. * */ void Stop(void); /** - * This method gets the Thread Network Key. + * Gets the Thread Network Key. * * @param[out] aNetworkKey A reference to a `NetworkKey` to output the Thread Network Key. * @@ -240,7 +240,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void GetNetworkKey(NetworkKey &aNetworkKey) const; /** - * This method sets the Thread Network Key. + * Sets the Thread Network Key. * * @param[in] aNetworkKey A Thread Network Key. * @@ -249,7 +249,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method returns a Key Ref to Thread Network Key. + * Returns a Key Ref to Thread Network Key. * * @returns A key reference to the Thread Network Key. * @@ -257,7 +257,7 @@ class KeyManager : public InstanceLocator, private NonCopyable NetworkKeyRef GetNetworkKeyRef(void) const { return mNetworkKeyRef; } /** - * This method sets the Thread Network Key using Key Reference. + * Sets the Thread Network Key using Key Reference. * * @param[in] aKeyRef Reference to Thread Network Key. * @@ -266,7 +266,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #endif /** - * This method indicates whether the PSKc is configured. + * Indicates whether the PSKc is configured. * * A value of all zeros indicates that the PSKc is not configured. * @@ -277,7 +277,7 @@ class KeyManager : public InstanceLocator, private NonCopyable bool IsPskcSet(void) const { return mIsPskcSet; } /** - * This method gets the PKSc. + * Gets the PKSc. * * @param[out] aPskc A reference to a `Pskc` to return the PSKc. * @@ -285,7 +285,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void GetPskc(Pskc &aPskc) const; /** - * This method sets the PSKc. + * Sets the PSKc. * * @param[in] aPskc A reference to the PSKc. * @@ -294,7 +294,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method returns a Key Ref to PSKc. + * Returns a Key Ref to PSKc. * * @returns A key reference to the PSKc. * @@ -302,7 +302,7 @@ class KeyManager : public InstanceLocator, private NonCopyable const PskcRef &GetPskcRef(void) const { return mPskcRef; } /** - * This method sets the PSKc as a Key reference. + * Sets the PSKc as a Key reference. * * @param[in] aPskc A reference to the PSKc. * @@ -311,7 +311,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #endif /** - * This method returns the current key sequence value. + * Returns the current key sequence value. * * @returns The current key sequence value. * @@ -319,7 +319,7 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetCurrentKeySequence(void) const { return mKeySequence; } /** - * This method sets the current key sequence value. + * Sets the current key sequence value. * * @param[in] aKeySequence The key sequence value. * @@ -328,7 +328,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method returns the current MAC key for TREL radio link. + * Returns the current MAC key for TREL radio link. * * @returns The current TREL MAC key. * @@ -336,7 +336,7 @@ class KeyManager : public InstanceLocator, private NonCopyable const Mac::KeyMaterial &GetCurrentTrelMacKey(void) const { return mTrelKey; } /** - * This method returns a temporary MAC key for TREL radio link computed from the given key sequence. + * Returns a temporary MAC key for TREL radio link computed from the given key sequence. * * @param[in] aKeySequence The key sequence value. * @@ -347,7 +347,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #endif /** - * This method returns the current MLE key Material. + * Returns the current MLE key Material. * * @returns The current MLE key. * @@ -355,7 +355,7 @@ class KeyManager : public InstanceLocator, private NonCopyable const Mle::KeyMaterial &GetCurrentMleKey(void) const { return mMleKey; } /** - * This method returns a temporary MLE key Material computed from the given key sequence. + * Returns a temporary MLE key Material computed from the given key sequence. * * @param[in] aKeySequence The key sequence value. * @@ -366,7 +366,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE /** - * This method returns the current MAC Frame Counter value for 15.4 radio link. + * Returns the current MAC Frame Counter value for 15.4 radio link. * * @returns The current MAC Frame Counter value. * @@ -376,7 +376,7 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method returns the current MAC Frame Counter value for TREL radio link. + * Returns the current MAC Frame Counter value for TREL radio link. * * @returns The current MAC Frame Counter value for TREL radio link. * @@ -384,14 +384,14 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetTrelMacFrameCounter(void) const { return mMacFrameCounters.GetTrel(); } /** - * This method increments the current MAC Frame Counter value for TREL radio link. + * Increments the current MAC Frame Counter value for TREL radio link. * */ void IncrementTrelMacFrameCounter(void); #endif /** - * This method gets the maximum MAC Frame Counter among all supported radio links. + * Gets the maximum MAC Frame Counter among all supported radio links. * * @return The maximum MAC frame Counter among all supported radio links. * @@ -399,7 +399,7 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetMaximumMacFrameCounter(void) const { return mMacFrameCounters.GetMaximum(); } /** - * This method sets the current MAC Frame Counter value for all radio links. + * Sets the current MAC Frame Counter value for all radio links. * * @param[in] aFrameCounter The MAC Frame Counter value. * @param[in] aSetIfLarger If `true`, set only if the new value @p aFrameCounter is larger than current value. @@ -409,7 +409,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetAllMacFrameCounters(uint32_t aFrameCounter, bool aSetIfLarger); /** - * This method sets the MAC Frame Counter value which is stored in non-volatile memory. + * Sets the MAC Frame Counter value which is stored in non-volatile memory. * * @param[in] aStoredMacFrameCounter The stored MAC Frame Counter value. * @@ -417,7 +417,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetStoredMacFrameCounter(uint32_t aStoredMacFrameCounter) { mStoredMacFrameCounter = aStoredMacFrameCounter; } /** - * This method returns the current MLE Frame Counter value. + * Returns the current MLE Frame Counter value. * * @returns The current MLE Frame Counter value. * @@ -425,7 +425,7 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetMleFrameCounter(void) const { return mMleFrameCounter; } /** - * This method sets the current MLE Frame Counter value. + * Sets the current MLE Frame Counter value. * * @param[in] aMleFrameCounter The MLE Frame Counter value. * @@ -433,7 +433,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetMleFrameCounter(uint32_t aMleFrameCounter) { mMleFrameCounter = aMleFrameCounter; } /** - * This method sets the MLE Frame Counter value which is stored in non-volatile memory. + * Sets the MLE Frame Counter value which is stored in non-volatile memory. * * @param[in] aStoredMleFrameCounter The stored MLE Frame Counter value. * @@ -441,13 +441,13 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetStoredMleFrameCounter(uint32_t aStoredMleFrameCounter) { mStoredMleFrameCounter = aStoredMleFrameCounter; } /** - * This method increments the current MLE Frame Counter value. + * Increments the current MLE Frame Counter value. * */ void IncrementMleFrameCounter(void); /** - * This method returns the KEK as `KekKeyMaterial` + * Returns the KEK as `KekKeyMaterial` * * @returns The KEK as `KekKeyMaterial`. * @@ -455,7 +455,7 @@ class KeyManager : public InstanceLocator, private NonCopyable const KekKeyMaterial &GetKek(void) const { return mKek; } /** - * This method retrieves the KEK as literal `Kek` key. + * Retrieves the KEK as literal `Kek` key. * * @param[out] aKek A reference to a `Kek` to output the retrieved KEK. * @@ -463,7 +463,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void ExtractKek(Kek &aKek) { mKek.ExtractKey(aKek); } /** - * This method sets the KEK. + * Sets the KEK. * * @param[in] aKek A KEK. * @@ -471,7 +471,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetKek(const Kek &aKek); /** - * This method sets the KEK. + * Sets the KEK. * * @param[in] aKekBytes A pointer to the KEK bytes. * @@ -479,7 +479,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetKek(const uint8_t *aKekBytes) { SetKek(*reinterpret_cast(aKekBytes)); } /** - * This method returns the current KEK Frame Counter value. + * Returns the current KEK Frame Counter value. * * @returns The current KEK Frame Counter value. * @@ -487,13 +487,13 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetKekFrameCounter(void) const { return mKekFrameCounter; } /** - * This method increments the current KEK Frame Counter value. + * Increments the current KEK Frame Counter value. * */ void IncrementKekFrameCounter(void) { mKekFrameCounter++; } /** - * This method returns the KeySwitchGuardTime. + * Returns the KeySwitchGuardTime. * * The KeySwitchGuardTime is the time interval during which key rotation procedure is prevented. * @@ -503,7 +503,7 @@ class KeyManager : public InstanceLocator, private NonCopyable uint32_t GetKeySwitchGuardTime(void) const { return mKeySwitchGuardTime; } /** - * This method sets the KeySwitchGuardTime. + * Sets the KeySwitchGuardTime. * * The KeySwitchGuardTime is the time interval during which key rotation procedure is prevented. * @@ -513,7 +513,7 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetKeySwitchGuardTime(uint32_t aKeySwitchGuardTime) { mKeySwitchGuardTime = aKeySwitchGuardTime; } /** - * This method returns the Security Policy. + * Returns the Security Policy. * * The Security Policy specifies Key Rotation Time and network administrator preferences * for which security-related operations are allowed or disallowed. @@ -524,7 +524,7 @@ class KeyManager : public InstanceLocator, private NonCopyable const SecurityPolicy &GetSecurityPolicy(void) const { return mSecurityPolicy; } /** - * This method sets the Security Policy. + * Sets the Security Policy. * * The Security Policy specifies Key Rotation Time and network administrator preferences * for which security-related operations are allowed or disallowed. @@ -535,13 +535,13 @@ class KeyManager : public InstanceLocator, private NonCopyable void SetSecurityPolicy(const SecurityPolicy &aSecurityPolicy); /** - * This method updates the MAC keys and MLE key. + * Updates the MAC keys and MLE key. * */ void UpdateKeyMaterial(void); /** - * This method handles MAC frame counter changes (callback from `SubMac` for 15.4 security frame change). + * Handles MAC frame counter changes (callback from `SubMac` for 15.4 security frame change). * * This is called to indicate the @p aMacFrameCounter value is now used. * @@ -552,13 +552,13 @@ class KeyManager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE /** - * This method destroys all the volatile mac keys stored in PSA ITS. + * Destroys all the volatile mac keys stored in PSA ITS. * */ void DestroyTemporaryKeys(void); /** - * This method destroys all the persistent keys stored in PSA ITS. + * Destroys all the persistent keys stored in PSA ITS. * */ void DestroyPersistentKeys(void); diff --git a/src/core/thread/link_metrics.cpp b/src/core/thread/link_metrics.cpp index cfe784c4ffe..96a789f8914 100644 --- a/src/core/thread/link_metrics.cpp +++ b/src/core/thread/link_metrics.cpp @@ -306,14 +306,13 @@ Error Initiator::HandleManagementResponse(const Message &aMessage, const Ip6::Ad Error error = kErrorNone; uint16_t offset; uint16_t endOffset; - uint16_t length; uint8_t status; bool hasStatus = false; VerifyOrExit(mMgmtResponseCallback.IsSet()); - SuccessOrExit(error = Tlv::FindTlvValueOffset(aMessage, Mle::Tlv::Type::kLinkMetricsManagement, offset, length)); - endOffset = offset + length; + SuccessOrExit( + error = Tlv::FindTlvValueStartEndOffsets(aMessage, Mle::Tlv::Type::kLinkMetricsManagement, offset, endOffset)); while (offset < endOffset) { @@ -434,9 +433,8 @@ Error Subject::AppendReport(Message &aMessage, const Message &aRequestMessage, N // Parse MLE Link Metrics Query TLV and its sub-TLVs from // `aRequestMessage`. - SuccessOrExit(error = Tlv::FindTlvValueOffset(aRequestMessage, Mle::Tlv::Type::kLinkMetricsQuery, offset, length)); - - endOffset = offset + length; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aRequestMessage, Mle::Tlv::Type::kLinkMetricsQuery, offset, + endOffset)); while (offset < endOffset) { @@ -519,13 +517,12 @@ Error Subject::HandleManagementRequest(const Message &aMessage, Neighbor &aNeigh uint16_t offset; uint16_t endOffset; uint16_t tlvEndOffset; - uint16_t length; FwdProbingRegSubTlv fwdProbingSubTlv; EnhAckConfigSubTlv enhAckConfigSubTlv; Metrics metrics; - SuccessOrExit(error = Tlv::FindTlvValueOffset(aMessage, Mle::Tlv::Type::kLinkMetricsManagement, offset, length)); - endOffset = offset + length; + SuccessOrExit( + error = Tlv::FindTlvValueStartEndOffsets(aMessage, Mle::Tlv::Type::kLinkMetricsManagement, offset, endOffset)); // Set sub-TLV lengths to zero to indicate that we have // not yet seen them in the message. @@ -812,7 +809,7 @@ int8_t ScaleRawValueToRssi(uint8_t aRawValue) value = DivideAndRoundToClosest(value, NumericLimits::kMax); value += kMinRssi; - return static_cast(value); + return ClampToInt8(value); } } // namespace LinkMetrics diff --git a/src/core/thread/link_metrics.hpp b/src/core/thread/link_metrics.hpp index 0dcdd991ffe..36b64820e63 100644 --- a/src/core/thread/link_metrics.hpp +++ b/src/core/thread/link_metrics.hpp @@ -74,7 +74,7 @@ namespace LinkMetrics { #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE /** - * This class implements the Thread Link Metrics Initiator. + * Implements the Thread Link Metrics Initiator. * * The Initiator makes queries, configures Link Metrics probing at the Subject and generates reports of the results. * @@ -88,7 +88,7 @@ class Initiator : public InstanceLocator, private NonCopyable typedef otLinkMetricsEnhAckProbingIeReportCallback EnhAckProbingIeReportCallback; /** - * This structure provides the info used for appending MLE Link Metric Query TLV. + * Provides the info used for appending MLE Link Metric Query TLV. * */ struct QueryInfo : public Clearable @@ -99,7 +99,7 @@ class Initiator : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes an instance of the Initiator class. + * Initializes an instance of the Initiator class. * * @param[in] aInstance A reference to the OpenThread interface. * @@ -107,7 +107,7 @@ class Initiator : public InstanceLocator, private NonCopyable explicit Initiator(Instance &aInstance); /** - * This method sends an MLE Data Request containing Link Metrics Query TLV to query Link Metrics data. + * Sends an MLE Data Request containing Link Metrics Query TLV to query Link Metrics data. * * It could be either a Single Probe or a Forward Tracking Series. * @@ -124,7 +124,7 @@ class Initiator : public InstanceLocator, private NonCopyable Error Query(const Ip6::Address &aDestination, uint8_t aSeriesId, const Metrics *aMetrics); /** - * This method appends MLE Link Metrics Query TLV to a given message. + * Appends MLE Link Metrics Query TLV to a given message. * * @param[in] aMessage The message to append to. * @param[in] aInfo The link metrics query info to use to prepare the message. @@ -136,7 +136,7 @@ class Initiator : public InstanceLocator, private NonCopyable Error AppendLinkMetricsQueryTlv(Message &aMessage, const QueryInfo &aInfo); /** - * This method registers a callback to handle Link Metrics report received. + * Registers a callback to handle Link Metrics report received. * * @param[in] aCallback A pointer to a function that is called when a Link Metrics report is received. * @param[in] aContext A pointer to application-specific context. @@ -145,7 +145,7 @@ class Initiator : public InstanceLocator, private NonCopyable void SetReportCallback(ReportCallback aCallback, void *aContext) { mReportCallback.Set(aCallback, aContext); } /** - * This method handles the received Link Metrics report contained in @p aMessage. + * Handles the received Link Metrics report contained in @p aMessage. * * @param[in] aMessage A reference to the message. * @param[in] aOffset The offset in bytes where the metrics report sub-TLVs start. @@ -156,7 +156,7 @@ class Initiator : public InstanceLocator, private NonCopyable void HandleReport(const Message &aMessage, uint16_t aOffset, uint16_t aLength, const Ip6::Address &aAddress); /** - * This method sends an MLE Link Metrics Management Request to configure/clear a Forward Tracking Series. + * Sends an MLE Link Metrics Management Request to configure/clear a Forward Tracking Series. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aSeriesId The Series ID. @@ -175,7 +175,7 @@ class Initiator : public InstanceLocator, private NonCopyable const Metrics *aMetrics); /** - * This method registers a callback to handle Link Metrics Management Response received. + * Registers a callback to handle Link Metrics Management Response received. * * @param[in] aCallback A pointer to a function that is called when a Link Metrics Management Response is received. * @param[in] aContext A pointer to application-specific context. @@ -187,7 +187,7 @@ class Initiator : public InstanceLocator, private NonCopyable } /** - * This method sends an MLE Link Metrics Management Request to configure/clear a Enhanced-ACK Based Probing. + * Sends an MLE Link Metrics Management Request to configure/clear a Enhanced-ACK Based Probing. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aEnhAckFlags Enh-ACK Flags to indicate whether to register or clear the probing. `0` to clear @@ -206,7 +206,7 @@ class Initiator : public InstanceLocator, private NonCopyable const Metrics *aMetrics); /** - * This method registers a callback to handle Link Metrics when Enh-ACK Probing IE is received. + * Registers a callback to handle Link Metrics when Enh-ACK Probing IE is received. * * @param[in] aCallback A pointer to a function that is called when Enh-ACK Probing IE is received is received. * @param[in] aContext A pointer to application-specific context. @@ -218,7 +218,7 @@ class Initiator : public InstanceLocator, private NonCopyable } /** - * This method handles the received Link Metrics Management Response contained in @p aMessage. + * Handles the received Link Metrics Management Response contained in @p aMessage. * * @param[in] aMessage A reference to the message that contains the Link Metrics Management Response. * @param[in] aAddress A reference to the source address of the message. @@ -230,7 +230,7 @@ class Initiator : public InstanceLocator, private NonCopyable Error HandleManagementResponse(const Message &aMessage, const Ip6::Address &aAddress); /** - * This method sends an MLE Link Probe message. + * Sends an MLE Link Probe message. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aSeriesId The Series ID which the Probe message targets at. @@ -245,7 +245,7 @@ class Initiator : public InstanceLocator, private NonCopyable Error SendLinkProbe(const Ip6::Address &aDestination, uint8_t aSeriesId, uint8_t aLength); /** - * This method processes received Enh-ACK Probing IE data. + * Processes received Enh-ACK Probing IE data. * * @param[in] aData A pointer to buffer containing the Enh-ACK Probing IE data. * @param[in] aLength The length of @p aData. @@ -269,7 +269,7 @@ class Initiator : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This class implements the Thread Link Metrics Subject. + * Implements the Thread Link Metrics Subject. * * The Subject reponds queries with reports, handles Link Metrics Management Requests and Link Probe Messages. * @@ -280,7 +280,7 @@ class Subject : public InstanceLocator, private NonCopyable typedef otLinkMetricsEnhAckProbingIeReportCallback EnhAckProbingIeReportCallback; /** - * This constructor initializes an instance of the Subject class. + * Initializes an instance of the Subject class. * * @param[in] aInstance A reference to the OpenThread interface. * @@ -288,7 +288,7 @@ class Subject : public InstanceLocator, private NonCopyable explicit Subject(Instance &aInstance); /** - * This method appends a Link Metrics Report to a message according to the Link Metrics query. + * Appends a Link Metrics Report to a message according to the Link Metrics query. * * @param[out] aMessage A reference to the message to append report. * @param[in] aRequestMessage A reference to the message of the Data Request. @@ -302,7 +302,7 @@ class Subject : public InstanceLocator, private NonCopyable Error AppendReport(Message &aMessage, const Message &aRequestMessage, Neighbor &aNeighbor); /** - * This method handles the received Link Metrics Management Request contained in @p aMessage and return a status. + * Handles the received Link Metrics Management Request contained in @p aMessage and return a status. * * @param[in] aMessage A reference to the message that contains the Link Metrics Management Request. * @param[in] aNeighbor A reference to the neighbor who sends the request. @@ -315,7 +315,7 @@ class Subject : public InstanceLocator, private NonCopyable Error HandleManagementRequest(const Message &aMessage, Neighbor &aNeighbor, Status &aStatus); /** - * This method handles the Link Probe contained in @p aMessage. + * Handles the Link Probe contained in @p aMessage. * * @param[in] aMessage A reference to the message that contains the Link Probe Message. * @param[out] aSeriesId A reference to Series ID that parsed from the message. @@ -327,7 +327,7 @@ class Subject : public InstanceLocator, private NonCopyable Error HandleLinkProbe(const Message &aMessage, uint8_t &aSeriesId); /** - * This method frees a SeriesInfo entry that was allocated from the Subject object. + * Frees a SeriesInfo entry that was allocated from the Subject object. * * @param[in] aSeries A reference to the SeriesInfo to free. * diff --git a/src/core/thread/link_metrics_tlvs.hpp b/src/core/thread/link_metrics_tlvs.hpp index ccf4af1ac97..46464c9b3ec 100644 --- a/src/core/thread/link_metrics_tlvs.hpp +++ b/src/core/thread/link_metrics_tlvs.hpp @@ -53,7 +53,7 @@ namespace LinkMetrics { using ot::Encoding::BigEndian::HostSwap32; /** - * This class defines constants related to Link Metrics Sub-TLVs. + * Defines constants related to Link Metrics Sub-TLVs. * */ class SubTlv @@ -75,19 +75,19 @@ class SubTlv }; /** - * This class defines Link Metrics Query ID Sub-TLV constants and types. + * Defines Link Metrics Query ID Sub-TLV constants and types. * */ typedef UintTlvInfo QueryIdSubTlv; /** - * This type defines a Link Metrics Status Sub-Tlv. + * Defines a Link Metrics Status Sub-Tlv. * */ typedef UintTlvInfo StatusSubTlv; /** - * This class implements Link Metrics Report Sub-TLV generation and parsing. + * Implements Link Metrics Report Sub-TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -97,13 +97,13 @@ class ReportSubTlv : public Tlv, public TlvInfo static constexpr uint8_t kMinLength = 2; ///< Minimum expected TLV length (type ID and u8 value). /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) { SetType(SubTlv::kReport); } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval true The TLV appears to be well-formed. * @retval false The TLV does not appear to be well-formed. @@ -112,7 +112,7 @@ class ReportSubTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= kMinLength; } /** - * This method returns the Link Metrics Type ID. + * Returns the Link Metrics Type ID. * * @returns The Link Metrics Type ID. * @@ -120,7 +120,7 @@ class ReportSubTlv : public Tlv, public TlvInfo uint8_t GetMetricsTypeId(void) const { return mMetricsTypeId; } /** - * This method sets the Link Metrics Type ID. + * Sets the Link Metrics Type ID. * * @param[in] aMetricsTypeId The Link Metrics Type ID to set. * @@ -128,7 +128,7 @@ class ReportSubTlv : public Tlv, public TlvInfo void SetMetricsTypeId(uint8_t aMetricsTypeId) { mMetricsTypeId = aMetricsTypeId; } /** - * This method returns the metric value in 8 bits. + * Returns the metric value in 8 bits. * * @returns The metric value. * @@ -136,7 +136,7 @@ class ReportSubTlv : public Tlv, public TlvInfo uint8_t GetMetricsValue8(void) const { return mMetricsValue.m8; } /** - * This method returns the metric value in 32 bits. + * Returns the metric value in 32 bits. * * @returns The metric value. * @@ -144,7 +144,7 @@ class ReportSubTlv : public Tlv, public TlvInfo uint32_t GetMetricsValue32(void) const { return HostSwap32(mMetricsValue.m32); } /** - * This method sets the metric value (8 bits). + * Sets the metric value (8 bits). * * @param[in] aMetricsValue Metrics value. * @@ -156,7 +156,7 @@ class ReportSubTlv : public Tlv, public TlvInfo } /** - * This method sets the metric value (32 bits). + * Sets the metric value (32 bits). * * @param[in] aMetricsValue Metrics value. * @@ -177,7 +177,7 @@ class ReportSubTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Link Metrics Query Options Sub-TLV generation and parsing. + * Implements Link Metrics Query Options Sub-TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -185,7 +185,7 @@ class QueryOptionsSubTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -195,7 +195,7 @@ class QueryOptionsSubTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -206,7 +206,7 @@ class QueryOptionsSubTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class defines Link Metrics Forward Probing Registration Sub-TLV. + * Defines Link Metrics Forward Probing Registration Sub-TLV. * */ OT_TOOL_PACKED_BEGIN @@ -216,7 +216,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo static constexpr uint8_t kMinLength = sizeof(uint8_t) + sizeof(uint8_t); ///< Minimum expected TLV length /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -226,7 +226,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval true The TLV appears to be well-formed. * @retval false The TLV does not appear to be well-formed. @@ -235,7 +235,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= kMinLength; } /** - * This method gets the Forward Series ID value. + * Gets the Forward Series ID value. * * @returns The Forward Series ID. * @@ -243,7 +243,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo uint8_t GetSeriesId(void) const { return mSeriesId; } /** - * This method sets the Forward Series ID value. + * Sets the Forward Series ID value. * * @param[in] aSeriesId The Forward Series ID. * @@ -251,7 +251,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo void SetSeriesId(uint8_t aSeriesId) { mSeriesId = aSeriesId; } /** - * This method gets the Forward Series Flags bit-mask. + * Gets the Forward Series Flags bit-mask. * * @returns The Forward Series Flags mask. * @@ -259,7 +259,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo uint8_t GetSeriesFlagsMask(void) const { return mSeriesFlagsMask; } /** - * This method sets the Forward Series Flags bit-mask + * Sets the Forward Series Flags bit-mask * * @param[in] aSeriesFlagsMask The Forward Series Flags. * @@ -267,7 +267,7 @@ class FwdProbingRegSubTlv : public Tlv, public TlvInfo void SetSeriesFlagsMask(uint8_t aSeriesFlagsMask) { mSeriesFlagsMask = aSeriesFlagsMask; } /** - * This method gets the start of Type ID array. + * Gets the start of Type ID array. * * @returns The start of Type ID array. Array has `kMaxTypeIds` max length. * @@ -287,7 +287,7 @@ class EnhAckConfigSubTlv : public Tlv, public TlvInfo static constexpr uint8_t kMinLength = sizeof(uint8_t); ///< Minimum TLV length (only `EnhAckFlags`). /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -297,7 +297,7 @@ class EnhAckConfigSubTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval true The TLV appears to be well-formed. * @retval false The TLV does not appear to be well-formed. @@ -306,7 +306,7 @@ class EnhAckConfigSubTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= kMinLength; } /** - * This method gets the Enhanced ACK Flags. + * Gets the Enhanced ACK Flags. * * @returns The Enhanced ACK Flags. * @@ -314,7 +314,7 @@ class EnhAckConfigSubTlv : public Tlv, public TlvInfo uint8_t GetEnhAckFlags(void) const { return mEnhAckFlags; } /** - * This method sets Enhanced ACK Flags. + * Sets Enhanced ACK Flags. * * @param[in] aEnhAckFlags The value of Enhanced ACK Flags. * @@ -322,7 +322,7 @@ class EnhAckConfigSubTlv : public Tlv, public TlvInfo void SetEnhAckFlags(EnhAckFlags aEnhAckFlags) { mEnhAckFlags = aEnhAckFlags; } /** - * This method gets the start of Type ID array. + * Gets the start of Type ID array. * * @returns The start of Type ID array. Array has `kMaxTypeIds` max length. * diff --git a/src/core/thread/link_metrics_types.hpp b/src/core/thread/link_metrics_types.hpp index eb10b2c0bd5..b7883b70560 100644 --- a/src/core/thread/link_metrics_types.hpp +++ b/src/core/thread/link_metrics_types.hpp @@ -52,7 +52,7 @@ namespace LinkMetrics { constexpr uint8_t kMaxTypeIds = 4; ///< Maximum number of Type IDs in a `Metrics`. /** - * This type represents Link Metric Flags indicating a set of metrics. + * Represents Link Metric Flags indicating a set of metrics. * * @sa otLinkMetrics * @@ -61,7 +61,7 @@ class Metrics : public otLinkMetrics, public Clearable { public: /** - * This method converts the `Metrics` into an array of Type IDs. + * Converts the `Metrics` into an array of Type IDs. * * @param[out] aTypeIds The array of Type IDs to populate. MUST have at least `kMaxTypeIds` elements. * @@ -72,7 +72,7 @@ class Metrics : public otLinkMetrics, public Clearable }; /** - * This type represents the results (values) for a set of metrics. + * Represents the results (values) for a set of metrics. * * @sa otLinkMetricsValues * @@ -81,7 +81,7 @@ class MetricsValues : public otLinkMetricsValues, public Clearable(mMetrics); } /** - * This method gets the metrics flags. + * Gets the metrics flags. * * @returns The metrics flags. * @@ -97,7 +97,7 @@ class MetricsValues : public otLinkMetricsValues, public Clearable(mMetrics); } /** - * This method set the metrics flags. + * Set the metrics flags. * * @param[in] aMetrics The metrics flags to set from. * @@ -137,7 +137,7 @@ class TypeId static constexpr uint8_t kRssi = (kMetricRssi | kTypeAve); ///< Type ID for RSSI. /** - * This static method indicates whether or not a given Type ID is extended. + * Indicates whether or not a given Type ID is extended. * * Extended Type IDs are reserved for future use. When set an additional second byte follows the current ID flags. * @@ -150,7 +150,7 @@ class TypeId static bool IsExtended(uint8_t aTypeId) { return (aTypeId & kExtendedFlag); } /** - * This static method determines the value length (number of bytes) associated with a given Type ID. + * Determines the value length (number of bytes) associated with a given Type ID. * * Type IDs can either have a short value as a `uint8_t` (e.g., `kLqi`, `kLinkMargin` or `kRssi`) or a long value as * a `uint32_t` (`kPdu`). @@ -166,7 +166,7 @@ class TypeId } /** - * This static method updates a Type ID to mark it as reversed. + * Updates a Type ID to mark it as reversed. * * This is used for testing only. * @@ -179,14 +179,14 @@ class TypeId }; /** - * This class represents the Series Flags for Forward Tracking Series. + * Represents the Series Flags for Forward Tracking Series. * */ class SeriesFlags : public otLinkMetricsSeriesFlags { public: /** - * This method converts the `SeriesFlags` to `uint8_t` bit-mask (for inclusion in TLVs). + * Converts the `SeriesFlags` to `uint8_t` bit-mask (for inclusion in TLVs). * * @returns The bit-mask representation. * @@ -194,7 +194,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags uint8_t ConvertToMask(void) const; /** - * This method sets the `SeriesFlags` from a given bit-mask value. + * Sets the `SeriesFlags` from a given bit-mask value. * * @param[in] aFlagsMask The bit-mask flags. * @@ -202,7 +202,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags void SetFrom(uint8_t aFlagsMask); /** - * This method indicates whether or not the Link Probe flag is set. + * Indicates whether or not the Link Probe flag is set. * * @retval true The Link Probe flag is set. * @retval false The Link Probe flag is not set. @@ -211,7 +211,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags bool IsLinkProbeFlagSet(void) const { return mLinkProbe; } /** - * This method indicates whether or not the MAC Data flag is set. + * Indicates whether or not the MAC Data flag is set. * * @retval true The MAC Data flag is set. * @retval false The MAC Data flag is not set. @@ -220,7 +220,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags bool IsMacDataFlagSet(void) const { return mMacData; } /** - * This method indicates whether or not the MAC Data Request flag is set. + * Indicates whether or not the MAC Data Request flag is set. * * @retval true The MAC Data Request flag is set. * @retval false The MAC Data Request flag is not set. @@ -229,7 +229,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags bool IsMacDataRequestFlagSet(void) const { return mMacDataRequest; } /** - * This method indicates whether or not the Mac Ack flag is set. + * Indicates whether or not the Mac Ack flag is set. * * @retval true The Mac Ack flag is set. * @retval false The Mac Ack flag is not set. @@ -245,7 +245,7 @@ class SeriesFlags : public otLinkMetricsSeriesFlags }; /** - * This enumeration type represent Enhanced-ACK Flags. + * Type represent Enhanced-ACK Flags. * */ enum EnhAckFlags : uint8_t @@ -255,13 +255,13 @@ enum EnhAckFlags : uint8_t }; /** - * This class represents one Series that is being tracked by the Subject. + * Represents one Series that is being tracked by the Subject. * * When an Initiator successfully configured a Forward Tracking Series, the Subject would use an instance of this class * to track the information of the Series. The Subject has a `Pool` of `SeriesInfo`. It would allocate one when a new * Series comes, and free it when a Series finishes. * - * This class inherits `LinkedListEntry` and each `Neighbor` has a list of `SeriesInfo` so that the Subject could track + * Inherits `LinkedListEntry` and each `Neighbor` has a list of `SeriesInfo` so that the Subject could track * per Series initiated by neighbors as long as it has available resources. * */ @@ -280,7 +280,7 @@ class SeriesInfo : public LinkedListEntry static constexpr uint8_t kSeriesTypeLinkProbe = 0; /** - * This method initializes the SeriesInfo object. + * Initializes the SeriesInfo object. * * @param[in] aSeriesId The Series ID. * @param[in] aSeriesFlagsMask The Series Flags bitmask which specify what types of frames are to be accounted. @@ -290,7 +290,7 @@ class SeriesInfo : public LinkedListEntry void Init(uint8_t aSeriesId, uint8_t aSeriesFlagsMask, const Metrics &aMetrics); /** - * This method gets the Series ID. + * Gets the Series ID. * * @returns The Series ID. * @@ -298,7 +298,7 @@ class SeriesInfo : public LinkedListEntry uint8_t GetSeriesId(void) const { return mSeriesId; } /** - * This method gets the PDU count. + * Gets the PDU count. * * @returns The PDU count. * @@ -306,7 +306,7 @@ class SeriesInfo : public LinkedListEntry uint32_t GetPduCount(void) const { return mPduCount; } /** - * This method gets the average LQI. + * Gets the average LQI. * * @returns The average LQI. * @@ -314,7 +314,7 @@ class SeriesInfo : public LinkedListEntry uint8_t GetAverageLqi(void) const { return mLqiAverager.GetAverage(); } /** - * This method gets the average RSS. + * Gets the average RSS. * * @returns The average RSS. * @@ -322,7 +322,7 @@ class SeriesInfo : public LinkedListEntry int8_t GetAverageRss(void) const { return mRssAverager.GetAverage(); } /** - * This method aggregates the Link Metrics data of a frame into this series. + * Aggregates the Link Metrics data of a frame into this series. * * @param[in] aFrameType The type of the frame. * @param[in] aLqi The LQI value. @@ -332,7 +332,7 @@ class SeriesInfo : public LinkedListEntry void AggregateLinkMetrics(uint8_t aFrameType, uint8_t aLqi, int8_t aRss); /** - * This methods gets the metrics. + * Gets the metrics. * * @returns The metrics associated with `SeriesInfo`. * @@ -353,7 +353,7 @@ class SeriesInfo : public LinkedListEntry }; /** - * This enumeration type represents Link Metrics Status. + * Type represents Link Metrics Status. * */ enum Status : uint8_t diff --git a/src/core/thread/link_quality.cpp b/src/core/thread/link_quality.cpp index 23a68c5f446..ed5bbb5bf7e 100644 --- a/src/core/thread/link_quality.cpp +++ b/src/core/thread/link_quality.cpp @@ -66,11 +66,9 @@ Error RssAverager::Add(int8_t aRss) VerifyOrExit(aRss != Radio::kInvalidRssi, error = kErrorInvalidArgs); - // Restrict the RSS value to the closed range [0, -128] so the RSS times precision multiple can fit in 11 bits. - if (aRss > 0) - { - aRss = 0; - } + // Restrict the RSS value to the closed range [-128, 0] + // so the RSS times precision multiple can fit in 11 bits. + aRss = Min(aRss, 0); // Multiply the RSS value by a precision multiple (currently -8). diff --git a/src/core/thread/link_quality.hpp b/src/core/thread/link_quality.hpp index 086d74774a8..319ebe74a24 100644 --- a/src/core/thread/link_quality.hpp +++ b/src/core/thread/link_quality.hpp @@ -55,7 +55,7 @@ namespace ot { */ /** - * This class implements an operation Success Rate Tracker. + * Implements an operation Success Rate Tracker. * * This can be used to track different link quality related metrics, e.g., CCA failure rate, frame tx success rate). * The success rate is maintained using an exponential moving IIR averaging filter with a `uint16_t` as the storage. @@ -67,7 +67,7 @@ class SuccessRateTracker : public Clearable static constexpr uint16_t kMaxRateValue = 0xffff; ///< Value corresponding to max (failure/success) rate of 100%. /** - * This method adds a sample (success or failure) to `SuccessRateTracker`. + * Adds a sample (success or failure) to `SuccessRateTracker`. * * @param[in] aSuccess The sample status be added, `true` for success, `false` for failure. * @param[in] aWeight The weight coefficient used for adding the new sample into average. @@ -76,7 +76,7 @@ class SuccessRateTracker : public Clearable void AddSample(bool aSuccess, uint16_t aWeight = kDefaultWeight); /** - * This method returns the average failure rate. + * Returns the average failure rate. * * @retval the average failure rate `[0-kMaxRateValue]` with `kMaxRateValue` corresponding to 100%. * @@ -84,7 +84,7 @@ class SuccessRateTracker : public Clearable uint16_t GetFailureRate(void) const { return mFailureRate; } /** - * This method returns the average success rate. + * Returns the average success rate. * * @retval the average success rate as [0-kMaxRateValue] with `kMaxRateValue` corresponding to 100%. * @@ -98,7 +98,7 @@ class SuccessRateTracker : public Clearable }; /** - * This class implements a Received Signal Strength (RSS) averager. + * Implements a Received Signal Strength (RSS) averager. * * The average is maintained using an adaptive exponentially weighted moving filter. * @@ -109,13 +109,13 @@ class RssAverager : public Clearable static constexpr uint16_t kStringSize = 10; ///< Max string size for average (@sa ToString()). /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; /** - * This method indicates whether the averager contains an average (i.e., at least one RSS value has been added). + * Indicates whether the averager contains an average (i.e., at least one RSS value has been added). * * @retval true If the average value is available (at least one RSS value has been added). * @retval false Averager is empty (no RSS value added yet). @@ -124,7 +124,7 @@ class RssAverager : public Clearable bool HasAverage(void) const { return (mCount != 0); } /** - * This method adds a received signal strength (RSS) value to the average. + * Adds a received signal strength (RSS) value to the average. * * If @p aRss is `Radio::kInvalidRssi`, it is ignored and error status kErrorInvalidArgs is returned. * The value of RSS is capped at 0dBm (i.e., for any given RSS value higher than 0dBm, 0dBm is used instead). @@ -138,7 +138,7 @@ class RssAverager : public Clearable Error Add(int8_t aRss); /** - * This method returns the current average signal strength value maintained by the averager. + * Returns the current average signal strength value maintained by the averager. * * @returns The current average value (in dBm) or `Radio::kInvalidRssi` if no average is available. * @@ -146,7 +146,7 @@ class RssAverager : public Clearable int8_t GetAverage(void) const; /** - * This method returns an raw/encoded version of current average signal strength value. The raw value is the + * Returns an raw/encoded version of current average signal strength value. The raw value is the * average multiplied by a precision factor (currently set as -8). * * @returns The current average multiplied by precision factor or zero if no average is available. @@ -155,7 +155,7 @@ class RssAverager : public Clearable uint16_t GetRaw(void) const { return mAverage; } /** - * This method converts the current average RSS value to a human-readable string (e.g., "-80.375"). If the + * Converts the current average RSS value to a human-readable string (e.g., "-80.375"). If the * average is unknown, empty string is returned. * * @returns An `InfoString` object containing the string representation of average RSS. @@ -188,7 +188,7 @@ class RssAverager : public Clearable }; /** - * This class implements a Link Quality Indicator (LQI) averager. + * Implements a Link Quality Indicator (LQI) averager. * * It maintains the exponential moving average value of LQI. * @@ -197,7 +197,7 @@ class LqiAverager : public Clearable { public: /** - * This method adds a link quality indicator (LQI) value to the average. + * Adds a link quality indicator (LQI) value to the average. * * @param[in] aLqi Link Quality Indicator value to be added to the average. * @@ -205,7 +205,7 @@ class LqiAverager : public Clearable void Add(uint8_t aLqi); /** - * This method returns the current average link quality value maintained by the averager. + * Returns the current average link quality value maintained by the averager. * * @returns The current average value. * @@ -213,7 +213,7 @@ class LqiAverager : public Clearable uint8_t GetAverage(void) const { return mAverage; } /** - * This method returns the count of frames calculated so far. + * Returns the count of frames calculated so far. * * @returns The count of frames calculated. * @@ -228,7 +228,7 @@ class LqiAverager : public Clearable }; /** - * This enumeration represents the link quality constants. + * Represents the link quality constants. * * Link Quality is an integer in [0, 3]. A higher link quality indicates a more usable link, with 0 indicating that the * link is non-existent or unusable. @@ -248,9 +248,9 @@ constexpr uint8_t kCostForLinkQuality2 = 2; ///< Link Cost for constexpr uint8_t kCostForLinkQuality3 = 1; ///< Link Cost for Link Quality 3. /** - * This function converts link quality to route cost. + * Converts link quality to route cost. * - * @param[in] aLinkQuality The link quality to covert. + * @param[in] aLinkQuality The link quality to convert. * * @returns The route cost corresponding to @p aLinkQuality. * @@ -258,7 +258,7 @@ constexpr uint8_t kCostForLinkQuality3 = 1; ///< Link Cost for uint8_t CostForLinkQuality(LinkQuality aLinkQuality); /** - * This function computes the link margin from a given noise floor and received signal strength. + * Computes the link margin from a given noise floor and received signal strength. * * @param[in] aNoiseFloor The noise floor value (in dBm). * @param[in] aRss The received signal strength value (in dBm). @@ -269,7 +269,7 @@ uint8_t CostForLinkQuality(LinkQuality aLinkQuality); uint8_t ComputeLinkMargin(int8_t aNoiseFloor, int8_t aRss); /** - * This function converts a link margin value to a link quality value. + * Converts a link margin value to a link quality value. * * @param[in] aLinkMargin The Link Margin in dB. * @@ -279,7 +279,7 @@ uint8_t ComputeLinkMargin(int8_t aNoiseFloor, int8_t aRss); LinkQuality LinkQualityForLinkMargin(uint8_t aLinkMargin); /** - * This function gets the typical received signal strength value for a given link quality. + * Gets the typical received signal strength value for a given link quality. * * @param[in] aNoiseFloor The noise floor value (in dBm). * @param[in] aLinkQuality The link quality value in [0, 3]. @@ -290,7 +290,7 @@ LinkQuality LinkQualityForLinkMargin(uint8_t aLinkMargin); int8_t GetTypicalRssForLinkQuality(int8_t aNoiseFloor, LinkQuality aLinkQuality); /** - * This class encapsulates/stores all relevant information about quality of a link, including average received signal + * Encapsulates/stores all relevant information about quality of a link, including average received signal * strength (RSS), last RSS, link margin, and link quality. * */ @@ -303,13 +303,13 @@ class LinkQualityInfo : public InstanceLocatorInit static constexpr uint16_t kInfoStringSize = 50; ///< `InfoString` size (@sa ToInfoString()). /** - * This type defines the fixed-length `String` object returned from `ToInfoString()`. + * Defines the fixed-length `String` object returned from `ToInfoString()`. * */ typedef String InfoString; /** - * This method initializes the `LinkQualityInfo` object. + * Initializes the `LinkQualityInfo` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -317,19 +317,19 @@ class LinkQualityInfo : public InstanceLocatorInit void Init(Instance &aInstance) { InstanceLocatorInit::Init(aInstance); } /** - * This method clears the all the data in the object. + * Clears the all the data in the object. * */ void Clear(void); /** - * This method clears the average RSS value. + * Clears the average RSS value. * */ void ClearAverageRss(void) { mRssAverager.Clear(); } /** - * This method adds a new received signal strength (RSS) value to the average. + * Adds a new received signal strength (RSS) value to the average. * * @param[in] aRss A new received signal strength value (in dBm) to be added to the average. * @@ -337,7 +337,7 @@ class LinkQualityInfo : public InstanceLocatorInit void AddRss(int8_t aRss); /** - * This method returns the current average received signal strength value. + * Returns the current average received signal strength value. * * @returns The current average value or `Radio::kInvalidRssi` if no average is available. * @@ -345,7 +345,7 @@ class LinkQualityInfo : public InstanceLocatorInit int8_t GetAverageRss(void) const { return mRssAverager.GetAverage(); } /** - * This method returns an encoded version of current average signal strength value. The encoded value is the + * Returns an encoded version of current average signal strength value. The encoded value is the * average multiplied by a precision factor (currently -8). * * @returns The current average multiplied by precision factor or zero if no average is available. @@ -354,7 +354,7 @@ class LinkQualityInfo : public InstanceLocatorInit uint16_t GetAverageRssRaw(void) const { return mRssAverager.GetRaw(); } /** - * This method converts the link quality info to info/debug human-readable string. + * Converts the link quality info to info/debug human-readable string. * * @returns An `InfoString` representing the link quality info. * @@ -362,7 +362,7 @@ class LinkQualityInfo : public InstanceLocatorInit InfoString ToInfoString(void) const; /** - * This method returns the link margin. The link margin is calculated using the link's current average received + * Returns the link margin. The link margin is calculated using the link's current average received * signal strength (RSS) and average noise floor. * * @returns Link margin derived from average received signal strength and average noise floor. @@ -395,7 +395,7 @@ class LinkQualityInfo : public InstanceLocatorInit int8_t GetLastRss(void) const { return mLastRss; } /** - * This method adds a MAC frame transmission status (success/failure) and updates the frame tx error rate. + * Adds a MAC frame transmission status (success/failure) and updates the frame tx error rate. * * @param[in] aTxStatus Success/Failure of MAC frame transmission (`true` -> success, `false` -> failure). * @@ -406,7 +406,7 @@ class LinkQualityInfo : public InstanceLocatorInit } /** - * This method adds a message transmission status (success/failure) and updates the message error rate. + * Adds a message transmission status (success/failure) and updates the message error rate. * * @param[in] aTxStatus Success/Failure of message (`true` -> success, `false` -> message tx failed). * A larger (IPv6) message may be fragmented and sent as multiple MAC frames. The message @@ -420,7 +420,7 @@ class LinkQualityInfo : public InstanceLocatorInit } /** - * This method returns the MAC frame transmission error rate for the link. + * Returns the MAC frame transmission error rate for the link. * * The rate is maintained over a window of (roughly) last `OPENTHREAD_CONFIG_FRAME_TX_ERR_RATE_AVERAGING_WINDOW` * frame transmissions. @@ -431,7 +431,7 @@ class LinkQualityInfo : public InstanceLocatorInit uint16_t GetFrameErrorRate(void) const { return mFrameErrorRate.GetFailureRate(); } /** - * This method returns the message error rate for the link. + * Returns the message error rate for the link. * * The rate is maintained over a window of (roughly) last `OPENTHREAD_CONFIG_IPV6_TX_ERR_RATE_AVERAGING_WINDOW` * (IPv6) messages. diff --git a/src/core/thread/lowpan.hpp b/src/core/thread/lowpan.hpp index 77139a63134..e0b7a59dc99 100644 --- a/src/core/thread/lowpan.hpp +++ b/src/core/thread/lowpan.hpp @@ -71,7 +71,7 @@ namespace Lowpan { using ot::Encoding::BigEndian::HostSwap16; /** - * This structure represents a LOWPAN_IPHC Context. + * Represents a LOWPAN_IPHC Context. * */ struct Context : public Clearable @@ -83,14 +83,14 @@ struct Context : public Clearable }; /** - * This class implements LOWPAN_IPHC header compression. + * Implements LOWPAN_IPHC header compression. * */ class Lowpan : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -98,7 +98,7 @@ class Lowpan : public InstanceLocator, private NonCopyable explicit Lowpan(Instance &aInstance); /** - * This method indicates whether or not the header is a LOWPAN_IPHC header. + * Indicates whether or not the header is a LOWPAN_IPHC header. * * @param[in] aHeader A pointer to the header. * @@ -111,7 +111,7 @@ class Lowpan : public InstanceLocator, private NonCopyable } /** - * This method indicates whether or not header in a given frame is a LOWPAN_IPHC header. + * Indicates whether or not header in a given frame is a LOWPAN_IPHC header. * * @param[in] aFrameData The frame data. * @@ -124,7 +124,7 @@ class Lowpan : public InstanceLocator, private NonCopyable } /** - * This method compresses an IPv6 header. + * Compresses an IPv6 header. * * @param[in] aMessage A reference to the IPv6 message. * @param[in] aMacAddrs The MAC source and destination addresses. @@ -136,7 +136,7 @@ class Lowpan : public InstanceLocator, private NonCopyable Error Compress(Message &aMessage, const Mac::Addresses &aMacAddrs, FrameBuilder &aFrameBuilder); /** - * This method decompresses a LOWPAN_IPHC header. + * Decompresses a LOWPAN_IPHC header. * * If the header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes. * @@ -156,7 +156,7 @@ class Lowpan : public InstanceLocator, private NonCopyable uint16_t aDatagramLength); /** - * This method decompresses a LOWPAN_IPHC header. + * Decompresses a LOWPAN_IPHC header. * * If the header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes. * @@ -175,7 +175,7 @@ class Lowpan : public InstanceLocator, private NonCopyable FrameData &aFrameData); /** - * This method decompresses a LOWPAN_NHC UDP header. + * Decompresses a LOWPAN_NHC UDP header. * * If the header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes. * @@ -189,7 +189,7 @@ class Lowpan : public InstanceLocator, private NonCopyable Error DecompressUdpHeader(Ip6::Udp::Header &aUdpHeader, FrameData &aFrameData); /** - * This method decompresses the IPv6 ECN field in a LOWPAN_IPHC header. + * Decompresses the IPv6 ECN field in a LOWPAN_IPHC header. * * @param[in] aMessage The message to read the IPHC header from. * @param[in] aOffset The offset in @p aMessage to start of IPHC header. @@ -200,9 +200,9 @@ class Lowpan : public InstanceLocator, private NonCopyable Ip6::Ecn DecompressEcn(const Message &aMessage, uint16_t aOffset) const; /** - * This method updates the compressed ECN field in a LOWPAN_IPHC header to `kEcnMarked`. + * Updates the compressed ECN field in a LOWPAN_IPHC header to `kEcnMarked`. * - * This method MUST be used when the ECN field is not elided in the IPHC header. Note that the ECN is not elided + * MUST be used when the ECN field is not elided in the IPHC header. Note that the ECN is not elided * when it is not zero (`kEcnNotCapable`). * * @param[in,out] aMessage The message containing the IPHC header and to update. @@ -291,14 +291,14 @@ class Lowpan : public InstanceLocator, private NonCopyable }; /** - * This class implements Mesh Header generation and processing. + * Implements Mesh Header generation and processing. * */ class MeshHeader { public: /** - * This method initializes the Mesh Header with a given Mesh Source, Mesh Destination and Hops Left value. + * Initializes the Mesh Header with a given Mesh Source, Mesh Destination and Hops Left value. * * @param[in] aSource The Mesh Source address. * @param[in] aDestination The Mesh Destination address. @@ -308,7 +308,7 @@ class MeshHeader void Init(uint16_t aSource, uint16_t aDestination, uint8_t aHopsLeft); /** - * This static method indicates whether or not the header (in a given frame) is a Mesh Header. + * Indicates whether or not the header (in a given frame) is a Mesh Header. * * @note This method checks whether the first byte in header/frame (dispatch byte) matches the Mesh Header dispatch * It does not fully parse and validate the Mesh Header. `ParseFrom()` method can be used to fully parse and @@ -321,7 +321,7 @@ class MeshHeader static bool IsMeshHeader(const FrameData &aFrameData); /** - * This method parses the Mesh Header from a frame @p aFrame. + * Parses the Mesh Header from a frame @p aFrame. * * @param[in] aFrame The pointer to the frame. * @param[in] aFrameLength The length of the frame. @@ -334,7 +334,7 @@ class MeshHeader Error ParseFrom(const uint8_t *aFrame, uint16_t aFrameLength, uint16_t &aHeaderLength); /** - * This method parses the Mesh Header from a given frame data. + * Parses the Mesh Header from a given frame data. * * If the Mesh Header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes. * @@ -347,7 +347,7 @@ class MeshHeader Error ParseFrom(FrameData &aFrameData); /** - * This method parses the Mesh Header from a given message. + * Parses the Mesh Header from a given message. * * @note The Mesh Header is read from offset zero within the @p aMessage. * @@ -360,7 +360,7 @@ class MeshHeader Error ParseFrom(const Message &aMessage); /** - * This method parses the Mesh Header from a given message. + * Parses the Mesh Header from a given message. * * @note The Mesh Header is read from offset zero within the @p aMessage. * @@ -374,7 +374,7 @@ class MeshHeader Error ParseFrom(const Message &aMessage, uint16_t &aHeaderLength); /** - * This method returns the the Mesh Header length when written to a frame. + * Returns the the Mesh Header length when written to a frame. * * @note The returned value from this method gives the header length (number of bytes) when the header is written * to a frame or message. This should not be used to determine the parsed length (number of bytes read) when the @@ -386,7 +386,7 @@ class MeshHeader uint16_t GetHeaderLength(void) const; /** - * This method returns the Hops Left value. + * Returns the Hops Left value. * * @returns The Hops Left value. * @@ -394,13 +394,13 @@ class MeshHeader uint8_t GetHopsLeft(void) const { return mHopsLeft; } /** - * This method decrements the Hops Left value (if it is not zero). + * Decrements the Hops Left value (if it is not zero). * */ void DecrementHopsLeft(void); /** - * This method returns the Mesh Source address. + * Returns the Mesh Source address. * * @returns The Mesh Source address. * @@ -408,7 +408,7 @@ class MeshHeader uint16_t GetSource(void) const { return mSource; } /** - * This method returns the Mesh Destination address. + * Returns the Mesh Destination address. * * @returns The Mesh Destination address. * @@ -416,7 +416,7 @@ class MeshHeader uint16_t GetDestination(void) const { return mDestination; } /** - * This method appends the Mesh Header into a given frame. + * Appends the Mesh Header into a given frame. * * @param[out] aFrameBuilder The `FrameBuilder` to append to. * @@ -427,7 +427,7 @@ class MeshHeader Error AppendTo(FrameBuilder &aFrameBuilder) const; /** - * This method appends the Mesh Header to a given message. + * Appends the Mesh Header to a given message. * * * @param[out] aMessage A message to append the Mesh Header to. @@ -456,7 +456,7 @@ class MeshHeader }; /** - * This class implements Fragment Header generation and parsing. + * Implements Fragment Header generation and parsing. * */ class FragmentHeader @@ -467,7 +467,7 @@ class FragmentHeader { public: /** - * This method initializes the `FirstFrag`. + * Initializes the `FirstFrag`. * * @param[in] aSize The Datagram Size value. * @param[in] aTag The Datagram Tag value. @@ -497,7 +497,7 @@ class FragmentHeader { public: /** - * This method initializes the `NextFrag`. + * Initializes the `NextFrag`. * * @param[in] aSize The Datagram Size value. * @param[in] aTag The Datagram Tag value. @@ -528,7 +528,7 @@ class FragmentHeader } OT_TOOL_PACKED_END; /** - * This static method indicates whether or not the header (in a given frame) is a Fragment Header. + * Indicates whether or not the header (in a given frame) is a Fragment Header. * * @note This method checks whether the frame has the minimum required length and that the first byte in * header (dispatch byte) matches the Fragment Header dispatch value. It does not fully parse and validate the @@ -543,7 +543,7 @@ class FragmentHeader static bool IsFragmentHeader(const FrameData &aFrameData); /** - * This method parses the Fragment Header from a given frame data. + * Parses the Fragment Header from a given frame data. * * If the Fragment Header is parsed successfully the @p aFrameData is updated to skip over the parsed header bytes. * @@ -556,7 +556,7 @@ class FragmentHeader Error ParseFrom(FrameData &aFrameData); /** - * This method parses the Fragment Header from a message. + * Parses the Fragment Header from a message. * * @param[in] aMessage The message to read from. * @param[in] aOffset The offset within the message to start reading from. @@ -569,7 +569,7 @@ class FragmentHeader Error ParseFrom(const Message &aMessage, uint16_t aOffset, uint16_t &aHeaderLength); /** - * This method returns the Datagram Size value. + * Returns the Datagram Size value. * * @returns The Datagram Size value. * @@ -577,7 +577,7 @@ class FragmentHeader uint16_t GetDatagramSize(void) const { return mSize; } /** - * This method returns the Datagram Tag value. + * Returns the Datagram Tag value. * * @returns The Datagram Tag value. * @@ -585,7 +585,7 @@ class FragmentHeader uint16_t GetDatagramTag(void) const { return mTag; } /** - * This method returns the Datagram Offset value. + * Returns the Datagram Offset value. * * The returned offset value is always multiple of 8. * diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 13efbcfeec1..390d7bf573b 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -1717,12 +1717,8 @@ void MeshForwarder::AppendHeaderIe(const Message *aMessage, Mac::TxFrame &aFrame if (Get().IsCslEnabled()) { IgnoreError(aFrame.AppendHeaderIeAt(index)); - aFrame.mInfo.mTxInfo.mCslPresent = true; - iePresent = true; - } - else - { - aFrame.mInfo.mTxInfo.mCslPresent = false; + aFrame.SetCslIePresent(true); + iePresent = true; } #endif diff --git a/src/core/thread/mesh_forwarder.hpp b/src/core/thread/mesh_forwarder.hpp index 9ee160b5c39..cfbb82aebf2 100644 --- a/src/core/thread/mesh_forwarder.hpp +++ b/src/core/thread/mesh_forwarder.hpp @@ -75,14 +75,14 @@ class HistoryTracker; */ /** - * This class represents link-specific information for messages received from the Thread radio. + * Represents link-specific information for messages received from the Thread radio. * */ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable { public: /** - * This method returns the IEEE 802.15.4 Source PAN ID. + * Returns the IEEE 802.15.4 Source PAN ID. * * @returns The IEEE 802.15.4 Source PAN ID. * @@ -90,7 +90,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable Mac::PanId GetPanId(void) const { return mPanId; } /** - * This method returns the IEEE 802.15.4 Channel. + * Returns the IEEE 802.15.4 Channel. * * @returns The IEEE 802.15.4 Channel. * @@ -98,7 +98,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable uint8_t GetChannel(void) const { return mChannel; } /** - * This method returns whether the Destination PAN ID is broadcast. + * Returns whether the Destination PAN ID is broadcast. * * @retval TRUE If Destination PAN ID is broadcast. * @retval FALSE If Destination PAN ID is not broadcast. @@ -107,7 +107,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable bool IsDstPanIdBroadcast(void) const { return mIsDstPanIdBroadcast; } /** - * This method indicates whether or not link security is enabled. + * Indicates whether or not link security is enabled. * * @retval TRUE If link security is enabled. * @retval FALSE If link security is not enabled. @@ -116,7 +116,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable bool IsLinkSecurityEnabled(void) const { return mLinkSecurity; } /** - * This method returns the Received Signal Strength (RSS) in dBm. + * Returns the Received Signal Strength (RSS) in dBm. * * @returns The Received Signal Strength (RSS) in dBm. * @@ -124,7 +124,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable int8_t GetRss(void) const { return mRss; } /** - * This method returns the frame/radio Link Quality Indicator (LQI) value. + * Returns the frame/radio Link Quality Indicator (LQI) value. * * @returns The Link Quality Indicator value. * @@ -133,7 +133,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method returns the Time Sync Sequence. + * Returns the Time Sync Sequence. * * @returns The Time Sync Sequence. * @@ -141,7 +141,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable uint8_t GetTimeSyncSeq(void) const { return mTimeSyncSeq; } /** - * This method returns the time offset to the Thread network time (in microseconds). + * Returns the time offset to the Thread network time (in microseconds). * * @returns The time offset to the Thread network time (in microseconds). * @@ -150,7 +150,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable #endif /** - * This method sets the `ThreadLinkInfo` from a given received frame. + * Sets the `ThreadLinkInfo` from a given received frame. * * @param[in] aFrame A received frame. * @@ -159,7 +159,7 @@ class ThreadLinkInfo : public otThreadLinkInfo, public Clearable }; /** - * This class implements mesh forwarding within Thread. + * Implements mesh forwarding within Thread. * */ class MeshForwarder : public InstanceLocator, private NonCopyable @@ -174,7 +174,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -182,19 +182,19 @@ class MeshForwarder : public InstanceLocator, private NonCopyable explicit MeshForwarder(Instance &aInstance); /** - * This method enables mesh forwarding and the IEEE 802.15.4 MAC layer. + * Enables mesh forwarding and the IEEE 802.15.4 MAC layer. * */ void Start(void); /** - * This method disables mesh forwarding and the IEEE 802.15.4 MAC layer. + * Disables mesh forwarding and the IEEE 802.15.4 MAC layer. * */ void Stop(void); /** - * This method submits a message to the mesh forwarder for forwarding. + * Submits a message to the mesh forwarder for forwarding. * * @param[in] aMessage A reference to the message. * @@ -207,7 +207,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method sends an empty data frame to the parent. + * Sends an empty data frame to the parent. * * @retval kErrorNone Successfully enqueued an empty message. * @retval kErrorInvalidState Device is not in Rx-Off-When-Idle mode or it has no parent. @@ -218,7 +218,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable #endif /** - * This method is called by the address resolver when an EID-to-RLOC mapping has been resolved. + * Is called by the address resolver when an EID-to-RLOC mapping has been resolved. * * @param[in] aEid A reference to the EID that has been resolved. * @param[in] aError kErrorNone on success and kErrorDrop otherwise. @@ -227,7 +227,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable void HandleResolved(const Ip6::Address &aEid, Error aError); /** - * This method indicates whether or not rx-on-when-idle mode is enabled. + * Indicates whether or not rx-on-when-idle mode is enabled. * * @retval TRUE The rx-on-when-idle mode is enabled. * @retval FALSE The rx-on-when-idle-mode is disabled. @@ -236,7 +236,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable bool GetRxOnWhenIdle(void) const; /** - * This method sets the rx-on-when-idle mode + * Sets the rx-on-when-idle mode * * @param[in] aRxOnWhenIdle TRUE to enable, FALSE otherwise. * @@ -244,7 +244,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable void SetRxOnWhenIdle(bool aRxOnWhenIdle); /** - * This method sets the scan parameters for MLE Discovery Request messages. + * Sets the scan parameters for MLE Discovery Request messages. * * @param[in] aScanChannels A reference to channel mask indicating which channels to scan. * If @p aScanChannels is empty, then all channels are used instead. @@ -254,7 +254,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method frees any messages queued for an existing child. + * Frees any messages queued for an existing child. * * @param[in] aChild A reference to the child. * @param[in] aSubType The message sub-type to remove. @@ -265,13 +265,13 @@ class MeshForwarder : public InstanceLocator, private NonCopyable #endif /** - * This method frees unicast/multicast MLE Data Responses from Send Message Queue if any. + * Frees unicast/multicast MLE Data Responses from Send Message Queue if any. * */ void RemoveDataResponseMessages(void); /** - * This method evicts the message with lowest priority in the send queue. + * Evicts the message with lowest priority in the send queue. * * @param[in] aPriority The highest priority level of the evicted message. * @@ -282,7 +282,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable Error EvictMessage(Message::Priority aPriority); /** - * This method returns a reference to the send queue. + * Returns a reference to the send queue. * * @returns A reference to the send queue. * @@ -290,7 +290,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable const PriorityQueue &GetSendQueue(void) const { return mSendQueue; } /** - * This method returns a reference to the reassembly queue. + * Returns a reference to the reassembly queue. * * @returns A reference to the reassembly queue. * @@ -298,7 +298,7 @@ class MeshForwarder : public InstanceLocator, private NonCopyable const MessageQueue &GetReassemblyQueue(void) const { return mReassemblyList; } /** - * This method returns a reference to the IP level counters. + * Returns a reference to the IP level counters. * * @returns A reference to the IP level counters. * @@ -306,14 +306,14 @@ class MeshForwarder : public InstanceLocator, private NonCopyable const otIpCounters &GetCounters(void) const { return mIpCounters; } /** - * This method resets the IP level counters. + * Resets the IP level counters. * */ void ResetCounters(void) { memset(&mIpCounters, 0, sizeof(mIpCounters)); } #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method handles a deferred ack. + * Handles a deferred ack. * * Some radio links can use deferred ack logic, where a tx request always report `HandleSentFrame()` quickly. The * link layer would wait for the ack and report it at a later time using this method. diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index bd6510185f2..6ceed76b663 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -781,12 +781,9 @@ void Mle::InformPreviousChannel(void) void Mle::SetTimeout(uint32_t aTimeout) { - VerifyOrExit(mTimeout != aTimeout); + aTimeout = Max(aTimeout, kMinTimeout); - if (aTimeout < kMinTimeout) - { - aTimeout = kMinTimeout; - } + VerifyOrExit(mTimeout != aTimeout); mTimeout = aTimeout; @@ -1542,12 +1539,7 @@ bool Mle::PrepareAnnounceState(void) } mAnnounceDelay = kAnnounceTimeout / (channelMask.GetNumberOfChannels() + 1); - - if (mAnnounceDelay < kMinAnnounceDelay) - { - mAnnounceDelay = kMinAnnounceDelay; - } - + mAnnounceDelay = Max(mAnnounceDelay, kMinAnnounceDelay); shouldAnnounce = true; exit: @@ -3153,14 +3145,7 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo) // Link Margin SuccessOrExit(error = Tlv::Find(aRxInfo.mMessage, linkMarginFromTlv)); - - linkMargin = Get().ComputeLinkMargin(rss); - - if (linkMargin > linkMarginFromTlv) - { - linkMargin = linkMarginFromTlv; - } - + linkMargin = Min(Get().ComputeLinkMargin(rss), linkMarginFromTlv); linkQuality = LinkQualityForLinkMargin(linkMargin); // Connectivity diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp index f33b525523f..5e7a9608735 100644 --- a/src/core/thread/mle.hpp +++ b/src/core/thread/mle.hpp @@ -95,7 +95,7 @@ namespace Mle { */ /** - * This class implements MLE functionality required by the Thread EndDevices, Router, and Leader roles. + * Implements MLE functionality required by the Thread EndDevices, Router, and Leader roles. * */ class Mle : public InstanceLocator, private NonCopyable @@ -109,7 +109,7 @@ class Mle : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the MLE object. + * Initializes the MLE object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -117,7 +117,7 @@ class Mle : public InstanceLocator, private NonCopyable explicit Mle(Instance &aInstance); /** - * This method enables MLE. + * Enables MLE. * * @retval kErrorNone Successfully enabled MLE. * @retval kErrorAlready MLE was already enabled. @@ -126,7 +126,7 @@ class Mle : public InstanceLocator, private NonCopyable Error Enable(void); /** - * This method disables MLE. + * Disables MLE. * * @retval kErrorNone Successfully disabled MLE. * @@ -134,7 +134,7 @@ class Mle : public InstanceLocator, private NonCopyable Error Disable(void); /** - * This method starts the MLE protocol operation. + * Starts the MLE protocol operation. * * @retval kErrorNone Successfully started the protocol operation. * @retval kErrorInvalidState IPv6 interface is down or device is in raw-link mode. @@ -143,19 +143,19 @@ class Mle : public InstanceLocator, private NonCopyable Error Start(void) { return Start(kNormalAttach); } /** - * This method stops the MLE protocol operation. + * Stops the MLE protocol operation. * */ void Stop(void) { Stop(kUpdateNetworkDatasets); } /** - * This method restores network information from non-volatile memory (if any). + * Restores network information from non-volatile memory (if any). * */ void Restore(void); /** - * This method stores network information into non-volatile memory. + * Stores network information into non-volatile memory. * * @retval kErrorNone Successfully store the network information. * @retval kErrorNoBufs Could not store the network information due to insufficient memory space. @@ -164,7 +164,7 @@ class Mle : public InstanceLocator, private NonCopyable Error Store(void); /** - * This method generates an MLE Announce message. + * Generates an MLE Announce message. * * @param[in] aChannel The channel to use when transmitting. * @@ -172,7 +172,7 @@ class Mle : public InstanceLocator, private NonCopyable void SendAnnounce(uint8_t aChannel) { SendAnnounce(aChannel, kNormalAnnounce); } /** - * This method causes the Thread interface to detach from the Thread network. + * Causes the Thread interface to detach from the Thread network. * * @retval kErrorNone Successfully detached from the Thread network. * @retval kErrorInvalidState MLE is Disabled. @@ -181,7 +181,7 @@ class Mle : public InstanceLocator, private NonCopyable Error BecomeDetached(void); /** - * This method causes the Thread interface to attempt an MLE attach. + * Causes the Thread interface to attempt an MLE attach. * * @retval kErrorNone Successfully began the attach process. * @retval kErrorInvalidState MLE is Disabled. @@ -191,7 +191,7 @@ class Mle : public InstanceLocator, private NonCopyable Error BecomeChild(void); /** - * This function notifies other nodes in the network (if any) and then stops Thread protocol operation. + * Notifies other nodes in the network (if any) and then stops Thread protocol operation. * * It sends an Address Release if it's a router, or sets its child timeout to 0 if it's a child. * @@ -205,7 +205,7 @@ class Mle : public InstanceLocator, private NonCopyable Error DetachGracefully(otDetachGracefullyCallback aCallback, void *aContext); /** - * This method indicates whether or not the Thread device is attached to a Thread network. + * Indicates whether or not the Thread device is attached to a Thread network. * * @retval TRUE Attached to a Thread network. * @retval FALSE Not attached to a Thread network. @@ -214,7 +214,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsAttached(void) const; /** - * This method indicates whether device is currently attaching or not. + * Indicates whether device is currently attaching or not. * * Note that an already attached device may also be in attaching state. Examples of this include a leader/router * trying to attach to a better partition, or a child trying to find a better parent (when feature @@ -227,7 +227,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsAttaching(void) const { return (mAttachState != kAttachStateIdle); } /** - * This method returns the current Thread device role. + * Returns the current Thread device role. * * @returns The current Thread device role. * @@ -235,7 +235,7 @@ class Mle : public InstanceLocator, private NonCopyable DeviceRole GetRole(void) const { return mRole; } /** - * This method indicates whether device role is disabled. + * Indicates whether device role is disabled. * * @retval TRUE Device role is disabled. * @retval FALSE Device role is not disabled. @@ -244,7 +244,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsDisabled(void) const { return (mRole == kRoleDisabled); } /** - * This method indicates whether device role is detached. + * Indicates whether device role is detached. * * @retval TRUE Device role is detached. * @retval FALSE Device role is not detached. @@ -253,7 +253,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsDetached(void) const { return (mRole == kRoleDetached); } /** - * This method indicates whether device role is child. + * Indicates whether device role is child. * * @retval TRUE Device role is child. * @retval FALSE Device role is not child. @@ -262,7 +262,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsChild(void) const { return (mRole == kRoleChild); } /** - * This method indicates whether device role is router. + * Indicates whether device role is router. * * @retval TRUE Device role is router. * @retval FALSE Device role is not router. @@ -271,7 +271,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsRouter(void) const { return (mRole == kRoleRouter); } /** - * This method indicates whether device role is leader. + * Indicates whether device role is leader. * * @retval TRUE Device role is leader. * @retval FALSE Device role is not leader. @@ -280,7 +280,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsLeader(void) const { return (mRole == kRoleLeader); } /** - * This method indicates whether device role is either router or leader. + * Indicates whether device role is either router or leader. * * @retval TRUE Device role is either router or leader. * @retval FALSE Device role is neither router nor leader. @@ -289,7 +289,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsRouterOrLeader(void) const; /** - * This method returns the Device Mode as reported in the Mode TLV. + * Returns the Device Mode as reported in the Mode TLV. * * @returns The Device Mode as reported in the Mode TLV. * @@ -297,7 +297,7 @@ class Mle : public InstanceLocator, private NonCopyable DeviceMode GetDeviceMode(void) const { return mDeviceMode; } /** - * This method sets the Device Mode as reported in the Mode TLV. + * Sets the Device Mode as reported in the Mode TLV. * * @param[in] aDeviceMode The device mode to set. * @@ -308,7 +308,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SetDeviceMode(DeviceMode aDeviceMode); /** - * This method indicates whether or not the device is rx-on-when-idle. + * Indicates whether or not the device is rx-on-when-idle. * * @returns TRUE if rx-on-when-idle, FALSE otherwise. * @@ -316,7 +316,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsRxOnWhenIdle(void) const { return mDeviceMode.IsRxOnWhenIdle(); } /** - * This method indicates whether or not the device is a Full Thread Device. + * Indicates whether or not the device is a Full Thread Device. * * @returns TRUE if a Full Thread Device, FALSE otherwise. * @@ -324,7 +324,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsFullThreadDevice(void) const { return mDeviceMode.IsFullThreadDevice(); } /** - * This method indicates whether or not the device is a Minimal End Device. + * Indicates whether or not the device is a Minimal End Device. * * @returns TRUE if the device is a Minimal End Device, FALSE otherwise. * @@ -332,7 +332,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsMinimalEndDevice(void) const { return mDeviceMode.IsMinimalEndDevice(); } /** - * This method gets the Network Data type (full set or stable subset) that this device requests. + * Gets the Network Data type (full set or stable subset) that this device requests. * * @returns The Network Data type requested by this device. * @@ -340,7 +340,7 @@ class Mle : public InstanceLocator, private NonCopyable NetworkData::Type GetNetworkDataType(void) const { return mDeviceMode.GetNetworkDataType(); } /** - * This method returns a pointer to the Mesh Local Prefix. + * Returns a pointer to the Mesh Local Prefix. * * @returns A reference to the Mesh Local Prefix. * @@ -348,7 +348,7 @@ class Mle : public InstanceLocator, private NonCopyable const Ip6::NetworkPrefix &GetMeshLocalPrefix(void) const { return mMeshLocal16.GetAddress().GetPrefix(); } /** - * This method sets the Mesh Local Prefix. + * Sets the Mesh Local Prefix. * * @param[in] aMeshLocalPrefix A reference to the Mesh Local Prefix. * @@ -357,7 +357,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method sets the Mesh Local IID. + * Sets the Mesh Local IID. * * Available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled. * @@ -371,13 +371,13 @@ class Mle : public InstanceLocator, private NonCopyable #endif /** - * This method applies the Mesh Local Prefix. + * Applies the Mesh Local Prefix. * */ void ApplyMeshLocalPrefix(void); /** - * This method returns a reference to the Thread link-local address. + * Returns a reference to the Thread link-local address. * * The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier. * @@ -387,7 +387,7 @@ class Mle : public InstanceLocator, private NonCopyable const Ip6::Address &GetLinkLocalAddress(void) const { return mLinkLocal64.GetAddress(); } /** - * This method updates the link local address. + * Updates the link local address. * * Call this method when the IEEE 802.15.4 Extended Address has changed. * @@ -395,7 +395,7 @@ class Mle : public InstanceLocator, private NonCopyable void UpdateLinkLocalAddress(void); /** - * This method returns a reference to the link-local all Thread nodes multicast address. + * Returns a reference to the link-local all Thread nodes multicast address. * * @returns A reference to the link-local all Thread nodes multicast address. * @@ -403,7 +403,7 @@ class Mle : public InstanceLocator, private NonCopyable const Ip6::Address &GetLinkLocalAllThreadNodesAddress(void) const { return mLinkLocalAllThreadNodes.GetAddress(); } /** - * This method returns a reference to the realm-local all Thread nodes multicast address. + * Returns a reference to the realm-local all Thread nodes multicast address. * * @returns A reference to the realm-local all Thread nodes multicast address. * @@ -414,7 +414,7 @@ class Mle : public InstanceLocator, private NonCopyable } /** - * This method gets the parent when operating in End Device mode. + * Gets the parent when operating in End Device mode. * * @returns A reference to the parent. * @@ -422,7 +422,7 @@ class Mle : public InstanceLocator, private NonCopyable Parent &GetParent(void) { return mParent; } /** - * This method gets the parent when operating in End Device mode. + * Gets the parent when operating in End Device mode. * * @returns A reference to the parent. * @@ -441,7 +441,7 @@ class Mle : public InstanceLocator, private NonCopyable Error GetParentInfo(Router::Info &aParentInfo) const; /** - * This method get the parent candidate. + * Get the parent candidate. * * The parent candidate is valid when attempting to attach to a new parent. * @@ -449,7 +449,7 @@ class Mle : public InstanceLocator, private NonCopyable Parent &GetParentCandidate(void) { return mParentCandidate; } /** - * This method starts the process for child to search for a better parent while staying attached to its current + * Starts the process for child to search for a better parent while staying attached to its current * parent * * @retval kErrorNone Successfully started the process to search for a better parent. @@ -459,7 +459,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SearchForBetterParent(void); /** - * This method indicates whether or not an IPv6 address is an RLOC. + * Indicates whether or not an IPv6 address is an RLOC. * * @retval TRUE If @p aAddress is an RLOC. * @retval FALSE If @p aAddress is not an RLOC. @@ -468,7 +468,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsRoutingLocator(const Ip6::Address &aAddress) const; /** - * This method indicates whether or not an IPv6 address is an ALOC. + * Indicates whether or not an IPv6 address is an ALOC. * * @retval TRUE If @p aAddress is an ALOC. * @retval FALSE If @p aAddress is not an ALOC. @@ -477,7 +477,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsAnycastLocator(const Ip6::Address &aAddress) const; /** - * This method indicates whether or not an IPv6 address is a Mesh Local Address. + * Indicates whether or not an IPv6 address is a Mesh Local Address. * * @retval TRUE If @p aAddress is a Mesh Local Address. * @retval FALSE If @p aAddress is not a Mesh Local Address. @@ -486,7 +486,7 @@ class Mle : public InstanceLocator, private NonCopyable bool IsMeshLocalAddress(const Ip6::Address &aAddress) const; /** - * This method returns the MLE Timeout value. + * Returns the MLE Timeout value. * * @returns The MLE Timeout value in seconds. * @@ -494,7 +494,7 @@ class Mle : public InstanceLocator, private NonCopyable uint32_t GetTimeout(void) const { return mTimeout; } /** - * This method sets the MLE Timeout value. + * Sets the MLE Timeout value. * * @param[in] aTimeout The Timeout value in seconds. * @@ -502,7 +502,7 @@ class Mle : public InstanceLocator, private NonCopyable void SetTimeout(uint32_t aTimeout); /** - * This method returns the RLOC16 assigned to the Thread interface. + * Returns the RLOC16 assigned to the Thread interface. * * @returns The RLOC16 assigned to the Thread interface. * @@ -510,7 +510,7 @@ class Mle : public InstanceLocator, private NonCopyable uint16_t GetRloc16(void) const { return mRloc16; } /** - * This method returns a reference to the RLOC assigned to the Thread interface. + * Returns a reference to the RLOC assigned to the Thread interface. * * @returns A reference to the RLOC assigned to the Thread interface. * @@ -518,7 +518,7 @@ class Mle : public InstanceLocator, private NonCopyable const Ip6::Address &GetMeshLocal16(void) const { return mMeshLocal16.GetAddress(); } /** - * This method returns a reference to the ML-EID assigned to the Thread interface. + * Returns a reference to the ML-EID assigned to the Thread interface. * * @returns A reference to the ML-EID assigned to the Thread interface. * @@ -526,7 +526,7 @@ class Mle : public InstanceLocator, private NonCopyable const Ip6::Address &GetMeshLocal64(void) const { return mMeshLocal64.GetAddress(); } /** - * This method returns the Router ID of the Leader. + * Returns the Router ID of the Leader. * * @returns The Router ID of the Leader. * @@ -534,7 +534,7 @@ class Mle : public InstanceLocator, private NonCopyable uint8_t GetLeaderId(void) const { return mLeaderData.GetLeaderRouterId(); } /** - * This method retrieves the Leader's RLOC. + * Retrieves the Leader's RLOC. * * @param[out] aAddress A reference to the Leader's RLOC. * @@ -545,7 +545,7 @@ class Mle : public InstanceLocator, private NonCopyable Error GetLeaderAddress(Ip6::Address &aAddress) const; /** - * This method retrieves the Leader's ALOC. + * Retrieves the Leader's ALOC. * * @param[out] aAddress A reference to the Leader's ALOC. * @@ -556,7 +556,7 @@ class Mle : public InstanceLocator, private NonCopyable Error GetLeaderAloc(Ip6::Address &aAddress) const { return GetLocatorAddress(aAddress, kAloc16Leader); } /** - * This method computes the Commissioner's ALOC. + * Computes the Commissioner's ALOC. * * @param[out] aAddress A reference to the Commissioner's ALOC. * @param[in] aSessionId Commissioner session id. @@ -571,7 +571,7 @@ class Mle : public InstanceLocator, private NonCopyable } /** - * This method retrieves the Service ALOC for given Service ID. + * Retrieves the Service ALOC for given Service ID. * * @param[in] aServiceId Service ID to get ALOC for. * @param[out] aAddress A reference to the Service ALOC. @@ -583,7 +583,7 @@ class Mle : public InstanceLocator, private NonCopyable Error GetServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const; /** - * This method returns the most recently received Leader Data. + * Returns the most recently received Leader Data. * * @returns A reference to the most recently received Leader Data. * @@ -591,7 +591,7 @@ class Mle : public InstanceLocator, private NonCopyable const LeaderData &GetLeaderData(void); /** - * This method returns a reference to the send queue. + * Returns a reference to the send queue. * * @returns A reference to the send queue. * @@ -599,13 +599,13 @@ class Mle : public InstanceLocator, private NonCopyable const MessageQueue &GetMessageQueue(void) const { return mDelayedResponses; } /** - * This method frees multicast MLE Data Response from Delayed Message Queue if any. + * Frees multicast MLE Data Response from Delayed Message Queue if any. * */ void RemoveDelayedDataResponseMessage(void); /** - * This method gets the MLE counters. + * Gets the MLE counters. * * @returns A reference to the MLE counters. * @@ -619,14 +619,14 @@ class Mle : public InstanceLocator, private NonCopyable } /** - * This method resets the MLE counters. + * Resets the MLE counters. * */ void ResetCounters(void); #if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE /** - * This function registers the client callback that is called when processing an MLE Parent Response message. + * Registers the client callback that is called when processing an MLE Parent Response message. * * @param[in] aCallback A pointer to a function that is called to deliver MLE Parent Response data. * @param[in] aContext A pointer to application-specific context. @@ -639,17 +639,17 @@ class Mle : public InstanceLocator, private NonCopyable #endif /** - * This method requests MLE layer to prepare and send a shorter version of Child ID Request message by only + * Requests MLE layer to prepare and send a shorter version of Child ID Request message by only * including the mesh-local IPv6 address in the Address Registration TLV. * - * This method should be called when a previous MLE Child ID Request message would require fragmentation at 6LoWPAN + * Should be called when a previous MLE Child ID Request message would require fragmentation at 6LoWPAN * layer. * */ void RequestShorterChildIdRequest(void); /** - * This method gets the RLOC or ALOC of a given RLOC16 or ALOC16. + * Gets the RLOC or ALOC of a given RLOC16 or ALOC16. * * @param[out] aAddress A reference to the RLOC or ALOC. * @param[in] aLocator RLOC16 or ALOC16. @@ -661,13 +661,13 @@ class Mle : public InstanceLocator, private NonCopyable Error GetLocatorAddress(Ip6::Address &aAddress, uint16_t aLocator) const; /** - * This method schedules a Child Update Request. + * Schedules a Child Update Request. * */ void ScheduleChildUpdateRequest(void); /* - * This method indicates whether or not the device has restored the network information from + * Indicates whether or not the device has restored the network information from * non-volatile settings after boot. * * @retval true Successfully restored the network information. @@ -678,7 +678,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method gets the CSL timeout. + * Gets the CSL timeout. * * @returns CSL timeout * @@ -686,7 +686,7 @@ class Mle : public InstanceLocator, private NonCopyable uint32_t GetCslTimeout(void) const { return mCslTimeout; } /** - * This method sets the CSL timeout. + * Sets the CSL timeout. * * @param[in] aTimeout The CSL timeout in seconds. * @@ -694,7 +694,7 @@ class Mle : public InstanceLocator, private NonCopyable void SetCslTimeout(uint32_t aTimeout); /** - * This method calculates CSL metric of parent. + * Calculates CSL metric of parent. * * @param[in] aCslAccuracy The CSL accuracy. * @@ -779,7 +779,7 @@ class Mle : public InstanceLocator, private NonCopyable static constexpr uint16_t kMleMaxResponseDelay = 1000u; ///< Max delay before responding to a multicast request. /** - * This enumeration type is used in `AppendAddressRegistrationTlv()` to determine which addresses to include in the + * Type is used in `AppendAddressRegistrationTlv()` to determine which addresses to include in the * appended Address Registration TLV. * */ @@ -790,7 +790,7 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This enumeration represents the message actions used in `Log()` methods. + * Represents the message actions used in `Log()` methods. * */ enum MessageAction : uint8_t @@ -802,7 +802,7 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This enumeration represents message types used in `Log()` methods. + * Represents message types used in `Log()` methods. * */ enum MessageType : uint8_t @@ -850,20 +850,20 @@ class Mle : public InstanceLocator, private NonCopyable static constexpr uint8_t kMaxTlvListSize = 32; ///< Maximum number of TLVs in a `TlvList`. /** - * This type represents a list of TLVs (array of TLV types). + * Represents a list of TLVs (array of TLV types). * */ class TlvList : public Array { public: /** - * This constructor initializes the `TlvList` as empty. + * Initializes the `TlvList` as empty. * */ TlvList(void) = default; /** - * This method checks if a given TLV type is not already present in the list and adds it in the list. + * Checks if a given TLV type is not already present in the list and adds it in the list. * * If the list is full, this method logs it as a warning. * @@ -873,7 +873,7 @@ class Mle : public InstanceLocator, private NonCopyable void Add(uint8_t aTlvType); /** - * This method adds elements from a given list to this TLV list (if not already present in the list). + * Adds elements from a given list to this TLV list (if not already present in the list). * * @param[in] aTlvList The TLV list to add elements from. * @@ -882,7 +882,7 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This type represents a Challenge (or Response) data. + * Represents a Challenge (or Response) data. * */ struct Challenge @@ -891,13 +891,13 @@ class Mle : public InstanceLocator, private NonCopyable uint8_t mLength; ///< Challenge length (in bytes). /** - * This method generates a cryptographically secure random sequence to populate the challenge data. + * Generates a cryptographically secure random sequence to populate the challenge data. * */ void GenerateRandom(void); /** - * This method indicates whether the Challenge matches a given buffer. + * Indicates whether the Challenge matches a given buffer. * * @param[in] aBuffer A pointer to a buffer to compare with the Challenge. * @param[in] aLength Length of @p aBuffer (in bytes). @@ -909,7 +909,7 @@ class Mle : public InstanceLocator, private NonCopyable bool Matches(const uint8_t *aBuffer, uint8_t aLength) const; /** - * This method indicates whether two Challenge data byte sequences are equal or not. + * Indicates whether two Challenge data byte sequences are equal or not. * * @param[in] aOther Another Challenge data to compare. * @@ -921,14 +921,14 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This class represents an MLE Tx message. + * Represents an MLE Tx message. * */ class TxMessage : public Message { public: /** - * This method appends a Source Address TLV to the message. + * Appends a Source Address TLV to the message. * * @retval kErrorNone Successfully appended the Source Address TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Source Address TLV. @@ -937,7 +937,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendSourceAddressTlv(void); /** - * This method appends a Mode TLV to the message. + * Appends a Mode TLV to the message. * * @param[in] aMode The Device Mode. * @@ -948,7 +948,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendModeTlv(DeviceMode aMode); /** - * This method appends a Timeout TLV to the message. + * Appends a Timeout TLV to the message. * * @param[in] aTimeout The Timeout value. * @@ -959,7 +959,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendTimeoutTlv(uint32_t aTimeout); /** - * This method appends a Challenge TLV to the message. + * Appends a Challenge TLV to the message. * * @param[in] aChallenge A pointer to the Challenge value. * @param[in] aChallengeLength The length of the Challenge value in bytes. @@ -971,7 +971,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendChallengeTlv(const uint8_t *aChallenge, uint8_t aChallengeLength); /** - * This method appends a Challenge TLV to the message. + * Appends a Challenge TLV to the message. * * @param[in] aChallenge A reference to the Challenge data. * @@ -982,7 +982,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendChallengeTlv(const Challenge &aChallenge); /** - * This method appends a Response TLV to the message. + * Appends a Response TLV to the message. * * @param[in] aResponse A reference to the Response data. * @@ -993,7 +993,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendResponseTlv(const Challenge &aResponse); /** - * This method appends a Link Frame Counter TLV to the message. + * Appends a Link Frame Counter TLV to the message. * * @retval kErrorNone Successfully appended the Link Frame Counter TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Link Frame Counter TLV. @@ -1002,7 +1002,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendLinkFrameCounterTlv(void); /** - * This method appends an MLE Frame Counter TLV to the message. + * Appends an MLE Frame Counter TLV to the message. * * @retval kErrorNone Successfully appended the Frame Counter TLV. * @retval kErrorNoBufs Insufficient buffers available to append the MLE Frame Counter TLV. @@ -1011,7 +1011,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendMleFrameCounterTlv(void); /** - * This method appends an Address16 TLV to the message. + * Appends an Address16 TLV to the message. * * @param[in] aRloc16 The RLOC16 value. * @@ -1022,7 +1022,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendAddress16Tlv(uint16_t aRloc16); /** - * This method appends a Network Data TLV to the message. + * Appends a Network Data TLV to the message. * * @param[in] aType The Network Data type to append, full set or stable subset. * @@ -1033,7 +1033,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendNetworkDataTlv(NetworkData::Type aType); /** - * This method appends a TLV Request TLV to the message. + * Appends a TLV Request TLV to the message. * * @param[in] aTlvs A pointer to the list of TLV types. * @param[in] aTlvsLength The number of TLV types in @p aTlvs @@ -1045,7 +1045,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendTlvRequestTlv(const uint8_t *aTlvs, uint8_t aTlvsLength); /** - * This method appends a TLV Request TLV to the message. + * Appends a TLV Request TLV to the message. * * @tparam kArrayLength The TLV array length. * @@ -1061,7 +1061,7 @@ class Mle : public InstanceLocator, private NonCopyable } /** - * This method appends a Leader Data TLV to the message. + * Appends a Leader Data TLV to the message. * * @retval kErrorNone Successfully appended the Leader Data TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Leader Data TLV. @@ -1070,7 +1070,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendLeaderDataTlv(void); /** - * This method appends a Scan Mask TLV to th message. + * Appends a Scan Mask TLV to th message. * * @param[in] aScanMask The Scan Mask value. * @@ -1081,7 +1081,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendScanMaskTlv(uint8_t aScanMask); /** - * This method appends a Status TLV to the message. + * Appends a Status TLV to the message. * * @param[in] aStatus The Status value. * @@ -1092,7 +1092,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendStatusTlv(StatusTlv::Status aStatus); /** - * This method appends a Link Margin TLV to the message. + * Appends a Link Margin TLV to the message. * * @param[in] aLinkMargin The Link Margin value. * @@ -1103,7 +1103,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendLinkMarginTlv(uint8_t aLinkMargin); /** - * This method appends a Version TLV to the message. + * Appends a Version TLV to the message. * * @retval kErrorNone Successfully appended the Version TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Version TLV. @@ -1112,7 +1112,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendVersionTlv(void); /** - * This method appends an Address Registration TLV to the message. + * Appends an Address Registration TLV to the message. * * @param[in] aMode Determines which addresses to include in the TLV (see `AddressRegistrationMode`). * @@ -1123,7 +1123,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendAddressRegistrationTlv(AddressRegistrationMode aMode = kAppendAllAddresses); /** - * This method appends a Supervision Interval TLV to the message. + * Appends a Supervision Interval TLV to the message. * * @param[in] aInterval The interval value. * @@ -1135,7 +1135,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method appends a Time Request TLV to the message. + * Appends a Time Request TLV to the message. * * @retval kErrorNone Successfully appended the Time Request TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Time Request TLV. @@ -1144,7 +1144,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendTimeRequestTlv(void); /** - * This method appends a Time Parameter TLV to the message. + * Appends a Time Parameter TLV to the message. * * @retval kErrorNone Successfully appended the Time Parameter TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Time Parameter TLV. @@ -1153,7 +1153,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendTimeParameterTlv(void); #endif /** - * This method appends a XTAL Accuracy TLV to the message. + * Appends a XTAL Accuracy TLV to the message. * * @retval kErrorNone Successfully appended the XTAL Accuracy TLV. * @retval kErrorNoBufs Insufficient buffers available to append the XTAl Accuracy TLV. @@ -1163,7 +1163,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method appends a CSL Channel TLV to the message. + * Appends a CSL Channel TLV to the message. * * @retval kErrorNone Successfully appended the CSL Channel TLV. * @retval kErrorNoBufs Insufficient buffers available to append the CSL Channel TLV. @@ -1172,7 +1172,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendCslChannelTlv(void); /** - * This method appends a CSL Sync Timeout TLV to the message. + * Appends a CSL Sync Timeout TLV to the message. * * @retval kErrorNone Successfully appended the CSL Timeout TLV. * @retval kErrorNoBufs Insufficient buffers available to append the CSL Timeout TLV. @@ -1183,7 +1183,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE /** - * This method appends a CSL Clock Accuracy TLV to the message. + * Appends a CSL Clock Accuracy TLV to the message. * * @retval kErrorNone Successfully appended the CSL Accuracy TLV. * @retval kErrorNoBufs Insufficient buffers available to append the CSL Accuracy TLV. @@ -1193,7 +1193,7 @@ class Mle : public InstanceLocator, private NonCopyable #endif /** - * This method appends a Active Timestamp TLV to the message. + * Appends a Active Timestamp TLV to the message. * * @retval kErrorNone Successfully appended the Active Timestamp TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Active Timestamp TLV. @@ -1202,7 +1202,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendActiveTimestampTlv(void); /** - * This method appends a Pending Timestamp TLV to the message. + * Appends a Pending Timestamp TLV to the message. * * @retval kErrorNone Successfully appended the Pending Timestamp TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Pending Timestamp TLV. @@ -1212,7 +1212,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method appends a Route TLV to the message. + * Appends a Route TLV to the message. * * @param[in] aNeighbor A pointer to the intended destination (can be `nullptr`). * @@ -1223,7 +1223,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendRouteTlv(Neighbor *aNeighbor = nullptr); /** - * This method appends a Active Dataset TLV to the message. + * Appends a Active Dataset TLV to the message. * * @retval kErrorNone Successfully appended the Active Dataset TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Active Dataset TLV. @@ -1232,7 +1232,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendActiveDatasetTlv(void); /** - * This method appends a Pending Dataset TLV to the message. + * Appends a Pending Dataset TLV to the message. * * @retval kErrorNone Successfully appended the Pending Dataset TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Pending Dataset TLV. @@ -1241,7 +1241,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendPendingDatasetTlv(void); /** - * This method appends a Connectivity TLV to the message. + * Appends a Connectivity TLV to the message. * * @retval kErrorNone Successfully appended the Connectivity TLV. * @retval kErrorNoBufs Insufficient buffers available to append the Connectivity TLV. @@ -1250,7 +1250,7 @@ class Mle : public InstanceLocator, private NonCopyable Error AppendConnectivityTlv(void); /** - * This method appends a Address Registration TLV to the message with addresses from a given child. + * Appends a Address Registration TLV to the message with addresses from a given child. * * @param[in] aChild The child to include its list of addresses in the Address Registration TLV. * @@ -1262,7 +1262,7 @@ class Mle : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_FTD /** - * This method submits the MLE message to the UDP socket to be sent. + * Submits the MLE message to the UDP socket to be sent. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @@ -1273,7 +1273,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SendTo(const Ip6::Address &aDestination); /** - * This method enqueues the message to be sent after a given delay. + * Enqueues the message to be sent after a given delay. * * @param[in] aDestination The IPv6 address of the recipient of the message. * @param[in] aDelay The delay in milliseconds before transmission of the message. @@ -1290,14 +1290,14 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This class represents an MLE Rx message. + * Represents an MLE Rx message. * */ class RxMessage : public Message { public: /** - * This method reads Challenge TLV from the message. + * Reads Challenge TLV from the message. * * @param[out] aChallenge A reference to the Challenge data where to output the read value. * @@ -1309,7 +1309,7 @@ class Mle : public InstanceLocator, private NonCopyable Error ReadChallengeTlv(Challenge &aChallenge) const; /** - * This method reads Response TLV from the message. + * Reads Response TLV from the message. * * @param[out] aResponse A reference to the Response data where to output the read value. * @@ -1321,7 +1321,7 @@ class Mle : public InstanceLocator, private NonCopyable Error ReadResponseTlv(Challenge &aResponse) const; /** - * This method reads Link and MLE Frame Counters from the message. + * Reads Link and MLE Frame Counters from the message. * * Link Frame Counter TLV must be present in the message and its value is read into @p aLinkFrameCounter. If MLE * Frame Counter TLV is present in the message, its value is read into @p aMleFrameCounter. If the MLE Frame @@ -1339,7 +1339,7 @@ class Mle : public InstanceLocator, private NonCopyable Error ReadFrameCounterTlvs(uint32_t &aLinkFrameCounter, uint32_t &aMleFrameCounter) const; /** - * This method reads TLV Request TLV from the message. + * Reads TLV Request TLV from the message. * * @param[out] aTlvList A reference to output the read list of requested TLVs. * @@ -1351,7 +1351,7 @@ class Mle : public InstanceLocator, private NonCopyable Error ReadTlvRequestTlv(TlvList &aTlvList) const; /** - * This method reads Leader Data TLV from a message. + * Reads Leader Data TLV from a message. * * @param[out] aLeaderData A reference to output the Leader Data. * @@ -1364,7 +1364,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method reads CSL Clock Accuracy TLV from a message. + * Reads CSL Clock Accuracy TLV from a message. * * @param[out] aCslAccuracy A reference to output the CSL accuracy. * @@ -1378,7 +1378,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method reads and validates Route TLV from a message. + * Reads and validates Route TLV from a message. * * @param[out] aRouteTlv A reference to output the read Route TLV. * @@ -1395,14 +1395,14 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This structure represents a received MLE message containing additional information about the message (e.g. + * Represents a received MLE message containing additional information about the message (e.g. * key sequence, neighbor from which it was received). * */ struct RxInfo { /** - * This enumeration represents a received MLE message class. + * Represents a received MLE message class. * */ enum Class : uint8_t @@ -1413,7 +1413,7 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `RxInfo`. + * Initializes the `RxInfo`. * * @param[in] aMessage The received MLE message. * @param[in] aMessageInfo The `Ip6::MessageInfo` associated with message. @@ -1430,7 +1430,7 @@ class Mle : public InstanceLocator, private NonCopyable } /** - * This method indicates whether the `mNeighbor` (neighbor from which message was received) is non-null and + * Indicates whether the `mNeighbor` (neighbor from which message was received) is non-null and * in valid state. * * @retval TRUE If `mNeighbor` is non-null and in valid state. @@ -1448,7 +1448,7 @@ class Mle : public InstanceLocator, private NonCopyable }; /** - * This method allocates and initializes new MLE message for a given command. + * Allocates and initializes new MLE message for a given command. * * @param[in] aCommand The MLE command. * @@ -1458,7 +1458,7 @@ class Mle : public InstanceLocator, private NonCopyable TxMessage *NewMleMessage(Command aCommand); /** - * This method sets the device role. + * Sets the device role. * * @param[in] aRole A device role. * @@ -1466,7 +1466,7 @@ class Mle : public InstanceLocator, private NonCopyable void SetRole(DeviceRole aRole); /** - * This method causes the Thread interface to attempt an MLE attach. + * Causes the Thread interface to attempt an MLE attach. * * @param[in] aMode Indicates what partitions to attach to. * @@ -1474,7 +1474,7 @@ class Mle : public InstanceLocator, private NonCopyable void Attach(AttachMode aMode); /** - * This method sets the attach state + * Sets the attach state * * @param[in] aState An attach state * @@ -1482,9 +1482,9 @@ class Mle : public InstanceLocator, private NonCopyable void SetAttachState(AttachState aState); /** - * This method initializes a given @p aNeighbor with information from @p aRxInfo. + * Initializes a given @p aNeighbor with information from @p aRxInfo. * - * This method updates the following properties on @p aNeighbor from @p aRxInfo: + * Updates the following properties on @p aNeighbor from @p aRxInfo: * * - Sets the Extended MAC address from `MessageInfo` peer IPv6 address IID. * - Clears the `GetLinkInfo()` and adds RSS from the `GetThreadLinkInfo()`. @@ -1498,13 +1498,13 @@ class Mle : public InstanceLocator, private NonCopyable void InitNeighbor(Neighbor &aNeighbor, const RxInfo &aRxInfo); /** - * This method clears the parent candidate. + * Clears the parent candidate. * */ void ClearParentCandidate(void) { mParentCandidate.Clear(); } /** - * This method checks if the destination is reachable. + * Checks if the destination is reachable. * * @param[in] aMeshDest The RLOC16 of the destination. * @param[in] aIp6Header The IPv6 header of the message. @@ -1516,7 +1516,7 @@ class Mle : public InstanceLocator, private NonCopyable Error CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header); /** - * This method returns the next hop towards an RLOC16 destination. + * Returns the next hop towards an RLOC16 destination. * * @param[in] aDestination The RLOC16 of the destination. * @@ -1526,7 +1526,7 @@ class Mle : public InstanceLocator, private NonCopyable Mac::ShortAddress GetNextHop(uint16_t aDestination) const; /** - * This method generates an MLE Data Request message. + * Generates an MLE Data Request message. * * @param[in] aDestination The IPv6 destination address. * @@ -1538,7 +1538,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE /** - * This method generates an MLE Data Request message which request Link Metrics Report TLV. + * Generates an MLE Data Request message which request Link Metrics Report TLV. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aQueryInfo A Link Metrics query info. @@ -1552,7 +1552,7 @@ class Mle : public InstanceLocator, private NonCopyable #endif /** - * This method generates an MLE Child Update Request message. + * Generates an MLE Child Update Request message. * * @retval kErrorNone Successfully generated an MLE Child Update Request message. * @retval kErrorNoBufs Insufficient buffers to generate the MLE Child Update Request message. @@ -1561,7 +1561,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SendChildUpdateRequest(void); /** - * This method generates an MLE Child Update Response message. + * Generates an MLE Child Update Response message. * * @param[in] aTlvList A list of requested TLV types. * @param[in] aChallenge The Challenge for the response. @@ -1573,7 +1573,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SendChildUpdateResponse(const TlvList &aTlvList, const Challenge &aChallenge); /** - * This method sets the RLOC16 assigned to the Thread interface. + * Sets the RLOC16 assigned to the Thread interface. * * @param[in] aRloc16 The RLOC16 to set. * @@ -1581,19 +1581,19 @@ class Mle : public InstanceLocator, private NonCopyable void SetRloc16(uint16_t aRloc16); /** - * This method sets the Device State to Detached. + * Sets the Device State to Detached. * */ void SetStateDetached(void); /** - * This method sets the Device State to Child. + * Sets the Device State to Child. * */ void SetStateChild(uint16_t aRloc16); /** - * This method sets the Leader's Partition ID, Weighting, and Router ID values. + * Sets the Leader's Partition ID, Weighting, and Router ID values. * * @param[in] aPartitionId The Leader's Partition ID value. * @param[in] aWeighting The Leader's Weighting value. @@ -1604,7 +1604,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) /** - * This static method emits a log message with an IPv6 address. + * Emits a log message with an IPv6 address. * * @param[in] aAction The message action (send/receive/delay, etc). * @param[in] aType The message type. @@ -1614,7 +1614,7 @@ class Mle : public InstanceLocator, private NonCopyable static void Log(MessageAction aAction, MessageType aType, const Ip6::Address &aAddress); /** - * This static method emits a log message with an IPv6 address and RLOC16. + * Emits a log message with an IPv6 address and RLOC16. * * @param[in] aAction The message action (send/receive/delay, etc). * @param[in] aType The message type. @@ -1630,7 +1630,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_WARN) /** - * This static method emits a log message indicating an error in processing of a message. + * Emits a log message indicating an error in processing of a message. * * Note that log message is emitted only if there is an error, i.e., @p aError is not `kErrorNone`. The log * message will have the format "Failed to process {aMessageString} : {ErrorString}". @@ -1642,7 +1642,7 @@ class Mle : public InstanceLocator, private NonCopyable static void LogProcessError(MessageType aType, Error aError); /** - * This static method emits a log message indicating an error when sending a message. + * Emits a log message indicating an error when sending a message. * * Note that log message is emitted only if there is an error, i.e. @p aError is not `kErrorNone`. The log * message will have the format "Failed to send {Message Type} : {ErrorString}". @@ -1658,7 +1658,7 @@ class Mle : public InstanceLocator, private NonCopyable #endif // #if OT_SHOULD_LOG_AT( OT_LOG_LEVEL_WARN) /** - * This method triggers MLE Announce on previous channel after the Thread device successfully + * Triggers MLE Announce on previous channel after the Thread device successfully * attaches and receives the new Active Commissioning Dataset if needed. * * MTD would send Announce immediately after attached. @@ -1668,7 +1668,7 @@ class Mle : public InstanceLocator, private NonCopyable void InformPreviousChannel(void); /** - * This method indicates whether or not in announce attach process. + * Indicates whether or not in announce attach process. * * @retval true if attaching/attached on the announced parameters, false otherwise. * @@ -1677,7 +1677,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE) /** - * This method converts an `AttachMode` enumeration value into a human-readable string. + * Converts an `AttachMode` enumeration value into a human-readable string. * * @param[in] aMode An attach mode * @@ -1687,7 +1687,7 @@ class Mle : public InstanceLocator, private NonCopyable static const char *AttachModeToString(AttachMode aMode); /** - * This method converts an `AttachState` enumeration value into a human-readable string. + * Converts an `AttachState` enumeration value into a human-readable string. * * @param[in] aState An attach state * @@ -1697,7 +1697,7 @@ class Mle : public InstanceLocator, private NonCopyable static const char *AttachStateToString(AttachState aState); /** - * This method converts a `ReattachState` enumeration value into a human-readable string. + * Converts a `ReattachState` enumeration value into a human-readable string. * * @param[in] aState A reattach state * @@ -1709,7 +1709,7 @@ class Mle : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE /** - * This method sends a Link Metrics Management Request message. + * Sends a Link Metrics Management Request message. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aSubTlv A reference to the sub-TLV to include. @@ -1721,7 +1721,7 @@ class Mle : public InstanceLocator, private NonCopyable Error SendLinkMetricsManagementRequest(const Ip6::Address &aDestination, const ot::Tlv &aSubTlv); /** - * This method sends an MLE Link Probe message. + * Sends an MLE Link Probe message. * * @param[in] aDestination A reference to the IPv6 address of the destination. * @param[in] aSeriesId The Series ID [1, 254] which the Probe message targets at. diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 417c1c57b17..c79a0745e47 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -94,7 +94,12 @@ MleRouter::MleRouter(Instance &aInstance) #endif { mDeviceMode.Set(mDeviceMode.Get() | DeviceMode::kModeFullThreadDevice | DeviceMode::kModeFullNetworkData); + +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) mLeaderWeight = mDeviceProperties.CalculateLeaderWeight(); +#else + mLeaderWeight = kDefaultLeaderWeight; +#endif SetRouterId(kInvalidRouterId); @@ -183,12 +188,14 @@ Error MleRouter::SetRouterEligible(bool aEligible) return error; } +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) void MleRouter::SetDeviceProperties(const DeviceProperties &aDeviceProperties) { mDeviceProperties = aDeviceProperties; mDeviceProperties.ClampWeightAdjustment(); SetLeaderWeight(mDeviceProperties.CalculateLeaderWeight()); } +#endif Error MleRouter::BecomeRouter(ThreadStatusTlv::Status aStatus) { @@ -1792,28 +1799,30 @@ Error MleRouter::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild) { Error error; uint16_t offset; - uint16_t length; uint16_t endOffset; uint8_t count = 0; uint8_t storedCount = 0; #if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - Ip6::Address oldDua; - const Ip6::Address *oldDuaPtr = nullptr; - bool hasDua = false; + bool hasOldDua = false; + bool hasNewDua = false; + Ip6::Address oldDua; #endif #if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE - Ip6::Address oldMlrRegisteredAddresses[kMaxChildIpAddresses - 1]; - uint16_t oldMlrRegisteredAddressNum = 0; + MlrManager::MlrAddressArray oldMlrRegisteredAddresses; #endif - SuccessOrExit(error = Tlv::FindTlvValueOffset(aRxInfo.mMessage, Tlv::kAddressRegistration, offset, length)); - - endOffset = offset + length; + SuccessOrExit(error = + Tlv::FindTlvValueStartEndOffsets(aRxInfo.mMessage, Tlv::kAddressRegistration, offset, endOffset)); #if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - if ((oldDuaPtr = aChild.GetDomainUnicastAddress()) != nullptr) { - oldDua = *oldDuaPtr; + const Ip6::Address *duaAddress = aChild.GetDomainUnicastAddress(); + + if (duaAddress != nullptr) + { + oldDua = *duaAddress; + hasOldDua = true; + } } #endif @@ -1828,7 +1837,7 @@ Error MleRouter::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild) { if (aChild.GetAddressMlrState(childAddress) == kMlrStateRegistered) { - oldMlrRegisteredAddresses[oldMlrRegisteredAddressNum++] = childAddress; + IgnoreError(oldMlrRegisteredAddresses.PushBack(childAddress)); } } } @@ -1897,40 +1906,42 @@ Error MleRouter::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild) if (error == kErrorNone) { storedCount++; + LogInfo("Child 0x%04x IPv6 address[%u]=%s", aChild.GetRloc16(), storedCount, + address.ToString().AsCString()); + } + else + { + LogWarn("Error %s adding IPv6 address %s to child 0x%04x", ErrorToString(error), + address.ToString().AsCString(), aChild.GetRloc16()); + } #if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - if (Get().IsDomainUnicast(address)) + if (Get().IsDomainUnicast(address)) + { + if (error == kErrorNone) { - hasDua = true; + DuaManager::ChildDuaAddressEvent event; - if (oldDuaPtr != nullptr) + hasNewDua = true; + + if (hasOldDua) { - Get().UpdateChildDomainUnicastAddress( - aChild, oldDua != address ? ChildDuaState::kChanged : ChildDuaState::kUnchanged); + event = (oldDua != address) ? DuaManager::kAddressChanged : DuaManager::kAddressUnchanged; } else { - Get().UpdateChildDomainUnicastAddress(aChild, ChildDuaState::kAdded); + event = DuaManager::kAddressAdded; } - } -#endif - LogInfo("Child 0x%04x IPv6 address[%u]=%s", aChild.GetRloc16(), storedCount, - address.ToString().AsCString()); - } - else - { -#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - if (Get().IsDomainUnicast(address)) + Get().HandleChildDuaAddressEvent(aChild, event); + } + else { // if not able to store DUA, then assume child does not have one - hasDua = false; + hasNewDua = false; } -#endif - - LogWarn("Error %s adding IPv6 address %s to child 0x%04x", ErrorToString(error), - address.ToString().AsCString(), aChild.GetRloc16()); } +#endif if (address.IsMulticast()) { @@ -1961,15 +1972,14 @@ Error MleRouter::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild) Get().RemoveEntryForAddress(address); } #if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - // Dua is removed - if (oldDuaPtr != nullptr && !hasDua) + if (hasOldDua && !hasNewDua) { - Get().UpdateChildDomainUnicastAddress(aChild, ChildDuaState::kRemoved); + Get().HandleChildDuaAddressEvent(aChild, DuaManager::kAddressRemoved); } #endif #if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE - Get().UpdateProxiedSubscriptions(aChild, oldMlrRegisteredAddresses, oldMlrRegisteredAddressNum); + Get().UpdateProxiedSubscriptions(aChild, oldMlrRegisteredAddresses); #endif if (count == 0) @@ -2712,7 +2722,6 @@ void MleRouter::HandleDiscoveryRequest(RxInfo &aRxInfo) MeshCoP::DiscoveryRequestTlv discoveryRequestTlv; MeshCoP::ExtendedPanId extPanId; uint16_t offset; - uint16_t length; uint16_t end; Log(kMessageReceive, kTypeDiscoveryRequest, aRxInfo.mMessageInfo.GetPeerAddr()); @@ -2722,8 +2731,7 @@ void MleRouter::HandleDiscoveryRequest(RxInfo &aRxInfo) // only Routers and REEDs respond VerifyOrExit(IsRouterEligible(), error = kErrorInvalidState); - SuccessOrExit(error = Tlv::FindTlvValueOffset(aRxInfo.mMessage, Tlv::kDiscovery, offset, length)); - end = offset + length; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aRxInfo.mMessage, Tlv::kDiscovery, offset, end)); while (offset < end) { @@ -3534,6 +3542,16 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message *aMessage, leader->SetNextHopAndCost(RouterIdFromRloc16(mParent.GetRloc16()), mParent.GetLeaderCost()); } + // We send a unicast Link Request to our former parent if its + // version is earlier than 1.3. This is to address a potential + // compatibility issue with some non-OpenThread stacks which may + // ignore MLE Advertisements from a former/existing child. + + if (mParent.GetVersion() < kThreadVersion1p3) + { + IgnoreError(SendLinkRequest(&mParent)); + } + // We send an Advertisement to inform our former parent of our // newly allocated Router ID. This will cause the parent to // reset its advertisement trickle timer which can help speed @@ -3936,7 +3954,7 @@ void MleRouter::SetChildStateToValid(Child &aChild) IgnoreError(mChildTable.StoreChild(aChild)); #if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE - Get().UpdateProxiedSubscriptions(aChild, nullptr, 0); + Get().UpdateProxiedSubscriptions(aChild, MlrManager::MlrAddressArray()); #endif mNeighborTable.Signal(NeighborTable::kChildAdded, aChild); diff --git a/src/core/thread/mle_router.hpp b/src/core/thread/mle_router.hpp index ac84f757f73..00cbade6ab1 100644 --- a/src/core/thread/mle_router.hpp +++ b/src/core/thread/mle_router.hpp @@ -70,7 +70,7 @@ namespace Mle { #if OPENTHREAD_FTD /** - * This class implements MLE functionality required by the Thread Router and Leader roles. + * Implements MLE functionality required by the Thread Router and Leader roles. * */ class MleRouter : public Mle @@ -82,7 +82,7 @@ class MleRouter : public Mle public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -90,7 +90,7 @@ class MleRouter : public Mle explicit MleRouter(Instance &aInstance); /** - * This method indicates whether or not the device is router-eligible. + * Indicates whether or not the device is router-eligible. * * @retval true If device is router-eligible. * @retval false If device is not router-eligible. @@ -99,7 +99,7 @@ class MleRouter : public Mle bool IsRouterEligible(void) const; /** - * This method sets whether or not the device is router-eligible. + * Sets whether or not the device is router-eligible. * * If @p aEligible is false and the device is currently operating as a router, this call will cause the device to * detach and attempt to reattach as a child. @@ -113,7 +113,7 @@ class MleRouter : public Mle Error SetRouterEligible(bool aEligible); /** - * This method indicates whether a node is the only router on the network. + * Indicates whether a node is the only router on the network. * * @retval TRUE It is the only router in the network. * @retval FALSE It is a child or is not a single router in the network. @@ -122,7 +122,7 @@ class MleRouter : public Mle bool IsSingleton(void) const; /** - * This method generates an Address Solicit request for a Router ID. + * Generates an Address Solicit request for a Router ID. * * @param[in] aStatus The reason for requesting a Router ID. * @@ -134,7 +134,7 @@ class MleRouter : public Mle Error BecomeRouter(ThreadStatusTlv::Status aStatus); /** - * This method causes the Thread interface to become a Leader and start a new partition. + * Causes the Thread interface to become a Leader and start a new partition. * * @retval kErrorNone Successfully become a Leader and started a new partition. * @retval kErrorNotCapable Device is not capable of becoming a leader @@ -143,8 +143,9 @@ class MleRouter : public Mle */ Error BecomeLeader(void); +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) /** - * This method gets the device properties which are used to determine the Leader Weight. + * Gets the device properties which are used to determine the Leader Weight. * * @returns The current device properties. * @@ -152,15 +153,16 @@ class MleRouter : public Mle const DeviceProperties &GetDeviceProperties(void) const { return mDeviceProperties; } /** - * This method sets the device properties which are then used to determine and set the Leader Weight. + * Sets the device properties which are then used to determine and set the Leader Weight. * * @param[in] aDeviceProperties The device properties. * */ void SetDeviceProperties(const DeviceProperties &aDeviceProperties); +#endif /** - * This method returns the Leader Weighting value for this Thread interface. + * Returns the Leader Weighting value for this Thread interface. * * @returns The Leader Weighting value for this Thread interface. * @@ -168,9 +170,9 @@ class MleRouter : public Mle uint8_t GetLeaderWeight(void) const { return mLeaderWeight; } /** - * This method sets the Leader Weighting value for this Thread interface. + * Sets the Leader Weighting value for this Thread interface. * - * This method directly sets the Leader Weight to the new value replacing its previous value (which may have been + * Directly sets the Leader Weight to the new value replacing its previous value (which may have been * determined from a previous call to `SetDeviceProperties()`). * * @param[in] aWeight The Leader Weighting value. @@ -181,7 +183,7 @@ class MleRouter : public Mle #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method returns the preferred Partition Id when operating in the Leader role for certification testing. + * Returns the preferred Partition Id when operating in the Leader role for certification testing. * * @returns The preferred Partition Id value. * @@ -189,7 +191,7 @@ class MleRouter : public Mle uint32_t GetPreferredLeaderPartitionId(void) const { return mPreferredLeaderPartitionId; } /** - * This method sets the preferred Partition Id when operating in the Leader role for certification testing. + * Sets the preferred Partition Id when operating in the Leader role for certification testing. * * @param[in] aPartitionId The preferred Leader Partition Id. * @@ -198,7 +200,7 @@ class MleRouter : public Mle #endif /** - * This method sets the preferred Router Id. Upon becoming a router/leader the node + * Sets the preferred Router Id. Upon becoming a router/leader the node * attempts to use this Router Id. If the preferred Router Id is not set or if it * can not be used, a randomly generated router Id is picked. * This property can be set when he device role is detached or disabled. @@ -212,13 +214,13 @@ class MleRouter : public Mle Error SetPreferredRouterId(uint8_t aRouterId); /** - * This method gets the Partition Id which the device joined successfully once. + * Gets the Partition Id which the device joined successfully once. * */ uint32_t GetPreviousPartitionId(void) const { return mPreviousPartitionId; } /** - * This method sets the Partition Id which the device joins successfully. + * Sets the Partition Id which the device joins successfully. * * @param[in] aPartitionId The Partition Id. * @@ -226,7 +228,7 @@ class MleRouter : public Mle void SetPreviousPartitionId(uint32_t aPartitionId) { mPreviousPartitionId = aPartitionId; } /** - * This method sets the Router Id. + * Sets the Router Id. * * @param[in] aRouterId The Router Id. * @@ -234,7 +236,7 @@ class MleRouter : public Mle void SetRouterId(uint8_t aRouterId); /** - * This method returns the next hop towards an RLOC16 destination. + * Returns the next hop towards an RLOC16 destination. * * @param[in] aDestination The RLOC16 of the destination. * @@ -244,7 +246,7 @@ class MleRouter : public Mle uint16_t GetNextHop(uint16_t aDestination) { return mRouterTable.GetNextHop(aDestination); } /** - * This method returns the NETWORK_ID_TIMEOUT value. + * Returns the NETWORK_ID_TIMEOUT value. * * @returns The NETWORK_ID_TIMEOUT value. * @@ -252,7 +254,7 @@ class MleRouter : public Mle uint8_t GetNetworkIdTimeout(void) const { return mNetworkIdTimeout; } /** - * This method sets the NETWORK_ID_TIMEOUT value. + * Sets the NETWORK_ID_TIMEOUT value. * * @param[in] aTimeout The NETWORK_ID_TIMEOUT value. * @@ -260,7 +262,7 @@ class MleRouter : public Mle void SetNetworkIdTimeout(uint8_t aTimeout) { mNetworkIdTimeout = aTimeout; } /** - * This method returns the ROUTER_SELECTION_JITTER value. + * Returns the ROUTER_SELECTION_JITTER value. * * @returns The ROUTER_SELECTION_JITTER value. * @@ -268,7 +270,7 @@ class MleRouter : public Mle uint8_t GetRouterSelectionJitter(void) const { return mRouterSelectionJitter; } /** - * This method sets the ROUTER_SELECTION_JITTER value. + * Sets the ROUTER_SELECTION_JITTER value. * * @returns The ROUTER_SELECTION_JITTER value. * @@ -276,7 +278,7 @@ class MleRouter : public Mle Error SetRouterSelectionJitter(uint8_t aRouterJitter); /** - * This method returns the current router selection jitter timeout value. + * Returns the current router selection jitter timeout value. * * @returns The current router selection jitter timeout value. * @@ -284,7 +286,7 @@ class MleRouter : public Mle uint8_t GetRouterSelectionJitterTimeout(void) const { return mRouterSelectionJitterTimeout; } /** - * This method returns the ROUTER_UPGRADE_THRESHOLD value. + * Returns the ROUTER_UPGRADE_THRESHOLD value. * * @returns The ROUTER_UPGRADE_THRESHOLD value. * @@ -292,7 +294,7 @@ class MleRouter : public Mle uint8_t GetRouterUpgradeThreshold(void) const { return mRouterUpgradeThreshold; } /** - * This method sets the ROUTER_UPGRADE_THRESHOLD value. + * Sets the ROUTER_UPGRADE_THRESHOLD value. * * @param[in] aThreshold The ROUTER_UPGRADE_THRESHOLD value. * @@ -300,7 +302,7 @@ class MleRouter : public Mle void SetRouterUpgradeThreshold(uint8_t aThreshold) { mRouterUpgradeThreshold = aThreshold; } /** - * This method returns the ROUTER_DOWNGRADE_THRESHOLD value. + * Returns the ROUTER_DOWNGRADE_THRESHOLD value. * * @returns The ROUTER_DOWNGRADE_THRESHOLD value. * @@ -308,7 +310,7 @@ class MleRouter : public Mle uint8_t GetRouterDowngradeThreshold(void) const { return mRouterDowngradeThreshold; } /** - * This method sets the ROUTER_DOWNGRADE_THRESHOLD value. + * Sets the ROUTER_DOWNGRADE_THRESHOLD value. * * @param[in] aThreshold The ROUTER_DOWNGRADE_THRESHOLD value. * @@ -316,7 +318,7 @@ class MleRouter : public Mle void SetRouterDowngradeThreshold(uint8_t aThreshold) { mRouterDowngradeThreshold = aThreshold; } /** - * This method returns the MLE_CHILD_ROUTER_LINKS value. + * Returns the MLE_CHILD_ROUTER_LINKS value. * * @returns The MLE_CHILD_ROUTER_LINKS value. * @@ -324,7 +326,7 @@ class MleRouter : public Mle uint8_t GetChildRouterLinks(void) const { return mChildRouterLinks; } /** - * This method sets the MLE_CHILD_ROUTER_LINKS value. + * Sets the MLE_CHILD_ROUTER_LINKS value. * * @param[in] aChildRouterLinks The MLE_CHILD_ROUTER_LINKS value. * @@ -334,7 +336,7 @@ class MleRouter : public Mle Error SetChildRouterLinks(uint8_t aChildRouterLinks); /** - * This method returns if the REED is expected to become Router soon. + * Returns if the REED is expected to become Router soon. * * @retval TRUE If the REED is going to become a Router soon. * @retval FALSE If the REED is not going to become a Router soon. @@ -343,7 +345,7 @@ class MleRouter : public Mle bool IsExpectedToBecomeRouterSoon(void) const; /** - * This method removes a link to a neighbor. + * Removes a link to a neighbor. * * @param[in] aNeighbor A reference to the neighbor object. * @@ -351,7 +353,7 @@ class MleRouter : public Mle void RemoveNeighbor(Neighbor &aNeighbor); /** - * This method invalidates a direct link to a neighboring router (due to failed link-layer acks). + * Invalidates a direct link to a neighboring router (due to failed link-layer acks). * * @param[in] aRouter A reference to the router object. * @@ -359,7 +361,7 @@ class MleRouter : public Mle void RemoveRouterLink(Router &aRouter); /** - * This method indicates whether or not the RLOC16 is an MTD child of this device. + * Indicates whether or not the RLOC16 is an MTD child of this device. * * @param[in] aRloc16 The RLOC16. * @@ -370,7 +372,7 @@ class MleRouter : public Mle bool IsMinimalChild(uint16_t aRloc16); /** - * This method indicates whether or not the given Thread partition attributes are preferred. + * Indicates whether or not the given Thread partition attributes are preferred. * * @param[in] aSingletonA Whether or not the Thread Partition A has a single router. * @param[in] aLeaderDataA A reference to Thread Partition A's Leader Data. @@ -388,7 +390,7 @@ class MleRouter : public Mle const LeaderData &aLeaderDataB); /** - * This method checks if the destination is reachable. + * Checks if the destination is reachable. * * @param[in] aMeshDest The RLOC16 of the destination. * @param[in] aIp6Header A reference to the IPv6 header of the message. @@ -400,7 +402,7 @@ class MleRouter : public Mle Error CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header); /** - * This method resolves 2-hop routing loops. + * Resolves 2-hop routing loops. * * @param[in] aSourceMac The RLOC16 of the previous hop. * @param[in] aDestRloc16 The RLOC16 of the final destination. @@ -409,7 +411,7 @@ class MleRouter : public Mle void ResolveRoutingLoops(uint16_t aSourceMac, uint16_t aDestRloc16); /** - * This method checks if a given Router ID has correct value. + * Checks if a given Router ID has correct value. * * @param[in] aRouterId The Router ID value. * @@ -420,7 +422,7 @@ class MleRouter : public Mle static bool IsRouterIdValid(uint8_t aRouterId) { return aRouterId <= kMaxRouterId; } /** - * This method fills an ConnectivityTlv. + * Fills an ConnectivityTlv. * * @param[out] aTlv A reference to the tlv to be filled. * @@ -428,7 +430,7 @@ class MleRouter : public Mle void FillConnectivityTlv(ConnectivityTlv &aTlv); /** - * This method generates an MLE Child Update Request message to be sent to the parent. + * Generates an MLE Child Update Request message to be sent to the parent. * * @retval kErrorNone Successfully generated an MLE Child Update Request message. * @retval kErrorNoBufs Insufficient buffers to generate the MLE Child Update Request message. @@ -440,7 +442,7 @@ class MleRouter : public Mle #if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE /** - * This method sets steering data out of band + * Sets steering data out of band * * @param[in] aExtAddress Value used to set steering data * All zeros clears steering data @@ -452,7 +454,7 @@ class MleRouter : public Mle #endif /** - * This method gets the assigned parent priority. + * Gets the assigned parent priority. * * @returns The assigned parent priority value, -2 means not assigned. * @@ -460,7 +462,7 @@ class MleRouter : public Mle int8_t GetAssignParentPriority(void) const { return mParentPriority; } /** - * This method sets the parent priority. + * Sets the parent priority. * * @param[in] aParentPriority The parent priority value. * @@ -471,7 +473,7 @@ class MleRouter : public Mle Error SetAssignParentPriority(int8_t aParentPriority); /** - * This method gets the longest MLE Timeout TLV for all active MTD children. + * Gets the longest MLE Timeout TLV for all active MTD children. * * @param[out] aTimeout A reference to where the information is placed. * @@ -483,7 +485,7 @@ class MleRouter : public Mle Error GetMaxChildTimeout(uint32_t &aTimeout) const; /** - * This function sets the callback that is called when processing an MLE Discovery Request message. + * Sets the callback that is called when processing an MLE Discovery Request message. * * @param[in] aCallback A pointer to a function that is called to deliver MLE Discovery Request data. * @param[in] aContext A pointer to application-specific context. @@ -495,14 +497,14 @@ class MleRouter : public Mle } /** - * This method resets the MLE Advertisement Trickle timer interval. + * Resets the MLE Advertisement Trickle timer interval. * */ void ResetAdvertiseInterval(void); #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method generates an MLE Time Synchronization message. + * Generates an MLE Time Synchronization message. * * @retval kErrorNone Successfully sent an MLE Time Synchronization message. * @retval kErrorNoBufs Insufficient buffers to generate the MLE Time Synchronization message. @@ -513,7 +515,7 @@ class MleRouter : public Mle #if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE /** - * This method sets the delay before registering Backbone Router service. + * Sets the delay before registering Backbone Router service. * * @param[in] aDelay The delay before registering Backbone Router service. * @@ -522,7 +524,7 @@ class MleRouter : public Mle #endif /** - * This method 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. * * @returns The maximum number of IP addresses that each MTD child may register with this device as parent. * @@ -531,7 +533,7 @@ class MleRouter : public Mle #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method sets/restores the maximum number of IP addresses that each MTD child may register with this + * Sets/restores the maximum number of IP addresses that each MTD child may register with this * device as parent. * * @param[in] aMaxIpAddresses The maximum number of IP addresses that each MTD child may register with this @@ -544,7 +546,7 @@ class MleRouter : public Mle Error SetMaxChildIpAddresses(uint8_t aMaxIpAddresses); /** - * This method sets whether the device was commissioned using CCM. + * Sets whether the device was commissioned using CCM. * * @param[in] aEnabled TRUE if the device was commissioned using CCM, FALSE otherwise. * @@ -552,7 +554,7 @@ class MleRouter : public Mle void SetCcmEnabled(bool aEnabled) { mCcmEnabled = aEnabled; } /** - * This function sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled. + * Sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled. * * @param[in] aEnabled TRUE to enable Security Policy TLV version-threshold for routing, FALSE otherwise. * @@ -564,6 +566,7 @@ class MleRouter : public Mle static constexpr uint16_t kDiscoveryMaxJitter = 250; // Max jitter delay Discovery Responses (in msec). static constexpr uint16_t kChallengeTimeout = 2; // Challenge timeout (in sec). static constexpr uint16_t kUnsolicitedDataResponseJitter = 500; // Max delay for unsol Data Response (in msec). + static constexpr uint8_t kDefaultLeaderWeight = 64; // Threshold to accept a router upgrade request with reason // `kBorderRouterRequest` (number of BRs acting as router in @@ -656,7 +659,9 @@ class MleRouter : public Mle TrickleTimer mAdvertiseTrickleTimer; +#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) DeviceProperties mDeviceProperties; +#endif ChildTable mChildTable; RouterTable mRouterTable; diff --git a/src/core/thread/mle_tlvs.hpp b/src/core/thread/mle_tlvs.hpp index 7449965b9ac..4676227174e 100644 --- a/src/core/thread/mle_tlvs.hpp +++ b/src/core/thread/mle_tlvs.hpp @@ -63,7 +63,7 @@ using ot::Encoding::BigEndian::HostSwap32; */ /** - * This class implements MLE TLV generation and parsing. + * Implements MLE TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -125,7 +125,7 @@ class Tlv : public ot::Tlv }; /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -133,7 +133,7 @@ class Tlv : public ot::Tlv Type GetType(void) const { return static_cast(ot::Tlv::GetType()); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -143,109 +143,109 @@ class Tlv : public ot::Tlv } OT_TOOL_PACKED_END; /** - * This class defines Source Address TLV constants and types. + * Defines Source Address TLV constants and types. * */ typedef UintTlvInfo SourceAddressTlv; /** - * This class defines Mode TLV constants and types. + * Defines Mode TLV constants and types. * */ typedef UintTlvInfo ModeTlv; /** - * This class defines Timeout TLV constants and types. + * Defines Timeout TLV constants and types. * */ typedef UintTlvInfo TimeoutTlv; /** - * This class defines Challenge TLV constants and types. + * Defines Challenge TLV constants and types. * */ typedef TlvInfo ChallengeTlv; /** - * This class defines Response TLV constants and types. + * Defines Response TLV constants and types. * */ typedef TlvInfo ResponseTlv; /** - * This class defines Link Frame Counter TLV constants and types. + * Defines Link Frame Counter TLV constants and types. * */ typedef UintTlvInfo LinkFrameCounterTlv; /** - * This class defines MLE Frame Counter TLV constants and types. + * Defines MLE Frame Counter TLV constants and types. * */ typedef UintTlvInfo MleFrameCounterTlv; /** - * This class defines Address16 TLV constants and types. + * Defines Address16 TLV constants and types. * */ typedef UintTlvInfo Address16Tlv; /** - * This class defines Network Data TLV constants and types. + * Defines Network Data TLV constants and types. * */ typedef TlvInfo NetworkDataTlv; /** - * This class defines TLV Request TLV constants and types. + * Defines TLV Request TLV constants and types. * */ typedef TlvInfo TlvRequestTlv; /** - * This class defines Link Margin TLV constants and types. + * Defines Link Margin TLV constants and types. * */ typedef UintTlvInfo LinkMarginTlv; /** - * This class defines Version TLV constants and types. + * Defines Version TLV constants and types. * */ typedef UintTlvInfo VersionTlv; /** - * This class defines PAN ID TLV constants and types. + * Defines PAN ID TLV constants and types. * */ typedef UintTlvInfo PanIdTlv; /** - * This class defines Active Timestamp TLV constants and types. + * Defines Active Timestamp TLV constants and types. * */ typedef SimpleTlvInfo ActiveTimestampTlv; /** - * This class defines Pending Timestamp TLV constants and types. + * Defines Pending Timestamp TLV constants and types. * */ typedef SimpleTlvInfo PendingTimestampTlv; /** - * This class defines Timeout TLV constants and types. + * Defines Timeout TLV constants and types. * */ typedef UintTlvInfo SupervisionIntervalTlv; /** - * This class defines CSL Timeout TLV constants and types. + * Defines CSL Timeout TLV constants and types. * */ typedef UintTlvInfo CslTimeoutTlv; /** - * This class defines XTAL Accuracy TLV constants and types. + * Defines XTAL Accuracy TLV constants and types. * */ typedef UintTlvInfo XtalAccuracyTlv; @@ -253,7 +253,7 @@ typedef UintTlvInfo XtalAccuracyTlv; #if !OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE /** - * This class implements Route TLV generation and parsing. + * Implements Route TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -261,13 +261,13 @@ class RouteTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void); /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -276,7 +276,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsValid(void) const; /** - * This method returns the Router ID Sequence value. + * Returns the Router ID Sequence value. * * @returns The Router ID Sequence value. * @@ -284,7 +284,7 @@ class RouteTlv : public Tlv, public TlvInfo uint8_t GetRouterIdSequence(void) const { return mRouterIdSequence; } /** - * This method sets the Router ID Sequence value. + * Sets the Router ID Sequence value. * * @param[in] aSequence The Router ID Sequence value. * @@ -292,13 +292,13 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouterIdSequence(uint8_t aSequence) { mRouterIdSequence = aSequence; } /** - * This method gets the Router ID Mask. + * Gets the Router ID Mask. * */ const RouterIdSet &GetRouterIdMask(void) const { return mRouterIdMask; } /** - * This method sets the Router ID Mask. + * Sets the Router ID Mask. * * @param[in] aRouterIdSet The Router ID Mask to set. * @@ -306,7 +306,7 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouterIdMask(const RouterIdSet &aRouterIdSet) { mRouterIdMask = aRouterIdSet; } /** - * This method indicates whether or not a Router ID bit is set. + * Indicates whether or not a Router ID bit is set. * * @param[in] aRouterId The Router ID bit. * @@ -317,7 +317,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsRouterIdSet(uint8_t aRouterId) const { return mRouterIdMask.Contains(aRouterId); } /** - * This method indicates whether the `RouteTlv` is a singleton, i.e., only one router is allocated. + * Indicates whether the `RouteTlv` is a singleton, i.e., only one router is allocated. * * @retval TRUE It is a singleton. * @retval FALSE It is not a singleton. @@ -326,7 +326,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsSingleton(void) const { return IsValid() && (mRouterIdMask.GetNumberOfAllocatedIds() <= 1); } /** - * This method returns the Route Data Length value. + * Returns the Route Data Length value. * * @returns The Route Data Length value. * @@ -334,7 +334,7 @@ class RouteTlv : public Tlv, public TlvInfo uint8_t GetRouteDataLength(void) const { return GetLength() - sizeof(mRouterIdSequence) - sizeof(mRouterIdMask); } /** - * This method sets the Route Data Length value. + * Sets the Route Data Length value. * * @param[in] aLength The Route Data Length value. * @@ -342,7 +342,7 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouteDataLength(uint8_t aLength) { SetLength(sizeof(mRouterIdSequence) + sizeof(mRouterIdMask) + aLength); } /** - * This method returns the Route Cost value for a given Router index. + * Returns the Route Cost value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -352,7 +352,7 @@ class RouteTlv : public Tlv, public TlvInfo uint8_t GetRouteCost(uint8_t aRouterIndex) const { return mRouteData[aRouterIndex] & kRouteCostMask; } /** - * This method returns the Link Quality In value for a given Router index. + * Returns the Link Quality In value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -365,7 +365,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method returns the Link Quality Out value for a given Router index. + * Returns the Link Quality Out value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -378,7 +378,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method sets the Route Data (Link Quality In/Out and Route Cost) for a given Router index. + * Sets the Route Data (Link Quality In/Out and Route Cost) for a given Router index. * * @param[in] aRouterIndex The Router index. * @param[in] aLinkQualityIn The Link Quality In value. @@ -409,7 +409,7 @@ class RouteTlv : public Tlv, public TlvInfo #else // OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE /** - * This class implements Route TLV generation and parsing. + * Implements Route TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -417,7 +417,7 @@ class RouteTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -427,7 +427,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -436,7 +436,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(mRouterIdSequence) + sizeof(mRouterIdMask); } /** - * This method returns the Router ID Sequence value. + * Returns the Router ID Sequence value. * * @returns The Router ID Sequence value. * @@ -444,7 +444,7 @@ class RouteTlv : public Tlv, public TlvInfo uint8_t GetRouterIdSequence(void) const { return mRouterIdSequence; } /** - * This method sets the Router ID Sequence value. + * Sets the Router ID Sequence value. * * @param[in] aSequence The Router ID Sequence value. * @@ -452,13 +452,13 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouterIdSequence(uint8_t aSequence) { mRouterIdSequence = aSequence; } /** - * This method gets the Router ID Mask. + * Gets the Router ID Mask. * */ const RouterIdSet &GetRouterIdMask(void) const { return mRouterIdMask; } /** - * This method sets the Router ID Mask. + * Sets the Router ID Mask. * * @param[in] aRouterIdSet The Router ID Mask to set. * @@ -466,7 +466,7 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouterIdMask(const RouterIdSet &aRouterIdSet) { mRouterIdMask = aRouterIdSet; } /** - * This method indicates whether or not a Router ID bit is set. + * Indicates whether or not a Router ID bit is set. * * @param[in] aRouterId The Router ID. * @@ -477,7 +477,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsRouterIdSet(uint8_t aRouterId) const { return mRouterIdMask.Contains(aRouterId); } /** - * This method indicates whether the `RouteTlv` is a singleton, i.e., only one router is allocated. + * Indicates whether the `RouteTlv` is a singleton, i.e., only one router is allocated. * * @retval TRUE It is a singleton. * @retval FALSE It is not a singleton. @@ -486,7 +486,7 @@ class RouteTlv : public Tlv, public TlvInfo bool IsSingleton(void) const { return IsValid() && (mRouterIdMask.GetNumberOfAllocatedIds() <= 1); } /** - * This method sets the Router ID bit. + * Sets the Router ID bit. * * @param[in] aRouterId The Router ID bit to set. * @@ -494,7 +494,7 @@ class RouteTlv : public Tlv, public TlvInfo void SetRouterId(uint8_t aRouterId) { mRouterIdMask.Add(aRouterId); } /** - * This method returns the Route Data Length value. + * Returns the Route Data Length value. * * @returns The Route Data Length value in bytes * @@ -502,7 +502,7 @@ class RouteTlv : public Tlv, public TlvInfo uint8_t GetRouteDataLength(void) const { return GetLength() - sizeof(mRouterIdSequence) - sizeof(mRouterIdMask); } /** - * This method sets the Route Data Length value. + * Sets the Route Data Length value. * * @param[in] aLength The Route Data Length value in number of router entries * @@ -513,7 +513,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method returns the Route Cost value for a given Router index. + * Returns the Route Cost value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -537,7 +537,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method returns the Link Quality In value for a given Router index. + * Returns the Link Quality In value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -553,7 +553,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method returns the Link Quality Out value for a given Router index. + * Returns the Link Quality Out value for a given Router index. * * @param[in] aRouterIndex The Router index. * @@ -569,7 +569,7 @@ class RouteTlv : public Tlv, public TlvInfo } /** - * This method sets the Route Data (Link Quality In/Out and Route Cost) for a given Router index. + * Sets the Route Data (Link Quality In/Out and Route Cost) for a given Router index. * * @param[in] aRouterIndex The Router index. * @param[in] aLinkQualityIn The Link Quality In value. @@ -636,7 +636,7 @@ class RouteTlv : public Tlv, public TlvInfo #endif // OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE /** - * This class implements Leader Data TLV generation and parsing. + * Implements Leader Data TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -644,7 +644,7 @@ class LeaderDataTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -654,7 +654,7 @@ class LeaderDataTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -663,7 +663,7 @@ class LeaderDataTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method gets the Leader Data info from TLV. + * Gets the Leader Data info from TLV. * * @param[out] aLeaderData A reference to output Leader Data info. * @@ -678,7 +678,7 @@ class LeaderDataTlv : public Tlv, public TlvInfo } /** - * This method sets the Leader Data. + * Sets the Leader Data. * * @param[in] aLeaderData A Leader Data. * @@ -701,7 +701,7 @@ class LeaderDataTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Scan Mask TLV generation and parsing. + * Implements Scan Mask TLV generation and parsing. * */ class ScanMaskTlv : public UintTlvInfo @@ -711,7 +711,7 @@ class ScanMaskTlv : public UintTlvInfo static constexpr uint8_t kEndDeviceFlag = 1 << 6; ///< Scan Mask End Device Flag. /** - * This method indicates whether or not the Router flag is set. + * Indicates whether or not the Router flag is set. * * @param[in] aMask A scan mask value. * @@ -721,7 +721,7 @@ class ScanMaskTlv : public UintTlvInfo static bool IsRouterFlagSet(uint8_t aMask) { return (aMask & kRouterFlag) != 0; } /** - * This method indicates whether or not the End Device flag is set. + * Indicates whether or not the End Device flag is set. * * @param[in] aMask A scan mask value. * @@ -732,7 +732,7 @@ class ScanMaskTlv : public UintTlvInfo }; /** - * This class implements Connectivity TLV generation and parsing. + * Implements Connectivity TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -740,7 +740,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -750,7 +750,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -763,7 +763,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the sed buffer size and datagram count are included. + * Indicates whether or not the sed buffer size and datagram count are included. * * @retval TRUE If the sed buffer size and datagram count are included. * @retval FALSE If the sed buffer size and datagram count are not included. @@ -772,7 +772,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo bool IsSedBufferingIncluded(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Parent Priority value. + * Returns the Parent Priority value. * * @returns The Parent Priority value. * @@ -780,7 +780,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo int8_t GetParentPriority(void) const; /** - * This method sets the Parent Priority value. + * Sets the Parent Priority value. * * @param[in] aParentPriority The Parent Priority value. * @@ -788,7 +788,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetParentPriority(int8_t aParentPriority); /** - * This method returns the Link Quality 3 value. + * Returns the Link Quality 3 value. * * @returns The Link Quality 3 value. * @@ -796,7 +796,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetLinkQuality3(void) const { return mLinkQuality3; } /** - * This method sets the Link Quality 3 value. + * Sets the Link Quality 3 value. * * @param[in] aLinkQuality The Link Quality 3 value. * @@ -804,7 +804,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetLinkQuality3(uint8_t aLinkQuality) { mLinkQuality3 = aLinkQuality; } /** - * This method returns the Link Quality 2 value. + * Returns the Link Quality 2 value. * * @returns The Link Quality 2 value. * @@ -812,7 +812,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetLinkQuality2(void) const { return mLinkQuality2; } /** - * This method sets the Link Quality 2 value. + * Sets the Link Quality 2 value. * * @param[in] aLinkQuality The Link Quality 2 value. * @@ -820,7 +820,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetLinkQuality2(uint8_t aLinkQuality) { mLinkQuality2 = aLinkQuality; } /** - * This method sets the Link Quality 1 value. + * Sets the Link Quality 1 value. * * @returns The Link Quality 1 value. * @@ -828,7 +828,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetLinkQuality1(void) const { return mLinkQuality1; } /** - * This method sets the Link Quality 1 value. + * Sets the Link Quality 1 value. * * @param[in] aLinkQuality The Link Quality 1 value. * @@ -836,7 +836,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetLinkQuality1(uint8_t aLinkQuality) { mLinkQuality1 = aLinkQuality; } /** - * This method increments the Link Quality N field in TLV for a given Link Quality N (1,2,3). + * Increments the Link Quality N field in TLV for a given Link Quality N (1,2,3). * * The Link Quality N field specifies the number of neighboring router devices with which the sender shares a link * of quality N. @@ -847,7 +847,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void IncrementLinkQuality(LinkQuality aLinkQuality); /** - * This method sets the Active Routers value. + * Sets the Active Routers value. * * @returns The Active Routers value. * @@ -855,7 +855,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetActiveRouters(void) const { return mActiveRouters; } /** - * This method sets the Active Routers value. + * Sets the Active Routers value. * * @param[in] aActiveRouters The Active Routers value. * @@ -863,7 +863,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetActiveRouters(uint8_t aActiveRouters) { mActiveRouters = aActiveRouters; } /** - * This method returns the Leader Cost value. + * Returns the Leader Cost value. * * @returns The Leader Cost value. * @@ -871,7 +871,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetLeaderCost(void) const { return mLeaderCost; } /** - * This method sets the Leader Cost value. + * Sets the Leader Cost value. * * @param[in] aCost The Leader Cost value. * @@ -879,7 +879,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetLeaderCost(uint8_t aCost) { mLeaderCost = aCost; } /** - * This method returns the ID Sequence value. + * Returns the ID Sequence value. * * @returns The ID Sequence value. * @@ -887,7 +887,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo uint8_t GetIdSequence(void) const { return mIdSequence; } /** - * This method sets the ID Sequence value. + * Sets the ID Sequence value. * * @param[in] aSequence The ID Sequence value. * @@ -895,7 +895,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetIdSequence(uint8_t aSequence) { mIdSequence = aSequence; } /** - * This method returns the SED Buffer Size value. + * Returns the SED Buffer Size value. * * @returns The SED Buffer Size value. * @@ -912,7 +912,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo } /** - * This method sets the SED Buffer Size value. + * Sets the SED Buffer Size value. * * @param[in] aSedBufferSize The SED Buffer Size value. * @@ -920,7 +920,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo void SetSedBufferSize(uint16_t aSedBufferSize) { mSedBufferSize = HostSwap16(aSedBufferSize); } /** - * This method returns the SED Datagram Count value. + * Returns the SED Datagram Count value. * * @returns The SED Datagram Count value. * @@ -937,7 +937,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo } /** - * This method sets the SED Datagram Count value. + * Sets the SED Datagram Count value. * * @param[in] aSedDatagramCount The SED Datagram Count value. * @@ -960,7 +960,7 @@ class ConnectivityTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class specifies Status TLV status values. + * Specifies Status TLV status values. * */ struct StatusTlv : public UintTlvInfo @@ -975,7 +975,7 @@ struct StatusTlv : public UintTlvInfo }; /** - * This class provides constants and methods for generation and parsing of Address Registration TLV. + * Provides constants and methods for generation and parsing of Address Registration TLV. * */ class AddressRegistrationTlv : public TlvInfo @@ -989,7 +989,7 @@ class AddressRegistrationTlv : public TlvInfo static constexpr uint8_t kControlByteUncompressed = 0; /** - * This static method returns the control byte to use in a compressed entry where the 64-prefix is replaced with a + * Returns the control byte to use in a compressed entry where the 64-prefix is replaced with a * 6LoWPAN context identifier. * * @param[in] aContextId The 6LoWPAN context ID. @@ -1000,7 +1000,7 @@ class AddressRegistrationTlv : public TlvInfo static uint8_t ControlByteFor(uint8_t aContextId) { return kCompressed | (aContextId & kContextIdMask); } /** - * This static method indicates whether or not an address entry is using compressed format. + * Indicates whether or not an address entry is using compressed format. * * @param[in] aControlByte The control byte (the first byte in the entry). * @@ -1011,7 +1011,7 @@ class AddressRegistrationTlv : public TlvInfo static bool IsEntryCompressed(uint8_t aControlByte) { return (aControlByte & kCompressed); } /** - * This static method gets the context ID in a compressed entry. + * Gets the context ID in a compressed entry. * * @param[in] aControlByte The control byte (the first byte in the entry). * @@ -1028,7 +1028,7 @@ class AddressRegistrationTlv : public TlvInfo }; /** - * This class implements Channel TLV generation and parsing. + * Implements Channel TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1036,7 +1036,7 @@ class ChannelTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1046,7 +1046,7 @@ class ChannelTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1055,7 +1055,7 @@ class ChannelTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Channel Page value. + * Returns the Channel Page value. * * @returns The Channel Page value. * @@ -1063,7 +1063,7 @@ class ChannelTlv : public Tlv, public TlvInfo uint8_t GetChannelPage(void) const { return mChannelPage; } /** - * This method sets the Channel Page value. + * Sets the Channel Page value. * * @param[in] aChannelPage The Channel Page value. * @@ -1071,7 +1071,7 @@ class ChannelTlv : public Tlv, public TlvInfo void SetChannelPage(uint8_t aChannelPage) { mChannelPage = aChannelPage; } /** - * This method returns the Channel value. + * Returns the Channel value. * * @returns The Channel value. * @@ -1079,7 +1079,7 @@ class ChannelTlv : public Tlv, public TlvInfo uint16_t GetChannel(void) const { return HostSwap16(mChannel); } /** - * This method sets the Channel value. + * Sets the Channel value. * * @param[in] aChannel The Channel value. * @@ -1093,13 +1093,13 @@ class ChannelTlv : public Tlv, public TlvInfo #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This class defines Time Request TLV constants and types. + * Defines Time Request TLV constants and types. * */ typedef TlvInfo TimeRequestTlv; /** - * This class implements Time Parameter TLV generation and parsing. + * Implements Time Parameter TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1107,7 +1107,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1117,7 +1117,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1126,7 +1126,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the time sync period. + * Returns the time sync period. * * @returns The time sync period. * @@ -1134,7 +1134,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo uint16_t GetTimeSyncPeriod(void) const { return HostSwap16(mTimeSyncPeriod); } /** - * This method sets the time sync period. + * Sets the time sync period. * * @param[in] aTimeSyncPeriod The time sync period. * @@ -1142,7 +1142,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo void SetTimeSyncPeriod(uint16_t aTimeSyncPeriod) { mTimeSyncPeriod = HostSwap16(aTimeSyncPeriod); } /** - * This method returns the XTAL accuracy threshold. + * Returns the XTAL accuracy threshold. * * @returns The XTAL accuracy threshold. * @@ -1150,7 +1150,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo uint16_t GetXtalThreshold(void) const { return HostSwap16(mXtalThreshold); } /** - * This method sets the XTAL accuracy threshold. + * Sets the XTAL accuracy threshold. * * @param[in] aXTALThreshold The XTAL accuracy threshold. * @@ -1166,7 +1166,7 @@ class TimeParameterTlv : public Tlv, public TlvInfo #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE) /** - * This class implements CSL Channel TLV generation and parsing. + * Implements CSL Channel TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1174,7 +1174,7 @@ class CslChannelTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1184,7 +1184,7 @@ class CslChannelTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1193,7 +1193,7 @@ class CslChannelTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the Channel Page value. + * Returns the Channel Page value. * * @returns The Channel Page value. * @@ -1201,7 +1201,7 @@ class CslChannelTlv : public Tlv, public TlvInfo uint8_t GetChannelPage(void) const { return mChannelPage; } /** - * This method sets the Channel Page value. + * Sets the Channel Page value. * * @param[in] aChannelPage The Channel Page value. * @@ -1209,7 +1209,7 @@ class CslChannelTlv : public Tlv, public TlvInfo void SetChannelPage(uint8_t aChannelPage) { mChannelPage = aChannelPage; } /** - * This method returns the Channel value. + * Returns the Channel value. * * @returns The Channel value. * @@ -1217,7 +1217,7 @@ class CslChannelTlv : public Tlv, public TlvInfo uint16_t GetChannel(void) const { return HostSwap16(mChannel); } /** - * This method sets the Channel value. + * Sets the Channel value. * * @param[in] aChannel The Channel value. * @@ -1233,7 +1233,7 @@ class CslChannelTlv : public Tlv, public TlvInfo #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE /** - * This class implements CSL Clock Accuracy TLV generation and parsing. + * Implements CSL Clock Accuracy TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1241,7 +1241,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1251,7 +1251,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1260,7 +1260,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the CSL Clock Accuracy value. + * Returns the CSL Clock Accuracy value. * * @returns The CSL Clock Accuracy value. * @@ -1268,7 +1268,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo uint8_t GetCslClockAccuracy(void) const { return mCslClockAccuracy; } /** - * This method sets the CSL Clock Accuracy value. + * Sets the CSL Clock Accuracy value. * * @param[in] aCslClockAccuracy The CSL Clock Accuracy value. * @@ -1276,7 +1276,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo void SetCslClockAccuracy(uint8_t aCslClockAccuracy) { mCslClockAccuracy = aCslClockAccuracy; } /** - * This method returns the Clock Uncertainty value. + * Returns the Clock Uncertainty value. * * @returns The Clock Uncertainty value. * @@ -1284,7 +1284,7 @@ class CslClockAccuracyTlv : public Tlv, public TlvInfo uint8_t GetCslUncertainty(void) const { return mCslUncertainty; } /** - * This method sets the CSL Uncertainty value. + * Sets the CSL Uncertainty value. * * @param[in] aCslUncertainty The CSL Uncertainty value. * diff --git a/src/core/thread/mle_types.cpp b/src/core/thread/mle_types.cpp index ca76165cff5..f762b1a3519 100644 --- a/src/core/thread/mle_types.cpp +++ b/src/core/thread/mle_types.cpp @@ -70,7 +70,7 @@ DeviceMode::InfoString DeviceMode::ToString(void) const //--------------------------------------------------------------------------------------------------------------------- // DeviceProperties -#if OPENTHREAD_FTD +#if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) DeviceProperties::DeviceProperties(void) { @@ -133,7 +133,7 @@ uint8_t DeviceProperties::CalculateLeaderWeight(void) const return weight; } -#endif // OPENTHREAD_FTD +#endif // #if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) //--------------------------------------------------------------------------------------------------------------------- // RouterIdSet diff --git a/src/core/thread/mle_types.hpp b/src/core/thread/mle_types.hpp index 286e63ae667..4ed90cadf5c 100644 --- a/src/core/thread/mle_types.hpp +++ b/src/core/thread/mle_types.hpp @@ -93,7 +93,7 @@ constexpr uint32_t kChildIdResponseTimeout = 1250; ///< Wait time to rec constexpr uint32_t kAttachStartJitter = 50; ///< Max jitter time added to start of attach (in msec) constexpr uint32_t kAnnounceProcessTimeout = 250; ///< Delay after Announce rx before channel/pan-id change constexpr uint32_t kAnnounceTimeout = 1400; ///< Total timeout for sending Announce messages (in msec) -constexpr uint32_t kMinAnnounceDelay = 80; ///< Min delay between Announcement messages (in msec) +constexpr uint16_t kMinAnnounceDelay = 80; ///< Min delay between Announcement messages (in msec) constexpr uint32_t kParentResponseMaxDelayRouters = 500; ///< Max response delay for Parent Req to routers (in msec) constexpr uint32_t kParentResponseMaxDelayAll = 1000; ///< Max response delay for Parent Req to all (in msec) constexpr uint32_t kUnicastRetransmissionDelay = 1000; ///< Base delay before an MLE unicast retx (in msec) @@ -193,7 +193,7 @@ constexpr int8_t kParentPriorityLow = -1; ///< Parent Priority Low constexpr int8_t kParentPriorityUnspecified = -2; ///< Parent Priority Unspecified /** - * This type represents a Thread device role. + * Represents a Thread device role. * */ enum DeviceRole : uint8_t @@ -221,7 +221,7 @@ constexpr uint8_t kServiceMinId = 0x00; ///< Minimal Service ID. constexpr uint8_t kServiceMaxId = 0x0f; ///< Maximal Service ID. /** - * This enumeration specifies the leader role start mode. + * Specifies the leader role start mode. * * The start mode indicates whether device is starting normally as leader or restoring its role after reset. * @@ -232,68 +232,8 @@ enum LeaderStartMode : uint8_t kRestoringLeaderRoleAfterReset, ///< Restoring leader role after reset. }; -#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 - -/* - * Backbone Router / DUA / MLR constants - * - */ -constexpr uint16_t kRegistrationDelayDefault = 5; ///< In seconds. -constexpr uint32_t kMlrTimeoutDefault = 3600; ///< In seconds. -constexpr uint32_t kMlrTimeoutMin = 300; ///< In seconds. -constexpr uint32_t kMlrTimeoutMax = 0x7fffffff / 1000; ///< In seconds (about 24 days). -constexpr uint8_t kBackboneRouterRegistrationJitter = 5; ///< In seconds. -constexpr uint8_t kParentAggregateDelay = 5; ///< In seconds. -constexpr uint8_t kNoBufDelay = 5; ///< In seconds. -constexpr uint8_t kImmediateReRegisterDelay = 1; ///< In seconds. -constexpr uint8_t KResponseTimeoutDelay = 30; ///< In seconds. - /** - * Time period after which the address becomes "Preferred" if no duplicate address error (in seconds). - * - */ -constexpr uint32_t kDuaDadPeriod = 100; - -/** - * Maximum number of times the multicast DAD query and wait time DUA_DAD_QUERY_TIMEOUT are repeated by the BBR, as - * part of the DAD process. - * - */ -constexpr uint8_t kDuaDadRepeats = 3; - -/** - * Time period (in seconds) during which a DUA registration is considered 'recent' at a BBR. - * - */ -constexpr uint32_t kDuaRecentTime = 20; -constexpr uint32_t kTimeSinceLastTransactionMax = 10 * 86400; ///< In seconds (10 days). -constexpr uint8_t kDefaultBackboneHoplimit = 1; ///< default hoplimit for Backbone Link Protocol messages - -static_assert(kMlrTimeoutDefault >= kMlrTimeoutMin && kMlrTimeoutDefault <= kMlrTimeoutMax, - "kMlrTimeoutDefault must be larger than or equal to kMlrTimeoutMin"); - -static_assert(Mle::kParentAggregateDelay > 1, "kParentAggregateDelay should be larger than 1 second"); -static_assert(kMlrTimeoutMax * 1000 > kMlrTimeoutMax, "SecToMsec(kMlrTimeoutMax) will overflow"); - -static_assert(kTimeSinceLastTransactionMax * 1000 > kTimeSinceLastTransactionMax, - "SecToMsec(kTimeSinceLastTransactionMax) will overflow"); - -/** - * State change of Child's DUA - * - */ -enum class ChildDuaState : uint8_t -{ - kAdded, ///< A new DUA registered by the Child via Address Registration. - kChanged, ///< A different DUA registered by the Child via Address Registration. - kRemoved, ///< DUA registered by the Child is removed and not in Address Registration. - kUnchanged, ///< The Child registers the same DUA again. -}; - -#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 - -/** - * This type represents a MLE device mode. + * Represents a MLE device mode. * */ class DeviceMode : public Equatable @@ -307,7 +247,7 @@ class DeviceMode : public Equatable static constexpr uint16_t kInfoStringSize = 45; ///< String buffer size used for `ToString()`. /** - * This type defines the fixed-length `String` object returned from `ToString()`. + * Defines the fixed-length `String` object returned from `ToString()`. * */ typedef String InfoString; @@ -325,7 +265,7 @@ class DeviceMode : public Equatable DeviceMode(void) = default; /** - * This constructor initializes a `DeviceMode` object from a given mode TLV bitmask. + * Initializes a `DeviceMode` object from a given mode TLV bitmask. * * @param[in] aMode A mode TLV bitmask to initialize the `DeviceMode` object. * @@ -333,7 +273,7 @@ class DeviceMode : public Equatable explicit DeviceMode(uint8_t aMode) { Set(aMode); } /** - * This constructor initializes a `DeviceMode` object from a given mode configuration structure. + * Initializes a `DeviceMode` object from a given mode configuration structure. * * @param[in] aModeConfig A mode configuration to initialize the `DeviceMode` object. * @@ -341,7 +281,7 @@ class DeviceMode : public Equatable explicit DeviceMode(ModeConfig aModeConfig) { Set(aModeConfig); } /** - * This method gets the device mode as a mode TLV bitmask. + * Gets the device mode as a mode TLV bitmask. * * @returns The device mode as a mode TLV bitmask. * @@ -349,7 +289,7 @@ class DeviceMode : public Equatable uint8_t Get(void) const { return mMode; } /** - * This method sets the device mode from a given mode TLV bitmask. + * Sets the device mode from a given mode TLV bitmask. * * @param[in] aMode A mode TLV bitmask. * @@ -357,7 +297,7 @@ class DeviceMode : public Equatable void Set(uint8_t aMode) { mMode = aMode | kModeReserved; } /** - * This method gets the device mode as a mode configuration structure. + * Gets the device mode as a mode configuration structure. * * @param[out] aModeConfig A reference to a mode configuration structure to output the device mode. * @@ -373,7 +313,7 @@ class DeviceMode : public Equatable void Set(const ModeConfig &aModeConfig); /** - * This method indicates whether or not the device is rx-on-when-idle. + * Indicates whether or not the device is rx-on-when-idle. * * @retval TRUE If the device is rx-on-when-idle (non-sleepy). * @retval FALSE If the device is not rx-on-when-idle (sleepy). @@ -382,7 +322,7 @@ class DeviceMode : public Equatable bool IsRxOnWhenIdle(void) const { return (mMode & kModeRxOnWhenIdle) != 0; } /** - * This method indicates whether or not the device is a Full Thread Device. + * Indicates whether or not the device is a Full Thread Device. * * @retval TRUE If the device is Full Thread Device. * @retval FALSE If the device if not Full Thread Device. @@ -391,7 +331,7 @@ class DeviceMode : public Equatable bool IsFullThreadDevice(void) const { return (mMode & kModeFullThreadDevice) != 0; } /** - * This method gets the Network Data type (full set or stable subset) that the device requests. + * Gets the Network Data type (full set or stable subset) that the device requests. * * @returns The Network Data type requested by this device. * @@ -402,7 +342,7 @@ class DeviceMode : public Equatable } /** - * This method indicates whether or not the device is a Minimal End Device. + * Indicates whether or not the device is a Minimal End Device. * * @retval TRUE If the device is a Minimal End Device. * @retval FALSE If the device is not a Minimal End Device. @@ -414,7 +354,7 @@ class DeviceMode : public Equatable } /** - * This method indicates whether or not the device mode flags are valid. + * Indicates whether or not the device mode flags are valid. * * An FTD which is not rx-on-when-idle (is sleepy) is considered invalid. * @@ -426,7 +366,7 @@ class DeviceMode : public Equatable bool IsValid(void) const { return !IsFullThreadDevice() || IsRxOnWhenIdle(); } /** - * This method converts the device mode into a human-readable string. + * Converts the device mode into a human-readable string. * * @returns An `InfoString` object representing the device mode. * @@ -437,9 +377,9 @@ class DeviceMode : public Equatable uint8_t mMode; }; -#if OPENTHREAD_FTD +#if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) /** - * This class represents device properties. + * Represents device properties. * * The device properties are used for calculating the local leader weight on the device. * @@ -448,7 +388,7 @@ class DeviceProperties : public otDeviceProperties, public Clearable= OT_THREAD_VERSION_1_3_1) /** - * This class represents the Thread Leader Data. + * Represents the Thread Leader Data. * */ class LeaderData : public otLeaderData, public Clearable { public: /** - * This method returns the Partition ID value. + * Returns the Partition ID value. * * @returns The Partition ID value. * @@ -514,7 +454,7 @@ class LeaderData : public otLeaderData, public Clearable uint32_t GetPartitionId(void) const { return mPartitionId; } /** - * This method sets the Partition ID value. + * Sets the Partition ID value. * * @param[in] aPartitionId The Partition ID value. * @@ -522,7 +462,7 @@ class LeaderData : public otLeaderData, public Clearable void SetPartitionId(uint32_t aPartitionId) { mPartitionId = aPartitionId; } /** - * This method returns the Weighting value. + * Returns the Weighting value. * * @returns The Weighting value. * @@ -530,7 +470,7 @@ class LeaderData : public otLeaderData, public Clearable uint8_t GetWeighting(void) const { return mWeighting; } /** - * This method sets the Weighting value. + * Sets the Weighting value. * * @param[in] aWeighting The Weighting value. * @@ -538,7 +478,7 @@ class LeaderData : public otLeaderData, public Clearable void SetWeighting(uint8_t aWeighting) { mWeighting = aWeighting; } /** - * This method returns the Data Version value for a type (full set or stable subset). + * Returns the Data Version value for a type (full set or stable subset). * * @param[in] aType The Network Data type (full set or stable subset). * @@ -551,7 +491,7 @@ class LeaderData : public otLeaderData, public Clearable } /** - * This method sets the Data Version value. + * Sets the Data Version value. * * @param[in] aVersion The Data Version value. * @@ -559,7 +499,7 @@ class LeaderData : public otLeaderData, public Clearable void SetDataVersion(uint8_t aVersion) { mDataVersion = aVersion; } /** - * This method sets the Stable Data Version value. + * Sets the Stable Data Version value. * * @param[in] aVersion The Stable Data Version value. * @@ -567,7 +507,7 @@ class LeaderData : public otLeaderData, public Clearable void SetStableDataVersion(uint8_t aVersion) { mStableDataVersion = aVersion; } /** - * This method returns the Leader Router ID value. + * Returns the Leader Router ID value. * * @returns The Leader Router ID value. * @@ -575,7 +515,7 @@ class LeaderData : public otLeaderData, public Clearable uint8_t GetLeaderRouterId(void) const { return mLeaderRouterId; } /** - * This method sets the Leader Router ID value. + * Sets the Leader Router ID value. * * @param[in] aRouterId The Leader Router ID value. * @@ -588,13 +528,13 @@ class RouterIdSet : public Equatable { public: /** - * This method clears the Router Id Set. + * Clears the Router Id Set. * */ void Clear(void) { memset(mRouterIdSet, 0, sizeof(mRouterIdSet)); } /** - * This method indicates whether or not a Router ID bit is set. + * Indicates whether or not a Router ID bit is set. * * @param[in] aRouterId The Router ID. * @@ -605,7 +545,7 @@ class RouterIdSet : public Equatable bool Contains(uint8_t aRouterId) const { return (mRouterIdSet[aRouterId / 8] & MaskFor(aRouterId)) != 0; } /** - * This method sets a given Router ID. + * Sets a given Router ID. * * @param[in] aRouterId The Router ID to set. * @@ -613,7 +553,7 @@ class RouterIdSet : public Equatable void Add(uint8_t aRouterId) { mRouterIdSet[aRouterId / 8] |= MaskFor(aRouterId); } /** - * This method removes a given Router ID. + * Removes a given Router ID. * * @param[in] aRouterId The Router ID to remove. * @@ -621,7 +561,7 @@ class RouterIdSet : public Equatable void Remove(uint8_t aRouterId) { mRouterIdSet[aRouterId / 8] &= ~MaskFor(aRouterId); } /** - * This method calculates the number of allocated Router IDs in the set. + * Calculates the number of allocated Router IDs in the set. * * @returns The number of allocated Router IDs in the set. * @@ -635,25 +575,25 @@ class RouterIdSet : public Equatable } OT_TOOL_PACKED_END; /** - * This class represents a MLE Key Material + * Represents a MLE Key Material * */ typedef Mac::KeyMaterial KeyMaterial; /** - * This class represents a MLE Key. + * Represents a MLE Key. * */ typedef Mac::Key Key; /** - * This structure represents the Thread MLE counters. + * Represents the Thread MLE counters. * */ typedef otMleCounters Counters; /** - * This function derives the Child ID from a given RLOC16. + * Derives the Child ID from a given RLOC16. * * @param[in] aRloc16 The RLOC16 value. * @@ -663,7 +603,7 @@ typedef otMleCounters Counters; inline uint16_t ChildIdFromRloc16(uint16_t aRloc16) { return aRloc16 & kMaxChildId; } /** - * This function derives the Router ID portion from a given RLOC16. + * Derives the Router ID portion from a given RLOC16. * * @param[in] aRloc16 The RLOC16 value. * @@ -673,7 +613,7 @@ inline uint16_t ChildIdFromRloc16(uint16_t aRloc16) { return aRloc16 & kMaxChild inline uint8_t RouterIdFromRloc16(uint16_t aRloc16) { return aRloc16 >> kRouterIdOffset; } /** - * This function returns whether the two RLOC16 have the same Router ID. + * Returns whether the two RLOC16 have the same Router ID. * * @param[in] aRloc16A The first RLOC16 value. * @param[in] aRloc16B The second RLOC16 value. @@ -687,7 +627,7 @@ inline bool RouterIdMatch(uint16_t aRloc16A, uint16_t aRloc16B) } /** - * This function returns the Service ID corresponding to a Service ALOC16. + * Returns the Service ID corresponding to a Service ALOC16. * * @param[in] aAloc16 The Service ALOC16 value. * @@ -697,7 +637,7 @@ inline bool RouterIdMatch(uint16_t aRloc16A, uint16_t aRloc16B) inline uint8_t ServiceIdFromAloc(uint16_t aAloc16) { return static_cast(aAloc16 - kAloc16ServiceStart); } /** - * This function returns the Service ALOC16 corresponding to a Service ID. + * Returns the Service ALOC16 corresponding to a Service ID. * * @param[in] aServiceId The Service ID value. * @@ -710,7 +650,7 @@ inline uint16_t ServiceAlocFromId(uint8_t aServiceId) } /** - * This function returns the Commissioner Aloc corresponding to a Commissioner Session ID. + * Returns the Commissioner Aloc corresponding to a Commissioner Session ID. * * @param[in] aSessionId The Commissioner Session ID value. * @@ -723,7 +663,7 @@ inline uint16_t CommissionerAloc16FromId(uint16_t aSessionId) } /** - * This function derives RLOC16 from a given Router ID. + * Derives RLOC16 from a given Router ID. * * @param[in] aRouterId The Router ID value. * @@ -733,7 +673,7 @@ inline uint16_t CommissionerAloc16FromId(uint16_t aSessionId) inline uint16_t Rloc16FromRouterId(uint8_t aRouterId) { return static_cast(aRouterId << kRouterIdOffset); } /** - * This function indicates whether or not @p aRloc16 refers to an active router. + * Indicates whether or not @p aRloc16 refers to an active router. * * @param[in] aRloc16 The RLOC16 value. * @@ -744,7 +684,7 @@ inline uint16_t Rloc16FromRouterId(uint8_t aRouterId) { return static_cast= OT_THREAD_VERSION_1_3_1) DefineCoreType(otDeviceProperties, Mle::DeviceProperties); DefineMapEnum(otPowerSupply, Mle::DeviceProperties::PowerSupply); #endif diff --git a/src/core/thread/mlr_manager.cpp b/src/core/thread/mlr_manager.cpp index d8e8a037837..3d988a73ec1 100644 --- a/src/core/thread/mlr_manager.cpp +++ b/src/core/thread/mlr_manager.cpp @@ -146,26 +146,14 @@ bool MlrManager::IsAddressMlrRegisteredByAnyChildExcept(const Ip6::Address &aAdd return ret; } -void MlrManager::UpdateProxiedSubscriptions(Child &aChild, - const Ip6::Address *aOldMlrRegisteredAddresses, - uint16_t aOldMlrRegisteredAddressNum) +void MlrManager::UpdateProxiedSubscriptions(Child &aChild, const MlrAddressArray &aOldMlrRegisteredAddresses) { VerifyOrExit(aChild.IsStateValid()); // Search the new multicast addresses and set its flag accordingly for (const Ip6::Address &address : aChild.IterateIp6Addresses(Ip6::Address::kTypeMulticastLargerThanRealmLocal)) { - bool isMlrRegistered = false; - - // Check if it's a new multicast address against old addresses - for (size_t i = 0; i < aOldMlrRegisteredAddressNum; i++) - { - if (aOldMlrRegisteredAddresses[i] == address) - { - isMlrRegistered = true; - break; - } - } + bool isMlrRegistered = aOldMlrRegisteredAddresses.Contains(address); #if OPENTHREAD_CONFIG_MLR_ENABLE // Check if it's a new multicast address against parent Netif @@ -183,7 +171,7 @@ void MlrManager::UpdateProxiedSubscriptions(Child &aChild, if (aChild.HasAnyMlrToRegisterAddress()) { - ScheduleSend(Random::NonCrypto::GetUint16InRange(1, Mle::kParentAggregateDelay)); + ScheduleSend(Random::NonCrypto::GetUint16InRange(1, BackboneRouter::kParentAggregateDelay)); } } @@ -648,7 +636,7 @@ void MlrManager::UpdateReregistrationDelay(bool aRereg) { // Calculate renewing period according to Thread Spec. 5.24.2.3.2 // The random time t SHOULD be chosen such that (0.5* MLR-Timeout) < t < (MLR-Timeout – 9 seconds). - effectiveMlrTimeout = Max(config.mMlrTimeout, Mle::kMlrTimeoutMin); + effectiveMlrTimeout = Max(config.mMlrTimeout, BackboneRouter::kMinMlrTimeout); reregDelay = Random::NonCrypto::GetUint32InRange((effectiveMlrTimeout >> 1u) + 1, effectiveMlrTimeout - 9); } diff --git a/src/core/thread/mlr_manager.hpp b/src/core/thread/mlr_manager.hpp index b78e0fba031..65df2afad27 100644 --- a/src/core/thread/mlr_manager.hpp +++ b/src/core/thread/mlr_manager.hpp @@ -71,7 +71,7 @@ namespace ot { */ /** - * This class implements MLR management. + * Implements MLR management. * */ class MlrManager : public InstanceLocator, private NonCopyable @@ -81,7 +81,7 @@ class MlrManager : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -89,7 +89,7 @@ class MlrManager : public InstanceLocator, private NonCopyable explicit MlrManager(Instance &aInstance); /** - * This method notifies Primary Backbone Router status. + * Notifies Primary Backbone Router status. * * @param[in] aState The state or state change of Primary Backbone Router. * @param[in] aConfig The Primary Backbone Router service. @@ -98,22 +98,23 @@ class MlrManager : public InstanceLocator, private NonCopyable void HandleBackboneRouterPrimaryUpdate(BackboneRouter::Leader::State aState, const BackboneRouter::Config &aConfig); #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE + static constexpr uint16_t kMaxMlrAddresses = OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD - 1; ///< Max MLR addresses + + typedef Array MlrAddressArray; ///< Registered MLR addresses array. + /** - * This method updates the Multicast Subscription Table according to the Child information. + * Updates the Multicast Subscription Table according to the Child information. * * @param[in] aChild A reference to the child information. - * @param[in] aOldMlrRegisteredAddresses Pointer to an array of the Child's previously registered IPv6 addresses. - * @param[in] aOldMlrRegisteredAddressNum The number of previously registered IPv6 addresses. + * @param[in] aOldMlrRegisteredAddresses Array of the Child's previously registered IPv6 addresses. * */ - void UpdateProxiedSubscriptions(Child &aChild, - const Ip6::Address *aOldMlrRegisteredAddresses, - uint16_t aOldMlrRegisteredAddressNum); + void UpdateProxiedSubscriptions(Child &aChild, const MlrAddressArray &aOldMlrRegisteredAddresses); #endif #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE /** - * This method registers Multicast Listeners to Primary Backbone Router. + * Registers Multicast Listeners to Primary Backbone Router. * * Note: only available when both `(OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)` and * `OPENTHREAD_CONFIG_COMMISSIONER_ENABLE` are enabled) diff --git a/src/core/thread/neighbor_table.cpp b/src/core/thread/neighbor_table.cpp index 9355473bb79..46ab1c7902c 100644 --- a/src/core/thread/neighbor_table.cpp +++ b/src/core/thread/neighbor_table.cpp @@ -305,8 +305,8 @@ void NeighborTable::Signal(Event aEvent, const Neighbor &aNeighbor) case kChildRemoved: Get().Signal(kEventThreadChildRemoved); #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE - Get().UpdateChildDomainUnicastAddress(static_cast(aNeighbor), - Mle::ChildDuaState::kRemoved); + Get().HandleChildDuaAddressEvent(static_cast(aNeighbor), + DuaManager::kAddressRemoved); #endif break; diff --git a/src/core/thread/neighbor_table.hpp b/src/core/thread/neighbor_table.hpp index d1e31d55790..2600d62aef3 100644 --- a/src/core/thread/neighbor_table.hpp +++ b/src/core/thread/neighbor_table.hpp @@ -43,14 +43,14 @@ namespace ot { /** - * This class represents the Thread neighbor table. + * Represents the Thread neighbor table. * */ class NeighborTable : public InstanceLocator, private NonCopyable { public: /** - * This function pointer is called to notify that a child or router neighbor is being added to or removed from + * Pointer is called to notify that a child or router neighbor is being added to or removed from * neighbor table. * * Note that this callback in invoked while the neighbor/child table is being updated and always before the related @@ -60,14 +60,14 @@ class NeighborTable : public InstanceLocator, private NonCopyable typedef otNeighborTableCallback Callback; /** - * This type represents a neighbor table entry info (child or router) and is used as a parameter in the neighbor + * Represents a neighbor table entry info (child or router) and is used as a parameter in the neighbor * table callback. * */ typedef otNeighborTableEntryInfo EntryInfo; /** - * This enumeration defines the constants used in `NeighborTable::Callback` to indicate whether a child or router + * Defines the constants used in `NeighborTable::Callback` to indicate whether a child or router * neighbor is being added or removed. * */ @@ -81,7 +81,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `NeighborTable` instance. + * Initializes the `NeighborTable` instance. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -89,7 +89,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable explicit NeighborTable(Instance &aInstance); /** - * This method searches among parent and parent candidate to find a `Neighbor` corresponding to a given short + * Searches among parent and parent candidate to find a `Neighbor` corresponding to a given short * address. * * @param[in] aShortAddress A short address. @@ -102,7 +102,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches in parent and parent candidate to find a `Neighbor` corresponding to a given MAC Extended + * Searches in parent and parent candidate to find a `Neighbor` corresponding to a given MAC Extended * Address. * * @param[in] aExtAddress A MAC Extended Address. @@ -115,7 +115,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches among parent and parent candidate to find a `Neighbor` object corresponding to a given MAC + * Searches among parent and parent candidate to find a `Neighbor` object corresponding to a given MAC * address. * * @param[in] aMacAddress A MAC address. @@ -128,7 +128,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches in the neighbor table to find a `Neighbor` corresponding to a given short address. + * Searches in the neighbor table to find a `Neighbor` corresponding to a given short address. * * @param[in] aShortAddress A short address. * @param[in] aFilter A neighbor state filter. @@ -140,7 +140,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches in the neighbor table to find a `Neighbor` corresponding to a given MAC Extended Address. + * Searches in the neighbor table to find a `Neighbor` corresponding to a given MAC Extended Address. * * @param[in] aExtAddress A MAC Extended Address. * @param[in] aFilter A neighbor state filter. @@ -152,7 +152,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches in the neighbor table to find a `Neighbor` object corresponding to a given MAC address. + * Searches in the neighbor table to find a `Neighbor` object corresponding to a given MAC address. * * @param[in] aMacAddress A MAC address. * @param[in] aFilter A neighbor state filter. @@ -166,7 +166,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable #if OPENTHREAD_FTD /** - * This method searches in the neighbor table to find a `Neighbor` object corresponding to a given IPv6 address. + * Searches in the neighbor table to find a `Neighbor` object corresponding to a given IPv6 address. * * @param[in] aIp6Address An IPv6 address. * @pram[in] aFilter A neighbor state filter. @@ -178,7 +178,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Neighbor::StateFilter aFilter = Neighbor::kInStateValidOrRestoring); /** - * This method searches in the neighbor table to find a `Neighbor` for which a one-way link is maintained (as in the + * Searches in the neighbor table to find a `Neighbor` for which a one-way link is maintained (as in the * case of an FTD child with neighbor routers). * * @param[in] aMacAddress A MAC address. @@ -191,7 +191,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_FTD /** - * This method gets the next neighbor information. It is used to iterate through the entries of + * Gets the next neighbor information. It is used to iterate through the entries of * the neighbor table. * * @param[in,out] aIterator A reference to the iterator context. To get the first neighbor entry @@ -205,7 +205,7 @@ class NeighborTable : public InstanceLocator, private NonCopyable Error GetNextNeighborInfo(otNeighborInfoIterator &aIterator, Neighbor::Info &aNeighInfo); /** - * This method registers the "neighbor table changed" callback function. + * Registers the "neighbor table changed" callback function. * * The provided callback (if non-`nullptr`) will be invoked when a child/router entry is being added/remove to/from * the neighbor table. Subsequent calls to this method will overwrite the previous callback. @@ -216,9 +216,9 @@ class NeighborTable : public InstanceLocator, private NonCopyable void RegisterCallback(Callback aCallback) { mCallback = aCallback; } /** - * This method signals a "neighbor table changed" event. + * Signals a "neighbor table changed" event. * - * This method invokes the `NeighborTable::Callback` and also signals the change through a related `Notifier` event. + * Invokes the `NeighborTable::Callback` and also signals the change through a related `Notifier` event. * * @param[in] aEvent The event to emit (child/router added/removed, or child mode changed). * @param[in] aNeighbor The neighbor that is being added/removed. diff --git a/src/core/thread/network_data.hpp b/src/core/thread/network_data.hpp index 3c1db30e432..40294cf07af 100644 --- a/src/core/thread/network_data.hpp +++ b/src/core/thread/network_data.hpp @@ -97,7 +97,7 @@ class Publisher; class MutableNetworkData; /** - * This type represents a Iterator used to iterate through Network Data info (e.g., see `GetNextOnMeshPrefix()`) + * Represents a Iterator used to iterate through Network Data info (e.g., see `GetNextOnMeshPrefix()`) * */ typedef otNetworkDataIterator Iterator; @@ -105,7 +105,7 @@ typedef otNetworkDataIterator Iterator; constexpr Iterator kIteratorInit = OT_NETWORK_DATA_ITERATOR_INIT; ///< Initializer for `Iterator` type. /** - * This class represents an immutable Network Data. + * Represents an immutable Network Data. * */ class NetworkData : public InstanceLocator @@ -119,7 +119,7 @@ class NetworkData : public InstanceLocator static constexpr uint8_t kMaxSize = 254; ///< Maximum size of Thread Network Data in bytes. /** - * This constructor initializes the `NetworkData` from a given pointer to a buffer and length. + * Initializes the `NetworkData` from a given pointer to a buffer and length. * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aTlvs A pointer to the buffer containing the TLVs. @@ -134,7 +134,7 @@ class NetworkData : public InstanceLocator } /** - * This constructor initializes the `NetworkData` from a range of TLVs (given as pair of start and end pointers). + * Initializes the `NetworkData` from a range of TLVs (given as pair of start and end pointers). * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aStartTlv A pointer to the start of the TLVs buffer. @@ -150,7 +150,7 @@ class NetworkData : public InstanceLocator } /** - * This method returns the length of `NetworkData` (number of bytes). + * Returns the length of `NetworkData` (number of bytes). * * @returns The length of `NetworkData` (number of bytes). * @@ -158,7 +158,7 @@ class NetworkData : public InstanceLocator uint8_t GetLength(void) const { return mLength; } /** - * This method returns a pointer to the start of the TLVs in `NetworkData`. + * Returns a pointer to the start of the TLVs in `NetworkData`. * * @returns A pointer to the start of the TLVs. * @@ -166,7 +166,7 @@ class NetworkData : public InstanceLocator const uint8_t *GetBytes(void) const { return mTlvs; } /** - * This method provides full or stable copy of the Thread Network Data. + * Provides full or stable copy of the Thread Network Data. * * @param[in] aType The Network Data type to copy, the full set or stable subset. * @param[out] aData A pointer to the data buffer to copy the Network Data into. @@ -180,7 +180,7 @@ class NetworkData : public InstanceLocator Error CopyNetworkData(Type aType, uint8_t *aData, uint8_t &aDataLength) const; /** - * This method provides full or stable copy of the Thread Network Data. + * Provides full or stable copy of the Thread Network Data. * * @param[in] aType The Network Data type to copy, the full set or stable subset. * @param[out] aNetworkData A reference to a `MutableNetworkData` to copy the Network Data into. @@ -192,7 +192,7 @@ class NetworkData : public InstanceLocator Error CopyNetworkData(Type aType, MutableNetworkData &aNetworkData) const; /** - * This method provides the next On Mesh prefix in the Thread Network Data. + * Provides the next On Mesh prefix in the Thread Network Data. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[out] aConfig A reference to a config variable where the On Mesh Prefix information will be placed. @@ -204,7 +204,7 @@ class NetworkData : public InstanceLocator Error GetNextOnMeshPrefix(Iterator &aIterator, OnMeshPrefixConfig &aConfig) const; /** - * This method provides the next On Mesh prefix in the Thread Network Data for a given RLOC16. + * Provides the next On Mesh prefix in the Thread Network Data for a given RLOC16. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[in] aRloc16 The RLOC16 value. @@ -217,7 +217,7 @@ class NetworkData : public InstanceLocator Error GetNextOnMeshPrefix(Iterator &aIterator, uint16_t aRloc16, OnMeshPrefixConfig &aConfig) const; /** - * This method provides the next external route in the Thread Network Data. + * Provides the next external route in the Thread Network Data. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[out] aConfig A reference to a config variable where the external route information will be placed. @@ -229,7 +229,7 @@ class NetworkData : public InstanceLocator Error GetNextExternalRoute(Iterator &aIterator, ExternalRouteConfig &aConfig) const; /** - * This method provides the next external route in the Thread Network Data for a given RLOC16. + * Provides the next external route in the Thread Network Data for a given RLOC16. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[in] aRloc16 The RLOC16 value. @@ -242,7 +242,7 @@ class NetworkData : public InstanceLocator Error GetNextExternalRoute(Iterator &aIterator, uint16_t aRloc16, ExternalRouteConfig &aConfig) const; /** - * This method provides the next service in the Thread Network Data. + * Provides the next service in the Thread Network Data. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[out] aConfig A reference to a config variable where the service information will be placed. @@ -254,7 +254,7 @@ class NetworkData : public InstanceLocator Error GetNextService(Iterator &aIterator, ServiceConfig &aConfig) const; /** - * This method provides the next service in the Thread Network Data for a given RLOC16. + * Provides the next service in the Thread Network Data for a given RLOC16. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[in] aRloc16 The RLOC16 value. @@ -267,7 +267,7 @@ class NetworkData : public InstanceLocator Error GetNextService(Iterator &aIterator, uint16_t aRloc16, ServiceConfig &aConfig) const; /** - * This method gets the next 6LoWPAN Context ID info in the Thread Network Data. + * Gets the next 6LoWPAN Context ID info in the Thread Network Data. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[out] aContextInfo A reference to where the retrieved 6LoWPAN Context ID information will be placed. @@ -279,7 +279,7 @@ class NetworkData : public InstanceLocator Error GetNextLowpanContextInfo(Iterator &aIterator, LowpanContextInfo &aContextInfo) const; /** - * This method indicates whether or not the Thread Network Data contains a given on mesh prefix entry. + * Indicates whether or not the Thread Network Data contains a given on mesh prefix entry. * * @param[in] aPrefix The on mesh prefix config to check. * @@ -290,7 +290,7 @@ class NetworkData : public InstanceLocator bool ContainsOnMeshPrefix(const OnMeshPrefixConfig &aPrefix) const; /** - * This method indicates whether or not the Thread Network Data contains a given external route entry. + * Indicates whether or not the Thread Network Data contains a given external route entry. * * @param[in] aRoute The external route config to check. * @@ -301,7 +301,7 @@ class NetworkData : public InstanceLocator bool ContainsExternalRoute(const ExternalRouteConfig &aRoute) const; /** - * This method indicates whether or not the Thread Network Data contains a given service entry. + * Indicates whether or not the Thread Network Data contains a given service entry. * * @param[in] aService The service config to check. * @@ -312,7 +312,7 @@ class NetworkData : public InstanceLocator bool ContainsService(const ServiceConfig &aService) const; /** - * This method indicates whether or not the Thread Network Data contains all the on mesh prefixes, external + * Indicates whether or not the Thread Network Data contains all the on mesh prefixes, external * routes, and service entries as in another given Network Data associated with a given RLOC16. * * @param[in] aCompare The Network Data to compare with. @@ -325,7 +325,7 @@ class NetworkData : public InstanceLocator bool ContainsEntriesFrom(const NetworkData &aCompare, uint16_t aRloc16) const; /** - * This method provides the next server RLOC16 in the Thread Network Data. + * Provides the next server RLOC16 in the Thread Network Data. * * @param[in,out] aIterator A reference to the Network Data iterator. * @param[out] aRloc16 The RLOC16 value. @@ -337,12 +337,12 @@ class NetworkData : public InstanceLocator Error GetNextServer(Iterator &aIterator, uint16_t &aRloc16) const; /** - * This method finds and returns the list of RLOCs of border routers providing external IP connectivity. + * Finds and returns the list of RLOCs of border routers providing external IP connectivity. * * A border router is considered to provide external IP connectivity if it has added at least one external route * entry, or an on-mesh prefix with default-route and on-mesh flags set. * - * This method should be used when the RLOC16s are present in the Network Data (when the Network Data contains the + * Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the * full set and not the stable subset). * * @param[in] aRoleFilter Indicates which devices to include (any role, router role only, or child only). @@ -358,7 +358,7 @@ class NetworkData : public InstanceLocator Error FindBorderRouters(RoleFilter aRoleFilter, uint16_t aRlocs[], uint8_t &aRlocsLength) const; /** - * This method counts the number of border routers providing external IP connectivity. + * Counts the number of border routers providing external IP connectivity. * * A border router is considered to provide external IP connectivity if at least one of the below conditions hold * @@ -366,7 +366,7 @@ class NetworkData : public InstanceLocator * - It has added at least one prefix entry with default-route and on-mesh flags set. * - It has added at least one domain prefix (domain and on-mesh flags set). * - * This method should be used when the RLOC16s are present in the Network Data (when the Network Data contains the + * Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the * full set and not the stable subset). * * @param[in] aRoleFilter Indicates which RLOCs to include (any role, router only, or child only). @@ -377,7 +377,7 @@ class NetworkData : public InstanceLocator uint8_t CountBorderRouters(RoleFilter aRoleFilter) const; /** - * This method indicates whether the network data contains a border providing external IP connectivity with a given + * Indicates whether the network data contains a border providing external IP connectivity with a given * RLOC16. * * A border router is considered to provide external IP connectivity if at least one of the below conditions hold @@ -386,7 +386,7 @@ class NetworkData : public InstanceLocator * - It has added at least one prefix entry with default-route and on-mesh flags set. * - It has added at least one domain prefix (domain and on-mesh flags set). * - * This method should be used when the RLOC16s are present in the Network Data (when the Network Data contains the + * Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the * full set and not the stable subset). * * @param[in] aRloc16 The RLOC16 to check. @@ -399,7 +399,7 @@ class NetworkData : public InstanceLocator protected: /** - * This enumeration defines Service Data match mode. + * Defines Service Data match mode. * */ enum ServiceMatchMode : uint8_t @@ -409,7 +409,7 @@ class NetworkData : public InstanceLocator }; /** - * This method returns a pointer to the start of Network Data TLV sequence. + * Returns a pointer to the start of Network Data TLV sequence. * * @returns A pointer to the start of Network Data TLV sequence. * @@ -417,7 +417,7 @@ class NetworkData : public InstanceLocator const NetworkDataTlv *GetTlvsStart(void) const { return reinterpret_cast(mTlvs); } /** - * This method returns a pointer to the end of Network Data TLV sequence. + * Returns a pointer to the end of Network Data TLV sequence. * * @returns A pointer to the end of Network Data TLV sequence. * @@ -425,7 +425,7 @@ class NetworkData : public InstanceLocator const NetworkDataTlv *GetTlvsEnd(void) const { return reinterpret_cast(mTlvs + mLength); } /** - * This method returns a pointer to a Prefix TLV. + * Returns a pointer to a Prefix TLV. * * @param[in] aPrefix A pointer to an IPv6 prefix. * @param[in] aPrefixLength The prefix length pointed to by @p aPrefix (in bits). @@ -436,7 +436,7 @@ class NetworkData : public InstanceLocator const PrefixTlv *FindPrefix(const uint8_t *aPrefix, uint8_t aPrefixLength) const; /** - * This method returns a pointer to a Prefix TLV. + * Returns a pointer to a Prefix TLV. * * @param[in] aPrefix An IPv6 prefix. * @@ -449,7 +449,7 @@ class NetworkData : public InstanceLocator } /** - * This method returns a pointer to a matching Service TLV. + * Returns a pointer to a matching Service TLV. * * @param[in] aEnterpriseNumber Enterprise Number. * @param[in] aServiceData A Service Data. @@ -463,9 +463,9 @@ class NetworkData : public InstanceLocator ServiceMatchMode aServiceMatchMode) const; /** - * This method returns the next pointer to a matching Service TLV. + * Returns the next pointer to a matching Service TLV. * - * This method can be used to iterate over all Service TLVs that start with a given Service Data. + * Can be used to iterate over all Service TLVs that start with a given Service Data. * * @param[in] aPrevServiceTlv Set to `nullptr` to start from the beginning of the TLVs (finding the first * matching Service TLV), or a pointer to the previous Service TLV returned from @@ -483,9 +483,9 @@ class NetworkData : public InstanceLocator ServiceMatchMode aServiceMatchMode) const; /** - * This method returns the next pointer to a matching Thread Service TLV (with Thread Enterprise number). + * Returns the next pointer to a matching Thread Service TLV (with Thread Enterprise number). * - * This method can be used to iterate over all Thread Service TLVs that start with a given Service Data. + * Can be used to iterate over all Thread Service TLVs that start with a given Service Data. * * @param[in] aPrevServiceTlv Set to `nullptr` to start from the beginning of the TLVs (finding the first * matching Service TLV), or a pointer to the previous Service TLV returned from @@ -584,7 +584,7 @@ class NetworkData : public InstanceLocator }; /** - * This class represents mutable Network Data. + * Represents mutable Network Data. * */ class MutableNetworkData : public NetworkData @@ -595,7 +595,7 @@ class MutableNetworkData : public NetworkData public: /** - * This constructor initializes the `MutableNetworkData` + * Initializes the `MutableNetworkData` * * @param[in] aInstance A reference to the OpenThread instance. * @param[in] aTlvs A pointer to the buffer to store the TLVs. @@ -613,7 +613,7 @@ class MutableNetworkData : public NetworkData using NetworkData::GetLength; /** - * This method returns the size of the buffer to store the mutable Network Data. + * Returns the size of the buffer to store the mutable Network Data. * * @returns The size of the buffer. * @@ -621,7 +621,7 @@ class MutableNetworkData : public NetworkData uint8_t GetSize(void) const { return mSize; } /** - * This method returns a pointer to start of the TLVs in `NetworkData`. + * Returns a pointer to start of the TLVs in `NetworkData`. * * @returns A pointer to start of the TLVs. * @@ -629,14 +629,14 @@ class MutableNetworkData : public NetworkData uint8_t *GetBytes(void) { return AsNonConst(AsConst(this)->GetBytes()); } /** - * This method clears the network data. + * Clears the network data. * */ void Clear(void) { mLength = 0; } protected: /** - * This method sets the Network Data length. + * Sets the Network Data length. * * @param[in] aLength The length. * @@ -646,7 +646,7 @@ class MutableNetworkData : public NetworkData using NetworkData::GetTlvsStart; /** - * This method returns a pointer to the start of Network Data TLV sequence. + * Returns a pointer to the start of Network Data TLV sequence. * * @returns A pointer to the start of Network Data TLV sequence. * @@ -656,7 +656,7 @@ class MutableNetworkData : public NetworkData using NetworkData::GetTlvsEnd; /** - * This method returns a pointer to the end of Network Data TLV sequence. + * Returns a pointer to the end of Network Data TLV sequence. * * @returns A pointer to the end of Network Data TLV sequence. * @@ -666,7 +666,7 @@ class MutableNetworkData : public NetworkData using NetworkData::FindPrefix; /** - * This method returns a pointer to a Prefix TLV. + * Returns a pointer to a Prefix TLV. * * @param[in] aPrefix A pointer to an IPv6 prefix. * @param[in] aPrefixLength The prefix length pointed to by @p aPrefix (in bits). @@ -680,7 +680,7 @@ class MutableNetworkData : public NetworkData } /** - * This method returns a pointer to a Prefix TLV. + * Returns a pointer to a Prefix TLV. * * @param[in] aPrefix An IPv6 prefix. * @@ -692,7 +692,7 @@ class MutableNetworkData : public NetworkData using NetworkData::FindService; /** - * This method returns a pointer to a matching Service TLV. + * Returns a pointer to a matching Service TLV. * * @param[in] aEnterpriseNumber Enterprise Number. * @param[in] aServiceData A Service Data. @@ -709,7 +709,7 @@ class MutableNetworkData : public NetworkData } /** - * This method indicates whether there is space in Network Data to insert/append new info and grow it by a given + * Indicates whether there is space in Network Data to insert/append new info and grow it by a given * number of bytes. * * @param[in] aSize The number of bytes to grow the Network Data. @@ -721,7 +721,7 @@ class MutableNetworkData : public NetworkData bool CanInsert(uint16_t aSize) const { return (mLength + aSize <= mSize); } /** - * This method grows the Network Data to append a TLV with a requested size. + * Grows the Network Data to append a TLV with a requested size. * * On success, the returned TLV is not initialized (i.e., the TLV Length field is not set) but the requested * size for it (@p aTlvSize number of bytes) is reserved in the Network Data. @@ -735,7 +735,7 @@ class MutableNetworkData : public NetworkData NetworkDataTlv *AppendTlv(uint16_t aTlvSize); /** - * This method inserts bytes into the Network Data. + * Inserts bytes into the Network Data. * * @param[in] aStart A pointer to the beginning of the insertion. * @param[in] aLength The number of bytes to insert. @@ -744,7 +744,7 @@ class MutableNetworkData : public NetworkData void Insert(void *aStart, uint8_t aLength); /** - * This method removes bytes from the Network Data. + * Removes bytes from the Network Data. * * @param[in] aRemoveStart A pointer to the beginning of the removal. * @param[in] aRemoveLength The number of bytes to remove. @@ -753,7 +753,7 @@ class MutableNetworkData : public NetworkData void Remove(void *aRemoveStart, uint8_t aRemoveLength); /** - * This method removes a TLV from the Network Data. + * Removes a TLV from the Network Data. * * @param[in] aTlv The TLV to remove. * @@ -761,7 +761,7 @@ class MutableNetworkData : public NetworkData void RemoveTlv(NetworkDataTlv *aTlv); /** - * This method strips non-stable data from the Thread Network Data. + * Strips non-stable data from the Thread Network Data. * */ void RemoveTemporaryData(void); diff --git a/src/core/thread/network_data_leader.hpp b/src/core/thread/network_data_leader.hpp index 92dae938220..a696b55889c 100644 --- a/src/core/thread/network_data_leader.hpp +++ b/src/core/thread/network_data_leader.hpp @@ -60,14 +60,14 @@ namespace NetworkData { */ /** - * This class implements the Thread Network Data maintained by the Leader. + * Implements the Thread Network Data maintained by the Leader. * */ class LeaderBase : public MutableNetworkData { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -80,13 +80,13 @@ class LeaderBase : public MutableNetworkData } /** - * This method reset the Thread Network Data. + * Reset the Thread Network Data. * */ void Reset(void); /** - * This method returns the maximum observed Network Data length since OT stack initialization or since the last + * Returns the maximum observed Network Data length since OT stack initialization or since the last * call to `ResetMaxLength()`. * * @returns The maximum observed Network Data length (high water mark for Network Data length). @@ -95,7 +95,7 @@ class LeaderBase : public MutableNetworkData uint8_t GetMaxLength(void) const { return mMaxLength; } /** - * This method resets the tracked maximum Network Data Length. + * Resets the tracked maximum Network Data Length. * * @sa GetMaxLength * @@ -103,7 +103,7 @@ class LeaderBase : public MutableNetworkData void ResetMaxLength(void) { mMaxLength = GetLength(); } /** - * This method returns the Data Version value for a type (full set or stable subset). + * Returns the Data Version value for a type (full set or stable subset). * * @param[in] aType The Network Data type (full set or stable subset). * @@ -113,7 +113,7 @@ class LeaderBase : public MutableNetworkData uint8_t GetVersion(Type aType) const { return (aType == kFullSet) ? mVersion : mStableVersion; } /** - * This method retrieves the 6LoWPAN Context information based on a given IPv6 address. + * Retrieves the 6LoWPAN Context information based on a given IPv6 address. * * @param[in] aAddress A reference to an IPv6 address. * @param[out] aContext A reference to 6LoWPAN Context information. @@ -125,7 +125,7 @@ class LeaderBase : public MutableNetworkData Error GetContext(const Ip6::Address &aAddress, Lowpan::Context &aContext) const; /** - * This method retrieves the 6LoWPAN Context information based on a given Context ID. + * Retrieves the 6LoWPAN Context information based on a given Context ID. * * @param[in] aContextId The Context ID value. * @param[out] aContext A reference to the 6LoWPAN Context information. @@ -137,7 +137,7 @@ class LeaderBase : public MutableNetworkData Error GetContext(uint8_t aContextId, Lowpan::Context &aContext) const; /** - * This method indicates whether or not the given IPv6 address is on-mesh. + * Indicates whether or not the given IPv6 address is on-mesh. * * @param[in] aAddress A reference to an IPv6 address. * @@ -148,7 +148,7 @@ class LeaderBase : public MutableNetworkData bool IsOnMesh(const Ip6::Address &aAddress) const; /** - * This method performs a route lookup using the Network Data. + * Performs a route lookup using the Network Data. * * @param[in] aSource A reference to the IPv6 source address. * @param[in] aDestination A reference to the IPv6 destination address. @@ -161,7 +161,7 @@ class LeaderBase : public MutableNetworkData Error RouteLookup(const Ip6::Address &aSource, const Ip6::Address &aDestination, uint16_t &aRloc16) const; /** - * This method is used by non-Leader devices to set Network Data by reading it from a message from Leader. + * Is used by non-Leader devices to set Network Data by reading it from a message from Leader. * * @param[in] aVersion The Version value. * @param[in] aStableVersion The Stable Version value. @@ -182,7 +182,7 @@ class LeaderBase : public MutableNetworkData uint16_t aLength); /** - * This method returns a pointer to the Commissioning Data. + * Returns a pointer to the Commissioning Data. * * @returns A pointer to the Commissioning Data or `nullptr` if no Commissioning Data exists. * @@ -190,7 +190,7 @@ class LeaderBase : public MutableNetworkData CommissioningDataTlv *GetCommissioningData(void) { return AsNonConst(AsConst(this)->GetCommissioningData()); } /** - * This method returns a pointer to the Commissioning Data. + * Returns a pointer to the Commissioning Data. * * @returns A pointer to the Commissioning Data or `nullptr` if no Commissioning Data exists. * @@ -198,7 +198,7 @@ class LeaderBase : public MutableNetworkData const CommissioningDataTlv *GetCommissioningData(void) const; /** - * This method returns a pointer to the Commissioning Data Sub-TLV. + * Returns a pointer to the Commissioning Data Sub-TLV. * * @param[in] aType The TLV type value. * @@ -211,7 +211,7 @@ class LeaderBase : public MutableNetworkData } /** - * This method returns a pointer to the Commissioning Data Sub-TLV. + * Returns a pointer to the Commissioning Data Sub-TLV. * * @param[in] aType The TLV type value. * @@ -221,7 +221,7 @@ class LeaderBase : public MutableNetworkData const MeshCoP::Tlv *GetCommissioningDataSubTlv(MeshCoP::Tlv::Type aType) const; /** - * This method indicates whether or not the Commissioning Data TLV indicates Joining is enabled. + * Indicates whether or not the Commissioning Data TLV indicates Joining is enabled. * * Joining is enabled if a Border Agent Locator TLV exist and the Steering Data TLV is non-zero. * @@ -231,7 +231,7 @@ class LeaderBase : public MutableNetworkData bool IsJoiningEnabled(void) const; /** - * This method adds Commissioning Data to the Thread Network Data. + * Adds Commissioning Data to the Thread Network Data. * * @param[in] aValue A pointer to the Commissioning Data value. * @param[in] aValueLength The length of @p aValue. @@ -243,7 +243,7 @@ class LeaderBase : public MutableNetworkData Error SetCommissioningData(const uint8_t *aValue, uint8_t aValueLength); /** - * This method checks if the steering data includes a Joiner. + * Checks if the steering data includes a Joiner. * * @param[in] aEui64 A reference to the Joiner's IEEE EUI-64. * @@ -255,7 +255,7 @@ class LeaderBase : public MutableNetworkData Error SteeringDataCheckJoiner(const Mac::ExtAddress &aEui64) const; /** - * This method checks if the steering data includes a Joiner with a given discerner value. + * Checks if the steering data includes a Joiner with a given discerner value. * * @param[in] aDiscerner A reference to the Joiner Discerner. * @@ -267,7 +267,7 @@ class LeaderBase : public MutableNetworkData Error SteeringDataCheckJoiner(const MeshCoP::JoinerDiscerner &aDiscerner) const; /** - * This method gets the Service ID for the specified service. + * Gets the Service ID for the specified service. * * @param[in] aEnterpriseNumber Enterprise Number (IANA-assigned) for Service TLV * @param[in] aServiceData The Service Data. @@ -284,7 +284,7 @@ class LeaderBase : public MutableNetworkData uint8_t &aServiceId) const; /** - * This methods gets the preferred NAT64 prefix from network data. + * Gets the preferred NAT64 prefix from network data. * * The returned prefix is the highest preference external route entry in Network Data with NAT64 flag set. If there * are multiple such entries the first one is returned. diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index 39a033ded60..4dc1ceb1cfc 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -60,6 +60,9 @@ RegisterLogModule("NetworkData"); Leader::Leader(Instance &aInstance) : LeaderBase(aInstance) +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + , mIsClone(false) +#endif , mWaitingForNetDataSync(false) , mContextIds(aInstance) , mTimer(aInstance) @@ -76,6 +79,10 @@ void Leader::Reset(void) void Leader::Start(Mle::LeaderStartMode aStartMode) { +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + OT_ASSERT(!mIsClone); +#endif + mWaitingForNetDataSync = (aStartMode == Mle::kRestoringLeaderRoleAfterReset); if (mWaitingForNetDataSync) @@ -110,6 +117,10 @@ void Leader::IncrementVersions(const ChangedFlags &aFlags) void Leader::IncrementVersions(bool aIncludeStable) { +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + VerifyOrExit(!mIsClone); +#endif + if (aIncludeStable) { mStableVersion++; @@ -117,6 +128,10 @@ void Leader::IncrementVersions(bool aIncludeStable) mVersion++; SignalNetDataChanged(); + ExitNow(); + +exit: + return; } void Leader::RemoveBorderRouter(uint16_t aRloc16, MatchMode aMatchMode) @@ -124,6 +139,7 @@ void Leader::RemoveBorderRouter(uint16_t aRloc16, MatchMode aMatchMode) ChangedFlags flags; RemoveRloc(aRloc16, aMatchMode, flags); + IncrementVersions(flags); } @@ -672,6 +688,52 @@ Leader::UpdateStatus Leader::UpdateTlv(NetworkDataTlv &aTlv, const NetworkDataTl return status; } +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + +void Leader::CheckForNetDataGettingFull(const NetworkData &aNetworkData, uint16_t aOldRloc16) +{ + // Determines whether there is still room in Network Data to register + // `aNetworkData` entries. The `aNetworkData` MUST follow the format of + // local Network Data (e.g., all entries associated with the RLOC16 of + // this device). Network data getting full is signaled by invoking the + // `Get().SignalNetworkDataFull()` method. + // + // Input `aOldRloc16` can be used to indicate the old RLOC16 of the + // device. If provided, then entries matching old RLOC16 are first + // removed, before checking if new entries from @p aNetworkData can fit. + + if (!Get().IsLeader()) + { + // Create a clone of the leader's network data, and try to register + // `aNetworkData` into the copy (as if this device itself is the + // leader). `mIsClone` flag is used to mark the clone and ensure + // that the cloned instance does interact with other OT modules, + // e.g., does not start timer, or does not signal version change + // using `Get().Signal()`, or allocate service or + // context ID. + + Leader leaderClone(GetInstance()); + + leaderClone.MarkAsClone(); + SuccessOrAssert(CopyNetworkData(kFullSet, leaderClone)); + + if (aOldRloc16 != Mac::kShortAddrInvalid) + { + leaderClone.RemoveBorderRouter(aOldRloc16, kMatchModeRloc16); + } + + leaderClone.RegisterNetworkData(Get().GetRloc16(), aNetworkData); + } +} + +void Leader::MarkAsClone(void) +{ + mIsClone = true; + mContextIds.MarkAsClone(); +} + +#endif // OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + void Leader::RegisterNetworkData(uint16_t aRloc16, const NetworkData &aNetworkData) { Error error = kErrorNone; @@ -710,9 +772,19 @@ void Leader::RegisterNetworkData(uint16_t aRloc16, const NetworkData &aNetworkDa exit: IncrementVersions(flags); - if (error != kErrorNone) +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + if (error == kErrorNoBufs) + { + Get().SignalNetworkDataFull(); + } + + if (!mIsClone) +#endif { - LogNote("Failed to register network data: %s", ErrorToString(error)); + if (error != kErrorNone) + { + LogNote("Failed to register network data: %s", ErrorToString(error)); + } } } @@ -943,6 +1015,15 @@ Error Leader::AllocateServiceId(uint8_t &aServiceId) const Error error = kErrorNotFound; uint8_t serviceId; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + if (mIsClone) + { + aServiceId = Mle::kServiceMinId; + error = kErrorNone; + ExitNow(); + } +#endif + for (serviceId = Mle::kServiceMinId; serviceId <= Mle::kServiceMaxId; serviceId++) { if (FindServiceById(serviceId) == nullptr) @@ -950,10 +1031,11 @@ Error Leader::AllocateServiceId(uint8_t &aServiceId) const aServiceId = serviceId; error = kErrorNone; LogInfo("Allocated Service ID = %d", serviceId); - break; + ExitNow(); } } +exit: return error; } @@ -1316,6 +1398,15 @@ bool Leader::ContainsOmrPrefix(const Ip6::Prefix &aPrefix) //--------------------------------------------------------------------------------------------------------------------- // Leader::ContextIds +Leader::ContextIds::ContextIds(Instance &aInstance) + : InstanceLocator(aInstance) + , mReuseDelay(kReuseDelay) +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + , mIsClone(false) +#endif +{ +} + void Leader::ContextIds::Clear(void) { for (uint8_t id = kMinId; id <= kMaxId; id++) @@ -1328,21 +1419,35 @@ Error Leader::ContextIds::GetUnallocatedId(uint8_t &aId) { Error error = kErrorNotFound; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + if (mIsClone) + { + aId = kMinId; + error = kErrorNone; + ExitNow(); + } +#endif + for (uint8_t id = kMinId; id <= kMaxId; id++) { if (IsUnallocated(id)) { aId = id; error = kErrorNone; - break; + ExitNow(); } } +exit: return error; } void Leader::ContextIds::ScheduleToRemove(uint8_t aId) { +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + VerifyOrExit(!mIsClone); +#endif + VerifyOrExit(IsInUse(aId)); SetRemoveTime(aId, TimerMilli::GetNow() + Time::SecToMsec(mReuseDelay)); @@ -1369,6 +1474,10 @@ void Leader::ContextIds::HandleTimer(void) TimeMilli now = TimerMilli::GetNow(); TimeMilli nextTime = now.GetDistantFuture(); +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + OT_ASSERT(!mIsClone); +#endif + for (uint8_t id = kMinId; id <= kMaxId; id++) { if (IsUnallocated(id) || IsInUse(id)) diff --git a/src/core/thread/network_data_leader_ftd.hpp b/src/core/thread/network_data_leader_ftd.hpp index 85096c33c18..bae0c7ff4d0 100644 --- a/src/core/thread/network_data_leader_ftd.hpp +++ b/src/core/thread/network_data_leader_ftd.hpp @@ -52,6 +52,8 @@ namespace ot { namespace NetworkData { +class Notifier; + /** * @addtogroup core-netdata-leader * @@ -63,16 +65,17 @@ namespace NetworkData { */ /** - * This class implements the Thread Network Data maintained by the Leader. + * Implements the Thread Network Data maintained by the Leader. * */ class Leader : public LeaderBase, private NonCopyable { friend class Tmf::Agent; + friend class Notifier; public: /** - * This enumeration defines the match mode constants to compare two RLOC16 values. + * Defines the match mode constants to compare two RLOC16 values. * */ enum MatchMode : uint8_t @@ -82,7 +85,7 @@ class Leader : public LeaderBase, private NonCopyable }; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -90,13 +93,13 @@ class Leader : public LeaderBase, private NonCopyable explicit Leader(Instance &aInstance); /** - * This method reset the Thread Network Data. + * Reset the Thread Network Data. * */ void Reset(void); /** - * This method starts the Leader services. + * Starts the Leader services. * * The start mode indicates whether device is starting normally as leader or restoring its role as leader after * reset. In the latter case, we do not accept any new registrations (`HandleServerData()`) and wait for @@ -109,19 +112,19 @@ class Leader : public LeaderBase, private NonCopyable void Start(Mle::LeaderStartMode aStartMode); /** - * This method increments the Thread Network Data version. + * Increments the Thread Network Data version. * */ void IncrementVersion(void); /** - * This method increments both the Thread Network Data version and stable version. + * Increments both the Thread Network Data version and stable version. * */ void IncrementVersionAndStableVersion(void); /** - * This method returns CONTEXT_ID_RESUSE_DELAY value. + * Returns CONTEXT_ID_RESUSE_DELAY value. * * @returns The CONTEXT_ID_REUSE_DELAY value (in seconds). * @@ -129,7 +132,7 @@ class Leader : public LeaderBase, private NonCopyable uint32_t GetContextIdReuseDelay(void) const { return mContextIds.GetReuseDelay(); } /** - * This method sets CONTEXT_ID_RESUSE_DELAY value. + * Sets CONTEXT_ID_RESUSE_DELAY value. * * @warning This method should only be used for testing. * @@ -139,7 +142,7 @@ class Leader : public LeaderBase, private NonCopyable void SetContextIdReuseDelay(uint32_t aDelay) { mContextIds.SetReuseDelay(aDelay); } /** - * This method removes Network Data entries matching with a given RLOC16. + * Removes Network Data entries matching with a given RLOC16. * * @param[in] aRloc16 A RLOC16 value. * @param[in] aMatchMode A match mode (@sa MatchMode). @@ -148,7 +151,7 @@ class Leader : public LeaderBase, private NonCopyable void RemoveBorderRouter(uint16_t aRloc16, MatchMode aMatchMode); /** - * This method synchronizes internal 6LoWPAN Context ID Set with recently obtained Thread Network Data. + * Synchronizes internal 6LoWPAN Context ID Set with recently obtained Thread Network Data. * * Note that this method should be called only by the Leader once after reset. * @@ -156,7 +159,7 @@ class Leader : public LeaderBase, private NonCopyable void HandleNetworkDataRestoredAfterReset(void); /** - * This method scans network data for given Service ID and returns pointer to the respective TLV, if present. + * Scans network data for given Service ID and returns pointer to the respective TLV, if present. * * @param aServiceId Service ID to look for. * @return Pointer to the Service TLV for given Service ID, or nullptr if not present. @@ -166,7 +169,7 @@ class Leader : public LeaderBase, private NonCopyable #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE /** - * This method indicates whether a given Prefix can act as a valid OMR prefix and exists in the network data. + * Indicates whether a given Prefix can act as a valid OMR prefix and exists in the network data. * * @param[in] aPrefix The OMR prefix to check. * @@ -219,11 +222,7 @@ class Leader : public LeaderBase, private NonCopyable static constexpr uint8_t kInvalidId = NumericLimits::kMax; - explicit ContextIds(Instance &aInstance) - : InstanceLocator(aInstance) - , mReuseDelay(kReuseDelay) - { - } + explicit ContextIds(Instance &aInstance); void Clear(void); Error GetUnallocatedId(uint8_t &aId); @@ -232,6 +231,9 @@ class Leader : public LeaderBase, private NonCopyable uint32_t GetReuseDelay(void) const { return mReuseDelay; } void SetReuseDelay(uint32_t aDelay) { mReuseDelay = aDelay; } void HandleTimer(void); +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + void MarkAsClone(void) { mIsClone = true; } +#endif private: static constexpr uint32_t kReuseDelay = 5 * 60; // 5 minutes (in seconds). @@ -256,6 +258,9 @@ class Leader : public LeaderBase, private NonCopyable TimeMilli mRemoveTimes[kMaxId - kMinId + 1]; uint32_t mReuseDelay; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + bool mIsClone; +#endif }; template void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); @@ -330,8 +335,16 @@ class Leader : public LeaderBase, private NonCopyable void IncrementVersions(bool aIncludeStable); void IncrementVersions(const ChangedFlags &aFlags); +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + void CheckForNetDataGettingFull(const NetworkData &aNetworkData, uint16_t aOldRloc16); + void MarkAsClone(void); +#endif + using UpdateTimer = TimerMilliIn; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + bool mIsClone; +#endif bool mWaitingForNetDataSync; ContextIds mContextIds; UpdateTimer mTimer; diff --git a/src/core/thread/network_data_local.cpp b/src/core/thread/network_data_local.cpp index a7eb9d9fd03..b99900fd590 100644 --- a/src/core/thread/network_data_local.cpp +++ b/src/core/thread/network_data_local.cpp @@ -134,6 +134,13 @@ Error Local::AddPrefix(const Ip6::Prefix &aPrefix, NetworkDataTlv::Type aSubTlvT DumpDebg("AddPrefix", GetBytes(), GetLength()); exit: +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + if (error == kErrorNoBufs) + { + Get().SignalNetworkDataFull(); + } +#endif + return error; } @@ -211,6 +218,13 @@ Error Local::AddService(uint32_t aEnterpriseNumber, DumpDebg("AddService", GetBytes(), GetLength()); exit: +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + if (error == kErrorNoBufs) + { + Get().SignalNetworkDataFull(); + } +#endif + return error; } diff --git a/src/core/thread/network_data_local.hpp b/src/core/thread/network_data_local.hpp index 27090a5ba79..761e7f875d9 100644 --- a/src/core/thread/network_data_local.hpp +++ b/src/core/thread/network_data_local.hpp @@ -57,7 +57,7 @@ namespace NetworkData { class Notifier; /** - * This class implements the Thread Network Data contributed by the local device. + * Implements the Thread Network Data contributed by the local device. * */ class Local : public MutableNetworkData, private NonCopyable @@ -66,7 +66,7 @@ class Local : public MutableNetworkData, private NonCopyable public: /** - * This constructor initializes the local Network Data. + * Initializes the local Network Data. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -78,7 +78,7 @@ class Local : public MutableNetworkData, private NonCopyable #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE /** - * This method adds a Border Router entry to the Thread Network Data. + * Adds a Border Router entry to the Thread Network Data. * * @param[in] aConfig A reference to the on mesh prefix configuration. * @@ -90,7 +90,7 @@ class Local : public MutableNetworkData, private NonCopyable Error AddOnMeshPrefix(const OnMeshPrefixConfig &aConfig); /** - * This method removes a Border Router entry from the Thread Network Data. + * Removes a Border Router entry from the Thread Network Data. * * @param[in] aPrefix The Prefix to remove. * @@ -101,7 +101,7 @@ class Local : public MutableNetworkData, private NonCopyable Error RemoveOnMeshPrefix(const Ip6::Prefix &aPrefix) { return RemovePrefix(aPrefix); } /** - * This method indicates whether or not the Thread Network Data contains a given on mesh prefix. + * Indicates whether or not the Thread Network Data contains a given on mesh prefix. * * @param[in] aPrefix The on mesh prefix to check. * @@ -112,7 +112,7 @@ class Local : public MutableNetworkData, private NonCopyable bool ContainsOnMeshPrefix(const Ip6::Prefix &aPrefix) const; /** - * This method adds a Has Route entry to the Thread Network data. + * Adds a Has Route entry to the Thread Network data. * * @param[in] aConfig A reference to the external route configuration. * @@ -124,7 +124,7 @@ class Local : public MutableNetworkData, private NonCopyable Error AddHasRoutePrefix(const ExternalRouteConfig &aConfig); /** - * This method removes a Border Router entry from the Thread Network Data. + * Removes a Border Router entry from the Thread Network Data. * * @param[in] aPrefix The Prefix to remove. * @@ -137,7 +137,7 @@ class Local : public MutableNetworkData, private NonCopyable #if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE /** - * This method adds a Service entry to the Thread Network local data. + * Adds a Service entry to the Thread Network local data. * * @param[in] aEnterpriseNumber Enterprise Number (IANA-assigned) for Service TLV. * @param[in] aServiceData The Service Data. @@ -154,7 +154,7 @@ class Local : public MutableNetworkData, private NonCopyable const ServerData &aServerData); /** - * This method removes a Service entry from the Thread Network local data. + * Removes a Service entry from the Thread Network local data. * * @param[in] aEnterpriseNumber Enterprise Number of the service to be deleted. * @param[in] aServiceData The service data. diff --git a/src/core/thread/network_data_notifier.cpp b/src/core/thread/network_data_notifier.cpp index 65b76e06a56..09597cad779 100644 --- a/src/core/thread/network_data_notifier.cpp +++ b/src/core/thread/network_data_notifier.cpp @@ -53,6 +53,9 @@ Notifier::Notifier(Instance &aInstance) : InstanceLocator(aInstance) , mTimer(aInstance) , mSynchronizeDataTask(aInstance) +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + , mNetDataFullTask(aInstance) +#endif , mNextDelay(0) , mOldRloc(Mac::kShortAddrInvalid) , mWaitingForResponse(false) @@ -201,6 +204,10 @@ Error Notifier::SendServerDataNotification(uint16_t aOldRloc16, const NetworkDat tlv.SetLength(aNetworkData->GetLength()); SuccessOrExit(error = message->Append(tlv)); SuccessOrExit(error = message->AppendBytes(aNetworkData->GetBytes(), aNetworkData->GetLength())); + +#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + Get().CheckForNetDataGettingFull(*aNetworkData, aOldRloc16); +#endif } if (aOldRloc16 != Mac::kShortAddrInvalid) @@ -273,6 +280,15 @@ void Notifier::HandleCoapResponse(Error aResult) } } +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL +void Notifier::SetNetDataFullCallback(NetDataCallback aCallback, void *aContext) +{ + mNetDataFullCallback.Set(aCallback, aContext); +} + +void Notifier::HandleNetDataFull(void) { mNetDataFullCallback.InvokeIfSet(); } +#endif + #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTER_REQUEST_ROUTER_ROLE bool Notifier::IsEligibleForRouterRoleUpgradeAsBorderRouter(void) const diff --git a/src/core/thread/network_data_notifier.hpp b/src/core/thread/network_data_notifier.hpp index 65426cda093..e12048f09aa 100644 --- a/src/core/thread/network_data_notifier.hpp +++ b/src/core/thread/network_data_notifier.hpp @@ -38,6 +38,8 @@ #if OPENTHREAD_FTD || OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE +#include + #include "coap/coap.hpp" #include "common/message.hpp" #include "common/non_copyable.hpp" @@ -51,7 +53,7 @@ namespace NetworkData { class NetworkData; /** - * This class implements the SVR_DATA.ntf transmission logic. + * Implements the SVR_DATA.ntf transmission logic. * */ class Notifier : public InstanceLocator, private NonCopyable @@ -71,19 +73,38 @@ class Notifier : public InstanceLocator, private NonCopyable /** * Call this method to inform the notifier that new server data is available. * - * This method posts a tasklet to sync new server data with leader so if there are multiple changes within the same + * Posts a tasklet to sync new server data with leader so if there are multiple changes within the same * flow of execution (multiple calls to this method) they are all synchronized together and included in the same * message to the leader. * */ void HandleServerDataUpdated(void); +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + typedef otBorderRouterNetDataFullCallback NetDataCallback; ///< Network Data full callback. + + /** + * Sets the callback to indicate when Network Data gets full. + * + * @param[in] aCallback The callback. + * @param[in] aContext The context to use with @p aCallback. + * + */ + void SetNetDataFullCallback(NetDataCallback aCallback, void *aContext); + + /** + * Signals that network data (local or leader) is getting full. + * + */ + void SignalNetworkDataFull(void) { mNetDataFullTask.Post(); } +#endif + #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTER_REQUEST_ROUTER_ROLE /** - * This method indicates whether the device as border router is eligible for router role upgrade request using the + * Indicates whether the device as border router is eligible for router role upgrade request using the * status reason `kBorderRouterRequest`. * - * This method checks whether device is providing IP connectivity and that there are fewer than two border routers + * Checks whether device is providing IP connectivity and that there are fewer than two border routers * in network data acting as router. Device is considered to provide external IP connectivity if at least one of * the below conditions hold: * @@ -91,7 +112,7 @@ class Notifier : public InstanceLocator, private NonCopyable * - It has added at least one prefix entry with default-route and on-mesh flags set. * - It has added at least one domain prefix (domain and on-mesh flags set). * - * This method does not check the current role of device. + * Does not check the current role of device. * * @retval TRUE Device is eligible to request router role upgrade as a border router. * @retval FALSE Device is not eligible to request router role upgrade as a border router. @@ -123,6 +144,10 @@ class Notifier : public InstanceLocator, private NonCopyable Error aResult); void HandleCoapResponse(Error aResult); +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + void HandleNetDataFull(void); +#endif + #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTER_REQUEST_ROUTER_ROLE void ScheduleRouterRoleUpgradeIfEligible(void); void HandleTimeTick(void); @@ -130,12 +155,19 @@ class Notifier : public InstanceLocator, private NonCopyable using SynchronizeDataTask = TaskletIn; using DelayTimer = TimerMilliIn; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + using NetDataFullTask = TaskletIn; +#endif DelayTimer mTimer; SynchronizeDataTask mSynchronizeDataTask; - uint32_t mNextDelay; - uint16_t mOldRloc; - bool mWaitingForResponse : 1; +#if OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL + NetDataFullTask mNetDataFullTask; + Callback mNetDataFullCallback; +#endif + uint32_t mNextDelay; + uint16_t mOldRloc; + bool mWaitingForResponse : 1; #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE && OPENTHREAD_CONFIG_BORDER_ROUTER_REQUEST_ROUTER_ROLE bool mDidRequestRouterRoleUpgrade : 1; diff --git a/src/core/thread/network_data_publisher.hpp b/src/core/thread/network_data_publisher.hpp index 3d3a37f27a3..3ac2c825af0 100644 --- a/src/core/thread/network_data_publisher.hpp +++ b/src/core/thread/network_data_publisher.hpp @@ -62,7 +62,7 @@ namespace ot { namespace NetworkData { /** - * This class implements the Network Data Publisher. + * Implements the Network Data Publisher. * * It 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. @@ -74,7 +74,7 @@ class Publisher : public InstanceLocator, private NonCopyable public: /** - * This enumeration represents the events reported from the Publisher callbacks. + * Represents the events reported from the Publisher callbacks. * */ enum Event : uint8_t @@ -84,7 +84,7 @@ class Publisher : public InstanceLocator, private NonCopyable }; /** - * This enumeration represents the requester associated with a published prefix. + * Represents the requester associated with a published prefix. * */ enum Requester : uint8_t @@ -94,7 +94,7 @@ class Publisher : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes `Publisher` object. + * Initializes `Publisher` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -104,7 +104,7 @@ class Publisher : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE /** - * This type represents the callback function pointer used to notify when a "DNS/SRP Service" entry is added to or + * Represents the callback function pointer used to notify when a "DNS/SRP Service" entry is added to or * removed from the Thread Network Data. * * On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there @@ -115,7 +115,7 @@ class Publisher : public InstanceLocator, private NonCopyable typedef otNetDataDnsSrpServicePublisherCallback DnsSrpServiceCallback; /** - * This method sets a callback for notifying when a published "DNS/SRP Service" is actually added to or removed + * Sets a callback for notifying when a published "DNS/SRP Service" is actually added to or removed * from the Thread Network Data. * * A subsequent call to this method replaces any previously set callback function. @@ -130,7 +130,7 @@ class Publisher : public InstanceLocator, private NonCopyable } /** - * This method requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data. * * A call to this method will remove and replace any previous "DNS/SRP Service" entry that was being published * (from earlier call to any of `PublishDnsSrpService{Type}()` methods). @@ -141,12 +141,12 @@ class Publisher : public InstanceLocator, private NonCopyable void PublishDnsSrpServiceAnycast(uint8_t aSequenceNumber) { mDnsSrpServiceEntry.PublishAnycast(aSequenceNumber); } /** - * This method requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. * * A call to this method will remove and replace any previous "DNS/SRP Service" entry that was being published * (from earlier call to any of `PublishDnsSrpService{Type}()` methods). * - * This method publishes the "DNS/SRP Service Unicast Address" by including the address and port info in the + * Publishes the "DNS/SRP Service Unicast Address" by including the address and port info in the * Service TLV data. * * @param[in] aAddress The DNS/SRP server address to publish. @@ -159,7 +159,7 @@ class Publisher : public InstanceLocator, private NonCopyable } /** - * This method requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. + * Requests "DNS/SRP Service Unicast Address" to be published in the Thread Network Data. * * A call to this method will remove and replace any previous "DNS/SRP Service" entry that was being published * (from earlier call to any of `PublishDnsSrpService{Type}()` methods). @@ -174,7 +174,7 @@ class Publisher : public InstanceLocator, private NonCopyable void PublishDnsSrpServiceUnicast(uint16_t aPort) { mDnsSrpServiceEntry.PublishUnicast(aPort); } /** - * This method indicates whether or not currently the "DNS/SRP Service" entry is added to the Thread Network Data. + * Indicates whether or not currently the "DNS/SRP Service" entry is added to the Thread Network Data. * * @retval TRUE The published DNS/SRP Service entry is added to the Thread Network Data. * @retval FALSE The entry is not added to Thread Network Data or there is no entry to publish. @@ -183,7 +183,7 @@ class Publisher : public InstanceLocator, private NonCopyable bool IsDnsSrpServiceAdded(void) const { return mDnsSrpServiceEntry.IsAdded(); } /** - * This method unpublishes any previously added "DNS/SRP (Anycast or Unicast) Service" entry from the Thread + * Unpublishes any previously added "DNS/SRP (Anycast or Unicast) Service" entry from the Thread * Network Data. * */ @@ -193,7 +193,7 @@ class Publisher : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE /** - * This type represents the callback function pointer used to notify when a prefix (on-mesh or external route) + * Represents the callback function pointer used to notify when a prefix (on-mesh or external route) * entry is added to or removed from the Thread Network Data. * * On remove the callback is invoked independent of whether the entry is removed by `Publisher` (e.g., when there @@ -204,7 +204,7 @@ class Publisher : public InstanceLocator, private NonCopyable typedef otNetDataPrefixPublisherCallback PrefixCallback; /** - * This method sets a callback for notifying when a published prefix entry is actually added to or removed from + * Sets a callback for notifying when a published prefix entry is actually added to or removed from * the Thread Network Data. * * A subsequent call to this method replaces any previously set callback function. @@ -216,7 +216,7 @@ class Publisher : public InstanceLocator, private NonCopyable void SetPrefixCallback(PrefixCallback aCallback, void *aContext) { mPrefixCallback.Set(aCallback, aContext); } /** - * This method requests an on-mesh prefix to be published in the Thread Network Data. + * Requests an on-mesh prefix to be published in the Thread Network Data. * * Only stable entries can be published (i.e.,`aConfig.mStable` MUST be `true`). * @@ -242,7 +242,7 @@ class Publisher : public InstanceLocator, private NonCopyable Error PublishOnMeshPrefix(const OnMeshPrefixConfig &aConfig, Requester aRequester); /** - * This method requests an external route prefix to be published in the Thread Network Data. + * Requests an external route prefix to be published in the Thread Network Data. * * Only stable entries can be published (i.e.,`aConfig.mStable` MUST be `true`). * @@ -267,7 +267,7 @@ class Publisher : public InstanceLocator, private NonCopyable Error PublishExternalRoute(const ExternalRouteConfig &aConfig, Requester aRequester); /** - * This method replaces a previously published external route. + * Replaces a previously published external route. * * Only stable entries can be published (i.e.,`aConfig.mStable` MUST be `true`). * @@ -304,7 +304,7 @@ class Publisher : public InstanceLocator, private NonCopyable Requester aRequester); /** - * This method indicates whether or not currently a published prefix entry (on-mesh or external route) is added to + * Indicates whether or not currently a published prefix entry (on-mesh or external route) is added to * the Thread Network Data. * * @param[in] aPrefix The prefix to check. @@ -316,7 +316,7 @@ class Publisher : public InstanceLocator, private NonCopyable bool IsPrefixAdded(const Ip6::Prefix &aPrefix) const; /** - * This method unpublishes a previously published prefix (on-mesh or external route). + * Unpublishes a previously published prefix (on-mesh or external route). * * @param[in] aPrefix The prefix to unpublish. * diff --git a/src/core/thread/network_data_service.hpp b/src/core/thread/network_data_service.hpp index 5dec83a69b9..aea859a9743 100644 --- a/src/core/thread/network_data_service.hpp +++ b/src/core/thread/network_data_service.hpp @@ -58,7 +58,7 @@ const uint32_t kThreadEnterpriseNumber = ServiceTlv::kThreadEnterpriseNumber; // #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) /** - * This type implements Thread Network Data "Backbone Router Service" server data generation and parsing. + * Implements Thread Network Data "Backbone Router Service" server data generation and parsing. * */ class BackboneRouter @@ -74,7 +74,7 @@ class BackboneRouter static constexpr uint8_t kServiceDataMinSize = 1; /** - * This class implements the generation and parsing of "Backbone Router Service" server data. + * Implements the generation and parsing of "Backbone Router Service" server data. * */ OT_TOOL_PACKED_BEGIN @@ -82,7 +82,7 @@ class BackboneRouter { public: /** - * This method returns the length (in bytes) of server data. + * Returns the length (in bytes) of server data. * * @returns The server data length in bytes. * @@ -90,7 +90,7 @@ class BackboneRouter uint8_t GetLength(void) const { return sizeof(ServerData); } /** - * This method returns the sequence number of Backbone Router. + * Returns the sequence number of Backbone Router. * * @returns The sequence number of the Backbone Router. * @@ -98,7 +98,7 @@ class BackboneRouter uint8_t GetSequenceNumber(void) const { return mSequenceNumber; } /** - * This method sets the sequence number of Backbone Router. + * Sets the sequence number of Backbone Router. * * @param[in] aSequenceNumber The sequence number of Backbone Router. * @@ -106,7 +106,7 @@ class BackboneRouter void SetSequenceNumber(uint8_t aSequenceNumber) { mSequenceNumber = aSequenceNumber; } /** - * This method returns the Registration Delay (in seconds) of Backbone Router. + * Returns the Registration Delay (in seconds) of Backbone Router. * * @returns The BBR Registration Delay (in seconds) of Backbone Router. * @@ -114,7 +114,7 @@ class BackboneRouter uint16_t GetReregistrationDelay(void) const { return HostSwap16(mReregistrationDelay); } /** - * This method sets the Registration Delay (in seconds) of Backbone Router. + * Sets the Registration Delay (in seconds) of Backbone Router. * * @param[in] aReregistrationDelay The Registration Delay (in seconds) of Backbone Router. * @@ -125,7 +125,7 @@ class BackboneRouter } /** - * This method returns the multicast listener report timeout (in seconds) of Backbone Router. + * Returns the multicast listener report timeout (in seconds) of Backbone Router. * * @returns The multicast listener report timeout (in seconds) of Backbone Router. * @@ -133,7 +133,7 @@ class BackboneRouter uint32_t GetMlrTimeout(void) const { return HostSwap32(mMlrTimeout); } /** - * This method sets multicast listener report timeout (in seconds) of Backbone Router. + * Sets multicast listener report timeout (in seconds) of Backbone Router. * * @param[in] aMlrTimeout The multicast listener report timeout (in seconds) of Backbone Router. * @@ -152,7 +152,7 @@ class BackboneRouter #endif // #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) /** - * This type implements Thread Network Data "DNS/SRP Service Anycast Address" generation and parsing. + * Implements Thread Network Data "DNS/SRP Service Anycast Address" generation and parsing. * */ class DnsSrpAnycast @@ -169,7 +169,7 @@ class DnsSrpAnycast static const uint8_t kServiceData = kServiceNumber; /** - * This structure represents information about an DNS/SRP server parsed from related Network Data service entries. + * Represents information about an DNS/SRP server parsed from related Network Data service entries. * */ struct Info @@ -179,7 +179,7 @@ class DnsSrpAnycast }; /** - * This class represents the "DNS/SRP Service (Anycast)" service data. + * Represents the "DNS/SRP Service (Anycast)" service data. * */ OT_TOOL_PACKED_BEGIN @@ -187,7 +187,7 @@ class DnsSrpAnycast { public: /** - * This constructor initializes the `ServiceData` object. + * Initializes the `ServiceData` object. * * @param[in] aSequenceNumber The sequence number of "DNS/SRP server" service. * @@ -200,7 +200,7 @@ class DnsSrpAnycast } /** - * This method returns the length (in bytes) of service data. + * Returns the length (in bytes) of service data. * * @returns The data length in bytes. * @@ -208,7 +208,7 @@ class DnsSrpAnycast uint8_t GetLength(void) const { return sizeof(ServiceData); } /** - * This method returns the sequence number. + * Returns the sequence number. * * @returns The sequence number. * @@ -224,7 +224,7 @@ class DnsSrpAnycast }; /** - * This type implements Thread Network Data DNS/SRP Service (Unicast Address) generation and parsing. + * Implements Thread Network Data DNS/SRP Service (Unicast Address) generation and parsing. * */ class DnsSrpUnicast @@ -241,7 +241,7 @@ class DnsSrpUnicast static const uint8_t kServiceData = kServiceNumber; /** - * This enumeration represents the origin a `DnsSrpUnicast` entry. + * Represents the origin a `DnsSrpUnicast` entry. * */ enum Origin : uint8_t @@ -251,7 +251,7 @@ class DnsSrpUnicast }; /** - * This structure represents information about an DNS/SRP server parsed from related Network Data service entries. + * Represents information about an DNS/SRP server parsed from related Network Data service entries. * */ struct Info @@ -262,7 +262,7 @@ class DnsSrpUnicast }; /** - * This class represents long version of "DNS/SRP Service (Unicast)" service data. + * Represents long version of "DNS/SRP Service (Unicast)" service data. * */ OT_TOOL_PACKED_BEGIN @@ -270,7 +270,7 @@ class DnsSrpUnicast { public: /** - * This constructor initializes the `ServiceData` object. + * Initializes the `ServiceData` object. * * @param[in] aAddress The IPv6 address of DNS/SRP server. * @param[in] aPort The port number of DNS/SRP server. @@ -285,7 +285,7 @@ class DnsSrpUnicast } /** - * This method returns the length (in bytes) of service data. + * Returns the length (in bytes) of service data. * * @returns The data length in bytes. * @@ -293,7 +293,7 @@ class DnsSrpUnicast uint8_t GetLength(void) const { return sizeof(ServiceData); } /** - * This method returns the IPv6 address. + * Returns the IPv6 address. * * @returns The IPv6 address * @@ -301,7 +301,7 @@ class DnsSrpUnicast const Ip6::Address &GetAddress(void) const { return mAddress; } /** - * This method returns the port number. + * Returns the port number. * * @returns The port number. * @@ -315,7 +315,7 @@ class DnsSrpUnicast } OT_TOOL_PACKED_END; /** - * This class represents long version of "DNS/SRP Service (Unicast)" server data. + * Represents long version of "DNS/SRP Service (Unicast)" server data. * */ OT_TOOL_PACKED_BEGIN @@ -323,7 +323,7 @@ class DnsSrpUnicast { public: /** - * This constructor initializes the `ServerData` object. + * Initializes the `ServerData` object. * * @param[in] aAddress The IPv6 address of DNS/SRP server. * @param[in] aPort The port number of DNS/SRP server. @@ -336,7 +336,7 @@ class DnsSrpUnicast } /** - * This method returns the length (in bytes) of server data. + * Returns the length (in bytes) of server data. * * @returns The data length in bytes. * @@ -344,7 +344,7 @@ class DnsSrpUnicast uint8_t GetLength(void) const { return sizeof(ServerData); } /** - * This method returns the IPv6 address. + * Returns the IPv6 address. * * @returns The IPv6 address * @@ -352,7 +352,7 @@ class DnsSrpUnicast const Ip6::Address &GetAddress(void) const { return mAddress; } /** - * This method returns the port number. + * Returns the port number. * * @returns The port number. * @@ -368,14 +368,14 @@ class DnsSrpUnicast }; /** - * This class manages the Thread Service entries in Thread Network Data. + * Manages the Thread Service entries in Thread Network Data. * */ class Manager : public InstanceLocator, private NonCopyable { public: /** - * This class represents an iterator used to iterate through Network Data Service entries. + * Represents an iterator used to iterate through Network Data Service entries. * */ class Iterator : public Clearable @@ -384,7 +384,7 @@ class Manager : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the iterator (as empty/clear). + * Initializes the iterator (as empty/clear). * */ Iterator(void) @@ -394,7 +394,7 @@ class Manager : public InstanceLocator, private NonCopyable } /** - * This method resets the iterator to start from beginning. + * Resets the iterator to start from beginning. * */ void Reset(void) @@ -409,7 +409,7 @@ class Manager : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `Manager` object. + * Initializes the `Manager` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -421,7 +421,7 @@ class Manager : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE /** - * This method adds a Thread Service entry to the local Thread Network Data. + * Adds a Thread Service entry to the local Thread Network Data. * * This version of `Add()` is intended for use with a `ServiceType` that has a constant service data * format with a non-empty and potentially non-const server data format (provided as input parameter). @@ -448,7 +448,7 @@ class Manager : public InstanceLocator, private NonCopyable } /** - * This method adds a Thread Service entry to the local Thread Network Data. + * Adds a Thread Service entry to the local Thread Network Data. * * This version of `Add()` is intended for use with a `ServiceType` that has a non-const service data * format (provided as input parameter) with an empty server data. @@ -473,7 +473,7 @@ class Manager : public InstanceLocator, private NonCopyable } /** - * This method removes a Thread Service entry from the local Thread Network Data. + * Removes a Thread Service entry from the local Thread Network Data. * * This version of `Remove()` is intended for use with a `ServiceType` that has a constant service data * format. @@ -493,7 +493,7 @@ class Manager : public InstanceLocator, private NonCopyable } /** - * This method removes a Thread Service entry from the local Thread Network Data. + * Removes a Thread Service entry from the local Thread Network Data. * * This version of `Remove()` is intended for use with a `ServiceType` that has a non-const service * data format (provided as input parameter). @@ -518,7 +518,7 @@ class Manager : public InstanceLocator, private NonCopyable #endif // OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE /** - * This method gets the Service ID for the specified service from Thread Network Data. + * Gets the Service ID for the specified service from Thread Network Data. * * The template type `ServiceType` has the following requirements: * - It MUST have a constant `ServiceType::kServiceNumber` specifying the service number. @@ -539,7 +539,7 @@ class Manager : public InstanceLocator, private NonCopyable #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) /** - * This method gets the Primary Backbone Router (PBBR) in the Thread Network Data. + * Gets the Primary Backbone Router (PBBR) in the Thread Network Data. * * @param[out] aConfig The Primary Backbone Router configuration. * @@ -548,7 +548,7 @@ class Manager : public InstanceLocator, private NonCopyable #endif /** - * This method gets the next DNS/SRP info from the Thread Network Data "DNS/SRP Service Anycast Address" entries. + * Gets the next DNS/SRP info from the Thread Network Data "DNS/SRP Service Anycast Address" entries. * * To get the first entry, @p aIterator should be cleared (e.g., a new instance of `Iterator` or calling `Clear()` * method). @@ -563,7 +563,7 @@ class Manager : public InstanceLocator, private NonCopyable Error GetNextDnsSrpAnycastInfo(Iterator &aIterator, DnsSrpAnycast::Info &aInfo) const; /** - * This method finds the preferred DNS/SRP info among all the Thread Network Data "DNS/SRP Service Anycast Address" + * Finds the preferred DNS/SRP info among all the Thread Network Data "DNS/SRP Service Anycast Address" * entries. * * The preferred entry is determined based on the sequence number value where a larger value (in the sense @@ -578,7 +578,7 @@ class Manager : public InstanceLocator, private NonCopyable Error FindPreferredDnsSrpAnycastInfo(DnsSrpAnycast::Info &aInfo) const; /** - * This method gets the next DNS/SRP info from the Thread Network Data "DNS/SRP Service Unicast Address" entries. + * Gets the next DNS/SRP info from the Thread Network Data "DNS/SRP Service Unicast Address" entries. * * To get the first entry @p aIterator should be cleared (e.g., a new instance of `Iterator` or calling `Clear()` * method). diff --git a/src/core/thread/network_data_tlvs.hpp b/src/core/thread/network_data_tlvs.hpp index 443d1e1ba2d..b93a97bac11 100644 --- a/src/core/thread/network_data_tlvs.hpp +++ b/src/core/thread/network_data_tlvs.hpp @@ -64,7 +64,7 @@ using ot::Encoding::BigEndian::HostSwap32; class NetworkDataTlv; /** - * This template method casts a `NetworkDataTlv` pointer to a given subclass `TlvType` pointer. + * Casts a `NetworkDataTlv` pointer to a given subclass `TlvType` pointer. * * @tparam TlvType The TLV type to cast into. MUST be a subclass of `NetworkDataTlv`. * @@ -76,7 +76,7 @@ class NetworkDataTlv; template TlvType *As(NetworkDataTlv *aTlv) { return static_cast(aTlv); } /** - * This template method casts a `NetworkDataTlv` pointer to a given subclass `TlvType` pointer. + * Casts a `NetworkDataTlv` pointer to a given subclass `TlvType` pointer. * * @tparam TlvType The TLV type to cast into. MUST be a subclass of `NetworkDataTlv`. * @@ -88,7 +88,7 @@ template TlvType *As(NetworkDataTlv *aTlv) { return static_cast< template const TlvType *As(const NetworkDataTlv *aTlv) { return static_cast(aTlv); } /** - * This template method casts a `NetworkDataTlv` reference to a given subclass `TlvType` reference. + * Casts a `NetworkDataTlv` reference to a given subclass `TlvType` reference. * * @tparam TlvType The TLV type to cast into. MUST be a subclass of `NetworkDataTlv`. * @@ -100,7 +100,7 @@ template const TlvType *As(const NetworkDataTlv *aTlv) { return template TlvType &As(NetworkDataTlv &aTlv) { return static_cast(aTlv); } /** - * This template method casts a `NetworkDataTlv` reference to a given subclass `TlvType` reference. + * Casts a `NetworkDataTlv` reference to a given subclass `TlvType` reference. * * @tparam TlvType The TLV type to cast into. MUST be a subclass of `NetworkDataTlv`. * @@ -112,7 +112,7 @@ template TlvType &As(NetworkDataTlv &aTlv) { return static_cast< template const TlvType &As(const NetworkDataTlv &aTlv) { return static_cast(aTlv); } /** - * This class implements Thread Network Data TLV generation and parsing. + * Implements Thread Network Data TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -135,7 +135,7 @@ class NetworkDataTlv }; /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -145,7 +145,7 @@ class NetworkDataTlv } /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -153,7 +153,7 @@ class NetworkDataTlv Type GetType(void) const { return static_cast(mType >> kTypeOffset); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -161,7 +161,7 @@ class NetworkDataTlv void SetType(Type aType) { mType = (mType & ~kTypeMask) | ((aType << kTypeOffset) & kTypeMask); } /** - * This method returns the Length value. + * Returns the Length value. * * @returns The Length value. * @@ -169,7 +169,7 @@ class NetworkDataTlv uint8_t GetLength(void) const { return mLength; } /** - * This method sets the Length value. + * Sets the Length value. * * @param[in] aLength The Length value. * @@ -177,7 +177,7 @@ class NetworkDataTlv void SetLength(uint8_t aLength) { mLength = aLength; } /** - * This methods increases the Length value by a given amount. + * Increases the Length value by a given amount. * * @param[in] aIncrement The increment amount to increase the length. * @@ -185,7 +185,7 @@ class NetworkDataTlv void IncreaseLength(uint8_t aIncrement) { mLength += aIncrement; } /** - * This methods decreases the Length value by a given amount. + * Decreases the Length value by a given amount. * * @param[in] aDecrement The decrement amount to decrease the length. * @@ -193,7 +193,7 @@ class NetworkDataTlv void DecreaseLength(uint8_t aDecrement) { mLength -= aDecrement; } /** - * This method returns the TLV's total size (number of bytes) including Type, Length, and Value fields. + * Returns the TLV's total size (number of bytes) including Type, Length, and Value fields. * * @returns The total size include Type, Length, and Value fields. * @@ -201,7 +201,7 @@ class NetworkDataTlv uint8_t GetSize(void) const { return sizeof(NetworkDataTlv) + mLength; } /** - * This method returns a pointer to the Value. + * Returns a pointer to the Value. * * @returns A pointer to the value. * @@ -209,7 +209,7 @@ class NetworkDataTlv uint8_t *GetValue(void) { return reinterpret_cast(this) + sizeof(NetworkDataTlv); } /** - * This method returns a pointer to the Value. + * Returns a pointer to the Value. * * @returns A pointer to the value. * @@ -217,7 +217,7 @@ class NetworkDataTlv const uint8_t *GetValue(void) const { return reinterpret_cast(this) + sizeof(NetworkDataTlv); } /** - * This method returns a pointer to the next Network Data TLV. + * Returns a pointer to the next Network Data TLV. * * @returns A pointer to the next Network Data TLV. * @@ -228,7 +228,7 @@ class NetworkDataTlv } /** - * This method returns a pointer to the next Network Data TLV. + * Returns a pointer to the next Network Data TLV. * * @returns A pointer to the next Network Data TLV. * @@ -240,13 +240,13 @@ class NetworkDataTlv } /** - * This method clears the Stable bit. + * Clears the Stable bit. * */ void ClearStable(void) { mType &= ~kStableMask; } /** - * This method indicates whether or not the Stable bit is set. + * Indicates whether or not the Stable bit is set. * * @retval TRUE If the Stable bit is set. * @retval FALSE If the Stable bit is not set. @@ -255,13 +255,13 @@ class NetworkDataTlv bool IsStable(void) const { return (mType & kStableMask); } /** - * This method sets the Stable bit. + * Sets the Stable bit. * */ void SetStable(void) { mType |= kStableMask; } /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given type. + * Searches in a given sequence of TLVs to find the first TLV with a given type. * * @param[in] aStart A pointer to the start of the sequence of TLVs to search within. * @param[in] aEnd A pointer to the end of the sequence of TLVs. @@ -276,7 +276,7 @@ class NetworkDataTlv } /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given type. + * Searches in a given sequence of TLVs to find the first TLV with a given type. * * @param[in] aStart A pointer to the start of the sequence of TLVs to search within. * @param[in] aEnd A pointer to the end of the sequence of TLVs. @@ -320,7 +320,7 @@ class NetworkDataTlv } /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given TLV type and stable + * Searches in a given sequence of TLVs to find the first TLV with a given TLV type and stable * flag. * * @param[in] aStart A pointer to the start of the sequence of TLVs to search within. @@ -337,7 +337,7 @@ class NetworkDataTlv } /** - * This static method searches in a given sequence of TLVs to find the first TLV with a given TLV type and stable + * Searches in a given sequence of TLVs to find the first TLV with a given TLV type and stable * flag. * * @param[in] aStart A pointer to the start of the sequence of TLVs to search within. @@ -400,7 +400,7 @@ class NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Has Route TLV entry generation and parsing. + * Implements Has Route TLV entry generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -410,7 +410,7 @@ class HasRouteEntry : public Equatable public: /** - * This method initializes the header. + * Initializes the header. * */ void Init(void) @@ -420,14 +420,14 @@ class HasRouteEntry : public Equatable } /** - * This method returns the RLOC16 value. + * Returns the RLOC16 value. * * @returns The RLOC16 value. */ uint16_t GetRloc(void) const { return HostSwap16(mRloc); } /** - * This method sets the RLOC16 value. + * Sets the RLOC16 value. * * @param[in] aRloc16 The RLOC16 value. * @@ -435,7 +435,7 @@ class HasRouteEntry : public Equatable void SetRloc(uint16_t aRloc16) { mRloc = HostSwap16(aRloc16); } /** - * This method returns the Preference value. + * Returns the Preference value. * * @returns The preference value. * @@ -443,7 +443,7 @@ class HasRouteEntry : public Equatable int8_t GetPreference(void) const { return PreferenceFromFlags(GetFlags()); } /** - * This method gets the Flags value. + * Gets the Flags value. * * @returns The Flags value. * @@ -451,7 +451,7 @@ class HasRouteEntry : public Equatable uint8_t GetFlags(void) const { return mFlags; } /** - * This method sets the Flags value. + * Sets the Flags value. * * @param[in] aFlags The Flags value. * @@ -459,7 +459,7 @@ class HasRouteEntry : public Equatable void SetFlags(uint8_t aFlags) { mFlags = aFlags; } /** - * This method indicates whether or not the NAT64 flag is set. + * Indicates whether or not the NAT64 flag is set. * * @retval TRUE If the NAT64 flag is set. * @retval FALSE If the NAT64 flag is not set. @@ -468,7 +468,7 @@ class HasRouteEntry : public Equatable bool IsNat64(void) const { return (mFlags & kNat64Flag) != 0; } /** - * This method returns a pointer to the next HasRouteEntry. + * Returns a pointer to the next HasRouteEntry. * * @returns A pointer to the next HasRouteEntry. * @@ -476,7 +476,7 @@ class HasRouteEntry : public Equatable HasRouteEntry *GetNext(void) { return (this + 1); } /** - * This method returns a pointer to the next HasRouteEntry. + * Returns a pointer to the next HasRouteEntry. * * @returns A pointer to the next HasRouteEntry. * @@ -484,7 +484,7 @@ class HasRouteEntry : public Equatable const HasRouteEntry *GetNext(void) const { return (this + 1); } /** - * This static method returns an updated flags bitmask by removing the preference bits (sets them to zero) from a + * Returns an updated flags bitmask by removing the preference bits (sets them to zero) from a * given flags bitmask. * * @param[in] aFlags The flags bitmask. @@ -495,7 +495,7 @@ class HasRouteEntry : public Equatable static uint8_t FlagsWithoutPreference(uint8_t aFlags) { return (aFlags & ~kPreferenceMask); } /** - * This static method gets the preference field from a flags bitmask. + * Gets the preference field from a flags bitmask. * * @param[in] aFlags The flags. * @@ -514,7 +514,7 @@ class HasRouteEntry : public Equatable } OT_TOOL_PACKED_END; /** - * This class implements Has Route TLV generation and parsing. + * Implements Has Route TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -524,7 +524,7 @@ class HasRouteTlv : public NetworkDataTlv static constexpr Type kType = kTypeHasRoute; ///< The TLV Type. /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -535,7 +535,7 @@ class HasRouteTlv : public NetworkDataTlv } /** - * This method returns the number of HasRoute entries. + * Returns the number of HasRoute entries. * * @returns The number of HasRoute entries. * @@ -543,7 +543,7 @@ class HasRouteTlv : public NetworkDataTlv uint8_t GetNumEntries(void) const { return GetLength() / sizeof(HasRouteEntry); } /** - * This method returns a pointer to the HasRoute entry at a given index. + * Returns a pointer to the HasRoute entry at a given index. * * @param[in] aIndex An index. * @@ -556,7 +556,7 @@ class HasRouteTlv : public NetworkDataTlv } /** - * This method returns a pointer to the HasRoute entry at a given index. + * Returns a pointer to the HasRoute entry at a given index. * * @param[in] aIndex An index. * @@ -569,7 +569,7 @@ class HasRouteTlv : public NetworkDataTlv } /** - * This method returns a pointer to the first HasRouteEntry (at index 0'th). + * Returns a pointer to the first HasRouteEntry (at index 0'th). * * @returns A pointer to the first HasRouteEntry. * @@ -577,7 +577,7 @@ class HasRouteTlv : public NetworkDataTlv HasRouteEntry *GetFirstEntry(void) { return reinterpret_cast(GetValue()); } /** - * This method returns a pointer to the first HasRouteEntry (at index 0'th). + * Returns a pointer to the first HasRouteEntry (at index 0'th). * * @returns A pointer to the first HasRouteEntry. * @@ -585,7 +585,7 @@ class HasRouteTlv : public NetworkDataTlv const HasRouteEntry *GetFirstEntry(void) const { return reinterpret_cast(GetValue()); } /** - * This method returns a pointer to the last HasRouteEntry. + * Returns a pointer to the last HasRouteEntry. * * If there are no entries the pointer will be invalid but guaranteed to be before the `GetFirstEntry()` pointer. * @@ -598,7 +598,7 @@ class HasRouteTlv : public NetworkDataTlv } /** - * This method returns a pointer to the last HasRouteEntry. + * Returns a pointer to the last HasRouteEntry. * * If there are no entries the pointer will be invalid but guaranteed to be before the `GetFirstEntry()` pointer. * @@ -613,7 +613,7 @@ class HasRouteTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Prefix TLV generation and parsing. + * Implements Prefix TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -623,7 +623,7 @@ class PrefixTlv : public NetworkDataTlv static constexpr Type kType = kTypePrefix; ///< The TLV Type. /** - * This method initializes the TLV. + * Initializes the TLV. * * @param[in] aDomainId The Domain ID. * @param[in] aPrefixLength The Prefix Length in bits. @@ -641,7 +641,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method initializes the TLV. + * Initializes the TLV. * * @param[in] aDomainId The Domain ID. * @param[in] aPrefix The Prefix. @@ -653,7 +653,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -667,7 +667,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method returns the Domain ID value. + * Returns the Domain ID value. * * @returns The Domain ID value. * @@ -675,7 +675,7 @@ class PrefixTlv : public NetworkDataTlv uint8_t GetDomainId(void) const { return mDomainId; } /** - * This method returns the Prefix Length value. + * Returns the Prefix Length value. * * @returns The Prefix Length value (in bits). * @@ -683,7 +683,7 @@ class PrefixTlv : public NetworkDataTlv uint8_t GetPrefixLength(void) const { return mPrefixLength; } /** - * This method returns a pointer to the Prefix. + * Returns a pointer to the Prefix. * * @returns A pointer to the Prefix. * @@ -691,7 +691,7 @@ class PrefixTlv : public NetworkDataTlv uint8_t *GetPrefix(void) { return reinterpret_cast(this) + sizeof(*this); } /** - * This method returns a pointer to the Prefix. + * Returns a pointer to the Prefix. * * @returns A pointer to the Prefix. * @@ -699,7 +699,7 @@ class PrefixTlv : public NetworkDataTlv const uint8_t *GetPrefix(void) const { return reinterpret_cast(this) + sizeof(*this); } /** - * This method copies the Prefix from TLV into a given `Ip6::Prefix`. + * Copies the Prefix from TLV into a given `Ip6::Prefix`. * * @param[out] aPrefix An `Ip6::Prefix` to copy the Prefix from TLV into. * @@ -707,7 +707,7 @@ class PrefixTlv : public NetworkDataTlv void CopyPrefixTo(Ip6::Prefix &aPrefix) const { aPrefix.Set(GetPrefix(), GetPrefixLength()); } /** - * This method indicates whether the Prefix from TLV is equal to a given `Ip6::Prefix`. + * Indicates whether the Prefix from TLV is equal to a given `Ip6::Prefix`. * * @param[in] aPrefix A Prefix to compare with. * @@ -718,7 +718,7 @@ class PrefixTlv : public NetworkDataTlv bool IsEqual(Ip6::Prefix &aPrefix) const { return aPrefix.IsEqual(GetPrefix(), GetPrefixLength()); } /** - * This method indicates whether the Prefix from TLV is equal to a given Prefix. + * Indicates whether the Prefix from TLV is equal to a given Prefix. * * @param[in] aPrefix A pointer to an IPv6 prefix to compare with. * @param[in] aPrefixLength The prefix length pointed to by @p aPrefix (in bits). @@ -735,7 +735,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method returns a pointer to the Sub-TLVs. + * Returns a pointer to the Sub-TLVs. * * @returns A pointer to the Sub-TLVs. * @@ -746,7 +746,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method returns a pointer to the Sub-TLVs. + * Returns a pointer to the Sub-TLVs. * * @returns A pointer to the Sub-TLVs. * @@ -757,7 +757,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method returns the Sub-TLVs length in bytes. + * Returns the Sub-TLVs length in bytes. * * @returns The Sub-TLVs length in bytes. * @@ -768,7 +768,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method sets the Sub-TLVs length in bytes. + * Sets the Sub-TLVs length in bytes. * * @param[in] aLength The Sub-TLVs length in bytes. * @@ -779,7 +779,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This template method searches in the sub-TLVs to find the first one matching a given TLV type. + * Searches in the sub-TLVs to find the first one matching a given TLV type. * * @tparam SubTlvType The sub-TLV type to search for (MUST be a sub-class of `NetworkDataTlv`). * @@ -792,7 +792,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This template method searches in the sub-TLVs to find the first one matching a given TLV Type. + * Searches in the sub-TLVs to find the first one matching a given TLV Type. * * @tparam SubTlvType The sub-TLV type to search for (MUST be a sub-class of `NetworkDataTlv`). * @@ -805,7 +805,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This template method searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. + * Searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. * * @tparam SubTlvType The sub-TLV type to search for (MUST be a sub-class of `NetworkDataTlv`). * @@ -820,7 +820,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This template method searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. + * Searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. * * @tparam SubTlvType The sub-TLV type to search for (MUST be a sub-class of `NetworkDataTlv`). * @@ -835,7 +835,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method searches in the sub-TLVs to find the first one matching a given TLV type. + * Searches in the sub-TLVs to find the first one matching a given TLV type. * * @param[in] aType The sub-TLV type to search for. * @@ -845,7 +845,7 @@ class PrefixTlv : public NetworkDataTlv NetworkDataTlv *FindSubTlv(Type aType) { return AsNonConst(AsConst(this)->FindSubTlv(aType)); } /** - * This method searches in the sub-TLVs to find the first one matching a given TLV type. + * Searches in the sub-TLVs to find the first one matching a given TLV type. * * @param[in] aType The sub-TLV type to search for. * @@ -855,7 +855,7 @@ class PrefixTlv : public NetworkDataTlv const NetworkDataTlv *FindSubTlv(Type aType) const; /** - * This method searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. + * Searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. * * @param[in] aType The sub-TLV type to search for. * @param[in] aStable TRUE to find a stable TLV, FALSE to find a TLV not marked as stable. @@ -869,7 +869,7 @@ class PrefixTlv : public NetworkDataTlv } /** - * This method searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. + * Searches in the sub-TLVs to find the first one matching a given TLV type and stable flag. * * @param[in] aType The sub-TLV type to search for. * @param[in] aStable TRUE to find a stable TLV, FALSE to find a TLV not marked as stable. @@ -880,7 +880,7 @@ class PrefixTlv : public NetworkDataTlv const NetworkDataTlv *FindSubTlv(Type aType, bool aStable) const; /** - * This static method calculates the total size (number of bytes) of a Prefix TLV with a given Prefix Length value. + * Calculates the total size (number of bytes) of a Prefix TLV with a given Prefix Length value. * * Note that the returned size does include the Type and Length fields in the TLV, but does not account for any * sub TLVs of the Prefix TLV. @@ -901,7 +901,7 @@ class PrefixTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Border Router Entry generation and parsing. + * Implements Border Router Entry generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -911,7 +911,7 @@ class BorderRouterEntry : public Equatable public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -921,14 +921,14 @@ class BorderRouterEntry : public Equatable } /** - * This method returns the RLOC16 value. + * Returns the RLOC16 value. * * @returns The RLOC16 value. */ uint16_t GetRloc(void) const { return HostSwap16(mRloc); } /** - * This method sets the RLOC16 value. + * Sets the RLOC16 value. * * @param[in] aRloc16 The RLOC16 value. * @@ -936,7 +936,7 @@ class BorderRouterEntry : public Equatable void SetRloc(uint16_t aRloc16) { mRloc = HostSwap16(aRloc16); } /** - * This method returns the Flags value. + * Returns the Flags value. * * @returns The Flags value. * @@ -944,7 +944,7 @@ class BorderRouterEntry : public Equatable uint16_t GetFlags(void) const { return HostSwap16(mFlags); } /** - * This method sets the Flags value. + * Sets the Flags value. * * @param[in] aFlags The Flags value. * @@ -952,7 +952,7 @@ class BorderRouterEntry : public Equatable void SetFlags(uint16_t aFlags) { mFlags = HostSwap16(aFlags); } /** - * This method returns the Preference value. + * Returns the Preference value. * * @returns the Preference value. * @@ -960,7 +960,7 @@ class BorderRouterEntry : public Equatable int8_t GetPreference(void) const { return PreferenceFromFlags(GetFlags()); } /** - * This method indicates whether or not the Preferred flag is set. + * Indicates whether or not the Preferred flag is set. * * @retval TRUE If the Preferred flag is set. * @retval FALSE If the Preferred flag is not set. @@ -969,7 +969,7 @@ class BorderRouterEntry : public Equatable bool IsPreferred(void) const { return (HostSwap16(mFlags) & kPreferredFlag) != 0; } /** - * This method indicates whether or not the SLAAC flag is set. + * Indicates whether or not the SLAAC flag is set. * * @retval TRUE If the SLAAC flag is set. * @retval FALSE If the SLAAC flag is not set. @@ -978,7 +978,7 @@ class BorderRouterEntry : public Equatable bool IsSlaac(void) const { return (HostSwap16(mFlags) & kSlaacFlag) != 0; } /** - * This method indicates whether or not the DHCP flag is set. + * Indicates whether or not the DHCP flag is set. * * @retval TRUE If the DHCP flag is set. * @retval FALSE If the DHCP flag is not set. @@ -987,7 +987,7 @@ class BorderRouterEntry : public Equatable bool IsDhcp(void) const { return (HostSwap16(mFlags) & kDhcpFlag) != 0; } /** - * This method indicates whether or not the Configure flag is set. + * Indicates whether or not the Configure flag is set. * * @retval TRUE If the Configure flag is set. * @retval FALSE If the Configure flag is not set. @@ -996,7 +996,7 @@ class BorderRouterEntry : public Equatable bool IsConfigure(void) const { return (HostSwap16(mFlags) & kConfigureFlag) != 0; } /** - * This method indicates whether or not the Default Route flag is set. + * Indicates whether or not the Default Route flag is set. * * @retval TRUE If the Default Route flag is set. * @retval FALSE If the Default Route flag is not set. @@ -1005,7 +1005,7 @@ class BorderRouterEntry : public Equatable bool IsDefaultRoute(void) const { return (HostSwap16(mFlags) & kDefaultRouteFlag) != 0; } /** - * This method indicates whether or not the On-Mesh flag is set. + * Indicates whether or not the On-Mesh flag is set. * * @retval TRUE If the On-Mesh flag is set. * @retval FALSE If the On-Mesh flag is not set. @@ -1014,7 +1014,7 @@ class BorderRouterEntry : public Equatable bool IsOnMesh(void) const { return (HostSwap16(mFlags) & kOnMeshFlag) != 0; } /** - * This method indicates whether or not the Nd-Dns flag is set. + * Indicates whether or not the Nd-Dns flag is set. * * @retval TRUE If the Nd-Dns flag is set. * @retval FALSE If the Nd-Dns flag is not set. @@ -1023,7 +1023,7 @@ class BorderRouterEntry : public Equatable bool IsNdDns(void) const { return (HostSwap16(mFlags) & kNdDnsFlag) != 0; } /** - * This method indicates whether or not the Domain Prefix flag is set. + * Indicates whether or not the Domain Prefix flag is set. * * @retval TRUE If the Domain Prefix flag is set. * @retval FALSE If the Domain Prefix flag is not set. @@ -1032,7 +1032,7 @@ class BorderRouterEntry : public Equatable bool IsDp(void) const { return (HostSwap16(mFlags) & kDpFlag) != 0; } /** - * This method returns a pointer to the next BorderRouterEntry + * Returns a pointer to the next BorderRouterEntry * * @returns A pointer to the next BorderRouterEntry. * @@ -1040,7 +1040,7 @@ class BorderRouterEntry : public Equatable BorderRouterEntry *GetNext(void) { return (this + 1); } /** - * This method returns a pointer to the next BorderRouterEntry + * Returns a pointer to the next BorderRouterEntry * * @returns A pointer to the next BorderRouterEntry. * @@ -1048,7 +1048,7 @@ class BorderRouterEntry : public Equatable const BorderRouterEntry *GetNext(void) const { return (this + 1); } /** - * This static method returns an updated flags bitmask by removing the preference bits (sets them to zero) from a + * Returns an updated flags bitmask by removing the preference bits (sets them to zero) from a * given flags bitmask. * * @param[in] aFlags The flags bitmask. @@ -1059,7 +1059,7 @@ class BorderRouterEntry : public Equatable static uint16_t FlagsWithoutPreference(uint16_t aFlags) { return (aFlags & ~kPreferenceMask); } /** - * This static method gets the preference field from a flags bitmask. + * Gets the preference field from a flags bitmask. * * @param[in] aFlags The flags. * @@ -1088,7 +1088,7 @@ class BorderRouterEntry : public Equatable } OT_TOOL_PACKED_END; /** - * This class implements Border Router TLV generation and parsing. + * Implements Border Router TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1098,7 +1098,7 @@ class BorderRouterTlv : public NetworkDataTlv static constexpr Type kType = kTypeBorderRouter; ///< The TLV Type. /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1109,7 +1109,7 @@ class BorderRouterTlv : public NetworkDataTlv } /** - * This method returns the number of Border Router entries. + * Returns the number of Border Router entries. * * @returns The number of Border Router entries. * @@ -1117,7 +1117,7 @@ class BorderRouterTlv : public NetworkDataTlv uint8_t GetNumEntries(void) const { return GetLength() / sizeof(BorderRouterEntry); } /** - * This method returns a pointer to the Border Router entry at a given index + * Returns a pointer to the Border Router entry at a given index * * @param[in] aIndex The index. * @@ -1130,7 +1130,7 @@ class BorderRouterTlv : public NetworkDataTlv } /** - * This method returns a pointer to the Border Router entry at a given index. + * Returns a pointer to the Border Router entry at a given index. * * @param[in] aIndex The index. * @@ -1143,7 +1143,7 @@ class BorderRouterTlv : public NetworkDataTlv } /** - * This method returns a pointer to the first BorderRouterEntry (at index 0'th). + * Returns a pointer to the first BorderRouterEntry (at index 0'th). * * @returns A pointer to the first BorderRouterEntry. * @@ -1151,7 +1151,7 @@ class BorderRouterTlv : public NetworkDataTlv BorderRouterEntry *GetFirstEntry(void) { return reinterpret_cast(GetValue()); } /** - * This method returns a pointer to the first BorderRouterEntry (at index 0'th). + * Returns a pointer to the first BorderRouterEntry (at index 0'th). * * @returns A pointer to the first BorderRouterEntry. * @@ -1162,7 +1162,7 @@ class BorderRouterTlv : public NetworkDataTlv } /** - * This method returns a pointer to the last BorderRouterEntry. + * Returns a pointer to the last BorderRouterEntry. * * If there are no entries the pointer will be invalid but guaranteed to be before the `GetFirstEntry()` pointer. * @@ -1175,7 +1175,7 @@ class BorderRouterTlv : public NetworkDataTlv } /** - * This method returns a pointer to the last BorderRouterEntry. + * Returns a pointer to the last BorderRouterEntry. * * If there are no entries the pointer will be invalid but guaranteed to be before the `GetFirstEntry()` pointer. * @@ -1190,7 +1190,7 @@ class BorderRouterTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Context TLV generation and processing. + * Implements Context TLV generation and processing. * */ OT_TOOL_PACKED_BEGIN @@ -1200,7 +1200,7 @@ class ContextTlv : public NetworkDataTlv static constexpr Type kType = kTypeContext; ///< The TLV Type. /** - * This method initializes the Context TLV. + * Initializes the Context TLV. * * @param[in] aContextId The Context ID value. * @param[in] aContextLength The Context Length value. @@ -1216,7 +1216,7 @@ class ContextTlv : public NetworkDataTlv } /** - * This method indicates whether or not the Compress flag is set. + * Indicates whether or not the Compress flag is set. * * @retval TRUE The Compress flag is set. * @retval FALSE The Compress flags is not set. @@ -1225,19 +1225,19 @@ class ContextTlv : public NetworkDataTlv bool IsCompress(void) const { return (mFlags & kCompressFlag) != 0; } /** - * This method clears the Compress flag. + * Clears the Compress flag. * */ void ClearCompress(void) { mFlags &= ~kCompressFlag; } /** - * This method sets the Compress flag. + * Sets the Compress flag. * */ void SetCompress(void) { mFlags |= kCompressFlag; } /** - * This method returns the Context ID value. + * Returns the Context ID value. * * @returns The Context ID value. * @@ -1245,7 +1245,7 @@ class ContextTlv : public NetworkDataTlv uint8_t GetContextId(void) const { return mFlags & kContextIdMask; } /** - * This method returns the Context Length value. + * Returns the Context Length value. * * @returns The Context Length value. * @@ -1262,7 +1262,7 @@ class ContextTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Commissioning Data TLV generation and parsing. + * Implements Commissioning Data TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1272,7 +1272,7 @@ class CommissioningDataTlv : public NetworkDataTlv static constexpr Type kType = kTypeCommissioningData; ///< The TLV Type. /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -1284,7 +1284,7 @@ class CommissioningDataTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Service Data TLV generation and parsing. + * Implements Service Data TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1296,7 +1296,7 @@ class ServiceTlv : public NetworkDataTlv static constexpr uint32_t kThreadEnterpriseNumber = 44970; ///< Thread enterprise number. /** - * This method initializes the TLV. + * Initializes the TLV. * * @param[in] aServiceId The Service Id value. * @param[in] aEnterpriseNumber The Enterprise Number. @@ -1306,7 +1306,7 @@ class ServiceTlv : public NetworkDataTlv void Init(uint8_t aServiceId, uint32_t aEnterpriseNumber, const ServiceData &aServiceData); /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1323,7 +1323,7 @@ class ServiceTlv : public NetworkDataTlv } /** - * This method returns the Service ID. It is in range 0x00-0x0f. + * Returns the Service ID. It is in range 0x00-0x0f. * * @returns the Service ID. * @@ -1331,7 +1331,7 @@ class ServiceTlv : public NetworkDataTlv uint8_t GetServiceId(void) const { return (mFlagsServiceId & kServiceIdMask); } /** - * This method returns Enterprise Number field. + * Returns Enterprise Number field. * * @returns The Enterprise Number. * @@ -1343,7 +1343,7 @@ class ServiceTlv : public NetworkDataTlv } /** - * This method gets the Service Data. + * Gets the Service Data. * * @param[out] aServiceData A reference to a`ServiceData` to return the data. * @@ -1354,7 +1354,7 @@ class ServiceTlv : public NetworkDataTlv } /** - * This method gets Service Data length. + * Gets Service Data length. * * @returns length of the Service Data field in bytes. * @@ -1365,7 +1365,7 @@ class ServiceTlv : public NetworkDataTlv } /** - * This method returns the Sub-TLVs length in bytes. + * Returns the Sub-TLVs length in bytes. * * @returns The Sub-TLVs length in bytes. * @@ -1373,7 +1373,7 @@ class ServiceTlv : public NetworkDataTlv uint8_t GetSubTlvsLength(void) { return GetLength() - GetFieldsLength(); } /** - * This method sets the Sub-TLVs length in bytes. + * Sets the Sub-TLVs length in bytes. * * @param[in] aLength The Sub-TLVs length in bytes. * @@ -1381,7 +1381,7 @@ class ServiceTlv : public NetworkDataTlv void SetSubTlvsLength(uint8_t aLength) { SetLength(GetFieldsLength() + aLength); } /** - * This method returns a pointer to the Sub-TLVs. + * Returns a pointer to the Sub-TLVs. * * @returns A pointer to the Sub-TLVs. * @@ -1389,7 +1389,7 @@ class ServiceTlv : public NetworkDataTlv NetworkDataTlv *GetSubTlvs(void) { return reinterpret_cast(GetValue() + GetFieldsLength()); } /** - * This method returns a pointer to the Sub-TLVs. + * Returns a pointer to the Sub-TLVs. * * @returns A pointer to the Sub-TLVs. * @@ -1400,7 +1400,7 @@ class ServiceTlv : public NetworkDataTlv } /** - * This static method calculates the total size (number of bytes) of a Service TLV with a given Enterprise Number + * Calculates the total size (number of bytes) of a Service TLV with a given Enterprise Number * and Service Data length. * * Note that the returned size does include the Type and Length fields in the TLV, but does not account for any @@ -1455,7 +1455,7 @@ class ServiceTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class implements Server Data TLV generation and parsing. + * Implements Server Data TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -1465,7 +1465,7 @@ class ServerTlv : public NetworkDataTlv static constexpr Type kType = kTypeServer; ///< The TLV Type. /** - * This method initializes the Server TLV. + * Initializes the Server TLV. * * @param[in] aServer16 The Server16 value. * @param[in] aServerData The Server Data. @@ -1481,7 +1481,7 @@ class ServerTlv : public NetworkDataTlv } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -1490,7 +1490,7 @@ class ServerTlv : public NetworkDataTlv bool IsValid(void) const { return GetLength() >= (sizeof(*this) - sizeof(NetworkDataTlv)); } /** - * This method returns the Server16 value. + * Returns the Server16 value. * * @returns The Server16 value. * @@ -1498,7 +1498,7 @@ class ServerTlv : public NetworkDataTlv uint16_t GetServer16(void) const { return HostSwap16(mServer16); } /* - * This method sets the Server16 value. + * Sets the Server16 value. * * @param[in] aServer16 The Server16 value. * @@ -1506,7 +1506,7 @@ class ServerTlv : public NetworkDataTlv void SetServer16(uint16_t aServer16) { mServer16 = HostSwap16(aServer16); } /** - * This method gets the Server Data. + * Gets the Server Data. * * @param[out] aServerData A reference to a`ServerData` to return the data. * @@ -1514,7 +1514,7 @@ class ServerTlv : public NetworkDataTlv void GetServerData(ServerData &aServerData) const { aServerData.Init(GetServerData(), GetServerDataLength()); } /** - * This method returns the Server Data length in bytes. + * Returns the Server Data length in bytes. * * @returns The Server Data length in bytes. * @@ -1522,7 +1522,7 @@ class ServerTlv : public NetworkDataTlv uint8_t GetServerDataLength(void) const { return GetLength() - (sizeof(*this) - sizeof(NetworkDataTlv)); } /** - * This method indicates whether two Server TLVs fully match. + * Indicates whether two Server TLVs fully match. * * @param[in] aOther Another Server TLV to compare with it. * @@ -1536,7 +1536,7 @@ class ServerTlv : public NetworkDataTlv } /** - * This static method calculates the total size (number of bytes) of a Service TLV with a given Server Data length. + * Calculates the total size (number of bytes) of a Service TLV with a given Server Data length. * * Note that the returned size does include the Type and Length fields in the TLV. * @@ -1555,14 +1555,14 @@ class ServerTlv : public NetworkDataTlv } OT_TOOL_PACKED_END; /** - * This class represents a Network Data TLV iterator. + * Represents a Network Data TLV iterator. * */ class TlvIterator { public: /** - * This constructor initializes the `TlvIterator` to iterate over a given sequence of TLVs. + * Initializes the `TlvIterator` to iterate over a given sequence of TLVs. * * @param[in] aStart A pointer to the start of the TLV sequence. * @param[in] aEnd A pointer to the end of the TLV sequence. @@ -1575,7 +1575,7 @@ class TlvIterator } /** - * This constructor initializes the `TlvIterator` to iterate over TLVs from a given buffer. + * Initializes the `TlvIterator` to iterate over TLVs from a given buffer. * * @param[in] aBuffer A pointer to a buffer containing the TLVs. * @param[in] aLength The length (number of bytes) of @p aBuffer. @@ -1588,7 +1588,7 @@ class TlvIterator } /** - * This constructor initializes the `TlvIterator` to iterate over sub-TLVs of a given Prefix TLV. + * Initializes the `TlvIterator` to iterate over sub-TLVs of a given Prefix TLV. * * @param[in] aPrefixTlv A Prefix TLV to iterate over its sub-TLVs. * @@ -1599,7 +1599,7 @@ class TlvIterator } /** - * This constructor initializes the `TlvIterator` to iterate over sub-TLVs of a given Service TLV. + * Initializes the `TlvIterator` to iterate over sub-TLVs of a given Service TLV. * * @param[in] aServiceTlv A Service TLV to iterate over its sub-TLVs. * @@ -1610,7 +1610,7 @@ class TlvIterator } /** - * This template method iterates to the next TLV with a given type. + * Iterates to the next TLV with a given type. * * @tparam TlvType The TLV Type to search for (MUST be a sub-class of `NetworkDataTlv`). * @@ -1620,7 +1620,7 @@ class TlvIterator template const TlvType *Iterate(void) { return As(Iterate(TlvType::kType)); } /** - * This template method iterates to the next TLV with a given type and stable flag. + * Iterates to the next TLV with a given type and stable flag. * * @tparam TlvType The TLV Type to search for (MUST be a sub-class of `NetworkDataTlv`). * diff --git a/src/core/thread/network_data_types.hpp b/src/core/thread/network_data_types.hpp index 642b398e6a5..1457aa23901 100644 --- a/src/core/thread/network_data_types.hpp +++ b/src/core/thread/network_data_types.hpp @@ -71,7 +71,7 @@ class ServerTlv; class ContextTlv; /** - * This enumeration represents the Network Data type. + * Represents the Network Data type. * */ enum Type : uint8_t @@ -81,7 +81,7 @@ enum Type : uint8_t }; /** - * This enumeration type represents the route preference values as a signed integer (per RFC-4191). + * Type represents the route preference values as a signed integer (per RFC-4191). * */ enum RoutePreference : int8_t @@ -96,7 +96,7 @@ static_assert(kRoutePreferenceMedium == Preference::kMedium, "kRoutePreferenceMe static_assert(kRoutePreferenceLow == Preference::kLow, "kRoutePreferenceLow is not valid"); /** - * This enumeration represents the border router RLOC role filter used when searching for border routers in the Network + * Represents the border router RLOC role filter used when searching for border routers in the Network * Data. * */ @@ -108,7 +108,7 @@ enum RoleFilter : uint8_t }; /** - * This function indicates whether a given `int8_t` preference value is a valid route preference (i.e., one of the + * Indicates whether a given `int8_t` preference value is a valid route preference (i.e., one of the * values from `RoutePreference` enumeration). * * @param[in] aPref The signed route preference value. @@ -120,7 +120,7 @@ enum RoleFilter : uint8_t inline bool IsRoutePreferenceValid(int8_t aPref) { return Preference::IsValid(aPref); } /** - * This function coverts a route preference to a 2-bit unsigned value. + * Coverts a route preference to a 2-bit unsigned value. * * The @p aPref MUST be valid (value from `RoutePreference` enumeration), or the behavior is undefined. * @@ -132,7 +132,7 @@ inline bool IsRoutePreferenceValid(int8_t aPref) { return Preference::IsValid(aP inline uint8_t RoutePreferenceToValue(int8_t aPref) { return Preference::To2BitUint(aPref); } /** - * This function coverts a 2-bit unsigned value to a route preference. + * Coverts a 2-bit unsigned value to a route preference. * * @param[in] aValue The 2-bit unsigned value to convert from. Note that only the first two bits of @p aValue * are used and the rest of bits are ignored. @@ -146,7 +146,7 @@ inline RoutePreference RoutePreferenceFromValue(uint8_t aValue) } /** - * This function converts a router preference to a human-readable string. + * Converts a router preference to a human-readable string. * * @param[in] aPreference The preference to convert * @@ -156,7 +156,7 @@ inline RoutePreference RoutePreferenceFromValue(uint8_t aValue) inline const char *RoutePreferenceToString(RoutePreference aPreference) { return Preference::ToString(aPreference); } /** - * This class represents an On-mesh Prefix (Border Router) configuration. + * Represents an On-mesh Prefix (Border Router) configuration. * */ class OnMeshPrefixConfig : public otBorderRouterConfig, @@ -170,7 +170,7 @@ class OnMeshPrefixConfig : public otBorderRouterConfig, public: /** - * This method gets the prefix. + * Gets the prefix. * * @return The prefix. * @@ -178,7 +178,7 @@ class OnMeshPrefixConfig : public otBorderRouterConfig, const Ip6::Prefix &GetPrefix(void) const { return AsCoreType(&mPrefix); } /** - * This method gets the prefix. + * Gets the prefix. * * @return The prefix. * @@ -186,7 +186,7 @@ class OnMeshPrefixConfig : public otBorderRouterConfig, Ip6::Prefix &GetPrefix(void) { return AsCoreType(&mPrefix); } /** - * This method gets the preference. + * Gets the preference. * * @return The preference. * @@ -195,7 +195,7 @@ class OnMeshPrefixConfig : public otBorderRouterConfig, #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE /** - * This method indicates whether or not the prefix configuration is valid. + * Indicates whether or not the prefix configuration is valid. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -217,7 +217,7 @@ class OnMeshPrefixConfig : public otBorderRouterConfig, }; /** - * This class represents an External Route configuration. + * Represents an External Route configuration. * */ class ExternalRouteConfig : public otExternalRouteConfig, @@ -230,7 +230,7 @@ class ExternalRouteConfig : public otExternalRouteConfig, public: /** - * This method gets the prefix. + * Gets the prefix. * * @return The prefix. * @@ -238,7 +238,7 @@ class ExternalRouteConfig : public otExternalRouteConfig, const Ip6::Prefix &GetPrefix(void) const { return AsCoreType(&mPrefix); } /** - * This method gets the prefix. + * Gets the prefix. * * @return The prefix. * @@ -246,7 +246,7 @@ class ExternalRouteConfig : public otExternalRouteConfig, Ip6::Prefix &GetPrefix(void) { return AsCoreType(&mPrefix); } /** - * This method sets the prefix. + * Sets the prefix. * * @param[in] aPrefix The prefix to set to. * @@ -255,7 +255,7 @@ class ExternalRouteConfig : public otExternalRouteConfig, #if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE /** - * This method indicates whether or not the external route configuration is valid. + * Indicates whether or not the external route configuration is valid. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -278,7 +278,7 @@ class ExternalRouteConfig : public otExternalRouteConfig, }; /** - * This class represents 6LoWPAN Context ID information associated with a prefix in Network Data. + * Represents 6LoWPAN Context ID information associated with a prefix in Network Data. * */ class LowpanContextInfo : public otLowpanContextInfo, public Clearable @@ -287,7 +287,7 @@ class LowpanContextInfo : public otLowpanContextInfo, public Clearable @@ -308,7 +308,7 @@ class ServiceData : public Data }; /** - * This class represents a Server Data. + * Represents a Server Data. * */ class ServerData : public Data @@ -316,7 +316,7 @@ class ServerData : public Data }; /** - * This type represents a Service configuration. + * Represents a Service configuration. * */ class ServiceConfig : public otServiceConfig, public Clearable, public Unequatable @@ -325,7 +325,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p public: /** - * This class represents a Server configuration. + * Represents a Server configuration. * */ class ServerConfig : public otServerConfig, public Unequatable @@ -334,7 +334,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p public: /** - * This method gets the Server Data. + * Gets the Server Data. * * @param[out] aServerData A reference to a`ServerData` to return the data. * @@ -342,7 +342,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p void GetServerData(ServerData &aServerData) const { aServerData.Init(mServerData, mServerDataLength); } /** - * This method overloads operator `==` to evaluate whether or not two `ServerConfig` instances are equal. + * Overloads operator `==` to evaluate whether or not two `ServerConfig` instances are equal. * * @param[in] aOther The other `ServerConfig` instance to compare with. * @@ -357,7 +357,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p }; /** - * This method gets the Service Data. + * Gets the Service Data. * * @param[out] aServiceData A reference to a `ServiceData` to return the data. * @@ -365,7 +365,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p void GetServiceData(ServiceData &aServiceData) const { aServiceData.Init(mServiceData, mServiceDataLength); } /** - * This method gets the Server configuration. + * Gets the Server configuration. * * @returns The Server configuration. * @@ -373,7 +373,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p const ServerConfig &GetServerConfig(void) const { return static_cast(mServerConfig); } /** - * This method gets the Server configuration. + * Gets the Server configuration. * * @returns The Server configuration. * @@ -381,7 +381,7 @@ class ServiceConfig : public otServiceConfig, public Clearable, p ServerConfig &GetServerConfig(void) { return static_cast(mServerConfig); } /** - * This method overloads operator `==` to evaluate whether or not two `ServiceConfig` instances are equal. + * Overloads operator `==` to evaluate whether or not two `ServiceConfig` instances are equal. * * @param[in] aOther The other `ServiceConfig` instance to compare with. * diff --git a/src/core/thread/network_diagnostic.cpp b/src/core/thread/network_diagnostic.cpp index dfa8570e799..547c80a627e 100644 --- a/src/core/thread/network_diagnostic.cpp +++ b/src/core/thread/network_diagnostic.cpp @@ -250,11 +250,9 @@ Error Server::AppendRequestedTlvs(const Message &aRequest, Message &aResponse) { Error error; uint16_t offset; - uint16_t length; uint16_t endOffset; - SuccessOrExit(error = Tlv::FindTlvValueOffset(aRequest, Tlv::kTypeList, offset, length)); - endOffset = offset + length; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aRequest, Tlv::kTypeList, offset, endOffset)); for (; offset < endOffset; offset++) { diff --git a/src/core/thread/network_diagnostic.hpp b/src/core/thread/network_diagnostic.hpp index 4026aa32c18..0070207b431 100644 --- a/src/core/thread/network_diagnostic.hpp +++ b/src/core/thread/network_diagnostic.hpp @@ -62,7 +62,7 @@ namespace NetworkDiagnostic { class Client; /** - * This class implements the Network Diagnostic server responding to requests. + * Implements the Network Diagnostic server responding to requests. * */ class Server : public InstanceLocator, private NonCopyable @@ -72,7 +72,7 @@ class Server : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the Server. + * Initializes the Server. * * @param[in] aInstance The OpenThread instance. * @@ -81,7 +81,7 @@ class Server : public InstanceLocator, private NonCopyable #if OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE /** - * This method returns the vendor name string. + * Returns the vendor name string. * * @returns The vendor name string. * @@ -89,7 +89,7 @@ class Server : public InstanceLocator, private NonCopyable const char *GetVendorName(void) const { return mVendorName; } /** - * This method sets the vendor name string. + * Sets the vendor name string. * * @param[in] aVendorName The vendor name string. * @@ -100,7 +100,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetVendorName(const char *aVendorName); /** - * This method returns the vendor model string. + * Returns the vendor model string. * * @returns The vendor model string. * @@ -108,7 +108,7 @@ class Server : public InstanceLocator, private NonCopyable const char *GetVendorModel(void) const { return mVendorModel; } /** - * This method sets the vendor model string. + * Sets the vendor model string. * * @param[in] aVendorModel The vendor model string. * @@ -119,7 +119,7 @@ class Server : public InstanceLocator, private NonCopyable Error SetVendorModel(const char *aVendorModel); /** - * This method returns the vendor software version string. + * Returns the vendor software version string. * * @returns The vendor software version string. * @@ -127,7 +127,7 @@ class Server : public InstanceLocator, private NonCopyable const char *GetVendorSwVersion(void) const { return mVendorSwVersion; } /** - * This method sets the vendor sw version string + * Sets the vendor sw version string * * @param[in] aVendorSwVersion The vendor sw version string. * @@ -175,7 +175,7 @@ DeclareTmfHandler(Server, kUriDiagnosticGetAnswer); #if OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE /** - * This class implements the Network Diagnostic client sending requests and queries. + * Implements the Network Diagnostic client sending requests and queries. * */ class Client : public InstanceLocator, private NonCopyable @@ -191,7 +191,7 @@ class Client : public InstanceLocator, private NonCopyable static constexpr Iterator kIteratorInit = OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT; ///< Initializer for Iterator. /** - * This constructor initializes the Client. + * Initializes the Client. * * @param[in] aInstance The OpenThread instance. * @@ -199,7 +199,7 @@ class Client : public InstanceLocator, private NonCopyable explicit Client(Instance &aInstance); /** - * This method sends Diagnostic Get request. If the @p aDestination is of multicast type, the DIAG_GET.qry + * Sends Diagnostic Get request. If the @p aDestination is of multicast type, the DIAG_GET.qry * message is sent or the DIAG_GET.req otherwise. * * @param[in] aDestination The destination address. @@ -216,7 +216,7 @@ class Client : public InstanceLocator, private NonCopyable void *Context); /** - * This method sends Diagnostic Reset request. + * Sends Diagnostic Reset request. * * @param[in] aDestination The destination address. * @param[in] aTlvTypes An array of Network Diagnostic TLV types. @@ -226,7 +226,7 @@ class Client : public InstanceLocator, private NonCopyable Error SendDiagnosticReset(const Ip6::Address &aDestination, const uint8_t aTlvTypes[], uint8_t aCount); /** - * This static method gets the next Network Diagnostic TLV in a given message. + * Gets the next Network Diagnostic TLV in a given message. * * @param[in] aMessage Message to read TLVs from. * @param[in,out] aIterator The Network Diagnostic iterator. To get the first TLV set it to `kIteratorInit`. diff --git a/src/core/thread/network_diagnostic_tlvs.hpp b/src/core/thread/network_diagnostic_tlvs.hpp index c46298cff9d..cc366c56a82 100644 --- a/src/core/thread/network_diagnostic_tlvs.hpp +++ b/src/core/thread/network_diagnostic_tlvs.hpp @@ -56,7 +56,7 @@ using ot::Encoding::BigEndian::HostSwap16; using ot::Encoding::BigEndian::HostSwap32; /** - * This class implements Network Diagnostic TLV generation and parsing. + * Implements Network Diagnostic TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -117,7 +117,7 @@ class Tlv : public ot::Tlv static constexpr uint8_t kMaxThreadStackVersionLength = OT_NETWORK_DIAGNOSTIC_MAX_THREAD_STACK_VERSION_TLV_LENGTH; /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -125,7 +125,7 @@ class Tlv : public ot::Tlv Type GetType(void) const { return static_cast(ot::Tlv::GetType()); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -135,91 +135,91 @@ class Tlv : public ot::Tlv } OT_TOOL_PACKED_END; /** - * This class defines Extended MAC Address TLV constants and types. + * Defines Extended MAC Address TLV constants and types. * */ typedef SimpleTlvInfo ExtMacAddressTlv; /** - * This class defines Address16 TLV constants and types. + * Defines Address16 TLV constants and types. * */ typedef UintTlvInfo Address16Tlv; /** - * This class defines Mode TLV constants and types. + * Defines Mode TLV constants and types. * */ typedef UintTlvInfo ModeTlv; /** - * This class defines Timeout TLV constants and types. + * Defines Timeout TLV constants and types. * */ typedef UintTlvInfo TimeoutTlv; /** - * This class defines Network Data TLV constants and types. + * Defines Network Data TLV constants and types. * */ typedef TlvInfo NetworkDataTlv; /** - * This class defines IPv6 Address List TLV constants and types. + * Defines IPv6 Address List TLV constants and types. * */ typedef TlvInfo Ip6AddressListTlv; /** - * This class defines Battery Level TLV constants and types. + * Defines Battery Level TLV constants and types. * */ typedef UintTlvInfo BatteryLevelTlv; /** - * This class defines Supply Voltage TLV constants and types. + * Defines Supply Voltage TLV constants and types. * */ typedef UintTlvInfo SupplyVoltageTlv; /** - * This class defines Child Table TLV constants and types. + * Defines Child Table TLV constants and types. * */ typedef TlvInfo ChildTableTlv; /** - * This class defines Max Child Timeout TLV constants and types. + * Defines Max Child Timeout TLV constants and types. * */ typedef UintTlvInfo MaxChildTimeoutTlv; /** - * This class defines Version TLV constants and types. + * Defines Version TLV constants and types. * */ typedef UintTlvInfo VersionTlv; /** - * This class defines Vendor Name TLV constants and types. + * Defines Vendor Name TLV constants and types. * */ typedef StringTlvInfo VendorNameTlv; /** - * This class defines Vendor Model TLV constants and types. + * Defines Vendor Model TLV constants and types. * */ typedef StringTlvInfo VendorModelTlv; /** - * This class defines Vendor SW Version TLV constants and types. + * Defines Vendor SW Version TLV constants and types. * */ typedef StringTlvInfo VendorSwVersionTlv; /** - * This class defines Thread Stack Version TLV constants and types. + * Defines Thread Stack Version TLV constants and types. * */ typedef StringTlvInfo ThreadStackVersionTlv; @@ -227,7 +227,7 @@ typedef StringTlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -328,7 +328,7 @@ class MacCountersTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -337,7 +337,7 @@ class MacCountersTlv : public Tlv, public TlvInfo bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } /** - * This method returns the IfInUnknownProtos counter. + * Returns the IfInUnknownProtos counter. * * @returns The IfInUnknownProtos counter * @@ -345,7 +345,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfInUnknownProtos(void) const { return HostSwap32(mIfInUnknownProtos); } /** - * This method sets the IfInUnknownProtos counter. + * Sets the IfInUnknownProtos counter. * * @param[in] aIfInUnknownProtos The IfInUnknownProtos counter * @@ -356,7 +356,7 @@ class MacCountersTlv : public Tlv, public TlvInfo } /** - * This method returns the IfInErrors counter. + * Returns the IfInErrors counter. * * @returns The IfInErrors counter * @@ -364,7 +364,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfInErrors(void) const { return HostSwap32(mIfInErrors); } /** - * This method sets the IfInErrors counter. + * Sets the IfInErrors counter. * * @param[in] aIfInErrors The IfInErrors counter * @@ -372,7 +372,7 @@ class MacCountersTlv : public Tlv, public TlvInfo void SetIfInErrors(const uint32_t aIfInErrors) { mIfInErrors = HostSwap32(aIfInErrors); } /** - * This method returns the IfOutErrors counter. + * Returns the IfOutErrors counter. * * @returns The IfOutErrors counter * @@ -380,7 +380,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfOutErrors(void) const { return HostSwap32(mIfOutErrors); } /** - * This method sets the IfOutErrors counter. + * Sets the IfOutErrors counter. * * @param[in] aIfOutErrors The IfOutErrors counter. * @@ -388,7 +388,7 @@ class MacCountersTlv : public Tlv, public TlvInfo void SetIfOutErrors(const uint32_t aIfOutErrors) { mIfOutErrors = HostSwap32(aIfOutErrors); } /** - * This method returns the IfInUcastPkts counter. + * Returns the IfInUcastPkts counter. * * @returns The IfInUcastPkts counter * @@ -396,14 +396,14 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfInUcastPkts(void) const { return HostSwap32(mIfInUcastPkts); } /** - * This method sets the IfInUcastPkts counter. + * Sets the IfInUcastPkts counter. * * @param[in] aIfInUcastPkts The IfInUcastPkts counter. * */ void SetIfInUcastPkts(const uint32_t aIfInUcastPkts) { mIfInUcastPkts = HostSwap32(aIfInUcastPkts); } /** - * This method returns the IfInBroadcastPkts counter. + * Returns the IfInBroadcastPkts counter. * * @returns The IfInBroadcastPkts counter * @@ -411,7 +411,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfInBroadcastPkts(void) const { return HostSwap32(mIfInBroadcastPkts); } /** - * This method sets the IfInBroadcastPkts counter. + * Sets the IfInBroadcastPkts counter. * * @param[in] aIfInBroadcastPkts The IfInBroadcastPkts counter. * @@ -422,7 +422,7 @@ class MacCountersTlv : public Tlv, public TlvInfo } /** - * This method returns the IfInDiscards counter. + * Returns the IfInDiscards counter. * * @returns The IfInDiscards counter * @@ -430,7 +430,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfInDiscards(void) const { return HostSwap32(mIfInDiscards); } /** - * This method sets the IfInDiscards counter. + * Sets the IfInDiscards counter. * * @param[in] aIfInDiscards The IfInDiscards counter. * @@ -438,7 +438,7 @@ class MacCountersTlv : public Tlv, public TlvInfo void SetIfInDiscards(const uint32_t aIfInDiscards) { mIfInDiscards = HostSwap32(aIfInDiscards); } /** - * This method returns the IfOutUcastPkts counter. + * Returns the IfOutUcastPkts counter. * * @returns The IfOutUcastPkts counter * @@ -446,7 +446,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfOutUcastPkts(void) const { return HostSwap32(mIfOutUcastPkts); } /** - * This method sets the IfOutUcastPkts counter. + * Sets the IfOutUcastPkts counter. * * @param[in] aIfOutUcastPkts The IfOutUcastPkts counter. * @@ -454,7 +454,7 @@ class MacCountersTlv : public Tlv, public TlvInfo void SetIfOutUcastPkts(const uint32_t aIfOutUcastPkts) { mIfOutUcastPkts = HostSwap32(aIfOutUcastPkts); } /** - * This method returns the IfOutBroadcastPkts counter. + * Returns the IfOutBroadcastPkts counter. * * @returns The IfOutBroadcastPkts counter * @@ -462,7 +462,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfOutBroadcastPkts(void) const { return HostSwap32(mIfOutBroadcastPkts); } /** - * This method sets the IfOutBroadcastPkts counter. + * Sets the IfOutBroadcastPkts counter. * * @param[in] aIfOutBroadcastPkts The IfOutBroadcastPkts counter. * @@ -473,7 +473,7 @@ class MacCountersTlv : public Tlv, public TlvInfo } /** - * This method returns the IfOutDiscards counter. + * Returns the IfOutDiscards counter. * * @returns The IfOutDiscards counter * @@ -481,7 +481,7 @@ class MacCountersTlv : public Tlv, public TlvInfo uint32_t GetIfOutDiscards(void) const { return HostSwap32(mIfOutDiscards); } /** - * This method sets the IfOutDiscards counter. + * Sets the IfOutDiscards counter. * * @param[in] aIfOutDiscards The IfOutDiscards counter. * @@ -501,7 +501,7 @@ class MacCountersTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements Child Table Entry generation and parsing. + * Implements Child Table Entry generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -509,7 +509,7 @@ class ChildTableEntry : public Clearable { public: /** - * This method returns the Timeout value. + * Returns the Timeout value. * * @returns The Timeout value. * @@ -517,7 +517,7 @@ class ChildTableEntry : public Clearable uint8_t GetTimeout(void) const { return (GetTimeoutChildId() & kTimeoutMask) >> kTimeoutOffset; } /** - * This method sets the Timeout value. + * Sets the Timeout value. * * @param[in] aTimeout The Timeout value. * @@ -528,7 +528,7 @@ class ChildTableEntry : public Clearable } /** - * This method the Link Quality value. + * The Link Quality value. * * @returns The Link Quality value. * @@ -539,7 +539,7 @@ class ChildTableEntry : public Clearable } /** - * This method set the Link Quality value. + * Set the Link Quality value. * * @param[in] aLinkQuality The Link Quality value. * @@ -550,7 +550,7 @@ class ChildTableEntry : public Clearable } /** - * This method returns the Child ID value. + * Returns the Child ID value. * * @returns The Child ID value. * @@ -558,7 +558,7 @@ class ChildTableEntry : public Clearable uint16_t GetChildId(void) const { return (GetTimeoutChildId() & kChildIdMask) >> kChildIdOffset; } /** - * This method sets the Child ID value. + * Sets the Child ID value. * * @param[in] aChildId The Child ID value. * @@ -569,7 +569,7 @@ class ChildTableEntry : public Clearable } /** - * This method returns the Device Mode + * Returns the Device Mode * * @returns The Device Mode * @@ -577,7 +577,7 @@ class ChildTableEntry : public Clearable Mle::DeviceMode GetMode(void) const { return Mle::DeviceMode(mMode); } /** - * This method sets the Device Mode. + * Sets the Device Mode. * * @param[in] aMode The Device Mode. * @@ -606,7 +606,7 @@ class ChildTableEntry : public Clearable } OT_TOOL_PACKED_END; /** - * This class implements Channel Pages TLV generation and parsing. + * Implements Channel Pages TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -614,7 +614,7 @@ class ChannelPagesTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -624,7 +624,7 @@ class ChannelPagesTlv : public Tlv, public TlvInfo } /** - * This method indicates whether or not the TLV appears to be well-formed. + * Indicates whether or not the TLV appears to be well-formed. * * @retval TRUE If the TLV appears to be well-formed. * @retval FALSE If the TLV does not appear to be well-formed. @@ -637,7 +637,7 @@ class ChannelPagesTlv : public Tlv, public TlvInfo } /** - * This method returns a pointer to the list of Channel Pages. + * Returns a pointer to the list of Channel Pages. * * @returns A pointer to the list of Channel Pages. * @@ -649,7 +649,7 @@ class ChannelPagesTlv : public Tlv, public TlvInfo } OT_TOOL_PACKED_END; /** - * This class implements IPv6 Address List TLV generation and parsing. + * Implements IPv6 Address List TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -657,7 +657,7 @@ class TypeListTlv : public Tlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) diff --git a/src/core/thread/panid_query_server.hpp b/src/core/thread/panid_query_server.hpp index 70deaf9e98c..ed0c674216e 100644 --- a/src/core/thread/panid_query_server.hpp +++ b/src/core/thread/panid_query_server.hpp @@ -47,7 +47,7 @@ namespace ot { /** - * This class implements handling PANID Query Requests. + * Implements handling PANID Query Requests. * */ class PanIdQueryServer : public InstanceLocator, private NonCopyable @@ -56,7 +56,7 @@ class PanIdQueryServer : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * */ explicit PanIdQueryServer(Instance &aInstance); diff --git a/src/core/thread/radio_selector.hpp b/src/core/thread/radio_selector.hpp index bf980cc15a9..40cb8b55f30 100644 --- a/src/core/thread/radio_selector.hpp +++ b/src/core/thread/radio_selector.hpp @@ -65,7 +65,7 @@ class RadioSelector : InstanceLocator { public: /** - * This class defines all the neighbor info required for multi radio link and radio selection. + * Defines all the neighbor info required for multi radio link and radio selection. * * `Neighbor` class publicly inherits from this class. * @@ -76,13 +76,13 @@ class RadioSelector : InstanceLocator public: /** - * This type represents multi radio information associated with a neighbor. + * Represents multi radio information associated with a neighbor. * */ typedef otMultiRadioNeighborInfo MultiRadioInfo; /** - * This method returns the supported radio types by the neighbor. + * Returns the supported radio types by the neighbor. * * @returns The supported radio types set. * @@ -90,7 +90,7 @@ class RadioSelector : InstanceLocator Mac::RadioTypes GetSupportedRadioTypes(void) const { return mSupportedRadioTypes; } /** - * This method retrieves the multi radio information `otMultiRadioNeighborInfo` associated with the neighbor. + * Retrieves the multi radio information `otMultiRadioNeighborInfo` associated with the neighbor. * * @param[out] aInfo A reference to `MultiRadioInfo` to populate with neighbor info. * @@ -110,7 +110,7 @@ class RadioSelector : InstanceLocator }; /** - * This constructor initializes the RadioSelector object. + * Initializes the RadioSelector object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -118,9 +118,9 @@ class RadioSelector : InstanceLocator explicit RadioSelector(Instance &aInstance); /** - * This method updates the neighbor info (for multi radio support) on a received frame event. + * Updates the neighbor info (for multi radio support) on a received frame event. * - * This method notifies `RadioSelector` of a received secure frame/message on a radio link type for neighbor. If + * Notifies `RadioSelector` of a received secure frame/message on a radio link type for neighbor. If * the frame/message happens to be received earlier on another radio link, the `aIsDuplicate` is set to `true`. * A duplicate frame/message should have passed the security check (i.e., tag/MIC should be valid). * @@ -132,9 +132,9 @@ class RadioSelector : InstanceLocator void UpdateOnReceive(Neighbor &aNeighbor, Mac::RadioType aRadioType, bool aIsDuplicate); /** - * This method updates the neighbor info (for multi radio support) on a send done event. + * Updates the neighbor info (for multi radio support) on a send done event. * - * This method notifies `RadioSelector` the status of frame transmission on a radio link type. The radio link + * Notifies `RadioSelector` the status of frame transmission on a radio link type. The radio link * type is provided by the `aFrame` itself. * * @param[in] aFrame A transmitted frame. @@ -145,7 +145,7 @@ class RadioSelector : InstanceLocator #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE /** - * This method updates the neighbor info (for multi radio support) on a deferred ack event. + * Updates the neighbor info (for multi radio support) on a deferred ack event. * * The deferred ack model is used by TREL radio link. * @@ -158,7 +158,7 @@ class RadioSelector : InstanceLocator #endif /** - * This method selects the radio link type for sending a data poll frame to a given parent neighbor. + * Selects the radio link type for sending a data poll frame to a given parent neighbor. * * @param[in] aParent The parent to which the data poll frame will be sent. * @@ -168,7 +168,7 @@ class RadioSelector : InstanceLocator Mac::RadioType SelectPollFrameRadio(const Neighbor &aParent); /** - * This method selects the radio link for sending a given message to a specified MAC destination. + * Selects the radio link for sending a given message to a specified MAC destination. * * The `aMessage` will be updated to store the selected radio type (please see `Message::GetRadioType()`). * The `aTxFrames` will also be updated to indicate which radio links are to be used. diff --git a/src/core/thread/router_table.hpp b/src/core/thread/router_table.hpp index e87ed0dbcb3..bed25ab1355 100644 --- a/src/core/thread/router_table.hpp +++ b/src/core/thread/router_table.hpp @@ -63,19 +63,19 @@ class RouterTable : public InstanceLocator, private NonCopyable explicit RouterTable(Instance &aInstance); /** - * This method clears the router table. + * Clears the router table. * */ void Clear(void); /** - * This method removes all neighbor links to routers. + * Removes all neighbor links to routers. * */ void ClearNeighbors(void); /** - * This method allocates a router with a random Router ID. + * Allocates a router with a random Router ID. * * @returns A pointer to the allocated router or `nullptr` if a Router ID is not available. * @@ -83,7 +83,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *Allocate(void); /** - * This method allocates a router with a specified Router ID. + * Allocates a router with a specified Router ID. * * @param[in] aRouterId The Router ID to try to allocate. * @@ -93,7 +93,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *Allocate(uint8_t aRouterId); /** - * This method releases a Router ID. + * Releases a Router ID. * * @param[in] aRouterId The Router ID. * @@ -105,7 +105,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Error Release(uint8_t aRouterId); /** - * This method removes a router link. + * Removes a router link. * * @param[in] aRouter A reference to the router. * @@ -113,7 +113,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void RemoveRouterLink(Router &aRouter); /** - * This method returns the number of active routers in the Thread network. + * Returns the number of active routers in the Thread network. * * @returns The number of active routers in the Thread network. * @@ -121,7 +121,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetActiveRouterCount(void) const { return mRouters.GetLength(); } /** - * This method returns the leader in the Thread network. + * Returns the leader in the Thread network. * * @returns A pointer to the Leader in the Thread network. * @@ -129,7 +129,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *GetLeader(void) { return AsNonConst(AsConst(this)->GetLeader()); } /** - * This method returns the leader in the Thread network. + * Returns the leader in the Thread network. * * @returns A pointer to the Leader in the Thread network. * @@ -137,7 +137,7 @@ class RouterTable : public InstanceLocator, private NonCopyable const Router *GetLeader(void) const; /** - * This method returns the leader's age in seconds, i.e., seconds since the last Router ID Sequence update. + * Returns the leader's age in seconds, i.e., seconds since the last Router ID Sequence update. * * @returns The leader's age. * @@ -145,7 +145,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint32_t GetLeaderAge(void) const; /** - * This method returns the link cost for a neighboring router. + * Returns the link cost for a neighboring router. * * @param[in] aRouter A router. * @@ -155,7 +155,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetLinkCost(const Router &aRouter) const; /** - * This method returns the link cost to the given Router. + * Returns the link cost to the given Router. * * @param[in] aRouterId The Router ID. * @@ -165,7 +165,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetLinkCost(uint8_t aRouterId) const; /** - * This method returns the minimum mesh path cost to the given RLOC16 + * Returns the minimum mesh path cost to the given RLOC16 * * @param[in] aDestRloc16 The RLOC16 of destination * @@ -175,7 +175,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetPathCost(uint16_t aDestRloc16) const; /** - * This method returns the mesh path cost to leader. + * Returns the mesh path cost to leader. * * @returns The path cost to leader. * @@ -183,7 +183,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetPathCostToLeader(void) const; /** - * This method determines the next hop towards an RLOC16 destination. + * Determines the next hop towards an RLOC16 destination. * * @param[in] aDestRloc16 The RLOC16 of the destination. * @@ -193,7 +193,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint16_t GetNextHop(uint16_t aDestRloc16) const; /** - * This method determines the next hop and the path cost towards an RLOC16 destination. + * Determines the next hop and the path cost towards an RLOC16 destination. * * @param[in] aDestRloc16 The RLOC16 of the destination. * @param[out] aNextHopRloc16 A reference to return the RLOC16 of next hop if known, or `Mle::kInvalidRloc16`. @@ -203,7 +203,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void GetNextHopAndPathCost(uint16_t aDestRloc16, uint16_t &aNextHopRloc16, uint8_t &aPathCost) const; /** - * This method finds the router for a given Router ID. + * Finds the router for a given Router ID. * * @param[in] aRouterId The Router ID to search for. * @@ -213,7 +213,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *FindRouterById(uint8_t aRouterId) { return AsNonConst(AsConst(this)->FindRouterById(aRouterId)); } /** - * This method finds the router for a given Router ID. + * Finds the router for a given Router ID. * * @param[in] aRouterId The Router ID to search for. * @@ -223,7 +223,7 @@ class RouterTable : public InstanceLocator, private NonCopyable const Router *FindRouterById(uint8_t aRouterId) const; /** - * This method finds the router for a given RLOC16. + * Finds the router for a given RLOC16. * * @param[in] aRloc16 The RLOC16 to search for. * @@ -233,7 +233,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *FindRouterByRloc16(uint16_t aRloc16) { return AsNonConst(AsConst(this)->FindRouterByRloc16(aRloc16)); } /** - * This method finds the router for a given RLOC16. + * Finds the router for a given RLOC16. * * @param[in] aRloc16 The RLOC16 to search for. * @@ -243,7 +243,7 @@ class RouterTable : public InstanceLocator, private NonCopyable const Router *FindRouterByRloc16(uint16_t aRloc16) const; /** - * This method finds the router that is the next hop of a given router. + * Finds the router that is the next hop of a given router. * * @param[in] aRouter The router to find next hop of. * @@ -253,7 +253,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *FindNextHopOf(const Router &aRouter) { return AsNonConst(AsConst(this)->FindNextHopOf(aRouter)); } /** - * This method finds the router that is the next hop of a given router. + * Finds the router that is the next hop of a given router. * * @param[in] aRouter The router to find next hop of. * @@ -263,7 +263,7 @@ class RouterTable : public InstanceLocator, private NonCopyable const Router *FindNextHopOf(const Router &aRouter) const; /** - * This method find the router for a given MAC Extended Address. + * Find the router for a given MAC Extended Address. * * @param[in] aExtAddress A reference to the MAC Extended Address. * @@ -273,7 +273,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Router *FindRouter(const Mac::ExtAddress &aExtAddress); /** - * This method indicates whether the router table contains a given `Neighbor` instance. + * Indicates whether the router table contains a given `Neighbor` instance. * * @param[in] aNeighbor A reference to a `Neighbor`. * @@ -288,7 +288,7 @@ class RouterTable : public InstanceLocator, private NonCopyable } /** - * This method retains diagnostic information for a given router. + * Retains diagnostic information for a given router. * * @param[in] aRouterId The router ID or RLOC16 for a given router. * @param[out] aRouterInfo The router information. @@ -301,7 +301,7 @@ class RouterTable : public InstanceLocator, private NonCopyable Error GetRouterInfo(uint16_t aRouterId, Router::Info &aRouterInfo); /** - * This method returns the Router ID Sequence. + * Returns the Router ID Sequence. * * @returns The Router ID Sequence. * @@ -309,7 +309,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetRouterIdSequence(void) const { return mRouterIdSequence; } /** - * This method returns the local time when the Router ID Sequence was last updated. + * Returns the local time when the Router ID Sequence was last updated. * * @returns The local time when the Router ID Sequence was last updated. * @@ -317,7 +317,7 @@ class RouterTable : public InstanceLocator, private NonCopyable TimeMilli GetRouterIdSequenceLastUpdated(void) const { return mRouterIdSequenceLastUpdated; } /** - * This method determines whether the Router ID Sequence in a received Route TLV is more recent than the current + * Determines whether the Router ID Sequence in a received Route TLV is more recent than the current * Router ID Sequence being used by `RouterTable`. * * @param[in] aRouteTlv The Route TLV to compare. @@ -329,7 +329,7 @@ class RouterTable : public InstanceLocator, private NonCopyable bool IsRouteTlvIdSequenceMoreRecent(const Mle::RouteTlv &aRouteTlv) const; /** - * This method returns the number of neighbor links. + * Returns the number of neighbor links. * * @returns The number of neighbor links. * @@ -337,7 +337,7 @@ class RouterTable : public InstanceLocator, private NonCopyable uint8_t GetNeighborCount(void) const; /** - * This method indicates whether or not a Router ID is allocated. + * Indicates whether or not a Router ID is allocated. * * @param[in] aRouterId The Router ID. * @@ -348,7 +348,7 @@ class RouterTable : public InstanceLocator, private NonCopyable bool IsAllocated(uint8_t aRouterId) const { return mRouterIdMap.IsAllocated(aRouterId); } /** - * This method updates the Router ID allocation set. + * Updates the Router ID allocation set. * * @param[in] aRouterIdSequence The Router ID Sequence. * @param[in] aRouterIdSet The Router ID Set. @@ -357,7 +357,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void UpdateRouterIdSet(uint8_t aRouterIdSequence, const Mle::RouterIdSet &aRouterIdSet); /** - * This method updates the routes based on a received `RouteTlv` from a neighboring router. + * Updates the routes based on a received `RouteTlv` from a neighboring router. * * @param[in] aRouteTlv The received `RouteTlv` * @param[in] aNeighborId The router ID of neighboring router from which @p aRouteTlv is received. @@ -366,9 +366,9 @@ class RouterTable : public InstanceLocator, private NonCopyable void UpdateRoutes(const Mle::RouteTlv &aRouteTlv, uint8_t aNeighborId); /** - * This method updates the routes on an FED based on a received `RouteTlv` from the parent. + * Updates the routes on an FED based on a received `RouteTlv` from the parent. * - * This method MUST be called when device is an FED child and @p aRouteTlv is received from its current parent. + * MUST be called when device is an FED child and @p aRouteTlv is received from its current parent. * * @param[in] aRouteTlv The received `RouteTlv` from parent. * @param[in] aParentId The Router ID of parent. @@ -377,7 +377,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void UpdateRoutesOnFed(const Mle::RouteTlv &aRouteTlv, uint8_t aParentId); /** - * This method gets the allocated Router ID set. + * Gets the allocated Router ID set. * * @returns The allocated Router ID set. * @@ -385,7 +385,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void GetRouterIdSet(Mle::RouterIdSet &aRouterIdSet) const { return mRouterIdMap.GetAsRouterIdSet(aRouterIdSet); } /** - * This method fills a Route TLV. + * Fills a Route TLV. * * When @p aNeighbor is not `nullptr`, we limit the number of router entries to `Mle::kLinkAcceptMaxRouters` when * populating `aRouteTlv`, so that the TLV can be appended in a Link Accept message. In this case, we ensure to @@ -398,14 +398,14 @@ class RouterTable : public InstanceLocator, private NonCopyable void FillRouteTlv(Mle::RouteTlv &aRouteTlv, const Neighbor *aNeighbor = nullptr) const; /** - * This method updates the router table and must be called with a one second period. + * Updates the router table and must be called with a one second period. * */ void HandleTimeTick(void); #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE /** - * This method gets the range of Router IDs. + * Gets the range of Router IDs. * * All the Router IDs in the range `[aMinRouterId, aMaxRouterId]` are allowed. This is intended for testing only. * @@ -416,7 +416,7 @@ class RouterTable : public InstanceLocator, private NonCopyable void GetRouterIdRange(uint8_t &aMinRouterId, uint8_t &aMaxRouterId) const; /** - * This method sets the range of Router IDs. + * Sets the range of Router IDs. * * All the Router IDs in the range `[aMinRouterId, aMaxRouterId]` are allowed. This is intended for testing only. * diff --git a/src/core/thread/src_match_controller.hpp b/src/core/thread/src_match_controller.hpp index 860caa05e88..b8871ded80e 100644 --- a/src/core/thread/src_match_controller.hpp +++ b/src/core/thread/src_match_controller.hpp @@ -56,12 +56,12 @@ class Child; */ /** - * This class implements the "source address match" controller. + * Implements the "source address match" controller. * * The source address match feature controls how the radio layer decides the "frame pending" bit for acks sent in * response to data request commands from sleepy children. * - * This class updates the source match table and also controls when to enable or disable the source matching + * Updates the source match table and also controls when to enable or disable the source matching * feature. * * The source address match table provides the list of children for which there is a pending frame. Either a short @@ -72,7 +72,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance * @@ -80,7 +80,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable explicit SourceMatchController(Instance &aInstance); /** - * This method returns the current state of source address matching. + * Returns the current state of source address matching. * * @returns `true` if source address matching is enabled, `false` otherwise. * @@ -88,7 +88,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable bool IsEnabled(void) const { return mEnabled; } /** - * This method increments the message count for a child and updates the source match table. + * Increments the message count for a child and updates the source match table. * * @param[in] aChild A reference to the child. * @@ -96,7 +96,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void IncrementMessageCount(Child &aChild); /** - * This method decrements the message count for a child and updates the source match table. + * Decrements the message count for a child and updates the source match table. * * @param[in] aChild A reference to the child. * @@ -104,7 +104,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void DecrementMessageCount(Child &aChild); /** - * This method resets the message count for a child to zero and updates the source match table. + * Resets the message count for a child to zero and updates the source match table. * * @param[in] aChild A reference to the child. * @@ -112,7 +112,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void ResetMessageCount(Child &aChild); /** - * This method sets whether or not to perform source address matching on the extended or short address for + * Sets whether or not to perform source address matching on the extended or short address for * a child. * * @param[in] aChild A reference to the child. @@ -123,13 +123,13 @@ class SourceMatchController : public InstanceLocator, private NonCopyable private: /** - * This method clears the source match table. + * Clears the source match table. * */ void ClearTable(void); /** - * This method enables or disables the source matching. + * Enables or disables the source matching. * * If enabled, the radio uses the source match table to determine whether to set or clear the "frame pending" bit * in an acknowledgment to a MAC Data Request command. If disabled, the radio layer sets the "frame pending" on all @@ -141,7 +141,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void Enable(bool aEnable); /** - * This method adds an entry to source match table for a given child and updates the state of source matching + * Adds an entry to source match table for a given child and updates the state of source matching * feature accordingly. * * If the entry is added successfully, source matching feature is enabled (if not already enabled) after ensuring @@ -154,7 +154,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void AddEntry(Child &aChild); /** - * This method clears an entry in source match table for a given child and updates the state of source matching + * Clears an entry in source match table for a given child and updates the state of source matching * feature accordingly. * * If the entry is removed successfully and frees up space in the source match table, any remaining pending @@ -166,7 +166,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable void ClearEntry(Child &aChild); /** - * This method adds a given child's address (short or extended address depending on child's setting) to the source + * Adds a given child's address (short or extended address depending on child's setting) to the source * source match table (@sa SetSrcMatchAsShort. * * @param[in] aChild A reference to the child @@ -178,7 +178,7 @@ class SourceMatchController : public InstanceLocator, private NonCopyable Error AddAddress(const Child &aChild); /** - * This method adds all pending entries to the source match table. + * Adds all pending entries to the source match table. * * @retval kErrorNone All pending entries were successfully added. * @retval kErrorNoBufs No available space in the source match table. diff --git a/src/core/thread/thread_netif.hpp b/src/core/thread/thread_netif.hpp index af776bee299..ab14a89b699 100644 --- a/src/core/thread/thread_netif.hpp +++ b/src/core/thread/thread_netif.hpp @@ -54,7 +54,7 @@ class ThreadNetif : public Ip6::Netif { public: /** - * This constructor initializes the Thread network interface. + * Initializes the Thread network interface. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -62,19 +62,19 @@ class ThreadNetif : public Ip6::Netif explicit ThreadNetif(Instance &aInstance); /** - * This method enables the Thread network interface. + * Enables the Thread network interface. * */ void Up(void); /** - * This method disables the Thread network interface. + * Disables the Thread network interface. * */ void Down(void); /** - * This method indicates whether or not the Thread network interface is enabled. + * Indicates whether or not the Thread network interface is enabled. * * @retval TRUE If the Thread network interface is enabled. * @retval FALSE If the Thread network interface is not enabled. diff --git a/src/core/thread/thread_tlvs.hpp b/src/core/thread/thread_tlvs.hpp index 4527aac39e7..5b3bdb24ad1 100644 --- a/src/core/thread/thread_tlvs.hpp +++ b/src/core/thread/thread_tlvs.hpp @@ -50,7 +50,7 @@ using ot::Encoding::BigEndian::HostSwap16; using ot::Encoding::BigEndian::HostSwap32; /** - * This class implements Network Layer TLV generation and parsing. + * Implements Network Layer TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -80,7 +80,7 @@ class ThreadTlv : public ot::Tlv }; /** - * This method returns the Type value. + * Returns the Type value. * * @returns The Type value. * @@ -88,7 +88,7 @@ class ThreadTlv : public ot::Tlv Type GetType(void) const { return static_cast(ot::Tlv::GetType()); } /** - * This method sets the Type value. + * Sets the Type value. * * @param[in] aType The Type value. * @@ -98,55 +98,55 @@ class ThreadTlv : public ot::Tlv } OT_TOOL_PACKED_END; /** - * This class defines Target TLV constants and types. + * Defines Target TLV constants and types. * */ typedef SimpleTlvInfo ThreadTargetTlv; /** - * This class defines Extended MAC Address TLV constants and types. + * Defines Extended MAC Address TLV constants and types. * */ typedef SimpleTlvInfo ThreadExtMacAddressTlv; /** - * This class defines RLOC16 TLV constants and types. + * Defines RLOC16 TLV constants and types. * */ typedef UintTlvInfo ThreadRloc16Tlv; /** - * This class defines ML-EID TLV constants and types. + * Defines ML-EID TLV constants and types. * */ typedef SimpleTlvInfo ThreadMeshLocalEidTlv; /** - * This class defines Time Since Last Transaction TLV constants and types. + * Defines Time Since Last Transaction TLV constants and types. * */ typedef UintTlvInfo ThreadLastTransactionTimeTlv; /** - * This class defines Timeout TLV constants and types. + * Defines Timeout TLV constants and types. * */ typedef UintTlvInfo ThreadTimeoutTlv; /** - * This class defines Network Name TLV constants and types. + * Defines Network Name TLV constants and types. * */ typedef StringTlvInfo ThreadNetworkNameTlv; /** - * This class defines Commissioner Session ID TLV constants and types. + * Defines Commissioner Session ID TLV constants and types. * */ typedef UintTlvInfo ThreadCommissionerSessionIdTlv; /** - * This class defines Status TLV constants and types. + * Defines Status TLV constants and types. * */ class ThreadStatusTlv : public UintTlvInfo @@ -199,14 +199,14 @@ class ThreadStatusTlv : public UintTlvInfo }; /** - * This class implements Router Mask TLV generation and parsing. + * Implements Router Mask TLV generation and parsing. * */ class ThreadRouterMaskTlv : public ThreadTlv, public TlvInfo { public: /** - * This method initializes the TLV. + * Initializes the TLV. * */ void Init(void) @@ -217,7 +217,7 @@ class ThreadRouterMaskTlv : public ThreadTlv, public TlvInfo= sizeof(*this) - sizeof(ThreadTlv); } /** - * This method returns the ID Sequence value. + * Returns the ID Sequence value. * * @returns The ID Sequence value. * @@ -234,7 +234,7 @@ class ThreadRouterMaskTlv : public ThreadTlv, public TlvInfo= OT_THREAD_VERSION_1_2 /** - * This class implements IPv6 Addresses TLV generation and parsing. + * Implements IPv6 Addresses TLV generation and parsing. * */ OT_TOOL_PACKED_BEGIN @@ -325,13 +325,13 @@ class Ip6AddressesTlv : public ThreadTlv, public TlvInfo` method) in a given `Type`. + * Declares a TMF handler (a full template specialization of `HandleTmf` method) in a given `Type`. * * The class `Type` MUST declare a template method of the following format: * @@ -62,7 +62,7 @@ constexpr uint16_t kUdpPort = 61631; ///< TMF UDP Port typedef Coap::Message Message; ///< A TMF message. /** - * This class represents message information for a TMF message. + * Represents message information for a TMF message. * * This is sub-class of `Ip6::MessageInfo` intended for use when sending TMF messages. * @@ -71,7 +71,7 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo { public: /** - * This constructor initializes the `MessageInfo`. + * Initializes the `MessageInfo`. * * The peer port is set to `Tmf::kUdpPort` and all other properties are cleared (set to zero). * @@ -85,19 +85,19 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo } /** - * This method sets the local socket port to TMF port. + * Sets the local socket port to TMF port. * */ void SetSockPortToTmf(void) { SetSockPort(kUdpPort); } /** - * This method sets the local socket address to mesh-local RLOC address. + * Sets the local socket address to mesh-local RLOC address. * */ void SetSockAddrToRloc(void); /** - * This method sets the local socket address to RLOC address and the peer socket address to leader ALOC. + * Sets the local socket address to RLOC address and the peer socket address to leader ALOC. * * @retval kErrorNone Successfully set the addresses. * @retval kErrorDetached Cannot set leader ALOC since device is currently detached. @@ -106,7 +106,7 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo Error SetSockAddrToRlocPeerAddrToLeaderAloc(void); /** - * This method sets the local socket address to RLOC address and the peer socket address to leader RLOC. + * Sets the local socket address to RLOC address and the peer socket address to leader RLOC. * * @retval kErrorNone Successfully set the addresses. * @retval kErrorDetached Cannot set leader RLOC since device is currently detached. @@ -115,14 +115,14 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo Error SetSockAddrToRlocPeerAddrToLeaderRloc(void); /** - * This method sets the local socket address to RLOC address and the peer socket address to realm-local all + * Sets the local socket address to RLOC address and the peer socket address to realm-local all * routers multicast address. * */ void SetSockAddrToRlocPeerAddrToRealmLocalAllRoutersMulticast(void); /** - * This method sets the local socket address to RLOC address and the peer socket address to a router RLOC based on + * Sets the local socket address to RLOC address and the peer socket address to a router RLOC based on * a given RLOC16. * * @param[in] aRloc16 The RLOC16 to use for peer address. @@ -131,7 +131,7 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo void SetSockAddrToRlocPeerAddrTo(uint16_t aRloc16); /** - * This method sets the local socket address to RLOC address and the peer socket address to a given address. + * Sets the local socket address to RLOC address and the peer socket address to a given address. * * @param[in] aPeerAddress The peer address. * @@ -140,14 +140,14 @@ class MessageInfo : public InstanceLocator, public Ip6::MessageInfo }; /** - * This class implements functionality of the Thread TMF agent. + * Implements functionality of the Thread TMF agent. * */ class Agent : public Coap::Coap { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -155,7 +155,7 @@ class Agent : public Coap::Coap explicit Agent(Instance &aInstance); /** - * This method starts the TMF agent. + * Starts the TMF agent. * * @retval kErrorNone Successfully started the CoAP service. * @retval kErrorFailed Failed to start the TMF agent. @@ -164,7 +164,7 @@ class Agent : public Coap::Coap Error Start(void); /** - * This method indicates whether or not a message meets TMF addressing rules. + * Indicates whether or not a message meets TMF addressing rules. * * A TMF message MUST comply with following rules: * @@ -183,7 +183,7 @@ class Agent : public Coap::Coap bool IsTmfMessage(const Ip6::Address &aSourceAddress, const Ip6::Address &aDestAddress, uint16_t aDestPort) const; /** - * This static method converts a TMF message priority to IPv6 header DSCP value. + * Converts a TMF message priority to IPv6 header DSCP value. * * @param[in] aPriority The message priority to convert. * @@ -193,7 +193,7 @@ class Agent : public Coap::Coap static uint8_t PriorityToDscp(Message::Priority aPriority); /** - * This static method converts a IPv6 header DSCP value to message priority for TMF message. + * Converts a IPv6 header DSCP value to message priority for TMF message. * * @param[in] aDscp The IPv6 header DSCP value in a TMF message. * @@ -217,14 +217,14 @@ class Agent : public Coap::Coap #if OPENTHREAD_CONFIG_DTLS_ENABLE /** - * This class implements functionality of the secure TMF agent. + * Implements functionality of the secure TMF agent. * */ class SecureAgent : public Coap::CoapSecure { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * diff --git a/src/core/thread/topology.hpp b/src/core/thread/topology.hpp index 2f89fae4c3a..7e4b0c00642 100644 --- a/src/core/thread/topology.hpp +++ b/src/core/thread/topology.hpp @@ -65,7 +65,7 @@ namespace ot { /** - * This class represents a Thread neighbor. + * Represents a Thread neighbor. * */ class Neighbor : public InstanceLocatorInit @@ -96,7 +96,7 @@ class Neighbor : public InstanceLocatorInit }; /** - * This enumeration defines state filters used for finding a neighbor or iterating through the child/neighbor table. + * Defines state filters used for finding a neighbor or iterating through the child/neighbor table. * * Each filter definition accepts a subset of `State` values. * @@ -114,7 +114,7 @@ class Neighbor : public InstanceLocatorInit }; /** - * This class represents an Address Matcher used to find a neighbor (child/router) with a given MAC address also + * Represents an Address Matcher used to find a neighbor (child/router) with a given MAC address also * matching a given state filter. * */ @@ -122,7 +122,7 @@ class Neighbor : public InstanceLocatorInit { public: /** - * This constructor initializes the `AddressMatcher` with a given MAC short address (RCOC16) and state filter. + * Initializes the `AddressMatcher` with a given MAC short address (RCOC16) and state filter. * * @param[in] aShortAddress A MAC short address (RLOC16). * @param[in] aStateFilter A state filter. @@ -134,7 +134,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This constructor initializes the `AddressMatcher` with a given MAC extended address and state filter. + * Initializes the `AddressMatcher` with a given MAC extended address and state filter. * * @param[in] aExtAddress A MAC extended address. * @param[in] aStateFilter A state filter. @@ -146,7 +146,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This constructor initializes the `AddressMatcher` with a given MAC address and state filter. + * Initializes the `AddressMatcher` with a given MAC address and state filter. * * @param[in] aMacAddress A MAC address. * @param[in] aStateFilter A state filter. @@ -161,7 +161,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This constructor initializes the `AddressMatcher` with a given state filter (it accepts any address). + * Initializes the `AddressMatcher` with a given state filter (it accepts any address). * * @param[in] aStateFilter A state filter. * @@ -172,7 +172,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This method indicates if a given neighbor matches the address and state filter of `AddressMatcher`. + * Indicates if a given neighbor matches the address and state filter of `AddressMatcher`. * * @param[in] aNeighbor A neighbor. * @@ -196,14 +196,14 @@ class Neighbor : public InstanceLocatorInit }; /** - * This type represents diagnostic information for a neighboring node. + * Represents diagnostic information for a neighboring node. * */ class Info : public otNeighborInfo, public Clearable { public: /** - * This method sets the `Info` instance from a given `Neighbor`. + * Sets the `Info` instance from a given `Neighbor`. * * @param[in] aNeighbor A neighbor. * @@ -212,7 +212,7 @@ class Neighbor : public InstanceLocatorInit }; /** - * This method returns the current state. + * Returns the current state. * * @returns The current state. * @@ -220,7 +220,7 @@ class Neighbor : public InstanceLocatorInit State GetState(void) const { return static_cast(mState); } /** - * This method sets the current state. + * Sets the current state. * * @param[in] aState The state value. * @@ -228,7 +228,7 @@ class Neighbor : public InstanceLocatorInit void SetState(State aState); /** - * This method indicates whether the neighbor is in the Invalid state. + * Indicates whether the neighbor is in the Invalid state. * * @returns TRUE if the neighbor is in the Invalid state, FALSE otherwise. * @@ -236,7 +236,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateInvalid(void) const { return (mState == kStateInvalid); } /** - * This method indicates whether the neighbor is in the Child ID Request state. + * Indicates whether the neighbor is in the Child ID Request state. * * @returns TRUE if the neighbor is in the Child ID Request state, FALSE otherwise. * @@ -244,7 +244,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateChildIdRequest(void) const { return (mState == kStateChildIdRequest); } /** - * This method indicates whether the neighbor is in the Link Request state. + * Indicates whether the neighbor is in the Link Request state. * * @returns TRUE if the neighbor is in the Link Request state, FALSE otherwise. * @@ -252,7 +252,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateLinkRequest(void) const { return (mState == kStateLinkRequest); } /** - * This method indicates whether the neighbor is in the Parent Response state. + * Indicates whether the neighbor is in the Parent Response state. * * @returns TRUE if the neighbor is in the Parent Response state, FALSE otherwise. * @@ -260,7 +260,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateParentResponse(void) const { return (mState == kStateParentResponse); } /** - * This method indicates whether the neighbor is being restored. + * Indicates whether the neighbor is being restored. * * @returns TRUE if the neighbor is being restored, FALSE otherwise. * @@ -268,7 +268,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateRestoring(void) const { return (mState == kStateRestored) || (mState == kStateChildUpdateRequest); } /** - * This method indicates whether the neighbor is in the Restored state. + * Indicates whether the neighbor is in the Restored state. * * @returns TRUE if the neighbor is in the Restored state, FALSE otherwise. * @@ -276,7 +276,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateRestored(void) const { return (mState == kStateRestored); } /** - * This method indicates whether the neighbor is valid (frame counters are synchronized). + * Indicates whether the neighbor is valid (frame counters are synchronized). * * @returns TRUE if the neighbor is valid, FALSE otherwise. * @@ -284,7 +284,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateValid(void) const { return (mState == kStateValid); } /** - * This method indicates whether the neighbor is in valid state or if it is being restored. + * Indicates whether the neighbor is in valid state or if it is being restored. * * When in these states messages can be sent to and/or received from the neighbor. * @@ -294,7 +294,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateValidOrRestoring(void) const { return (mState == kStateValid) || IsStateRestoring(); } /** - * This method indicates if the neighbor state is valid, attaching, or restored. + * Indicates if the neighbor state is valid, attaching, or restored. * * The states `kStateRestored`, `kStateChildIdRequest`, `kStateChildUpdateRequest`, `kStateValid`, and * `kStateLinkRequest` are considered as valid, attaching, or restored. @@ -305,7 +305,7 @@ class Neighbor : public InstanceLocatorInit bool IsStateValidOrAttaching(void) const; /** - * This method indicates whether neighbor state matches a given state filter. + * Indicates whether neighbor state matches a given state filter. * * @param[in] aFilter A state filter (`StateFilter` enumeration) to match against. * @@ -315,7 +315,7 @@ class Neighbor : public InstanceLocatorInit bool MatchesFilter(StateFilter aFilter) const; /** - * This method indicates whether neighbor matches a given `AddressMatcher`. + * Indicates whether neighbor matches a given `AddressMatcher`. * * @param[in] aMatcher An `AddressMatcher` to match against. * @@ -325,7 +325,7 @@ class Neighbor : public InstanceLocatorInit bool Matches(const AddressMatcher &aMatcher) const { return aMatcher.Matches(*this); } /** - * This method gets the device mode flags. + * Gets the device mode flags. * * @returns The device mode flags. * @@ -333,7 +333,7 @@ class Neighbor : public InstanceLocatorInit Mle::DeviceMode GetDeviceMode(void) const { return Mle::DeviceMode(mMode); } /** - * This method sets the device mode flags. + * Sets the device mode flags. * * @param[in] aMode The device mode flags. * @@ -341,7 +341,7 @@ class Neighbor : public InstanceLocatorInit void SetDeviceMode(Mle::DeviceMode aMode) { mMode = aMode.Get(); } /** - * This method indicates whether or not the device is rx-on-when-idle. + * Indicates whether or not the device is rx-on-when-idle. * * @returns TRUE if rx-on-when-idle, FALSE otherwise. * @@ -349,7 +349,7 @@ class Neighbor : public InstanceLocatorInit bool IsRxOnWhenIdle(void) const { return GetDeviceMode().IsRxOnWhenIdle(); } /** - * This method indicates whether or not the device is a Full Thread Device. + * Indicates whether or not the device is a Full Thread Device. * * @returns TRUE if a Full Thread Device, FALSE otherwise. * @@ -357,7 +357,7 @@ class Neighbor : public InstanceLocatorInit bool IsFullThreadDevice(void) const { return GetDeviceMode().IsFullThreadDevice(); } /** - * This method gets the Network Data type (full set or stable subset) that the device requests. + * Gets the Network Data type (full set or stable subset) that the device requests. * * @returns The Network Data type. * @@ -365,7 +365,7 @@ class Neighbor : public InstanceLocatorInit NetworkData::Type GetNetworkDataType(void) const { return GetDeviceMode().GetNetworkDataType(); } /** - * This method returns the Extended Address. + * Returns the Extended Address. * * @returns A const reference to the Extended Address. * @@ -373,7 +373,7 @@ class Neighbor : public InstanceLocatorInit const Mac::ExtAddress &GetExtAddress(void) const { return mMacAddr; } /** - * This method returns the Extended Address. + * Returns the Extended Address. * * @returns A reference to the Extended Address. * @@ -381,7 +381,7 @@ class Neighbor : public InstanceLocatorInit Mac::ExtAddress &GetExtAddress(void) { return mMacAddr; } /** - * This method sets the Extended Address. + * Sets the Extended Address. * * @param[in] aAddress The Extended Address value to set. * @@ -389,7 +389,7 @@ class Neighbor : public InstanceLocatorInit void SetExtAddress(const Mac::ExtAddress &aAddress) { mMacAddr = aAddress; } /** - * This method gets the key sequence value. + * Gets the key sequence value. * * @returns The key sequence value. * @@ -397,7 +397,7 @@ class Neighbor : public InstanceLocatorInit uint32_t GetKeySequence(void) const { return mKeySequence; } /** - * This method sets the key sequence value. + * Sets the key sequence value. * * @param[in] aKeySequence The key sequence value. * @@ -405,7 +405,7 @@ class Neighbor : public InstanceLocatorInit void SetKeySequence(uint32_t aKeySequence) { mKeySequence = aKeySequence; } /** - * This method returns the last heard time. + * Returns the last heard time. * * @returns The last heard time. * @@ -413,7 +413,7 @@ class Neighbor : public InstanceLocatorInit TimeMilli GetLastHeard(void) const { return mLastHeard; } /** - * This method sets the last heard time. + * Sets the last heard time. * * @param[in] aLastHeard The last heard time. * @@ -421,7 +421,7 @@ class Neighbor : public InstanceLocatorInit void SetLastHeard(TimeMilli aLastHeard) { mLastHeard = aLastHeard; } /** - * This method gets the link frame counters. + * Gets the link frame counters. * * @returns A reference to `Mac::LinkFrameCounters` containing link frame counter for all supported radio links. * @@ -429,7 +429,7 @@ class Neighbor : public InstanceLocatorInit Mac::LinkFrameCounters &GetLinkFrameCounters(void) { return mValidPending.mValid.mLinkFrameCounters; } /** - * This method gets the link frame counters. + * Gets the link frame counters. * * @returns A reference to `Mac::LinkFrameCounters` containing link frame counter for all supported radio links. * @@ -438,7 +438,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 /** - * This method gets the link ACK frame counter value. + * Gets the link ACK frame counter value. * * @returns The link ACK frame counter value. * @@ -447,7 +447,7 @@ class Neighbor : public InstanceLocatorInit #endif /** - * This method sets the link ACK frame counter value. + * Sets the link ACK frame counter value. * * @param[in] aAckFrameCounter The link ACK frame counter value. * @@ -462,7 +462,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This method gets the MLE frame counter value. + * Gets the MLE frame counter value. * * @returns The MLE frame counter value. * @@ -470,7 +470,7 @@ class Neighbor : public InstanceLocatorInit uint32_t GetMleFrameCounter(void) const { return mValidPending.mValid.mMleFrameCounter; } /** - * This method sets the MLE frame counter value. + * Sets the MLE frame counter value. * * @param[in] aFrameCounter The MLE frame counter value. * @@ -478,7 +478,7 @@ class Neighbor : public InstanceLocatorInit void SetMleFrameCounter(uint32_t aFrameCounter) { mValidPending.mValid.mMleFrameCounter = aFrameCounter; } /** - * This method gets the RLOC16 value. + * Gets the RLOC16 value. * * @returns The RLOC16 value. * @@ -486,7 +486,7 @@ class Neighbor : public InstanceLocatorInit uint16_t GetRloc16(void) const { return mRloc16; } /** - * This method gets the Router ID value. + * Gets the Router ID value. * * @returns The Router ID value. * @@ -494,7 +494,7 @@ class Neighbor : public InstanceLocatorInit uint8_t GetRouterId(void) const { return mRloc16 >> Mle::kRouterIdOffset; } /** - * This method sets the RLOC16 value. + * Sets the RLOC16 value. * * @param[in] aRloc16 The RLOC16 value. * @@ -503,7 +503,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method clears the last received fragment tag. + * Clears the last received fragment tag. * * The last received fragment tag is used for detect duplicate frames (received over different radios) when * multi-radio feature is enabled. @@ -512,9 +512,9 @@ class Neighbor : public InstanceLocatorInit void ClearLastRxFragmentTag(void) { mLastRxFragmentTag = 0; } /** - * This method gets the last received fragment tag. + * Gets the last received fragment tag. * - * This method MUST be used only when the tag is set (and not cleared). Otherwise its behavior is undefined. + * MUST be used only when the tag is set (and not cleared). Otherwise its behavior is undefined. * * @returns The last received fragment tag. * @@ -522,7 +522,7 @@ class Neighbor : public InstanceLocatorInit uint16_t GetLastRxFragmentTag(void) const { return mLastRxFragmentTag; } /** - * This method set the last received fragment tag. + * Set the last received fragment tag. * * @param[in] aTag The new tag value. * @@ -530,7 +530,7 @@ class Neighbor : public InstanceLocatorInit void SetLastRxFragmentTag(uint16_t aTag); /** - * This method indicates whether or not the last received fragment tag is set and valid (i.e., not yet timed out). + * Indicates whether or not the last received fragment tag is set and valid (i.e., not yet timed out). * * @returns TRUE if the last received fragment tag is set and valid, FALSE otherwise. * @@ -538,9 +538,9 @@ class Neighbor : public InstanceLocatorInit bool IsLastRxFragmentTagSet(void) const; /** - * This method indicates whether the last received fragment tag is strictly after a given tag value. + * Indicates whether the last received fragment tag is strictly after a given tag value. * - * This method MUST be used only when the tag is set (and not cleared). Otherwise its behavior is undefined. + * MUST be used only when the tag is set (and not cleared). Otherwise its behavior is undefined. * * The tag value compassion follows the Serial Number Arithmetic logic from RFC-1982. It is semantically equivalent * to `LastRxFragmentTag > aTag`. @@ -556,7 +556,7 @@ class Neighbor : public InstanceLocatorInit #endif // OPENTHREAD_CONFIG_MULTI_RADIO /** - * This method indicates whether or not it is Thread 1.1. + * Indicates whether or not it is Thread 1.1. * * @returns TRUE if neighbors is Thread 1.1, FALSE otherwise. * @@ -564,7 +564,7 @@ class Neighbor : public InstanceLocatorInit bool IsThreadVersion1p1(void) const { return mState != kStateInvalid && mVersion == kThreadVersion1p1; } /** - * This method indicates whether or not neighbor is Thread 1.2 or higher.. + * Indicates whether or not neighbor is Thread 1.2 or higher.. * * @returns TRUE if neighbor is Thread 1.2 or higher, FALSE otherwise. * @@ -572,7 +572,7 @@ class Neighbor : public InstanceLocatorInit bool IsThreadVersion1p2OrHigher(void) const { return mState != kStateInvalid && mVersion >= kThreadVersion1p2; } /** - * This method indicates whether Thread version supports CSL. + * Indicates whether Thread version supports CSL. * * @returns TRUE if CSL is supported, FALSE otherwise. * @@ -580,7 +580,7 @@ class Neighbor : public InstanceLocatorInit bool IsThreadVersionCslCapable(void) const { return IsThreadVersion1p2OrHigher() && !IsRxOnWhenIdle(); } /** - * This method indicates whether Enhanced Keep-Alive is supported or not. + * Indicates whether Enhanced Keep-Alive is supported or not. * * @returns TRUE if Enhanced Keep-Alive is supported, FALSE otherwise. * @@ -591,13 +591,13 @@ class Neighbor : public InstanceLocatorInit } /** - * This method gets the device MLE version. + * Gets the device MLE version. * */ uint16_t GetVersion(void) const { return mVersion; } /** - * This method sets the device MLE version. + * Sets the device MLE version. * * @param[in] aVersion The device MLE version. * @@ -605,7 +605,7 @@ class Neighbor : public InstanceLocatorInit void SetVersion(uint16_t aVersion) { mVersion = aVersion; } /** - * This method gets the number of consecutive link failures. + * Gets the number of consecutive link failures. * * @returns The number of consecutive link failures. * @@ -613,19 +613,19 @@ class Neighbor : public InstanceLocatorInit uint8_t GetLinkFailures(void) const { return mLinkFailures; } /** - * This method increments the number of consecutive link failures. + * Increments the number of consecutive link failures. * */ void IncrementLinkFailures(void) { mLinkFailures++; } /** - * This method resets the number of consecutive link failures to zero. + * Resets the number of consecutive link failures to zero. * */ void ResetLinkFailures(void) { mLinkFailures = 0; } /** - * This method returns the LinkQualityInfo object. + * Returns the LinkQualityInfo object. * * @returns The LinkQualityInfo object. * @@ -633,7 +633,7 @@ class Neighbor : public InstanceLocatorInit LinkQualityInfo &GetLinkInfo(void) { return mLinkInfo; } /** - * This method returns the LinkQualityInfo object. + * Returns the LinkQualityInfo object. * * @returns The LinkQualityInfo object. * @@ -641,7 +641,7 @@ class Neighbor : public InstanceLocatorInit const LinkQualityInfo &GetLinkInfo(void) const { return mLinkInfo; } /** - * This method gets the link quality in value. + * Gets the link quality in value. * * @returns The link quality in value. * @@ -649,13 +649,13 @@ class Neighbor : public InstanceLocatorInit LinkQuality GetLinkQualityIn(void) const { return GetLinkInfo().GetLinkQuality(); } /** - * This method generates a new challenge value for MLE Link Request/Response exchanges. + * Generates a new challenge value for MLE Link Request/Response exchanges. * */ void GenerateChallenge(void); /** - * This method returns the current challenge value for MLE Link Request/Response exchanges. + * Returns the current challenge value for MLE Link Request/Response exchanges. * * @returns The current challenge value. * @@ -663,7 +663,7 @@ class Neighbor : public InstanceLocatorInit const uint8_t *GetChallenge(void) const { return mValidPending.mPending.mChallenge; } /** - * This method returns the size (bytes) of the challenge value for MLE Link Request/Response exchanges. + * Returns the size (bytes) of the challenge value for MLE Link Request/Response exchanges. * * @returns The size (bytes) of the challenge value for MLE Link Request/Response exchanges. * @@ -672,7 +672,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_CONFIG_UPTIME_ENABLE /** - * This method returns the connection time (in seconds) of the neighbor (seconds since entering `kStateValid`). + * Returns the connection time (in seconds) of the neighbor (seconds since entering `kStateValid`). * * @returns The connection time (in seconds), zero if device is not currently in `kStateValid`. * @@ -682,7 +682,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE /** - * This method indicates whether or not time sync feature is enabled. + * Indicates whether or not time sync feature is enabled. * * @returns TRUE if time sync feature is enabled, FALSE otherwise. * @@ -690,7 +690,7 @@ class Neighbor : public InstanceLocatorInit bool IsTimeSyncEnabled(void) const { return mTimeSyncEnabled; } /** - * This method sets whether or not time sync feature is enabled. + * Sets whether or not time sync feature is enabled. * * @param[in] aEnable TRUE if time sync feature is enabled, FALSE otherwise. * @@ -700,7 +700,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method aggregates the Link Metrics data into all the series that is running for this neighbor. + * Aggregates the Link Metrics data into all the series that is running for this neighbor. * * If a series wants to account frames of @p aFrameType, it would add count by 1 and aggregate @p aLqi and * @p aRss into its averagers. @@ -714,7 +714,7 @@ class Neighbor : public InstanceLocatorInit void AggregateLinkMetrics(uint8_t aSeriesId, uint8_t aFrameType, uint8_t aLqi, int8_t aRss); /** - * This method adds a new LinkMetrics::SeriesInfo to the neighbor's list. + * Adds a new LinkMetrics::SeriesInfo to the neighbor's list. * * @param[in] aSeriesInfo A reference to the new SeriesInfo. * @@ -722,7 +722,7 @@ class Neighbor : public InstanceLocatorInit void AddForwardTrackingSeriesInfo(LinkMetrics::SeriesInfo &aSeriesInfo); /** - * This method finds a specific LinkMetrics::SeriesInfo by Series ID. + * Finds a specific LinkMetrics::SeriesInfo by Series ID. * * @param[in] aSeriesId A reference to the Series ID. * @@ -732,7 +732,7 @@ class Neighbor : public InstanceLocatorInit LinkMetrics::SeriesInfo *GetForwardTrackingSeriesInfo(const uint8_t &aSeriesId); /** - * This method removes a specific LinkMetrics::SeriesInfo by Series ID. + * Removes a specific LinkMetrics::SeriesInfo by Series ID. * * @param[in] aSeriesId A reference to the Series ID to remove. * @@ -742,13 +742,13 @@ class Neighbor : public InstanceLocatorInit LinkMetrics::SeriesInfo *RemoveForwardTrackingSeriesInfo(const uint8_t &aSeriesId); /** - * This method removes all the Series and return the data structures to the Pool. + * Removes all the Series and return the data structures to the Pool. * */ void RemoveAllForwardTrackingSeriesInfo(void); /** - * This method gets the Enh-ACK Probing metrics (this `Neighbor` object is the Probing Subject). + * Gets the Enh-ACK Probing metrics (this `Neighbor` object is the Probing Subject). * * @returns Enh-ACK Probing metrics configured. * @@ -756,7 +756,7 @@ class Neighbor : public InstanceLocatorInit const LinkMetrics::Metrics &GetEnhAckProbingMetrics(void) const { return mEnhAckProbingMetrics; } /** - * This method sets the Enh-ACK Probing metrics (this `Neighbor` object is the Probing Subject). + * Sets the Enh-ACK Probing metrics (this `Neighbor` object is the Probing Subject). * * @param[in] aEnhAckProbingMetrics The metrics value to set. * @@ -767,7 +767,7 @@ class Neighbor : public InstanceLocatorInit } /** - * This method indicates if Enh-ACK Probing is configured and active for this `Neighbor` object. + * Indicates if Enh-ACK Probing is configured and active for this `Neighbor` object. * * @retval TRUE Enh-ACK Probing is configured and active for this `Neighbor`. * @retval FALSE Otherwise. @@ -781,7 +781,7 @@ class Neighbor : public InstanceLocatorInit #endif // OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE || OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE /** - * This method converts a given `State` to a human-readable string. + * Converts a given `State` to a human-readable string. * * @param[in] aState A neighbor state. * @@ -792,7 +792,7 @@ class Neighbor : public InstanceLocatorInit protected: /** - * This method initializes the `Neighbor` object. + * Initializes the `Neighbor` object. * * @param[in] aInstance A reference to OpenThread instance. * @@ -859,7 +859,7 @@ class Neighbor : public InstanceLocatorInit #if OPENTHREAD_FTD /** - * This class represents a Thread Child. + * Represents a Thread Child. * */ class Child : public Neighbor, @@ -876,14 +876,14 @@ class Child : public Neighbor, static constexpr uint8_t kMaxRequestTlvs = 6; /** - * This class represents diagnostic information for a Thread Child. + * Represents diagnostic information for a Thread Child. * */ class Info : public otChildInfo, public Clearable { public: /** - * This method sets the `Info` instance from a given `Child`. + * Sets the `Info` instance from a given `Child`. * * @param[in] aChild A neighbor. * @@ -892,7 +892,7 @@ class Child : public Neighbor, }; /** - * This class defines an iterator used to go through IPv6 address entries of a child. + * Defines an iterator used to go through IPv6 address entries of a child. * */ class AddressIterator : public Unequatable @@ -901,13 +901,13 @@ class Child : public Neighbor, public: /** - * This type represents an index indicating the current IPv6 address entry to which the iterator is pointing. + * Represents an index indicating the current IPv6 address entry to which the iterator is pointing. * */ typedef otChildIp6AddressIterator Index; /** - * This constructor initializes the iterator associated with a given `Child` starting from beginning of the + * Initializes the iterator associated with a given `Child` starting from beginning of the * IPv6 address list. * * @param[in] aChild A reference to a child entry. @@ -920,7 +920,7 @@ class Child : public Neighbor, } /** - * This constructor initializes the iterator associated with a given `Child` starting from a given index + * Initializes the iterator associated with a given `Child` starting from a given index * * @param[in] aChild A reference to the child entry. * @param[in] aIndex An index (`Index`) with which to initialize the iterator. @@ -936,7 +936,7 @@ class Child : public Neighbor, } /** - * This method converts the iterator into an index. + * Converts the iterator into an index. * * @returns An index corresponding to the iterator. * @@ -944,7 +944,7 @@ class Child : public Neighbor, Index GetAsIndex(void) const { return mIndex; } /** - * This method gets the iterator's associated `Child` entry. + * Gets the iterator's associated `Child` entry. * * @returns The associated child entry. * @@ -952,7 +952,7 @@ class Child : public Neighbor, const Child &GetChild(void) const { return mChild; } /** - * This method gets the current `Child` IPv6 Address to which the iterator is pointing. + * Gets the current `Child` IPv6 Address to which the iterator is pointing. * * @returns A pointer to the associated IPv6 Address, or `nullptr` if iterator is done. * @@ -960,7 +960,7 @@ class Child : public Neighbor, const Ip6::Address *GetAddress(void) const; /** - * This method indicates whether the iterator has reached end of the list. + * Indicates whether the iterator has reached end of the list. * * @retval TRUE There are no more entries in the list (reached end of the list). * @retval FALSE The current entry is valid. @@ -969,7 +969,7 @@ class Child : public Neighbor, bool IsDone(void) const { return (mIndex >= kMaxIndex); } /** - * This method overloads `++` operator (pre-increment) to advance the iterator. + * Overloads `++` operator (pre-increment) to advance the iterator. * * The iterator is moved to point to the next `Address` entry. If there are no more `Ip6::Address` entries * `IsDone()` returns `true`. @@ -978,7 +978,7 @@ class Child : public Neighbor, void operator++(void) { mIndex++, Update(); } /** - * This method overloads `++` operator (post-increment) to advance the iterator. + * Overloads `++` operator (post-increment) to advance the iterator. * * The iterator is moved to point to the next `Address` entry. If there are no more `Ip6::Address` entries * `IsDone()` returns `true`. @@ -987,10 +987,10 @@ class Child : public Neighbor, void operator++(int) { mIndex++, Update(); } /** - * This method overloads the `*` dereference operator and gets a reference to `Ip6::Address` to which the + * Overloads the `*` dereference operator and gets a reference to `Ip6::Address` to which the * iterator is currently pointing. * - * This method MUST be used when the iterator is not done (i.e., `IsDone()` returns `false`). + * MUST be used when the iterator is not done (i.e., `IsDone()` returns `false`). * * @returns A reference to the `Ip6::Address` entry currently pointed by the iterator. * @@ -998,9 +998,9 @@ class Child : public Neighbor, const Ip6::Address &operator*(void) const { return *GetAddress(); } /** - * This method overloads operator `==` to evaluate whether or not two `Iterator` instances are equal. + * Overloads operator `==` to evaluate whether or not two `Iterator` instances are equal. * - * This method MUST be used when the two iterators are associated with the same `Child` entry. + * MUST be used when the two iterators are associated with the same `Child` entry. * * @param[in] aOther The other `Iterator` to compare with. * @@ -1033,7 +1033,7 @@ class Child : public Neighbor, }; /** - * This method initializes the `Child` object. + * Initializes the `Child` object. * * @param[in] aInstance A reference to OpenThread instance. * @@ -1041,19 +1041,19 @@ class Child : public Neighbor, void Init(Instance &aInstance) { Neighbor::Init(aInstance); } /** - * This method clears the child entry. + * Clears the child entry. * */ void Clear(void); /** - * This method clears the IPv6 address list for the child. + * Clears the IPv6 address list for the child. * */ void ClearIp6Addresses(void); /** - * This method sets the device mode flags. + * Sets the device mode flags. * * @param[in] aMode The device mode flags. * @@ -1061,7 +1061,7 @@ class Child : public Neighbor, void SetDeviceMode(Mle::DeviceMode aMode); /** - * This method gets the mesh-local IPv6 address. + * Gets the mesh-local IPv6 address. * * @param[out] aAddress A reference to an IPv6 address to provide address (if any). * @@ -1072,7 +1072,7 @@ class Child : public Neighbor, Error GetMeshLocalIp6Address(Ip6::Address &aAddress) const; /** - * This method returns the Mesh Local Interface Identifier. + * Returns the Mesh Local Interface Identifier. * * @returns The Mesh Local Interface Identifier. * @@ -1080,9 +1080,9 @@ class Child : public Neighbor, const Ip6::InterfaceIdentifier &GetMeshLocalIid(void) const { return mMeshLocalIid; } /** - * This method enables range-based `for` loop iteration over all (or a subset of) IPv6 addresses. + * Enables range-based `for` loop iteration over all (or a subset of) IPv6 addresses. * - * This method should be used as follows: to iterate over all addresses + * Should be used as follows: to iterate over all addresses * * for (const Ip6::Address &address : child.IterateIp6Addresses()) { ... } * @@ -1102,7 +1102,7 @@ class Child : public Neighbor, } /** - * This method adds an IPv6 address to the list. + * Adds an IPv6 address to the list. * * @param[in] aAddress A reference to IPv6 address to be added. * @@ -1115,7 +1115,7 @@ class Child : public Neighbor, Error AddIp6Address(const Ip6::Address &aAddress); /** - * This method removes an IPv6 address from the list. + * Removes an IPv6 address from the list. * * @param[in] aAddress A reference to IPv6 address to be removed. * @@ -1127,7 +1127,7 @@ class Child : public Neighbor, Error RemoveIp6Address(const Ip6::Address &aAddress); /** - * This method indicates whether an IPv6 address is in the list of IPv6 addresses of the child. + * Indicates whether an IPv6 address is in the list of IPv6 addresses of the child. * * @param[in] aAddress A reference to IPv6 address. * @@ -1139,7 +1139,7 @@ class Child : public Neighbor, #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE /** - * This method retrieves the Domain Unicast Address registered by the child. + * Retrieves the Domain Unicast Address registered by the child. * * @returns A pointer to Domain Unicast Address registered by the child if there is. * @@ -1148,7 +1148,7 @@ class Child : public Neighbor, #endif /** - * This method gets the child timeout. + * Gets the child timeout. * * @returns The child timeout. * @@ -1156,7 +1156,7 @@ class Child : public Neighbor, uint32_t GetTimeout(void) const { return mTimeout; } /** - * This method sets the child timeout. + * Sets the child timeout. * * @param[in] aTimeout The child timeout. * @@ -1164,7 +1164,7 @@ class Child : public Neighbor, void SetTimeout(uint32_t aTimeout) { mTimeout = aTimeout; } /** - * This method gets the network data version. + * Gets the network data version. * * @returns The network data version. * @@ -1172,7 +1172,7 @@ class Child : public Neighbor, uint8_t GetNetworkDataVersion(void) const { return mNetworkDataVersion; } /** - * This method sets the network data version. + * Sets the network data version. * * @param[in] aVersion The network data version. * @@ -1180,13 +1180,13 @@ class Child : public Neighbor, void SetNetworkDataVersion(uint8_t aVersion) { mNetworkDataVersion = aVersion; } /** - * This method generates a new challenge value to use during a child attach. + * Generates a new challenge value to use during a child attach. * */ void GenerateChallenge(void); /** - * This method gets the current challenge value used during attach. + * Gets the current challenge value used during attach. * * @returns The current challenge value. * @@ -1194,7 +1194,7 @@ class Child : public Neighbor, const uint8_t *GetChallenge(void) const { return mAttachChallenge; } /** - * This method gets the challenge size (bytes) used during attach. + * Gets the challenge size (bytes) used during attach. * * @returns The challenge size (bytes). * @@ -1202,13 +1202,13 @@ class Child : public Neighbor, uint8_t GetChallengeSize(void) const { return sizeof(mAttachChallenge); } /** - * This method clears the requested TLV list. + * Clears the requested TLV list. * */ void ClearRequestTlvs(void) { memset(mRequestTlvs, Mle::Tlv::kInvalid, sizeof(mRequestTlvs)); } /** - * This method returns the requested TLV at index @p aIndex. + * Returns the requested TLV at index @p aIndex. * * @param[in] aIndex The index into the requested TLV list. * @@ -1218,7 +1218,7 @@ class Child : public Neighbor, uint8_t GetRequestTlv(uint8_t aIndex) const { return mRequestTlvs[aIndex]; } /** - * This method sets the requested TLV at index @p aIndex. + * Sets the requested TLV at index @p aIndex. * * @param[in] aIndex The index into the requested TLV list. * @param[in] aType The TLV type. @@ -1227,7 +1227,7 @@ class Child : public Neighbor, void SetRequestTlv(uint8_t aIndex, uint8_t aType) { mRequestTlvs[aIndex] = aType; } /** - * This method returns the supervision interval (in seconds). + * Returns the supervision interval (in seconds). * * @returns The supervision interval (in seconds). * @@ -1235,7 +1235,7 @@ class Child : public Neighbor, uint16_t GetSupervisionInterval(void) const { return mSupervisionInterval; } /** - * This method sets the supervision interval. + * Sets the supervision interval. * * @param[in] aInterval The supervision interval (in seconds). * @@ -1243,13 +1243,13 @@ class Child : public Neighbor, void SetSupervisionInterval(uint16_t aInterval) { mSupervisionInterval = aInterval; } /** - * This method increments the number of seconds since last supervision of the child. + * Increments the number of seconds since last supervision of the child. * */ void IncrementSecondsSinceLastSupervision(void) { mSecondsSinceSupervision++; } /** - * This method returns the number of seconds since last supervision of the child (last message to the child) + * Returns the number of seconds since last supervision of the child (last message to the child) * * @returns Number of seconds since last supervision of the child. * @@ -1257,14 +1257,14 @@ class Child : public Neighbor, uint16_t GetSecondsSinceLastSupervision(void) const { return mSecondsSinceSupervision; } /** - * This method resets the number of seconds since last supervision of the child to zero. + * Resets the number of seconds since last supervision of the child to zero. * */ void ResetSecondsSinceLastSupervision(void) { mSecondsSinceSupervision = 0; } #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE /** - * This method returns MLR state of an IPv6 multicast address. + * Returns MLR state of an IPv6 multicast address. * * @note The @p aAddress reference MUST be from `IterateIp6Addresses()` or `AddressIterator`. * @@ -1276,7 +1276,7 @@ class Child : public Neighbor, MlrState GetAddressMlrState(const Ip6::Address &aAddress) const; /** - * This method sets MLR state of an IPv6 multicast address. + * Sets MLR state of an IPv6 multicast address. * * @note The @p aAddress reference MUST be from `IterateIp6Addresses()` or `AddressIterator`. * @@ -1287,7 +1287,7 @@ class Child : public Neighbor, void SetAddressMlrState(const Ip6::Address &aAddress, MlrState aState); /** - * This method returns if the Child has IPv6 address @p aAddress of MLR state `kMlrStateRegistered`. + * Returns if the Child has IPv6 address @p aAddress of MLR state `kMlrStateRegistered`. * * @param[in] aAddress The IPv6 address. * @@ -1298,7 +1298,7 @@ class Child : public Neighbor, bool HasMlrRegisteredAddress(const Ip6::Address &aAddress) const; /** - * This method returns if the Child has any IPv6 address of MLR state `kMlrStateRegistered`. + * Returns if the Child has any IPv6 address of MLR state `kMlrStateRegistered`. * * @retval true If the Child has any IPv6 address of MLR state `kMlrStateRegistered`. * @retval false If the Child does not have any IPv6 address of MLR state `kMlrStateRegistered`. @@ -1307,7 +1307,7 @@ class Child : public Neighbor, bool HasAnyMlrRegisteredAddress(void) const { return mMlrRegisteredMask.HasAny(); } /** - * This method returns if the Child has any IPv6 address of MLR state `kMlrStateToRegister`. + * Returns if the Child has any IPv6 address of MLR state `kMlrStateToRegister`. * * @retval true If the Child has any IPv6 address of MLR state `kMlrStateToRegister`. * @retval false If the Child does not have any IPv6 address of MLR state `kMlrStateToRegister`. @@ -1370,21 +1370,21 @@ class Child : public Neighbor, class Parent; /** - * This class represents a Thread Router + * Represents a Thread Router * */ class Router : public Neighbor { public: /** - * This class represents diagnostic information for a Thread Router. + * Represents diagnostic information for a Thread Router. * */ class Info : public otRouterInfo, public Clearable { public: /** - * This method sets the `Info` instance from a given `Router`. + * Sets the `Info` instance from a given `Router`. * * @param[in] aRouter A router. * @@ -1392,7 +1392,7 @@ class Router : public Neighbor void SetFrom(const Router &aRouter); /** - * This method sets the `Info` instance from a given `Parent`. + * Sets the `Info` instance from a given `Parent`. * * @param[in] aParent A parent. * @@ -1401,7 +1401,7 @@ class Router : public Neighbor }; /** - * This method initializes the `Router` object. + * Initializes the `Router` object. * * @param[in] aInstance A reference to OpenThread instance. * @@ -1409,19 +1409,19 @@ class Router : public Neighbor void Init(Instance &aInstance) { Neighbor::Init(aInstance); } /** - * This method clears the router entry. + * Clears the router entry. * */ void Clear(void); /** - * This method sets the `Router` entry from a `Parent` + * Sets the `Router` entry from a `Parent` * */ void SetFrom(const Parent &aParent); /** - * This method gets the router ID of the next hop to this router. + * Gets the router ID of the next hop to this router. * * @returns The router ID of the next hop to this router. * @@ -1429,7 +1429,7 @@ class Router : public Neighbor uint8_t GetNextHop(void) const { return mNextHop; } /** - * This method gets the link quality out value for this router. + * Gets the link quality out value for this router. * * @returns The link quality out value for this router. * @@ -1437,7 +1437,7 @@ class Router : public Neighbor LinkQuality GetLinkQualityOut(void) const { return static_cast(mLinkQualityOut); } /** - * This method sets the link quality out value for this router. + * Sets the link quality out value for this router. * * @param[in] aLinkQuality The link quality out value for this router. * @@ -1445,7 +1445,7 @@ class Router : public Neighbor void SetLinkQualityOut(LinkQuality aLinkQuality) { mLinkQualityOut = aLinkQuality; } /** - * This method gets the two-way link quality value (minimum of link quality in and out). + * Gets the two-way link quality value (minimum of link quality in and out). * * @returns The two-way link quality value. * @@ -1453,7 +1453,7 @@ class Router : public Neighbor LinkQuality GetTwoWayLinkQuality(void) const; /** - * This method get the route cost to this router. + * Get the route cost to this router. * * @returns The route cost to this router. * @@ -1461,7 +1461,7 @@ class Router : public Neighbor uint8_t GetCost(void) const { return mCost; } /** - * This method sets the next hop and cost to this router. + * Sets the next hop and cost to this router. * * @param[in] aNextHop The Router ID of the next hop to this router. * @param[in] aCost The cost to this router. @@ -1473,7 +1473,7 @@ class Router : public Neighbor bool SetNextHopAndCost(uint8_t aNextHop, uint8_t aCost); /** - * This method sets the next hop to this router as invalid and clears the cost. + * Sets the next hop to this router as invalid and clears the cost. * * @retval TRUE If there was a change (next hop was valid before). * @retval FALSE No change to next hop (next hop was invalid before). @@ -1493,14 +1493,14 @@ class Router : public Neighbor }; /** - * This class represent parent of a child node. + * Represent parent of a child node. * */ class Parent : public Router { public: /** - * This method initializes the `Parent`. + * Initializes the `Parent`. * * @param[in] aInstance A reference to OpenThread instance. * @@ -1514,13 +1514,13 @@ class Parent : public Router } /** - * This method clears the parent entry. + * Clears the parent entry. * */ void Clear(void); /** - * This method gets route cost from parent to leader. + * Gets route cost from parent to leader. * * @returns The route cost from parent to leader * @@ -1528,7 +1528,7 @@ class Parent : public Router uint8_t GetLeaderCost(void) const { return mLeaderCost; } /** - * This method sets route cost from parent to leader. + * Sets route cost from parent to leader. * * @param[in] aLaderConst The route cost. * @@ -1537,7 +1537,7 @@ class Parent : public Router #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE /** - * This method gets the CSL accuracy (clock accuracy and uncertainty). + * Gets the CSL accuracy (clock accuracy and uncertainty). * * @returns The CSL accuracy. * @@ -1545,7 +1545,7 @@ class Parent : public Router const Mac::CslAccuracy &GetCslAccuracy(void) const { return mCslAccuracy; } /** - * This method sets CSL accuracy. + * Sets CSL accuracy. * * @param[in] aCslAccuracy The CSL accuracy. * diff --git a/src/core/thread/uri_paths.hpp b/src/core/thread/uri_paths.hpp index 01ef7b08c38..e40666920f7 100644 --- a/src/core/thread/uri_paths.hpp +++ b/src/core/thread/uri_paths.hpp @@ -41,7 +41,7 @@ namespace ot { /** - * This enumeration represents Thread URIs. + * Represents Thread URIs. * */ enum Uri : uint8_t @@ -89,7 +89,7 @@ enum Uri : uint8_t }; /** - * This function returns URI path string for a given URI. + * Returns URI path string for a given URI. * * @param[in] aUri A URI. * @@ -99,7 +99,7 @@ enum Uri : uint8_t const char *PathForUri(Uri aUri); /** - * This function looks up the URI from a given path string. + * Looks up the URI from a given path string. * * @param[in] aPath A path string. * diff --git a/src/core/utils/channel_manager.hpp b/src/core/utils/channel_manager.hpp index f375be02244..ad46141e897 100644 --- a/src/core/utils/channel_manager.hpp +++ b/src/core/utils/channel_manager.hpp @@ -58,7 +58,7 @@ namespace Utils { */ /** - * This class implements the Channel Manager. + * Implements the Channel Manager. * */ class ChannelManager : public InstanceLocator, private NonCopyable @@ -71,7 +71,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable static constexpr uint16_t kMinimumDelay = OPENTHREAD_CONFIG_CHANNEL_MANAGER_MINIMUM_DELAY; /** - * This constructor initializes a `ChanelManager` object. + * Initializes a `ChanelManager` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -79,7 +79,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable explicit ChannelManager(Instance &aInstance); /** - * This method requests a Thread network channel change. + * Requests a Thread network channel change. * * The Thread network switches to the given channel after a specified delay (@sa GetDelay()). The channel change is * performed by updating the Pending Operational Dataset. @@ -94,7 +94,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable void RequestChannelChange(uint8_t aChannel); /** - * This method gets the channel from the last successful call to `RequestChannelChange()`. + * Gets the channel from the last successful call to `RequestChannelChange()`. * * @returns The last requested channel, or zero if there has been no channel change request yet. * @@ -102,7 +102,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint8_t GetRequestedChannel(void) const { return mChannel; } /** - * This method gets the delay (in seconds) used for a channel change. + * Gets the delay (in seconds) used for a channel change. * * @returns The delay (in seconds) * @@ -110,7 +110,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint16_t GetDelay(void) const { return mDelay; } /** - * This method 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 * Thread network. @@ -124,7 +124,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable Error SetDelay(uint16_t aDelay); /** - * This method requests that `ChannelManager` checks and selects a new channel and starts a channel change. + * Requests that `ChannelManager` checks and selects a new channel and starts a channel change. * * Unlike the `RequestChannelChange()` where the channel must be given as a parameter, this method asks the * `ChannelManager` to select a channel by itself (based on the collected channel quality info). @@ -155,7 +155,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable Error RequestChannelSelect(bool aSkipQualityCheck); /** - * This method enables/disables the auto-channel-selection functionality. + * Enables/disables the auto-channel-selection functionality. * * When enabled, `ChannelManager` will periodically invoke a `RequestChannelSelect(false)`. The period interval * can be set by `SetAutoChannelSelectionInterval()`. @@ -166,7 +166,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable void SetAutoChannelSelectionEnabled(bool aEnabled); /** - * This method indicates whether the auto-channel-selection functionality is enabled or not. + * Indicates whether the auto-channel-selection functionality is enabled or not. * * @returns TRUE if enabled, FALSE if disabled. * @@ -174,7 +174,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable bool GetAutoChannelSelectionEnabled(void) const { return mAutoSelectEnabled; } /** - * This method 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] aInterval The interval (in seconds). * @@ -185,7 +185,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable Error SetAutoChannelSelectionInterval(uint32_t aInterval); /** - * This method gets the period interval (in seconds) used by auto-channel-selection functionality. + * Gets the period interval (in seconds) used by auto-channel-selection functionality. * * @returns The interval (in seconds). * @@ -193,7 +193,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint32_t GetAutoChannelSelectionInterval(void) const { return mAutoSelectInterval; } /** - * This method gets the supported channel mask. + * Gets the supported channel mask. * * @returns The supported channels mask. * @@ -201,7 +201,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint32_t GetSupportedChannels(void) const { return mSupportedChannelMask.GetMask(); } /** - * This method sets the supported channel mask. + * Sets the supported channel mask. * * @param[in] aChannelMask A channel mask. * @@ -209,7 +209,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable void SetSupportedChannels(uint32_t aChannelMask); /** - * This method gets the favored channel mask. + * Gets the favored channel mask. * * @returns The favored channels mask. * @@ -217,7 +217,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint32_t GetFavoredChannels(void) const { return mFavoredChannelMask.GetMask(); } /** - * This method sets the favored channel mask. + * Sets the favored channel mask. * * @param[in] aChannelMask A channel mask. * @@ -225,7 +225,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable void SetFavoredChannels(uint32_t aChannelMask); /** - * This method gets the CCA failure rate threshold + * Gets the CCA failure rate threshold * * @returns The CCA failure rate threshold * @@ -233,7 +233,7 @@ class ChannelManager : public InstanceLocator, private NonCopyable uint16_t GetCcaFailureRateThreshold(void) const { return mCcaFailureRateThreshold; } /** - * This method sets the CCA failure rate threshold + * Sets the CCA failure rate threshold * * @param[in] aThreshold A CCA failure rate threshold. * diff --git a/src/core/utils/channel_monitor.hpp b/src/core/utils/channel_monitor.hpp index b0221af5223..2c638a10e23 100644 --- a/src/core/utils/channel_monitor.hpp +++ b/src/core/utils/channel_monitor.hpp @@ -59,7 +59,7 @@ namespace Utils { */ /** - * This class implements the channel monitoring logic. + * Implements the channel monitoring logic. * * Channel Monitoring will periodically monitor all channels to help determine the cleaner channels (channels * with less interference). @@ -95,7 +95,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable static constexpr uint32_t kSampleWindow = OPENTHREAD_CONFIG_CHANNEL_MONITOR_SAMPLE_WINDOW; /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -103,7 +103,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable explicit ChannelMonitor(Instance &aInstance); /** - * This method starts the Channel Monitoring operation. + * Starts the Channel Monitoring operation. * * Once started, any previously collected data is cleared. * @@ -114,7 +114,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable Error Start(void); /** - * This method stops the Channel Monitoring operation. + * Stops the Channel Monitoring operation. * * @note After `Stop()`, the previous data is still valid and can be read. * @@ -125,7 +125,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable Error Stop(void); /** - * This method indicates whether the Channel Monitoring operation is started and running. + * Indicates whether the Channel Monitoring operation is started and running. * * @returns TRUE if the Channel Monitoring operation is running, FALSE otherwise. * @@ -133,13 +133,13 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable bool IsRunning(void) const { return mTimer.IsRunning(); } /** - * This method clears all currently stored data. + * Clears all currently stored data. * */ void Clear(void); /** - * This method returns the total number of RSSI samples (per channel) taken so far (since call to `Start()`). + * Returns the total number of RSSI samples (per channel) taken so far (since call to `Start()`). * * @returns total number of RSSI sample taken since last call to `Start()`. * @@ -147,7 +147,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable uint32_t GetSampleCount(void) const { return mSampleCount; } /** - * This method returns the current channel occupancy for a given channel. + * Returns the current channel occupancy for a given channel. * * The channel occupancy represents the average rate/percentage of RSSI samples that were above RSSI threshold * `kRssiThreshold` ("bad" RSSI samples). @@ -168,7 +168,7 @@ class ChannelMonitor : public InstanceLocator, private NonCopyable uint16_t GetChannelOccupancy(uint8_t aChannel) const; /** - * This method finds the best channel(s) (with least occupancy rate) in a given channel mask. + * Finds the best channel(s) (with least occupancy rate) in a given channel mask. * * The channels are compared based on their occupancy rate from `GetChannelOccupancy()` and lower occupancy rate * is considered better. diff --git a/src/core/utils/flash.hpp b/src/core/utils/flash.hpp index 795a47a59ab..4f1d5e62d35 100644 --- a/src/core/utils/flash.hpp +++ b/src/core/utils/flash.hpp @@ -45,7 +45,7 @@ namespace ot { /** - * This class implements the flash storage driver. + * Implements the flash storage driver. * */ class Flash : public InstanceLocator @@ -61,13 +61,13 @@ class Flash : public InstanceLocator } /** - * This method initializes the flash storage driver. + * Initializes the flash storage driver. * */ void Init(void); /** - * This method fetches the value identified by @p aKey. + * Fetches the value identified by @p aKey. * * @param[in] aKey The key associated with the requested value. * @param[in] aIndex The index of the specific item to get. @@ -86,7 +86,7 @@ class Flash : public InstanceLocator Error Get(uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength) const; /** - * This method sets or replaces the value identified by @p aKey. + * Sets or replaces the value identified by @p aKey. * * If there was more than one value previously associated with @p aKey, then they are all deleted and replaced with * this single entry. @@ -103,7 +103,7 @@ class Flash : public InstanceLocator Error Set(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This method adds a value to @p aKey. + * Adds a value to @p aKey. * * @param[in] aKey The key associated with the value. * @param[in] aValue A pointer to where the new value of the setting should be read from. @@ -117,7 +117,7 @@ class Flash : public InstanceLocator Error Add(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This method removes a value from @p aKey. + * Removes a value from @p aKey. * * * @param[in] aKey The key associated with the value. @@ -131,7 +131,7 @@ class Flash : public InstanceLocator Error Delete(uint16_t aKey, int aIndex); /** - * This method removes all values. + * Removes all values. * */ void Wipe(void); diff --git a/src/core/utils/heap.hpp b/src/core/utils/heap.hpp index bd391a97db9..c4125b14b1b 100644 --- a/src/core/utils/heap.hpp +++ b/src/core/utils/heap.hpp @@ -49,7 +49,7 @@ namespace ot { namespace Utils { /** - * This class represents a memory block. + * Represents a memory block. * * A block is of the structure as below. * @@ -69,7 +69,7 @@ class Block public: /** - * This method returns the size of this block. + * Returns the size of this block. * * @returns Size of this block. * @@ -77,7 +77,7 @@ class Block uint16_t GetSize(void) const { return mSize; } /** - * This method updates the size of this block. + * Updates the size of this block. * * @param[in] aSize Size of this block in bytes. * @@ -85,7 +85,7 @@ class Block void SetSize(uint16_t aSize) { mSize = aSize; } /** - * This method returns the offset of the free block after this block. + * Returns the offset of the free block after this block. * * @note This offset is relative to the start of the heap. * @@ -101,7 +101,7 @@ class Block } /** - * This method updates the offset of the free block after this block. + * Updates the offset of the free block after this block. * * @note This offset @p aNext must be relative to the start of the heap. * @@ -115,7 +115,7 @@ class Block } /** - * This method returns the pointer to the start of the memory for user. + * Returns the pointer to the start of the memory for user. * * @retval Pointer to the user memory. The pointer address is aligned to sizeof(long). * @@ -123,7 +123,7 @@ class Block void *GetPointer(void) { return &mMemory; } /** - * This method returns the offset of the free block after the left neighbor block. + * Returns the offset of the free block after the left neighbor block. * * @returns Offset in bytes. * @@ -131,7 +131,7 @@ class Block uint16_t GetLeftNext(void) const { return *(&mSize - 1); } /** - * This method returns whether the left neighbor block is a free block. + * Returns whether the left neighbor block is a free block. * * @retval true The left neighbor block is free. * @retval false The left neighbor block is not free. @@ -140,7 +140,7 @@ class Block bool IsLeftFree(void) const { return GetLeftNext() != 0; } /** - * This method returns whether the current block is a free block. + * Returns whether the current block is a free block. * * @retval true The block is free. * @retval false The block is not free. @@ -160,7 +160,7 @@ class Block }; /** - * This class defines functionality to manipulate heap. + * Defines functionality to manipulate heap. * * This implementation is currently for mbedTLS. * @@ -177,13 +177,13 @@ class Heap : private NonCopyable { public: /** - * This constructor initializes a memory heap. + * Initializes a memory heap. * */ Heap(void); /** - * This method allocates at least @p aCount * @aSize bytes memory and initialize to zero. + * Allocates at least @p aCount * @aSize bytes memory and initialize to zero. * * @param[in] aCount Number of allocate units. * @param[in] aSize Unit size in bytes. @@ -196,7 +196,7 @@ class Heap : private NonCopyable void *CAlloc(size_t aCount, size_t aSize); /** - * This method free memory pointed by @p aPointer. + * Free memory pointed by @p aPointer. * * @param[in] aPointer A pointer to the memory to free. * @@ -204,7 +204,7 @@ class Heap : private NonCopyable void Free(void *aPointer); /** - * This method returns whether the heap is clean. + * Returns whether the heap is clean. * */ bool IsClean(void) const @@ -216,13 +216,13 @@ class Heap : private NonCopyable } /** - * This method returns the capacity of this heap. + * Returns the capacity of this heap. * */ size_t GetCapacity(void) const { return kFirstBlockSize; } /** - * This method returns free space of this heap. + * Returns free space of this heap. */ size_t GetFreeSize(void) const { return mMemory.mFreeSize; } @@ -243,7 +243,7 @@ class Heap : private NonCopyable static_assert(kMemorySize % kAlignSize == 0, "The heap memory size is not aligned to kAlignSize!"); /** - * This method returns the block at offset @p aOffset. + * Returns the block at offset @p aOffset. * * @param[in] aOffset Offset in bytes. * @@ -253,7 +253,7 @@ class Heap : private NonCopyable Block &BlockAt(uint16_t aOffset) { return *reinterpret_cast(&mMemory.m16[aOffset / 2]); } /** - * This method returns the block of @p aPointer. + * Returns the block of @p aPointer. * * @param[in] aPointer The pointer returned by CAlloc(). * @@ -268,7 +268,7 @@ class Heap : private NonCopyable } /** - * This method returns the super block. + * Returns the super block. * * @returns Reference to the super block. * @@ -276,7 +276,7 @@ class Heap : private NonCopyable Block &BlockSuper(void) { return BlockAt(kSuperBlockOffset); } /** - * This method returns the free block after @p aBlock in the free block list. + * Returns the free block after @p aBlock in the free block list. * * @param[in] aBlock A reference to the block. * @@ -286,7 +286,7 @@ class Heap : private NonCopyable Block &BlockNext(const Block &aBlock) { return BlockAt(aBlock.GetNext()); } /** - * This method returns the block on the right side of @p aBlock. + * Returns the block on the right side of @p aBlock. * * @param[in] aBlock A reference to the block. * @@ -296,7 +296,7 @@ class Heap : private NonCopyable Block &BlockRight(const Block &aBlock) { return BlockAt(BlockOffset(aBlock) + sizeof(Block) + aBlock.GetSize()); } /** - * This method returns the free block before @p aBlock in the free block list. + * Returns the free block before @p aBlock in the free block list. * * @returns Reference to the free block before this block. * @@ -304,7 +304,7 @@ class Heap : private NonCopyable Block &BlockPrev(const Block &aBlock); /** - * This method returns whether the block on the left side of @p aBlock is free. + * Returns whether the block on the left side of @p aBlock is free. * * @param[in] aBlock A reference to the block. * @@ -312,7 +312,7 @@ class Heap : private NonCopyable bool IsLeftFree(const Block &aBlock) { return (BlockOffset(aBlock) != kFirstBlockOffset && aBlock.IsLeftFree()); } /** - * This method returns the offset of @p aBlock. + * Returns the offset of @p aBlock. * * @param[in] aBlock A reference to the block. * @@ -325,7 +325,7 @@ class Heap : private NonCopyable } /** - * This method inserts @p aBlock into the free block list. + * Inserts @p aBlock into the free block list. * * The free block list is single linked and is sorted by size from minimal to maximum. * diff --git a/src/core/utils/history_tracker.hpp b/src/core/utils/history_tracker.hpp index f1cabbf8918..173292d74bf 100644 --- a/src/core/utils/history_tracker.hpp +++ b/src/core/utils/history_tracker.hpp @@ -69,7 +69,7 @@ namespace Utils { (OPENTHREAD_CONFIG_HISTORY_TRACKER_EXTERNAL_ROUTE_LIST_SIZE > 0)) /** - * This class implements History Tracker. + * Implements History Tracker. * */ class HistoryTracker : public InstanceLocator, private NonCopyable @@ -101,13 +101,13 @@ class HistoryTracker : public InstanceLocator, private NonCopyable /** * This constants specified no next hop. * - * Used for `mNextHop` in `RouteInfo` struture. + * Used for `mNextHop` in `RouteInfo` structure. * */ static constexpr uint8_t kNoNextHop = OT_HISTORY_TRACKER_NO_NEXT_HOP; /** - * This type represents an iterator to iterate through a history list. + * Represents an iterator to iterate through a history list. * */ class Iterator : public otHistoryTrackerIterator @@ -116,7 +116,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable public: /** - * This method initializes an `Iterator` + * Initializes an `Iterator` * * An iterator MUST be initialized before it is used. An iterator can be initialized again to start from * the beginning of the list. @@ -142,7 +142,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable typedef otHistoryTrackerExternalRouteInfo ExternalRouteInfo; ///< Network Data external route info /** - * This constructor initializes the `HistoryTracker`. + * Initializes the `HistoryTracker`. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -150,7 +150,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable explicit HistoryTracker(Instance &aInstance); /** - * This method iterates over the entries in the network info history list. + * Iterates over the entries in the network info history list. * * @param[in,out] aIterator An iterator. MUST be initialized. * @param[out] aEntryAge A reference to a variable to output the entry's age. @@ -167,7 +167,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable } /** - * This method iterates over the entries in the unicast address history list. + * Iterates over the entries in the unicast address history list. * * @param[in,out] aIterator An iterator. MUST be initialized. * @param[out] aEntryAge A reference to a variable to output the entry's age. @@ -184,7 +184,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable } /** - * This method iterates over the entries in the multicast address history list. + * Iterates over the entries in the multicast address history list. * * @param[in,out] aIterator An iterator. MUST be initialized. * @param[out] aEntryAge A reference to a variable to output the entry's age. @@ -201,7 +201,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable } /** - * This method iterates over the entries in the RX history list. + * Iterates over the entries in the RX history list. * * @param[in,out] aIterator An iterator. MUST be initialized. * @param[out] aEntryAge A reference to a variable to output the entry's age. @@ -218,7 +218,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable } /** - * This method iterates over the entries in the TX history list. + * Iterates over the entries in the TX history list. * * @param[in,out] aIterator An iterator. MUST be initialized. * @param[out] aEntryAge A reference to a variable to output the entry's age. @@ -255,7 +255,7 @@ class HistoryTracker : public InstanceLocator, private NonCopyable } /** - * This static method converts a given entry age to a human-readable string. + * Converts a given entry age to a human-readable string. * * The entry age string follows the format "::." for hours, minutes, seconds and millisecond * (if shorter than one day) or "
days ::." (if longer than one day). diff --git a/src/core/utils/jam_detector.hpp b/src/core/utils/jam_detector.hpp index 084ab777375..3bbe9fbf5f3 100644 --- a/src/core/utils/jam_detector.hpp +++ b/src/core/utils/jam_detector.hpp @@ -58,7 +58,7 @@ class JamDetector : public InstanceLocator, private NonCopyable public: /** - * This function pointer is called if jam state changes (assuming jamming detection is enabled). + * Pointer is called if jam state changes (assuming jamming detection is enabled). * * @param[in] aJamState `true` if jam is detected, `false` if jam is cleared. * @param[in] aContext A pointer to application-specific context. @@ -67,7 +67,7 @@ class JamDetector : public InstanceLocator, private NonCopyable typedef void (*Handler)(bool aJamState, void *aContext); /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * diff --git a/src/core/utils/mesh_diag.cpp b/src/core/utils/mesh_diag.cpp index f49932990bb..1e08e855f98 100644 --- a/src/core/utils/mesh_diag.cpp +++ b/src/core/utils/mesh_diag.cpp @@ -239,12 +239,10 @@ Error MeshDiag::RouterInfo::ParseFrom(const Message &aMessage) Error MeshDiag::Ip6AddrIterator::InitFrom(const Message &aMessage) { - Error error; - uint16_t tlvLength; + Error error; - SuccessOrExit(error = Tlv::FindTlvValueOffset(aMessage, Ip6AddressListTlv::kType, mCurOffset, tlvLength)); - mEndOffset = mCurOffset + tlvLength; - mMessage = &aMessage; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aMessage, Ip6AddressListTlv::kType, mCurOffset, mEndOffset)); + mMessage = &aMessage; exit: return error; @@ -269,11 +267,9 @@ Error MeshDiag::Ip6AddrIterator::GetNextAddress(Ip6::Address &aAddress) Error MeshDiag::ChildIterator::InitFrom(const Message &aMessage, uint16_t aParentRloc16) { - Error error; - uint16_t tlvLength; + Error error; - SuccessOrExit(error = Tlv::FindTlvValueOffset(aMessage, ChildTableTlv::kType, mCurOffset, tlvLength)); - mEndOffset = mCurOffset + tlvLength; + SuccessOrExit(error = Tlv::FindTlvValueStartEndOffsets(aMessage, ChildTableTlv::kType, mCurOffset, mEndOffset)); mMessage = &aMessage; mParentRloc16 = aParentRloc16; diff --git a/src/core/utils/mesh_diag.hpp b/src/core/utils/mesh_diag.hpp index 931a080a762..2f1768a05de 100644 --- a/src/core/utils/mesh_diag.hpp +++ b/src/core/utils/mesh_diag.hpp @@ -60,7 +60,7 @@ namespace ot { namespace Utils { /** - * This class implements the Mesh Diagnostics. + * Implements the Mesh Diagnostics. * */ class MeshDiag : public InstanceLocator @@ -72,7 +72,7 @@ class MeshDiag : public InstanceLocator typedef otMeshDiagDiscoverCallback DiscoverCallback; ///< The discovery callback function pointer type. /** - * This type represents an iterator to go over list of IPv6 addresses of a router. + * Represents an iterator to go over list of IPv6 addresses of a router. * */ class Ip6AddrIterator : public otMeshDiagIp6AddrIterator @@ -81,7 +81,7 @@ class MeshDiag : public InstanceLocator public: /** - * This method iterates through the discovered IPv6 address of a router. + * Iterates through the discovered IPv6 address of a router. * * @param[out] aIp6Address A reference to return the next IPv6 address (if any). * @@ -100,7 +100,7 @@ class MeshDiag : public InstanceLocator }; /** - * This type represents information about a router in Thread mesh. + * Represents information about a router in Thread mesh. * */ class RouterInfo : public otMeshDiagRouterInfo, public Clearable @@ -112,7 +112,7 @@ class MeshDiag : public InstanceLocator }; /** - * This type represents information about a child in Thread mesh. + * Represents information about a child in Thread mesh. * */ class ChildInfo : public otMeshDiagChildInfo, public Clearable @@ -120,7 +120,7 @@ class MeshDiag : public InstanceLocator }; /** - * This type represents an iterator to go over list of IPv6 addresses of a router. + * Represents an iterator to go over list of IPv6 addresses of a router. * */ class ChildIterator : public otMeshDiagChildIterator @@ -129,7 +129,7 @@ class MeshDiag : public InstanceLocator public: /** - * This method iterates through the discovered children of a router. + * Iterates through the discovered children of a router. * * @param[out] aChildInfo A reference to return the info for the next child (if any). * @@ -149,7 +149,7 @@ class MeshDiag : public InstanceLocator }; /** - * This constructor initializes the `MeshDiag` instance. + * Initializes the `MeshDiag` instance. * * @param[in] aInstance The OpenThread instance. * @@ -157,7 +157,7 @@ class MeshDiag : public InstanceLocator explicit MeshDiag(Instance &aInstance); /** - * This method starts network topology discovery. + * Starts network topology discovery. * * @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. @@ -172,7 +172,7 @@ class MeshDiag : public InstanceLocator Error DiscoverTopology(const DiscoverConfig &aConfig, DiscoverCallback aCallback, void *aContext); /** - * This method cancels an ongoing topology discovery if there one, otherwise no action. + * Cancels an ongoing topology discovery if there one, otherwise no action. * * When ongoing discovery is cancelled, the callback from `DiscoverTopology()` will not be called anymore. * diff --git a/src/core/utils/otns.hpp b/src/core/utils/otns.hpp index ce9b2ef16d2..c949fd8bfd3 100644 --- a/src/core/utils/otns.hpp +++ b/src/core/utils/otns.hpp @@ -56,7 +56,7 @@ namespace ot { namespace Utils { /** - * This class implements the OTNS Stub that interacts with OTNS. + * Implements the OTNS Stub that interacts with OTNS. * */ class Otns : public InstanceLocator, private NonCopyable @@ -65,7 +65,7 @@ class Otns : public InstanceLocator, private NonCopyable public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -76,7 +76,7 @@ class Otns : public InstanceLocator, private NonCopyable } /** - * This function emits radio short address to OTNS when changed. + * Emits radio short address to OTNS when changed. * * @param[in] aShortAddress The new short address. * @@ -84,7 +84,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitShortAddress(uint16_t aShortAddress); /** - * This function emits radio extended address to OTNS when changed. + * Emits radio extended address to OTNS when changed. * * @param[in] aExtAddress The new extended address. * @@ -92,7 +92,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitExtendedAddress(const Mac::ExtAddress &aExtAddress); /** - * This function emits ping request information to OTNS when sending. + * Emits ping request information to OTNS when sending. * * @param[in] aPeerAddress The peer address of the ping request. * @param[in] aPingLength The data length of the ping request. @@ -106,7 +106,7 @@ class Otns : public InstanceLocator, private NonCopyable uint8_t aHopLimit); /** - * This function emits ping reply information to OTNS when received. + * Emits ping reply information to OTNS when received. * * @param[in] aPeerAddress The peer address of the ping request. * @param[in] aPingLength The data length of the ping reply. @@ -120,7 +120,7 @@ class Otns : public InstanceLocator, private NonCopyable uint8_t aHopLimit); /** - * This function emits a neighbor table event to OTNS when a neighbor is added or removed. + * Emits a neighbor table event to OTNS when a neighbor is added or removed. * * @param[in] aEvent The event type. * @param[in] aNeighbor The neighbor that is added or removed. @@ -129,7 +129,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitNeighborChange(NeighborTable::Event aEvent, const Neighbor &aNeighbor); /** - * This function emits a transmit event to OTNS. + * Emits a transmit event to OTNS. * * @param[in] aFrame The frame of the transmission. * @@ -137,7 +137,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitTransmit(const Mac::TxFrame &aFrame); /** - * This function emits the device mode to OTNS. + * Emits the device mode to OTNS. * * @param[in] aMode The device mode. * @@ -145,7 +145,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitDeviceMode(Mle::DeviceMode aMode); /** - * This function emits the sending COAP message info to OTNS. + * Emits the sending COAP message info to OTNS. * * @param[in] aMessage The sending COAP message. * @param[in] aMessageInfo The message info. @@ -154,7 +154,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitCoapSend(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This function emits the COAP message sending failure to OTNS. + * Emits the COAP message sending failure to OTNS. * * @param[in] aError The error in sending the COAP message. * @param[in] aMessage The COAP message failed to send. @@ -164,7 +164,7 @@ class Otns : public InstanceLocator, private NonCopyable static void EmitCoapSendFailure(Error aError, Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo); /** - * This function emits the received COAP message info to OTNS. + * Emits the received COAP message info to OTNS. * * @param[in] aMessage The received COAP message. * @param[in] aMessageInfo The message info. diff --git a/src/core/utils/parse_cmdline.hpp b/src/core/utils/parse_cmdline.hpp index 777a50aaeb7..4216487ae72 100644 --- a/src/core/utils/parse_cmdline.hpp +++ b/src/core/utils/parse_cmdline.hpp @@ -56,7 +56,7 @@ namespace CmdLineParser { */ /** - * This function parses a string as a `uint8_t` value. + * Parses a string as a `uint8_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -70,7 +70,7 @@ namespace CmdLineParser { otError ParseAsUint8(const char *aString, uint8_t &aUint8); /** - * This function parses a string as a `uint16_t` value. + * Parses a string as a `uint16_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -84,7 +84,7 @@ otError ParseAsUint8(const char *aString, uint8_t &aUint8); otError ParseAsUint16(const char *aString, uint16_t &aUint16); /** - * This function parses a string as a `uint32_t` value. + * Parses a string as a `uint32_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -98,7 +98,7 @@ otError ParseAsUint16(const char *aString, uint16_t &aUint16); otError ParseAsUint32(const char *aString, uint32_t &aUint32); /** - * This function parses a string as a `uint64_t` value. + * Parses a string as a `uint64_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -112,7 +112,7 @@ otError ParseAsUint32(const char *aString, uint32_t &aUint32); otError ParseAsUint64(const char *aString, uint64_t &aUint64); /** - * This function parses a string as a `int8_t` value. + * Parses a string as a `int8_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -127,7 +127,7 @@ otError ParseAsUint64(const char *aString, uint64_t &aUint64); otError ParseAsInt8(const char *aString, int8_t &aInt8); /** - * This function parses a string as a `int16_t` value. + * Parses a string as a `int16_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -142,7 +142,7 @@ otError ParseAsInt8(const char *aString, int8_t &aInt8); otError ParseAsInt16(const char *aString, int16_t &aInt16); /** - * This function parses a string as a `int32_t` value. + * Parses a string as a `int32_t` value. * * The number in string is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -157,7 +157,7 @@ otError ParseAsInt16(const char *aString, int16_t &aInt16); otError ParseAsInt32(const char *aString, int32_t &aInt32); /** - * This function parses a string as a `bool` value. + * Parses a string as a `bool` value. * * Zero value is treated as `false`, non-zero value as `true`. * @@ -172,7 +172,7 @@ otError ParseAsBool(const char *aString, bool &aBool); #if OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This function parses a string as an IPv6 address. + * Parses a string as an IPv6 address. * * * @param[in] aString The string to parse. @@ -185,7 +185,7 @@ otError ParseAsBool(const char *aString, bool &aBool); otError ParseAsIp6Address(const char *aString, otIp6Address &aAddress); /** - * This function parses a string as an IPv4 address. + * Parses a string as an IPv4 address. * * @param[in] aString The string to parse. * @param[out] aAddress A reference to an `otIp6Address` to output the parsed IPv6 address. @@ -197,7 +197,7 @@ otError ParseAsIp6Address(const char *aString, otIp6Address &aAddress); otError ParseAsIp4Address(const char *aString, otIp4Address &aAddress); /** - * This function parses a string as an IPv6 prefix. + * Parses a string as an IPv6 prefix. * * The string is parsed as `{IPv6Address}/{PrefixLength}`. * @@ -212,13 +212,13 @@ otError ParseAsIp6Prefix(const char *aString, otIp6Prefix &aPrefix); #endif // OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This function parses a hex string into a byte array of fixed expected size. + * Parses a hex string into a byte array of fixed expected size. * - * This function returns `kErrorNone` only when the hex string contains exactly @p aSize bytes (after parsing). If + * Returns `kErrorNone` only when the hex string contains exactly @p aSize bytes (after parsing). If * there are fewer or more bytes in hex string that @p aSize, the parsed bytes (up to @p aSize) are copied into the * `aBuffer` and `kErrorInvalidArgs` is returned. * - * This function correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is + * Correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is * parsed as {0xaa, 0xbb, 0xcc, 0xdd} and "123" (with odd length) is parsed as {0x01, 0x23}. * * @param[in] aString The string to parse. @@ -234,11 +234,11 @@ otError ParseAsHexString(const char *aString, uint8_t *aBuffer, uint16_t aSize); /** * This template function parses a hex string into a a given fixed size array. * - * This function returns `kErrorNone` only when the hex string contains exactly @p kBufferSize bytes (after parsing). + * Returns `kErrorNone` only when the hex string contains exactly @p kBufferSize bytes (after parsing). * If there are fewer or more bytes in hex string that @p kBufferSize, the parsed bytes (up to @p kBufferSize) are * copied into the `aBuffer` and `kErrorInvalidArgs` is returned. * - * This function correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is + * Correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is * parsed as {0xaa, 0xbb, 0xcc, 0xdd} and "123" (with odd length) is parsed as {0x01, 0x23}. * * @tparam kBufferSize The byte array size (number of bytes). @@ -256,11 +256,11 @@ template static otError ParseAsHexString(const char *aStr } /** - * This function parses a hex string into a byte array. + * Parses a hex string into a byte array. * - * This function verifies that the parsed hex string bytes fit in @p aBuffer with its given @p aSize. + * Verifies that the parsed hex string bytes fit in @p aBuffer with its given @p aSize. * - * This function correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is + * Correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is * parsed as {0xaa, 0xbb, 0xcc, 0xdd} and "123" (with odd length) is parsed as {0x01, 0x23}. * * @param[in] aString The string to parse. @@ -275,14 +275,14 @@ template static otError ParseAsHexString(const char *aStr otError ParseAsHexString(const char *aString, uint16_t &aSize, uint8_t *aBuffer); /** - * This function parses a segment of a hex string up to a given size. + * Parses a segment of a hex string up to a given size. * - * This function allows a longer hex string to be parsed and read in smaller segments into a given buffer. If the + * Allows a longer hex string to be parsed and read in smaller segments into a given buffer. If the * entire hex string bytes can fit in the given @p aBuffer with its @p aSize, they are copied into @p aBuffer and * function returns `kErrorNone`. Otherwise, @p aSize bytes are read and copied and function returns `kErrorPending` * to indicate that there are more bytes to parse. The @p aString is also updated to skip over the parsed segment. * - * This function correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is + * Correctly handles hex strings with even or odd length. For example, "AABBCCDD" (with even length) is * parsed as {0xaa, 0xbb, 0xcc, 0xdd} and "123" (with odd length) is parsed as {0x01, 0x23}. * * @param[in,out] aString A reference to string to parse. On successful parse, updated to skip parsed digits. @@ -299,20 +299,20 @@ otError ParseAsHexString(const char *aString, uint16_t &aSize, uint8_t *aBuffer) otError ParseAsHexStringSegment(const char *&aString, uint16_t &aSize, uint8_t *aBuffer); /** - * This class represents a single argument from an argument list. + * Represents a single argument from an argument list. * */ class Arg { public: /** - * This method clears the argument. + * Clears the argument. * */ void Clear(void) { mString = nullptr; } /** - * This method indicates whether or not the argument is empty (i.e., reached the end of argument list). + * Indicates whether or not the argument is empty (i.e., reached the end of argument list). * * @retval TRUE The argument is empty. * @retval FALSE The argument is not empty. @@ -321,7 +321,7 @@ class Arg bool IsEmpty(void) const { return (mString == nullptr); } /** - * This method returns the length (number of characters) in the argument C string. + * Returns the length (number of characters) in the argument C string. * * @returns The argument string length if argument is not empty, zero otherwise. * @@ -329,7 +329,7 @@ class Arg uint16_t GetLength(void) const; /** - * This method gets the argument as a C string. + * Gets the argument as a C string. * * @returns A pointer to the argument as a C string, or `nullptr` if argument is empty. * @@ -337,7 +337,7 @@ class Arg const char *GetCString(void) const { return mString; } /** - * This method gets the argument as C string. + * Gets the argument as C string. * * @returns A pointer to the argument as a C string, or `nullptr` if argument is empty. * @@ -345,7 +345,7 @@ class Arg char *GetCString(void) { return mString; } /** - * This method sets the argument with a given C string. + * Sets the argument with a given C string. * * @param[in] aString A pointer to the new C string. * @@ -353,7 +353,7 @@ class Arg void SetCString(char *aString) { mString = aString; } /** - * This method overload the operator `==` to evaluate whether the argument is equal to a given C string. + * Overload the operator `==` to evaluate whether the argument is equal to a given C string. * * If the argument is empty (`IsEmpty()` is `true`) then comparing it using operator `==` with any C string will * return false. @@ -367,7 +367,7 @@ class Arg bool operator==(const char *aString) const; /** - * This method overload the operator `!=` to evaluate whether the argument is unequal to a given C string. + * Overload the operator `!=` to evaluate whether the argument is unequal to a given C string. * * @param[in] aString The C string to compare with (MUST not be `nullptr`). * @@ -378,7 +378,7 @@ class Arg bool operator!=(const char *aString) const { return !(*this == aString); } /** - * This method parses the argument as a `uint8_t` value. + * Parses the argument as a `uint8_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -391,7 +391,7 @@ class Arg otError ParseAsUint8(uint8_t &aUint8) const { return CmdLineParser::ParseAsUint8(mString, aUint8); } /** - * This method parses the argument as a `uint16_t` value. + * Parses the argument as a `uint16_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -404,7 +404,7 @@ class Arg otError ParseAsUint16(uint16_t &aUint16) const { return CmdLineParser::ParseAsUint16(mString, aUint16); } /** - * This method parses the argument as a `uint32_t` value. + * Parses the argument as a `uint32_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -417,7 +417,7 @@ class Arg otError ParseAsUint32(uint32_t &aUint32) const { return CmdLineParser::ParseAsUint32(mString, aUint32); } /** - * This method parses the argument as a `uint64_t` value. + * Parses the argument as a `uint64_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). * @@ -430,7 +430,7 @@ class Arg otError ParseAsUint64(uint64_t &aUint64) const { return CmdLineParser::ParseAsUint64(mString, aUint64); } /** - * This method parses the argument as a `int8_t` value. + * Parses the argument as a `int8_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -444,7 +444,7 @@ class Arg otError ParseAsInt8(int8_t &aInt8) const { return CmdLineParser::ParseAsInt8(mString, aInt8); } /** - * This method parses the argument as a `int16_t` value. + * Parses the argument as a `int16_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -458,7 +458,7 @@ class Arg otError ParseAsInt16(int16_t &aInt16) const { return CmdLineParser::ParseAsInt16(mString, aInt16); } /** - * This method parses the argument as a `int32_t` value. + * Parses the argument as a `int32_t` value. * * The number is parsed as decimal or hex format (if contains `0x` or `0X` prefix). The string can start with * `+`/`-` sign. @@ -472,7 +472,7 @@ class Arg otError ParseAsInt32(int32_t &aInt32) const { return CmdLineParser::ParseAsInt32(mString, aInt32); } /** - * This method parses the argument as a `bool` value. + * Parses the argument as a `bool` value. * * Zero value is treated as `false`, non-zero value as `true`. * @@ -486,7 +486,7 @@ class Arg #if OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This method parses the argument as an IPv6 address. + * Parses the argument as an IPv6 address. * * @param[out] aAddress A reference to an `otIp6Address` to output the parsed IPv6 address. * @@ -500,7 +500,7 @@ class Arg } /** - * This method parses the argument as an IPv4 address. + * Parses the argument as an IPv4 address. * * @param[out] aAddress A reference to an `otIp4Address` to output the parsed IPv4 address. * @@ -514,7 +514,7 @@ class Arg } /** - * This method parses the argument as an IPv6 prefix. + * Parses the argument as an IPv6 prefix. * * The string is parsed as `{IPv6Address}/{PrefixLength}`. * @@ -529,7 +529,7 @@ class Arg #endif // OPENTHREAD_FTD || OPENTHREAD_MTD /** - * This template method parses the argument as a specified value type. + * Parses the argument as a specified value type. * * @tparam Type The value type. * @@ -542,9 +542,9 @@ class Arg template otError ParseAs(Type &aValue) const; /** - * This method parses the argument as a hex string into a byte array of fixed expected size. + * Parses the argument as a hex string into a byte array of fixed expected size. * - * This method returns `kErrorNone` only when the hex string contains exactly @p aSize bytes (after parsing). If + * Returns `kErrorNone` only when the hex string contains exactly @p aSize bytes (after parsing). If * there are fewer or more bytes in hex string that @p aSize, the parsed bytes (up to @p aSize) are copied into the * `aBuffer` and `kErrorInvalidArgs` is returned. * @@ -561,9 +561,9 @@ class Arg } /** - * This template method parses the argument as a hex string into a a given fixed size array. + * Parses the argument as a hex string into a a given fixed size array. * - * This method returns `kErrorNone` only when the hex string contains exactly @p kBufferSize bytes (after parsing). + * Returns `kErrorNone` only when the hex string contains exactly @p kBufferSize bytes (after parsing). * If there are fewer or more bytes in hex string that @p kBufferSize, the parsed bytes (up to @p kBufferSize) are * copied into the `aBuffer` and `kErrorInvalidArgs` is returned. * @@ -581,9 +581,9 @@ class Arg } /** - * This method parses the argument as a hex string into a byte array. + * Parses the argument as a hex string into a byte array. * - * This method verifies that the parsed hex string bytes fit in @p aBuffer with its given @p aSize. + * Verifies that the parsed hex string bytes fit in @p aBuffer with its given @p aSize. * * @param[in,out] aSize On entry indicates the number of bytes in @p aBuffer (max size of @p aBuffer). * On exit provides number of bytes parsed and copied into @p aBuffer. @@ -599,7 +599,7 @@ class Arg } /** - * This static method copies the argument string pointers from an `Arg` array to a C string array. + * Copies the argument string pointers from an `Arg` array to a C string array. * * @note this method only copies the string pointer value (i.e., `GetString()` pointer) from `aArgs` array to the * @p aStrings array (the content of strings are not copied). @@ -612,7 +612,7 @@ class Arg static void CopyArgsToStringArray(Arg aArgs[], char *aStrings[]); /** - * This static method returns the length of argument array, i.e. number of consecutive non-empty arguments. + * Returns the length of argument array, i.e. number of consecutive non-empty arguments. * * @param[in] aArgs An `Arg` array. * @@ -626,9 +626,9 @@ class Arg }; /** - * This function parses a given command line string and breaks it into an argument list. + * Parses a given command line string and breaks it into an argument list. * - * This function may change the input @p aCommandString, it will put a '\0' by the end of each argument, and @p aArgs + * May change the input @p aCommandString, it will put a '\0' by the end of each argument, and @p aArgs * will point to the arguments in the input @p aCommandString. Backslash ('\') can be used to escape separators * (' ', '\t', '\r', '\n') and the backslash itself. * @@ -636,7 +636,7 @@ class Arg * will be cleared and marked as empty. So the number of arguments can be determined by going through @p aArgs array * entries till we get to an empty `Arg` (i.e., `Arg::IsEmpty()` returns `true). * - * This function ensures that the last entry in @p aArgs array is always used to indicate the end (always marked as + * Ensures that the last entry in @p aArgs array is always used to indicate the end (always marked as * empty), so the @p aArgs array should have one more entry than the desired max number of arguments. * * @param[in] aCommandString A null-terminated input string. diff --git a/src/core/utils/ping_sender.hpp b/src/core/utils/ping_sender.hpp index 9eb0a9129f2..8037b10ce24 100644 --- a/src/core/utils/ping_sender.hpp +++ b/src/core/utils/ping_sender.hpp @@ -55,20 +55,20 @@ namespace ot { namespace Utils { /** - * This class implements sending ICMPv6 Echo Request messages and processing ICMPv6 Echo Reply messages. + * Implements sending ICMPv6 Echo Request messages and processing ICMPv6 Echo Reply messages. * */ class PingSender : public InstanceLocator, private NonCopyable { public: /** - * This class represents a ping reply. + * Represents a ping reply. * */ typedef otPingSenderReply Reply; /** - * This class represents the statistics of several ping requests. + * Represents the statistics of several ping requests. * */ struct Statistics : public otPingSenderStatistics @@ -87,7 +87,7 @@ class PingSender : public InstanceLocator, private NonCopyable }; /** - * This class represents a ping request configuration. + * Represents a ping request configuration. * */ class Config : public otPingSenderConfig @@ -96,7 +96,7 @@ class PingSender : public InstanceLocator, private NonCopyable public: /** - * This method gets the source IPv6 address of the ping. + * Gets the source IPv6 address of the ping. * * @returns The ping source IPv6 address. * @@ -104,7 +104,7 @@ class PingSender : public InstanceLocator, private NonCopyable Ip6::Address &GetSource(void) { return AsCoreType(&mSource); } /** - * This method gets the source IPv6 address of the ping. + * Gets the source IPv6 address of the ping. * * @returns The ping source IPv6 address. * @@ -112,7 +112,7 @@ class PingSender : public InstanceLocator, private NonCopyable const Ip6::Address &GetSource(void) const { return AsCoreType(&mSource); } /** - * This method gets the destination IPv6 address to ping. + * Gets the destination IPv6 address to ping. * * @returns The ping destination IPv6 address. * @@ -120,7 +120,7 @@ class PingSender : public InstanceLocator, private NonCopyable Ip6::Address &GetDestination(void) { return AsCoreType(&mDestination); } /** - * This method gets the destination IPv6 address to ping. + * Gets the destination IPv6 address to ping. * * @returns The ping destination IPv6 address. * @@ -139,7 +139,7 @@ class PingSender : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `PingSender` object. + * Initializes the `PingSender` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -147,7 +147,7 @@ class PingSender : public InstanceLocator, private NonCopyable explicit PingSender(Instance &aInstance); /** - * This method starts a ping. + * Starts a ping. * * @param[in] aConfig The ping config to use. * @@ -159,7 +159,7 @@ class PingSender : public InstanceLocator, private NonCopyable Error Ping(const Config &aConfig); /** - * This method stops an ongoing ping. + * Stops an ongoing ping. * */ void Stop(void); diff --git a/src/core/utils/power_calibration.hpp b/src/core/utils/power_calibration.hpp index e16775b3a3f..1f2d83c57ba 100644 --- a/src/core/utils/power_calibration.hpp +++ b/src/core/utils/power_calibration.hpp @@ -49,7 +49,7 @@ namespace ot { namespace Utils { /** - * This class implements power calibration module. + * Implements power calibration module. * * The power calibration module implements the radio platform power calibration APIs. It mainly stores the calibrated * power table and the target power table, provides an API for the platform to get the raw power setting of the diff --git a/src/core/utils/slaac_address.cpp b/src/core/utils/slaac_address.cpp index 825130a178c..ade19541c06 100644 --- a/src/core/utils/slaac_address.cpp +++ b/src/core/utils/slaac_address.cpp @@ -335,11 +335,11 @@ void Slaac::GetIidSecretKey(IidSecretKey &aKey) const // If there is no previously saved secret key, generate // a random one and save it. - error = Random::Crypto::FillBuffer(aKey.m8, sizeof(IidSecretKey)); + error = Random::Crypto::Fill(aKey); if (error != kErrorNone) { - IgnoreError(Random::Crypto::FillBuffer(aKey.m8, sizeof(IidSecretKey))); + IgnoreError(Random::Crypto::Fill(aKey)); } IgnoreError(Get().Save(aKey)); diff --git a/src/core/utils/slaac_address.hpp b/src/core/utils/slaac_address.hpp index 1784d33ac16..3e73f19205b 100644 --- a/src/core/utils/slaac_address.hpp +++ b/src/core/utils/slaac_address.hpp @@ -57,7 +57,7 @@ namespace Utils { */ /** - * This class implements the SLAAC utility for Thread protocol. + * Implements the SLAAC utility for Thread protocol. * */ class Slaac : public InstanceLocator, private NonCopyable @@ -66,7 +66,7 @@ class Slaac : public InstanceLocator, private NonCopyable public: /** - * This type represents the secret key used for generating semantically opaque IID (per RFC 7217). + * Represents the secret key used for generating semantically opaque IID (per RFC 7217). * */ struct IidSecretKey @@ -77,7 +77,7 @@ class Slaac : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the SLAAC manager object. + * Initializes the SLAAC manager object. * * Note that SLAAC module starts enabled. * @@ -87,7 +87,7 @@ class Slaac : public InstanceLocator, private NonCopyable explicit Slaac(Instance &aInstance); /** - * This method enables the SLAAC module. + * Enables the SLAAC module. * * When enabled, new SLAAC addresses are generated and added from on-mesh prefixes in network data. * @@ -95,7 +95,7 @@ class Slaac : public InstanceLocator, private NonCopyable void Enable(void); /** - * This method disables the SLAAC module. + * Disables the SLAAC module. * * When disabled, any previously added SLAAC address by this module is removed. * @@ -103,7 +103,7 @@ class Slaac : public InstanceLocator, private NonCopyable void Disable(void); /** - * This method indicates whether SLAAC module is enabled or not. + * Indicates whether SLAAC module is enabled or not. * * @retval TRUE SLAAC module is enabled. * @retval FALSE SLAAC module is disabled. @@ -112,7 +112,7 @@ class Slaac : public InstanceLocator, private NonCopyable bool IsEnabled(void) const { return mEnabled; } /** - * This method sets a SLAAC prefix filter handler. + * Sets a SLAAC prefix filter handler. * * The handler is invoked by SLAAC module when it is about to add a SLAAC address based on a prefix. The return * boolean value from handler determines whether the address is filtered or added (TRUE to filter the address, @@ -124,7 +124,7 @@ class Slaac : public InstanceLocator, private NonCopyable void SetFilter(otIp6SlaacPrefixFilter aFilter); /** - * This method generates the IID of an IPv6 address. + * Generates the IID of an IPv6 address. * * @param[in,out] aAddress A reference to the address that will be filled with the IID generated. * Note the prefix of the address must already be filled and will be used diff --git a/src/core/utils/srp_client_buffers.hpp b/src/core/utils/srp_client_buffers.hpp index a60be7b73bd..37028afb931 100644 --- a/src/core/utils/srp_client_buffers.hpp +++ b/src/core/utils/srp_client_buffers.hpp @@ -56,7 +56,7 @@ namespace Utils { #endif /** - * This class represents the SRP client buffers and service pool. + * Represents the SRP client buffers and service pool. * */ class SrpClientBuffers : public InstanceLocator, private NonCopyable @@ -105,7 +105,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable static constexpr uint16_t kTxtBufferSize = OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_TXT_BUFFER_SIZE; /** - * This class represents a SRP client service entry from the pool. + * Represents a SRP client service entry from the pool. * */ class ServiceEntry : public otSrpClientBuffersServiceEntry, public Clearable @@ -115,7 +115,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable public: /** - * This method gets the string buffer for the service name from the service entry. + * Gets the string buffer for the service name from the service entry. * * @param[out] aSize Reference to a variable to return the size (number of bytes) of the string buffer. * @@ -129,7 +129,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable } /** - * This method gets the string buffer for the instance name from the service entry. + * Gets the string buffer for the instance name from the service entry. * * @param[out] aSize Reference to a variable to return the size (number of bytes) of the string buffer. * @@ -143,7 +143,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable } /** - * This method gets the buffer for the TXT value from the service entry. + * Gets the buffer for the TXT value from the service entry. * * @param[out] aSize Reference to a variable to return the size (number of bytes) of the buffer. * @@ -157,7 +157,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable } /** - * This method gets the array for service subtype labels from the service entry. + * Gets the array for service subtype labels from the service entry. * * @param[out] aArrayLength Reference to a variable to return the array length. * @@ -182,7 +182,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable }; /** - * This constructor initializes the `SrpClientBuffers` object. + * Initializes the `SrpClientBuffers` object. * * @param[in] aInstance A reference to the OpenThread instance. * @@ -190,7 +190,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable explicit SrpClientBuffers(Instance &aInstance); /** - * This method gets the string buffer to use for SRP client host name. + * Gets the string buffer to use for SRP client host name. * * @param[out] aSize Reference to a variable to return the size (number of bytes) of the string buffer. * @@ -204,7 +204,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable } /** - * This method gets the array of IPv6 address entries to use as SRP client host address list. + * Gets the array of IPv6 address entries to use as SRP client host address list. * * @param[out] aArrayLength Reference to a variable to return the array length (number of IPv6 address entries in * * the array). @@ -219,7 +219,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable } /** - * This method allocates a new service entry from the pool. + * Allocates a new service entry from the pool. * * The returned service entry instance will be initialized as follows: * @@ -240,7 +240,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable ServiceEntry *AllocateService(void); /** - * This method frees a previously allocated service entry. + * Frees a previously allocated service entry. * * The @p aService MUST be previously allocated using `AllocateService()` and not yet freed. Otherwise the behavior * of this method is undefined. @@ -251,7 +251,7 @@ class SrpClientBuffers : public InstanceLocator, private NonCopyable void FreeService(ServiceEntry &aServiceEntry) { mServicePool.Free(aServiceEntry); } /** - * This method frees all previously allocated service entries. + * Frees all previously allocated service entries. * */ void FreeAllServices(void) { mServicePool.FreeAll(); } diff --git a/src/lib/hdlc/CMakeLists.txt b/src/lib/hdlc/CMakeLists.txt index 433bc2f93c5..1838e2315aa 100644 --- a/src/lib/hdlc/CMakeLists.txt +++ b/src/lib/hdlc/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories(openthread-hdlc PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE + ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/core ) diff --git a/src/lib/hdlc/Makefile.am b/src/lib/hdlc/Makefile.am index c410f146900..b908f591b6f 100644 --- a/src/lib/hdlc/Makefile.am +++ b/src/lib/hdlc/Makefile.am @@ -32,6 +32,7 @@ noinst_LIBRARIES = libopenthread-hdlc.a libopenthread_hdlc_a_CPPFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/core \ $(NULL) diff --git a/src/lib/hdlc/hdlc.cpp b/src/lib/hdlc/hdlc.cpp index b75b42e47a4..26b1bd5caf1 100644 --- a/src/lib/hdlc/hdlc.cpp +++ b/src/lib/hdlc/hdlc.cpp @@ -40,7 +40,7 @@ namespace ot { namespace Hdlc { /** - * This method updates an FCS. + * Updates an FCS. * * @param[in] aFcs The FCS to update. * @param[in] aByte The input byte value. @@ -117,7 +117,7 @@ static bool HdlcByteNeedsEscape(uint8_t aByte) return rval; } -Encoder::Encoder(FrameWritePointer &aWritePointer) +Encoder::Encoder(Spinel::FrameWritePointer &aWritePointer) : mWritePointer(aWritePointer) , mFcs(0) { @@ -154,9 +154,9 @@ otError Encoder::Encode(uint8_t aByte) otError Encoder::Encode(const uint8_t *aData, uint16_t aLength) { - otError error = OT_ERROR_NONE; - uint16_t oldFcs = mFcs; - FrameWritePointer oldPointer = mWritePointer; + otError error = OT_ERROR_NONE; + uint16_t oldFcs = mFcs; + Spinel::FrameWritePointer oldPointer = mWritePointer; while (aLength--) { @@ -176,10 +176,10 @@ otError Encoder::Encode(const uint8_t *aData, uint16_t aLength) otError Encoder::EndFrame(void) { - otError error = OT_ERROR_NONE; - FrameWritePointer oldPointer = mWritePointer; - uint16_t oldFcs = mFcs; - uint16_t fcs = mFcs; + otError error = OT_ERROR_NONE; + Spinel::FrameWritePointer oldPointer = mWritePointer; + uint16_t oldFcs = mFcs; + uint16_t fcs = mFcs; fcs ^= 0xffff; @@ -199,7 +199,7 @@ otError Encoder::EndFrame(void) return error; } -Decoder::Decoder(FrameWritePointer &aFrameWritePointer, FrameHandler aFrameHandler, void *aContext) +Decoder::Decoder(Spinel::FrameWritePointer &aFrameWritePointer, FrameHandler aFrameHandler, void *aContext) : mState(kStateNoSync) , mWritePointer(aFrameWritePointer) , mFrameHandler(aFrameHandler) diff --git a/src/lib/hdlc/hdlc.hpp b/src/lib/hdlc/hdlc.hpp index eb80f6f2c30..37ebb324c55 100644 --- a/src/lib/hdlc/hdlc.hpp +++ b/src/lib/hdlc/hdlc.hpp @@ -39,10 +39,7 @@ #include -#include "common/array.hpp" -#include "common/code_utils.hpp" -#include "common/debug.hpp" -#include "common/encoding.hpp" +#include "lib/spinel/multi_frame_buffer.hpp" namespace ot { @@ -56,422 +53,22 @@ namespace ot { namespace Hdlc { /** - * This class defines a frame write pointer used by `Hdlc::Encoder` or `Hdlc::Decoder`. - * - * This class defines the minimum set of APIs used by `Encoder/Decoder` for writing an encoded/decoded frame. It is - * simply a wrapper over a pointer into a buffer indicating where next byte should be written. Along with a write - * pointer, this class stores a remaining length variable indicating number of remaining bytes that can be written into - * the buffer. - * - * @note This class does NOT define the underlying buffer space or how it is being managed. - * - * `Encoder` or `Decoder` users are expected to use sub-classes of this class adding the buffer space and implementing - * the frame buffer management scheme. - * - * Two template sub-class `FrameBuffer` and `MultiFrameBuffer` are defined which respectively allow storing a single - * frame or multiple frames (FIFO queue of frame) in a buffer of a given size. - * - */ -class FrameWritePointer -{ -public: - /** - * This method indicates whether there is buffer space available to write @p aWriteLength bytes. - * - * param[in] aWriteLength Number of bytes to write. - * - * @retval TRUE Enough buffer space is available to write the requested number of bytes. - * @retval FALSE Insufficient buffer space to write the requested number of bytes. - * - */ - bool CanWrite(uint16_t aWriteLength) const { return (mRemainingLength >= aWriteLength); } - - /** - * This method writes a byte into the buffer and updates the write pointer (if space is available). - * - * @retval OT_ERROR_NONE Successfully wrote the byte and updated the pointer. - * @retval OT_ERROR_NO_BUFS Insufficient buffer space to write the byte. - * - */ - otError WriteByte(uint8_t aByte) - { - return CanWrite(sizeof(uint8_t)) ? (*mWritePointer++ = aByte, mRemainingLength--, OT_ERROR_NONE) - : OT_ERROR_NO_BUFS; - } - - /** - * This method undoes the last @p aUndoLength writes, removing them from frame. - * - * @note Caller should ensure that @p aUndoLength is less than or equal to the number of previously written bytes - * into the frame. This method does not perform any checks and its behavior is undefined if @p aUndoLength is - * larger than the number of bytes previously written into the frame. - * - * @param[in] aUndoLength Number of bytes to remove (number of last `WriteByte()` calls to undo). - * - */ - void UndoLastWrites(uint16_t aUndoLength) - { - mWritePointer -= aUndoLength; - mRemainingLength += aUndoLength; - } - -protected: - FrameWritePointer(void) - : mWritePointer(nullptr) - , mRemainingLength(0) - { - } - - uint8_t *mWritePointer; ///< A pointer to current write position in the buffer. - uint16_t mRemainingLength; ///< Number of remaining bytes available to write. -}; - -/** - * This class defines a template frame buffer of a given size for storing a single frame. - * - * The template parameter `kSize` specifies the size of the buffer. - * - */ -template class FrameBuffer : public FrameWritePointer -{ -public: - /** - * This constructor initializes the `FrameBuffer` object. - * - */ - FrameBuffer(void) - : FrameWritePointer() - { - Clear(); - } - - /** - * This method clears the buffer, moving the write pointer to the beginning of the buffer. - * - */ - void Clear(void) - { - mWritePointer = mBuffer; - mRemainingLength = sizeof(mBuffer); - } - - /** - * This method indicates whether the buffer is empty or contains a frame. - * - * @retval TRUE Buffer is empty - * @retval FALSE Buffer contains a frame - * - */ - bool IsEmpty(void) const { return (mWritePointer == mBuffer); } - - /** - * This method gets the length (number of bytes) in the frame. - * - * @returns The length (number of bytes) in the frame. - * - */ - uint16_t GetLength(void) const { return static_cast(mWritePointer - mBuffer); } - - /** - * This method gets a pointer to start of the frame. - * - * @returns A pointer to start of the frame. - * - */ - uint8_t *GetFrame(void) { return mBuffer; } - -private: - uint8_t mBuffer[kSize]; -}; - -/** - * This class defines a template frame buffer of a given size for storing multiple frames. - * - * The template parameter `kSize` specifies the total size of the buffer. - * - * Unlike `FrameBuffer` class where a single frame can be stored, this class is capable of saving multiple frames - * in a FIFO queue format. - * - */ -template class MultiFrameBuffer : public FrameWritePointer -{ -public: - /** - * This constructor initializes the `MultiFrameBuffer` object. - * - */ - MultiFrameBuffer(void) - : FrameWritePointer() - { - Clear(); - } - - /** - * This method clears the buffer, removing current frame and all previously saved frames. - * - * It moves the write pointer to the beginning of the buffer. - * - */ - void Clear(void) - { - mWriteFrameStart = mBuffer; - mWritePointer = mBuffer + kHeaderSize; - mRemainingLength = kSize - kHeaderSize; - - IgnoreError(SetSkipLength(0)); - } - - /** - * This method indicates whether the current frame (being written) is empty or not. - * - * @retval TRUE Current frame is empty. - * @retval FALSE Current frame is not empty. - * - */ - bool HasFrame(void) const { return (mWritePointer != GetFrame()); } - - /** - * This method sets the length (number of bytes) of the current frame being written. - * - * param[in] aLength The length of current frame. - * - * @retval OT_ERROR_NONE Successfully set the length of the current frame. - * @retval OT_ERROR_NO_BUFS Insufficient buffer space to hold a frame of length @p aLength. - * - */ - otError SetLength(uint16_t aLength) - { - otError error = OT_ERROR_NO_BUFS; - - if (GetFrame() + aLength <= GetArrayEnd(mBuffer)) - { - mWritePointer = GetFrame() + aLength; - mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); - error = OT_ERROR_NONE; - } - - return error; - } - - /** - * This method gets the length (number of bytes) in the current frame being written into the buffer. - * - * @returns The length (number of bytes) in the frame. - * - */ - uint16_t GetLength(void) const { return static_cast(mWritePointer - GetFrame()); } - - /** - * This method sets the length (number of bytes) of reserved buffer in front of the current frame being written. - * - * param[in] aSkipLength The length of reserved buffer. - * - * @retval OT_ERROR_NONE Successfully set the length of reserved buffer. - * @retval OT_ERROR_NO_BUFS Insufficient buffer space to hold a reserved buffer of length @p aLength. - * - */ - otError SetSkipLength(uint16_t aSkipLength) - { - otError error = OT_ERROR_NO_BUFS; - - if (mWriteFrameStart + kHeaderSize + aSkipLength <= GetArrayEnd(mBuffer)) - { - Encoding::LittleEndian::WriteUint16(aSkipLength, mWriteFrameStart + kHeaderSkipLengthOffset); - mWritePointer = GetFrame(); - mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); - error = OT_ERROR_NONE; - } - - return error; - } - - /** - * This method gets the length (number of bytes) of reserved buffer in front of the current frame being written. - * - * @returns The length (number of bytes) of the reserved buffer. - * - */ - uint16_t GetSkipLength(void) const - { - return Encoding::LittleEndian::ReadUint16(mWriteFrameStart + kHeaderSkipLengthOffset); - } - - /** - * This method gets a pointer to the start of the current frame. - * - * @returns A pointer to the start of the frame. - * - */ - uint8_t *GetFrame(void) const { return mWriteFrameStart + kHeaderSize + GetSkipLength(); } - - /** - * This method gets the maximum length of the current frame. - * - * @returns The maximum length of the current frame. - * - */ - uint16_t GetFrameMaxLength(void) const { return static_cast(mBuffer + kSize - GetFrame()); } - - /** - * This method saves the current frame and prepares the write pointer for a next frame to be written into the - * buffer. - * - * Saved frame can be retrieved later using `GetNextSavedFrame()`. - * - */ - void SaveFrame(void) - { - Encoding::LittleEndian::WriteUint16(GetSkipLength() + GetLength(), mWriteFrameStart + kHeaderTotalLengthOffset); - mWriteFrameStart = mWritePointer; - IgnoreError(SetSkipLength(0)); - mWritePointer = GetFrame(); - mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); - } - - /** - * This method discards the current frame and prepares the write pointer for a next frame to be written into the - * buffer. - * - */ - void DiscardFrame(void) - { - IgnoreError(SetSkipLength(0)); - - mWritePointer = GetFrame(); - mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); - } - - /** - * This method indicates whether there are any saved frames in the buffer. - * - * @retval TRUE There is at least one saved frame in the buffer. - * @retval FALSE There is no saved frame in the buffer. - * - */ - bool HasSavedFrame(void) const { return (mWriteFrameStart != mBuffer); } - - /** - * This method iterates through previously saved frames in the buffer, getting a next frame in the queue. - * - * @param[in,out] aFrame On entry, should point to a previous saved frame or nullptr to get the first frame. - * On exit, the pointer variable is updated to next frame or set to nullptr if there are - * none. - * @param[in,out] aLength On entry, should be a reference to the frame length of the previous saved frame. - * On exit, the reference is updated to the frame length (number of bytes) of next frame. - * - * @retval OT_ERROR_NONE Updated @aFrame and @aLength successfully with the next saved frame. - * @retval OT_ERROR_NOT_FOUND No more saved frame in the buffer. - * - */ - otError GetNextSavedFrame(uint8_t *&aFrame, uint16_t &aLength) - { - otError error = OT_ERROR_NONE; - - OT_ASSERT(aFrame == nullptr || (mBuffer <= aFrame && aFrame < GetArrayEnd(mBuffer))); - - aFrame = (aFrame == nullptr) ? mBuffer : aFrame + aLength; - - if (aFrame != mWriteFrameStart) - { - uint16_t totalLength = Encoding::LittleEndian::ReadUint16(aFrame + kHeaderTotalLengthOffset); - uint16_t skipLength = Encoding::LittleEndian::ReadUint16(aFrame + kHeaderSkipLengthOffset); - - aLength = totalLength - skipLength; - aFrame += kHeaderSize + skipLength; - } - else - { - aLength = 0; - aFrame = nullptr; - error = OT_ERROR_NOT_FOUND; - } - - return error; - } - - /** - * This method clears all saved frames from the buffer and adjusts all the pointers. - * - * @note This method moves the pointers into the buffer and also copies the content. Any previously retrieved - * pointer to buffer (from `GetFrame()` or `GetNextSavedFrame()`) should be considered invalid after calling this - * method. - * - */ - void ClearSavedFrames(void) - { - uint16_t len = static_cast(mWriteFrameStart - mBuffer); - - if (len > 0) - { - memmove(mBuffer, mWriteFrameStart, static_cast(mWritePointer - mWriteFrameStart)); - mWritePointer -= len; - mWriteFrameStart -= len; - mRemainingLength += len; - } - } - -private: - /* - * The diagram below illustrates the format of a saved frame. - * - * +---------+-------------+------------+----------------+----------------------------+ - * | Octets: | 2 | 2 | SkipLength | TotalLength - SkipLength | - * +---------+-------------+------------+----------------+----------------------------+ - * | Fields: | TotalLength | SkipLength | ReservedBuffer | FrameBuffer | - * +---------+-------------+------------+----------------+----------------------------+ - * - * - "TotalLength" : The total length of the `ReservedBuffer` and `FrameBuffer`. It is stored in header bytes - * as a `uint16_t` value using little-endian encoding. - * - "SkipLength" : The length of the `ReservedBuffer`. It is stored in header bytes as a `uint16_t` value - * using little-endian encoding. - * - "ReservedBuffer": A reserved buffer in front of `FrameBuffer`. User can use it to store extra header, etc. - * - "FrameBuffer" : Frame buffer. - * - * The diagram below illustrates how the frames are saved in the buffer. - * - * The diagram shows `mBuffer` and different pointers into the buffer. It represents buffer state when there are - * two saved frames in the buffer. - * - * Saved frame #1 Saved frame #2 Current frame being written - * / \ / \ / \ - * +-----------+-------------+-----------+------------+---------+--------------------------------------------+ - * | header #1 | ... | header #2 | ... | header | ... | ... | - * +-----------+-------------+-----------+------------+---------+--------------------------------------------+ - * ^ ^ ^\ /^ - * | | | mRemainingLength | - * mBuffer[0] mWriteFrameStart | | - * | mBuffer[kSize] - * mWritePointer - */ - - enum - { - kHeaderTotalLengthOffset = 0, - kHeaderSkipLengthOffset = sizeof(uint16_t), - kHeaderSize = sizeof(uint16_t) + sizeof(uint16_t), - }; - - uint8_t mBuffer[kSize]; - uint8_t *mWriteFrameStart; // Pointer to start of current frame being written. -}; - -/** - * This class implements the HDLC-lite encoder. + * Implements the HDLC-lite encoder. * */ class Encoder { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aWritePointer The `FrameWritePointer` used by `Encoder` to write the encoded frames. * */ - explicit Encoder(FrameWritePointer &aWritePointer); + explicit Encoder(Spinel::FrameWritePointer &aWritePointer); /** - * This method begins an HDLC frame. + * Begins an HDLC frame. * * @retval OT_ERROR_NONE Successfully started the HDLC frame. * @retval OT_ERROR_NO_BUFS Insufficient buffer space available to start the HDLC frame. @@ -480,7 +77,7 @@ class Encoder otError BeginFrame(void); /** - * This method encodes a single byte into current frame. + * Encodes a single byte into current frame. * * If there is no space to add the byte, the write pointer in frame buffer remains the same. * @@ -493,9 +90,9 @@ class Encoder otError Encode(uint8_t aByte); /** - * This method encodes a given block of data into current frame. + * Encodes a given block of data into current frame. * - * This method returns success only if there is space in buffer to encode the entire block of data. If there is no + * Returns success only if there is space in buffer to encode the entire block of data. If there is no * space to encode the entire block of data, the write pointer in frame buffer remains the same. * * @param[in] aData A pointer to a buffer containing the data to encode. @@ -508,7 +105,7 @@ class Encoder otError Encode(const uint8_t *aData, uint16_t aLength); /** - * This method ends/finalizes the HDLC frame. + * Ends/finalizes the HDLC frame. * * @retval OT_ERROR_NONE Successfully ended the HDLC frame. * @retval OT_ERROR_NO_BUFS Insufficient buffer space available to end the HDLC frame. @@ -517,19 +114,19 @@ class Encoder otError EndFrame(void); private: - FrameWritePointer &mWritePointer; - uint16_t mFcs; + Spinel::FrameWritePointer &mWritePointer; + uint16_t mFcs; }; /** - * This class implements the HDLC-lite decoder. + * Implements the HDLC-lite decoder. * */ class Decoder { public: /** - * This function pointer is called when either a complete frame has been decoded or an error occurs during + * Pointer is called when either a complete frame has been decoded or an error occurs during * decoding. * * The decoded frame (or the partially decoded frame in case of an error) is available in `aFrameWritePointer` @@ -544,17 +141,17 @@ class Decoder typedef void (*FrameHandler)(void *aContext, otError aError); /** - * This constructor initializes the decoder. + * Initializes the decoder. * * @param[in] aFrameWritePointer The `FrameWritePointer` used by `Decoder` to write the decoded frames. * @param[in] aFrameHandler The frame handler callback function pointer. * @param[in] aContext A pointer to arbitrary context information. * */ - Decoder(FrameWritePointer &aFrameWritePointer, FrameHandler aFrameHandler, void *aContext); + Decoder(Spinel::FrameWritePointer &aFrameWritePointer, FrameHandler aFrameHandler, void *aContext); /** - * This method feeds a block of data into the decoder. + * Feeds a block of data into the decoder. * * If during decoding, a full HDLC frame is successfully decoded or an error occurs, the `FrameHandler` callback * is called. The decoded frame (or the partially decoded frame in case of an error) is available in @@ -568,7 +165,7 @@ class Decoder void Decode(const uint8_t *aData, uint16_t aLength); /** - * This method resets internal states of the decoder. + * Resets internal states of the decoder. * */ void Reset(void); @@ -581,12 +178,12 @@ class Decoder kStateEscaped, }; - State mState; - FrameWritePointer &mWritePointer; - FrameHandler mFrameHandler; - void *mContext; - uint16_t mFcs; - uint16_t mDecodedLength; + State mState; + Spinel::FrameWritePointer &mWritePointer; + FrameHandler mFrameHandler; + void *mContext; + uint16_t mFcs; + uint16_t mDecodedLength; }; } // namespace Hdlc diff --git a/src/lib/platform/exit_code.h b/src/lib/platform/exit_code.h index ccb8f7c66e9..c809eb1d150 100644 --- a/src/lib/platform/exit_code.h +++ b/src/lib/platform/exit_code.h @@ -43,7 +43,7 @@ extern "C" { #endif /** - * This enumeration represents exit codes used when OpenThread exits. + * Represents exit codes used when OpenThread exits. * */ enum @@ -85,7 +85,7 @@ enum }; /** - * This function converts an exit code into a string. + * Converts an exit code into a string. * * @param[in] aExitCode An exit code. * @@ -95,7 +95,7 @@ enum const char *otExitCodeToString(uint8_t aExitCode); /** - * This macro checks for the specified condition, which is expected to commonly be true, + * Checks for the specified condition, which is expected to commonly be true, * and both records exit status and terminates the program if the condition is false. * * @param[in] aCondition The condition to verify @@ -116,7 +116,7 @@ const char *otExitCodeToString(uint8_t aExitCode); } while (false) /** - * This macro checks for the specified error code, which is expected to commonly be successful, + * Checks for the specified error code, which is expected to commonly be successful, * and both records exit status and terminates the program if the error code is unsuccessful. * * @param[in] aError An error code to be evaluated against OT_ERROR_NONE. @@ -127,7 +127,7 @@ const char *otExitCodeToString(uint8_t aExitCode); (aError == OT_ERROR_INVALID_ARGS ? OT_EXIT_INVALID_ARGUMENTS : OT_EXIT_FAILURE)) /** - * This macro unconditionally both records exit status and terminates the program. + * Unconditionally both records exit status and terminates the program. * * @param[in] aExitCode The exit code. * @@ -135,7 +135,7 @@ const char *otExitCodeToString(uint8_t aExitCode); #define DieNow(aExitCode) VerifyOrDie(false, aExitCode) /** - * This macro unconditionally both records exit status and exit message and terminates the program. + * Unconditionally both records exit status and exit message and terminates the program. * * @param[in] aMessage The exit message. * @param[in] aExitCode The exit code. diff --git a/src/lib/spinel/BUILD.gn b/src/lib/spinel/BUILD.gn index e4e8f035490..13ca106c40d 100644 --- a/src/lib/spinel/BUILD.gn +++ b/src/lib/spinel/BUILD.gn @@ -36,6 +36,7 @@ spinel_sources = [ "openthread-spinel-config.h", "radio_spinel.hpp", "radio_spinel_impl.hpp", + "spi_frame.hpp", "spinel.c", "spinel_buffer.cpp", "spinel_buffer.hpp", diff --git a/src/lib/spinel/Makefile.am b/src/lib/spinel/Makefile.am index 1540424fb2a..b8fe68db519 100644 --- a/src/lib/spinel/Makefile.am +++ b/src/lib/spinel/Makefile.am @@ -70,8 +70,10 @@ include_HEADERS = \ $(NULL) noinst_HEADERS = \ + multi_frame_buffer.hpp \ radio_spinel.hpp \ radio_spinel_impl.hpp \ + spi_frame.hpp \ spinel_buffer.hpp \ spinel_decoder.hpp \ spinel_encoder.hpp \ diff --git a/src/lib/spinel/multi_frame_buffer.hpp b/src/lib/spinel/multi_frame_buffer.hpp new file mode 100644 index 00000000000..9a374cd6a15 --- /dev/null +++ b/src/lib/spinel/multi_frame_buffer.hpp @@ -0,0 +1,451 @@ +/* + * 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 + * This file includes definitions for the multiple frame buffer. + */ + +#ifndef SPINEL_MULTI_FRAME_BUFFER_HPP_ +#define SPINEL_MULTI_FRAME_BUFFER_HPP_ + +#include +#include +#include + +#include + +#include "common/array.hpp" +#include "common/code_utils.hpp" +#include "common/debug.hpp" +#include "common/encoding.hpp" + +namespace ot { +namespace Spinel { + +/** + * Defines a frame write pointer. + * + * Defines the minimum set of APIs used by `Encoder/Decoder` for writing an encoded/decoded frame. It is + * simply a wrapper over a pointer into a buffer indicating where next byte should be written. Along with a write + * pointer, this class stores a remaining length variable indicating number of remaining bytes that can be written into + * the buffer. + * + * @note This class does NOT define the underlying buffer space or how it is being managed. + * + * Two template sub-class `FrameBuffer` and `MultiFrameBuffer` are defined which respectively allow storing a single + * frame or multiple frames (FIFO queue of frame) in a buffer of a given size. + * + */ +class FrameWritePointer +{ +public: + /** + * Indicates whether there is buffer space available to write @p aWriteLength bytes. + * + * param[in] aWriteLength Number of bytes to write. + * + * @retval TRUE Enough buffer space is available to write the requested number of bytes. + * @retval FALSE Insufficient buffer space to write the requested number of bytes. + * + */ + bool CanWrite(uint16_t aWriteLength) const { return (mRemainingLength >= aWriteLength); } + + /** + * Writes a byte into the buffer and updates the write pointer (if space is available). + * + * @param[in] aByte A byte to be written to the buffer. + * + * @retval OT_ERROR_NONE Successfully wrote the byte and updated the pointer. + * @retval OT_ERROR_NO_BUFS Insufficient buffer space to write the byte. + * + */ + otError WriteByte(uint8_t aByte) + { + return CanWrite(sizeof(uint8_t)) ? (*mWritePointer++ = aByte, mRemainingLength--, OT_ERROR_NONE) + : OT_ERROR_NO_BUFS; + } + + /** + * Undoes the last @p aUndoLength writes, removing them from frame. + * + * @note Caller should ensure that @p aUndoLength is less than or equal to the number of previously written bytes + * into the frame. This method does not perform any checks and its behavior is undefined if @p aUndoLength is + * larger than the number of bytes previously written into the frame. + * + * @param[in] aUndoLength Number of bytes to remove (number of last `WriteByte()` calls to undo). + * + */ + void UndoLastWrites(uint16_t aUndoLength) + { + mWritePointer -= aUndoLength; + mRemainingLength += aUndoLength; + } + +protected: + FrameWritePointer(void) + : mWritePointer(nullptr) + , mRemainingLength(0) + { + } + + uint8_t *mWritePointer; ///< A pointer to current write position in the buffer. + uint16_t mRemainingLength; ///< Number of remaining bytes available to write. +}; + +/** + * Defines a template frame buffer of a given size for storing a single frame. + * + * @tparam kSize The size of the frame buffer. + * + */ +template class FrameBuffer : public FrameWritePointer +{ +public: + /** + * Initializes the `FrameBuffer` object. + * + */ + FrameBuffer(void) + : FrameWritePointer() + { + Clear(); + } + + /** + * Clears the buffer, moving the write pointer to the beginning of the buffer. + * + */ + void Clear(void) + { + mWritePointer = mBuffer; + mRemainingLength = sizeof(mBuffer); + } + + /** + * Indicates whether the buffer is empty or contains a frame. + * + * @retval TRUE Buffer is empty. + * @retval FALSE Buffer contains a frame. + * + */ + bool IsEmpty(void) const { return (mWritePointer == mBuffer); } + + /** + * Gets the length (number of bytes) in the frame. + * + * @returns The length (number of bytes) in the frame. + * + */ + uint16_t GetLength(void) const { return static_cast(mWritePointer - mBuffer); } + + /** + * Gets a pointer to start of the frame. + * + * @returns A pointer to start of the frame. + * + */ + uint8_t *GetFrame(void) { return mBuffer; } + +private: + uint8_t mBuffer[kSize]; +}; + +/** + * Defines a template frame buffer of a given size for storing multiple frames. + * + * Unlike `FrameBuffer` class where a single frame can be stored, this class is capable of saving multiple frames + * in a FIFO queue format. + * + * @tparam kSize The total size of the buffer. + * + */ +template class MultiFrameBuffer : public FrameWritePointer +{ +public: + /** + * Initializes the `MultiFrameBuffer` object. + * + */ + MultiFrameBuffer(void) + : FrameWritePointer() + { + Clear(); + } + + /** + * Clears the buffer, removing current frame and all previously saved frames. + * + * It moves the write pointer to the beginning of the buffer. + * + */ + void Clear(void) + { + mWriteFrameStart = mBuffer; + mWritePointer = mBuffer + kHeaderSize; + mRemainingLength = kSize - kHeaderSize; + + IgnoreError(SetSkipLength(0)); + } + + /** + * Indicates whether the current frame (being written) is empty or not. + * + * @retval TRUE Current frame is empty. + * @retval FALSE Current frame is not empty. + * + */ + bool HasFrame(void) const { return (mWritePointer != GetFrame()); } + + /** + * Sets the length (number of bytes) of the current frame being written. + * + * param[in] aLength The length of current frame. + * + * @retval OT_ERROR_NONE Successfully set the length of the current frame. + * @retval OT_ERROR_NO_BUFS Insufficient buffer space to hold a frame of length @p aLength. + * + */ + otError SetLength(uint16_t aLength) + { + otError error = OT_ERROR_NO_BUFS; + + if (GetFrame() + aLength <= GetArrayEnd(mBuffer)) + { + mWritePointer = GetFrame() + aLength; + mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); + error = OT_ERROR_NONE; + } + + return error; + } + + /** + * Gets the length (number of bytes) in the current frame being written into the buffer. + * + * @returns The length (number of bytes) in the frame. + * + */ + uint16_t GetLength(void) const { return static_cast(mWritePointer - GetFrame()); } + + /** + * Sets the length (number of bytes) of reserved buffer in front of the current frame being written. + * + * param[in] aSkipLength The length of reserved buffer. + * + * @retval OT_ERROR_NONE Successfully set the length of reserved buffer. + * @retval OT_ERROR_NO_BUFS Insufficient buffer space to hold a reserved buffer of length @p aLength. + * + */ + otError SetSkipLength(uint16_t aSkipLength) + { + otError error = OT_ERROR_NO_BUFS; + + if (mWriteFrameStart + kHeaderSize + aSkipLength <= GetArrayEnd(mBuffer)) + { + Encoding::LittleEndian::WriteUint16(aSkipLength, mWriteFrameStart + kHeaderSkipLengthOffset); + mWritePointer = GetFrame(); + mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); + error = OT_ERROR_NONE; + } + + return error; + } + + /** + * Gets the length (number of bytes) of reserved buffer in front of the current frame being written. + * + * @returns The length (number of bytes) of the reserved buffer. + * + */ + uint16_t GetSkipLength(void) const + { + return Encoding::LittleEndian::ReadUint16(mWriteFrameStart + kHeaderSkipLengthOffset); + } + + /** + * Gets a pointer to the start of the current frame. + * + * @returns A pointer to the start of the frame. + * + */ + uint8_t *GetFrame(void) const { return mWriteFrameStart + kHeaderSize + GetSkipLength(); } + + /** + * Gets the maximum length of the current frame. + * + * @returns The maximum length of the current frame. + * + */ + uint16_t GetFrameMaxLength(void) const { return static_cast(mBuffer + kSize - GetFrame()); } + + /** + * Saves the current frame and prepares the write pointer for a next frame to be written into the + * buffer. + * + * Saved frame can be retrieved later using `GetNextSavedFrame()`. + * + */ + void SaveFrame(void) + { + Encoding::LittleEndian::WriteUint16(GetSkipLength() + GetLength(), mWriteFrameStart + kHeaderTotalLengthOffset); + mWriteFrameStart = mWritePointer; + IgnoreError(SetSkipLength(0)); + mWritePointer = GetFrame(); + mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); + } + + /** + * Discards the current frame and prepares the write pointer for a next frame to be written into the + * buffer. + * + */ + void DiscardFrame(void) + { + IgnoreError(SetSkipLength(0)); + + mWritePointer = GetFrame(); + mRemainingLength = static_cast(mBuffer + kSize - mWritePointer); + } + + /** + * Indicates whether there are any saved frames in the buffer. + * + * @retval TRUE There is at least one saved frame in the buffer. + * @retval FALSE There is no saved frame in the buffer. + * + */ + bool HasSavedFrame(void) const { return (mWriteFrameStart != mBuffer); } + + /** + * Iterates through previously saved frames in the buffer, getting a next frame in the queue. + * + * @param[in,out] aFrame On entry, should point to a previous saved frame or nullptr to get the first frame. + * On exit, the pointer variable is updated to next frame or set to nullptr if there are + * none. + * @param[in,out] aLength On entry, should be a reference to the frame length of the previous saved frame. + * On exit, the reference is updated to the frame length (number of bytes) of next frame. + * + * @retval OT_ERROR_NONE Updated @aFrame and @aLength successfully with the next saved frame. + * @retval OT_ERROR_NOT_FOUND No more saved frame in the buffer. + * + */ + otError GetNextSavedFrame(uint8_t *&aFrame, uint16_t &aLength) + { + otError error = OT_ERROR_NONE; + + OT_ASSERT(aFrame == nullptr || (mBuffer <= aFrame && aFrame < GetArrayEnd(mBuffer))); + + aFrame = (aFrame == nullptr) ? mBuffer : aFrame + aLength; + + if (aFrame != mWriteFrameStart) + { + uint16_t totalLength = Encoding::LittleEndian::ReadUint16(aFrame + kHeaderTotalLengthOffset); + uint16_t skipLength = Encoding::LittleEndian::ReadUint16(aFrame + kHeaderSkipLengthOffset); + + aLength = totalLength - skipLength; + aFrame += kHeaderSize + skipLength; + } + else + { + aLength = 0; + aFrame = nullptr; + error = OT_ERROR_NOT_FOUND; + } + + return error; + } + + /** + * Clears all saved frames from the buffer and adjusts all the pointers. + * + * @note This method moves the pointers into the buffer and also copies the content. Any previously retrieved + * pointer to buffer (from `GetFrame()` or `GetNextSavedFrame()`) should be considered invalid after calling this + * method. + * + */ + void ClearSavedFrames(void) + { + uint16_t len = static_cast(mWriteFrameStart - mBuffer); + + if (len > 0) + { + memmove(mBuffer, mWriteFrameStart, static_cast(mWritePointer - mWriteFrameStart)); + mWritePointer -= len; + mWriteFrameStart -= len; + mRemainingLength += len; + } + } + +private: + /* + * The diagram below illustrates the format of a saved frame. + * + * +---------+-------------+------------+----------------+----------------------------+ + * | Octets: | 2 | 2 | SkipLength | TotalLength - SkipLength | + * +---------+-------------+------------+----------------+----------------------------+ + * | Fields: | TotalLength | SkipLength | ReservedBuffer | FrameBuffer | + * +---------+-------------+------------+----------------+----------------------------+ + * + * - "TotalLength" : The total length of the `ReservedBuffer` and `FrameBuffer`. It is stored in header bytes + * as a `uint16_t` value using little-endian encoding. + * - "SkipLength" : The length of the `ReservedBuffer`. It is stored in header bytes as a `uint16_t` value + * using little-endian encoding. + * - "ReservedBuffer": A reserved buffer in front of `FrameBuffer`. User can use it to store extra header, etc. + * - "FrameBuffer" : Frame buffer. + * + * The diagram below illustrates how the frames are saved in the buffer. + * + * The diagram shows `mBuffer` and different pointers into the buffer. It represents buffer state when there are + * two saved frames in the buffer. + * + * Saved frame #1 Saved frame #2 Current frame being written + * / \ / \ / \ + * +-----------+-------------+-----------+------------+---------+--------------------------------------------+ + * | header #1 | ... | header #2 | ... | header | ... | ... | + * +-----------+-------------+-----------+------------+---------+--------------------------------------------+ + * ^ ^ ^\ /^ + * | | | mRemainingLength | + * mBuffer[0] mWriteFrameStart | | + * | mBuffer[kSize] + * mWritePointer + */ + + enum + { + kHeaderTotalLengthOffset = 0, + kHeaderSkipLengthOffset = sizeof(uint16_t), + kHeaderSize = sizeof(uint16_t) + sizeof(uint16_t), + }; + + uint8_t mBuffer[kSize]; + uint8_t *mWriteFrameStart; // Pointer to start of current frame being written. +}; + +} // namespace Spinel +} // namespace ot +#endif // SPINEL_MULTI_FRAME_BUFFER_HPP_ diff --git a/src/lib/spinel/radio_spinel.hpp b/src/lib/spinel/radio_spinel.hpp index 5aa474415a3..f851127b837 100644 --- a/src/lib/spinel/radio_spinel.hpp +++ b/src/lib/spinel/radio_spinel.hpp @@ -91,10 +91,9 @@ namespace Spinel { * * // This method performs radio driver processing. * - * // @param[in] aContext The context containing fd_sets. - * // The type is specified by the user in template parameters. + * // @param[in] aContext The process context. * - * void Process(const ProcessContextType &aContext); + * void Process(const void *aContext); * * * // This method deinitializes the interface to the RCP. @@ -102,11 +101,11 @@ namespace Spinel { * void Deinit(void); * }; */ -template class RadioSpinel +template class RadioSpinel { public: /** - * This constructor initializes the spinel based OpenThread transceiver. + * Initializes the spinel based OpenThread transceiver. * */ RadioSpinel(void); @@ -115,14 +114,11 @@ template class RadioSpinel * Initialize this radio transceiver. * * @param[in] aResetRadio TRUE to reset on init, FALSE to not reset on init. - * @param[in] aRestoreDatasetFromNcp TRUE to restore dataset to host from non-volatile memory - * (only used when attempts to upgrade from NCP to RCP mode), - * FALSE otherwise. * @param[in] aSkipRcpCompatibilityCheck TRUE to skip RCP compatibility check, FALSE to perform the check. * @param[in] aIid The IID of the Host Application. * */ - void Init(bool aResetRadio, bool aRestoreDataSetFromNcp, bool aSkipRcpCompatibilityCheck, spinel_iid_t aIid); + void Init(bool aResetRadio, bool aSkipRcpCompatibilityCheck, spinel_iid_t aIid); /** * Deinitialize this radio transceiver. @@ -131,7 +127,7 @@ template class RadioSpinel void Deinit(void); /** - * This method gets the status of promiscuous mode. + * Gets the status of promiscuous mode. * * @retval true Promiscuous mode is enabled. * @retval false Promiscuous mode is disabled. @@ -140,7 +136,7 @@ template class RadioSpinel bool IsPromiscuous(void) const { return mIsPromiscuous; } /** - * This method sets the status of promiscuous mode. + * Sets the status of promiscuous mode. * * @param[in] aEnable Whether to enable or disable promiscuous mode. * @@ -152,7 +148,7 @@ template class RadioSpinel otError SetPromiscuous(bool aEnable); /** - * This method sets the Short Address for address filtering. + * Sets the Short Address for address filtering. * * @param[in] aShortAddress The IEEE 802.15.4 Short Address. * @@ -164,7 +160,7 @@ template class RadioSpinel otError SetShortAddress(uint16_t aAddress); /** - * This method gets the factory-assigned IEEE EUI-64 for this transceiver. + * Gets the factory-assigned IEEE EUI-64 for this transceiver. * * @param[in] aInstance The OpenThread instance structure. * @param[out] aIeeeEui64 A pointer to the factory-assigned IEEE EUI-64. @@ -177,7 +173,7 @@ template class RadioSpinel otError GetIeeeEui64(uint8_t *aIeeeEui64); /** - * This method sets the Extended Address for address filtering. + * Sets the Extended Address for address filtering. * * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. * @@ -189,7 +185,7 @@ template class RadioSpinel otError SetExtendedAddress(const otExtAddress &aAddress); /** - * This method sets the PAN ID for address filtering. + * Sets the PAN ID for address filtering. * * @param[in] aPanId The IEEE 802.15.4 PAN ID. * @@ -201,7 +197,7 @@ template class RadioSpinel otError SetPanId(uint16_t aPanId); /** - * This method gets the radio's transmit power in dBm. + * Gets the radio's transmit power in dBm. * * @param[out] aPower The transmit power in dBm. * @@ -213,7 +209,7 @@ template class RadioSpinel otError GetTransmitPower(int8_t &aPower); /** - * This method sets the radio's transmit power in dBm. + * Sets the radio's transmit power in dBm. * * @param[in] aPower The transmit power in dBm. * @@ -225,7 +221,7 @@ template class RadioSpinel otError SetTransmitPower(int8_t aPower); /** - * This method gets the radio's CCA ED threshold in dBm. + * Gets the radio's CCA ED threshold in dBm. * * @param[out] aThreshold The CCA ED threshold in dBm. * @@ -237,7 +233,7 @@ template class RadioSpinel otError GetCcaEnergyDetectThreshold(int8_t &aThreshold); /** - * This method sets the radio's CCA ED threshold in dBm. + * Sets the radio's CCA ED threshold in dBm. * * @param[in] aThreshold The CCA ED threshold in dBm. * @@ -249,7 +245,7 @@ template class RadioSpinel otError SetCcaEnergyDetectThreshold(int8_t aThreshold); /** - * This method gets the FEM's Rx LNA gain in dBm. + * Gets the FEM's Rx LNA gain in dBm. * * @param[out] aGain The FEM's Rx LNA gain in dBm. * @@ -261,7 +257,7 @@ template class RadioSpinel otError GetFemLnaGain(int8_t &aGain); /** - * This method sets the FEM's Rx LNA gain in dBm. + * Sets the FEM's Rx LNA gain in dBm. * * @param[in] aGain The FEM's Rx LNA gain in dBm. * @@ -273,7 +269,7 @@ template class RadioSpinel otError SetFemLnaGain(int8_t aGain); /** - * This method returns the radio sw version string. + * Returns the radio sw version string. * * @returns A pointer to the radio version string. * @@ -281,7 +277,7 @@ template class RadioSpinel const char *GetVersion(void) const { return mVersion; } /** - * This method returns the radio capabilities. + * Returns the radio capabilities. * * @returns The radio capability bit vector. * @@ -289,14 +285,14 @@ template class RadioSpinel otRadioCaps GetRadioCaps(void) const { return mRadioCaps; } /** - * This method gets the most recent RSSI measurement. + * Gets the most recent RSSI measurement. * * @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid. */ int8_t GetRssi(void); /** - * This method returns the radio receive sensitivity value. + * Returns the radio receive sensitivity value. * * @returns The radio receive sensitivity value in dBm. * @@ -308,7 +304,7 @@ template class RadioSpinel int8_t GetReceiveSensitivity(void) const { return mRxSensitivity; } /** - * This method gets current state of the radio. + * Gets current state of the radio. * * @return Current state of the radio. * @@ -316,7 +312,7 @@ template class RadioSpinel otRadioState GetState(void) const; /** - * This method gets the current receiving channel. + * Gets the current receiving channel. * * @returns Current receiving channel. * @@ -347,7 +343,7 @@ template class RadioSpinel bool IsCoexEnabled(void); /** - * This method retrieves the radio coexistence metrics. + * Retrieves the radio coexistence metrics. * * @param[out] aCoexMetrics A reference to the coexistence metrics structure. * @@ -359,7 +355,7 @@ template class RadioSpinel #endif // OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE /** - * This method returns a reference to the transmit buffer. + * Returns a reference to the transmit buffer. * * The caller forms the IEEE 802.15.4 frame in this buffer then calls otPlatRadioTransmit() to request transmission. * @@ -369,7 +365,7 @@ template class RadioSpinel otRadioFrame &GetTransmitFrame(void) { return mTxRadioFrame; } /** - * This method enables or disables source address match feature. + * Enables or disables source address match feature. * * @param[in] aEnable Enable/disable source address match feature. * @@ -381,7 +377,7 @@ template class RadioSpinel otError EnableSrcMatch(bool aEnable); /** - * This method adds a short address to the source address match table. + * Adds a short address to the source address match table. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aShortAddress The short address to be added. @@ -394,7 +390,7 @@ template class RadioSpinel otError AddSrcMatchShortEntry(uint16_t aShortAddress); /** - * This method removes a short address from the source address match table. + * Removes a short address from the source address match table. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aShortAddress The short address to be removed. @@ -457,7 +453,7 @@ template class RadioSpinel otError ClearSrcMatchExtEntries(void); /** - * This method begins the energy scan sequence on the radio. + * Begins the energy scan sequence on the radio. * * @param[in] aScanChannel The channel to perform the energy scan on. * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. @@ -470,7 +466,7 @@ template class RadioSpinel otError EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration); /** - * This method switches the radio state from Receive to Transmit. + * Switches the radio state from Receive to Transmit. * * @param[in] aFrame A reference to the transmitted frame. * @@ -482,7 +478,7 @@ template class RadioSpinel otError Transmit(otRadioFrame &aFrame); /** - * This method switches the radio state from Sleep to Receive. + * Switches the radio state from Sleep to Receive. * * @param[in] aChannel The channel to use for receiving. * @@ -493,7 +489,7 @@ template class RadioSpinel otError Receive(uint8_t aChannel); /** - * This method switches the radio state from Receive to Sleep. + * Switches the radio state from Receive to Sleep. * * @retval OT_ERROR_NONE Successfully transitioned to Sleep. * @retval OT_ERROR_BUSY The radio was transmitting @@ -524,7 +520,7 @@ template class RadioSpinel otError Disable(void); /** - * This method checks whether radio is enabled or not. + * Checks whether radio is enabled or not. * * @returns TRUE if the radio is enabled, FALSE otherwise. * @@ -532,7 +528,7 @@ template class RadioSpinel bool IsEnabled(void) const { return mState != kStateDisabled; } /** - * This method indicates whether there is a pending transmission. + * Indicates whether there is a pending transmission. * * @retval TRUE There is a pending transmission. * @retval FALSE There is no pending transmission. @@ -541,7 +537,7 @@ template class RadioSpinel bool IsTransmitting(void) const { return mState == kStateTransmitting; } /** - * This method indicates whether a transmit has just finished. + * Indicates whether a transmit has just finished. * * @retval TRUE The transmission is done. * @retval FALSE The transmission is not done. @@ -550,7 +546,7 @@ template class RadioSpinel bool IsTransmitDone(void) const { return mState == kStateTransmitDone; } /** - * This method returns the timeout timepoint for the pending transmission. + * Returns the timeout timepoint for the pending transmission. * * @returns The timeout timepoint for the pending transmission. * @@ -558,15 +554,15 @@ template class RadioSpinel uint64_t GetTxRadioEndUs(void) const { return mTxRadioEndUs; } /** - * This method processes any pending the I/O data. + * Processes any pending the I/O data. * * @param[in] aContext The process context. * */ - void Process(const ProcessContextType &aContext); + void Process(const void *aContext); /** - * This method returns the underlying spinel interface. + * Returns the underlying spinel interface. * * @returns The underlying spinel interface. * @@ -575,7 +571,7 @@ template class RadioSpinel #if OPENTHREAD_CONFIG_DIAG_ENABLE /** - * This method enables/disables the factory diagnostics mode. + * Enables/disables the factory diagnostics mode. * * @param[in] aMode TRUE to enable diagnostics mode, FALSE otherwise. * @@ -583,7 +579,7 @@ template class RadioSpinel void SetDiagEnabled(bool aMode) { mDiagMode = aMode; } /** - * This method indicates whether or not factory diagnostics mode is enabled. + * Indicates whether or not factory diagnostics mode is enabled. * * @returns TRUE if factory diagnostics mode is enabled, FALSE otherwise. * @@ -591,7 +587,7 @@ template class RadioSpinel bool IsDiagEnabled(void) const { return mDiagMode; } /** - * This method processes platform diagnostics commands. + * Processes platform diagnostics commands. * * @param[in] aString A null-terminated input string. * @param[out] aOutput The diagnostics execution result. @@ -606,7 +602,7 @@ template class RadioSpinel #endif /** - * This method returns the radio channel mask. + * Returns the radio channel mask. * * @param[in] aPreferred TRUE to get preferred channel mask, FALSE to get supported channel mask. * @@ -618,7 +614,7 @@ template class RadioSpinel uint32_t GetRadioChannelMask(bool aPreferred); /** - * This method processes a received Spinel frame. + * Processes a received Spinel frame. * * The newly received frame is available in `RxFrameBuffer` from `SpinelInterface::GetRxFrameBuffer()`. * @@ -626,7 +622,7 @@ template class RadioSpinel void HandleReceivedFrame(void); /** - * This method sets MAC key and key index to RCP. + * Sets MAC key and key index to RCP. * * @param[in] aKeyIdMode The key ID mode. * @param[in] aKeyId The key index. @@ -647,7 +643,7 @@ template class RadioSpinel const otMacKeyMaterial *aNextKey); /** - * This method sets the current MAC Frame Counter value. + * Sets the current MAC Frame Counter value. * * @param[in] aMacFrameCounter The MAC Frame Counter value. * @param[in] aSetIfLarger If `true`, set only if the new value is larger than the current value. @@ -657,7 +653,7 @@ template class RadioSpinel otError SetMacFrameCounter(uint32_t aMacFrameCounter, bool aSetIfLarger); /** - * This method sets the radio region code. + * Sets the radio region code. * * @param[in] aRegionCode The radio region code. * @@ -668,7 +664,7 @@ template class RadioSpinel otError SetRadioRegion(uint16_t aRegionCode); /** - * This method gets the radio region code. + * Gets the radio region code. * * @param[out] aRegionCode The radio region code. * @@ -728,7 +724,7 @@ template class RadioSpinel #endif /** - * This method checks whether the spinel interface is radio-only. + * Checks whether the spinel interface is radio-only. * * @param[out] aSupportsRcpApiVersion A reference to a boolean variable to update whether the list of * spinel capabilities includes `SPINEL_CAP_RCP_API_VERSION`. @@ -742,7 +738,7 @@ template class RadioSpinel bool IsRcp(bool &aSupportsRcpApiVersion, bool &aSupportsRcpMinHostApiVersion); /** - * This method checks whether there is pending frame in the buffer. + * Checks whether there is pending frame in the buffer. * * @returns Whether there is pending frame in the buffer. * @@ -750,18 +746,7 @@ template class RadioSpinel bool HasPendingFrame(void) const { return mRxFrameBuffer.HasSavedFrame(); } /** - * This method gets dataset from NCP radio and saves it. - * - * @retval OT_ERROR_NONE Successfully restore dataset. - * @retval OT_ERROR_BUSY Failed due to another operation is on going. - * @retval OT_ERROR_RESPONSE_TIMEOUT Failed due to no response received from the radio. - * @retval OT_ERROR_NOT_FOUND Failed due to spinel property not supported in radio. - * @retval OT_ERROR_FAILED Failed due to other reasons. - */ - otError RestoreDatasetFromNcp(void); - - /** - * This method returns the next timepoint to recalculate RCP time offset. + * Returns the next timepoint to recalculate RCP time offset. * * @returns The timepoint to start the recalculation of RCP time offset. * @@ -769,7 +754,7 @@ template class RadioSpinel uint64_t GetNextRadioTimeRecalcStart(void) const { return mRadioTimeRecalcStart; } /** - * This method gets the current estimated time on RCP. + * Gets the current estimated time on RCP. * * @returns The current estimated RCP time in microseconds. * @@ -777,7 +762,7 @@ template class RadioSpinel uint64_t GetNow(void); /** - * This method returns the bus speed between the host and the radio. + * Returns the bus speed between the host and the radio. * * @returns bus speed in bits/second. * @@ -785,7 +770,7 @@ template class RadioSpinel uint32_t GetBusSpeed(void) const; /** - * This method sets the max transmit power. + * Sets the max transmit power. * * @param[in] aChannel The radio channel. * @param[in] aPower The max transmit power in dBm. @@ -797,7 +782,7 @@ template class RadioSpinel otError SetChannelMaxTransmitPower(uint8_t aChannel, int8_t aPower); /** - * This method tries to retrieve a spinel property from OpenThread transceiver. + * Tries to retrieve a spinel property from OpenThread transceiver. * * @param[in] aKey Spinel property key. * @param[in] aFormat Spinel formatter to unpack property value. @@ -811,7 +796,7 @@ template class RadioSpinel otError Get(spinel_prop_key_t aKey, const char *aFormat, ...); /** - * This method tries to retrieve a spinel property from OpenThread transceiver with parameter appended. + * Tries to retrieve a spinel property from OpenThread transceiver with parameter appended. * * @param[in] aKey Spinel property key. * @param[in] aParam Parameter appended to spinel command. @@ -831,7 +816,7 @@ template class RadioSpinel ...); /** - * This method tries to update a spinel property of OpenThread transceiver. + * Tries to update a spinel property of OpenThread transceiver. * * @param[in] aKey Spinel property key. * @param[in] aFormat Spinel formatter to pack property value. @@ -845,7 +830,7 @@ template class RadioSpinel otError Set(spinel_prop_key_t aKey, const char *aFormat, ...); /** - * This method tries to insert a item into a spinel list property of OpenThread transceiver. + * Tries to insert a item into a spinel list property of OpenThread transceiver. * * @param[in] aKey Spinel property key. * @param[in] aFormat Spinel formatter to pack the item. @@ -859,7 +844,7 @@ template class RadioSpinel otError Insert(spinel_prop_key_t aKey, const char *aFormat, ...); /** - * This method tries to remove a item from a spinel list property of OpenThread transceiver. + * Tries to remove a item from a spinel list property of OpenThread transceiver. * * @param[in] aKey Spinel property key. * @param[in] aFormat Spinel formatter to pack the item. @@ -873,7 +858,7 @@ template class RadioSpinel otError Remove(spinel_prop_key_t aKey, const char *aFormat, ...); /** - * This method tries to reset the co-processor. + * Tries to reset the co-processor. * * @prarm[in] aResetType The reset type, SPINEL_RESET_PLATFORM or SPINEL_RESET_STACK. * @@ -884,7 +869,7 @@ template class RadioSpinel otError SendReset(uint8_t aResetType); /** - * This method returns the radio Spinel metrics. + * Returns the radio Spinel metrics. * * @returns The radio Spinel metrics. * @@ -969,13 +954,13 @@ template class RadioSpinel otError CheckRcpApiVersion(bool aSupportsRcpApiVersion, bool aSupportsMinHostRcpApiVersion); /** - * This method triggers a state transfer of the state machine. + * Triggers a state transfer of the state machine. * */ void ProcessRadioStateMachine(void); /** - * This method processes the frame queue. + * Processes the frame queue. * */ void ProcessFrameQueue(void); @@ -1007,10 +992,9 @@ template class RadioSpinel const char *aFormat, va_list aArgs); otError ParseRadioFrame(otRadioFrame &aFrame, const uint8_t *aBuffer, uint16_t aLength, spinel_ssize_t &aUnpacked); - otError ThreadDatasetHandler(const uint8_t *aBuffer, uint16_t aLength); /** - * This method returns if the property changed event is safe to be handled now. + * Returns if the property changed event is safe to be handled now. * * If a property handler will go up to core stack, it may cause reentrant issue of `Hdlc::Decode()` and * `WaitResponse()`. diff --git a/src/lib/spinel/radio_spinel_impl.hpp b/src/lib/spinel/radio_spinel_impl.hpp index 09ce60d73b4..07ed77a8917 100644 --- a/src/lib/spinel/radio_spinel_impl.hpp +++ b/src/lib/spinel/radio_spinel_impl.hpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -45,13 +44,10 @@ #include "common/encoding.hpp" #include "common/instance.hpp" #include "common/new.hpp" -#include "common/settings.hpp" #include "lib/platform/exit_code.h" #include "lib/spinel/radio_spinel.hpp" #include "lib/spinel/spinel.h" #include "lib/spinel/spinel_decoder.hpp" -#include "meshcop/dataset.hpp" -#include "meshcop/meshcop_tlvs.hpp" #include "radio/radio.hpp" #include "thread/key_manager.hpp" @@ -162,14 +158,13 @@ static inline void LogIfFail(const char *aText, otError aError) } } -template -void RadioSpinel::HandleReceivedFrame(void *aContext) +template void RadioSpinel::HandleReceivedFrame(void *aContext) { static_cast(aContext)->HandleReceivedFrame(); } -template -RadioSpinel::RadioSpinel(void) +template +RadioSpinel::RadioSpinel(void) : mInstance(nullptr) , mRxFrameBuffer() , mSpinelInterface(HandleReceivedFrame, this, mRxFrameBuffer) @@ -218,11 +213,8 @@ RadioSpinel::RadioSpinel(void) memset(&mRadioSpinelMetrics, 0, sizeof(mRadioSpinelMetrics)); } -template -void RadioSpinel::Init(bool aResetRadio, - bool aRestoreDatasetFromNcp, - bool aSkipRcpCompatibilityCheck, - spinel_iid_t aIid) +template +void RadioSpinel::Init(bool aResetRadio, bool aSkipRcpCompatibilityCheck, spinel_iid_t aIid) { otError error = OT_ERROR_NONE; bool supportsRcpApiVersion; @@ -239,19 +231,7 @@ void RadioSpinel::Init(bool aResetRad SuccessOrExit(error = Get(SPINEL_PROP_NCP_VERSION, SPINEL_DATATYPE_UTF8_S, mVersion, sizeof(mVersion))); SuccessOrExit(error = Get(SPINEL_PROP_HWADDR, SPINEL_DATATYPE_EUI64_S, mIeeeEui64.m8)); - if (!IsRcp(supportsRcpApiVersion, supportsRcpMinHostApiVersion)) - { - uint8_t exitCode = OT_EXIT_RADIO_SPINEL_INCOMPATIBLE; - - if (aRestoreDatasetFromNcp) - { -#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE - exitCode = (RestoreDatasetFromNcp() == OT_ERROR_NONE) ? OT_EXIT_SUCCESS : OT_EXIT_FAILURE; -#endif - } - - DieNow(exitCode); - } + VerifyOrDie(IsRcp(supportsRcpApiVersion, supportsRcpMinHostApiVersion), OT_EXIT_RADIO_SPINEL_INCOMPATIBLE); if (!aSkipRcpCompatibilityCheck) { @@ -267,8 +247,7 @@ void RadioSpinel::Init(bool aResetRad SuccessOrDie(error); } -template -void RadioSpinel::ResetRcp(bool aResetRadio) +template void RadioSpinel::ResetRcp(bool aResetRadio) { bool hardwareReset; bool resetDone = false; @@ -304,8 +283,7 @@ void RadioSpinel::ResetRcp(bool aResetRadio) } } -template -otError RadioSpinel::CheckSpinelVersion(void) +template otError RadioSpinel::CheckSpinelVersion(void) { otError error = OT_ERROR_NONE; unsigned int versionMajor; @@ -327,9 +305,8 @@ otError RadioSpinel::CheckSpinelVersion(void) return error; } -template -bool RadioSpinel::IsRcp(bool &aSupportsRcpApiVersion, - bool &aSupportsRcpMinHostApiVersion) +template +bool RadioSpinel::IsRcp(bool &aSupportsRcpApiVersion, bool &aSupportsRcpMinHostApiVersion) { uint8_t capsBuffer[kCapsBufferSize]; const uint8_t *capsData = capsBuffer; @@ -388,8 +365,7 @@ bool RadioSpinel::IsRcp(bool &aSupportsRcpApi return isRcp; } -template -otError RadioSpinel::CheckRadioCapabilities(void) +template otError RadioSpinel::CheckRadioCapabilities(void) { const otRadioCaps kRequiredRadioCaps = #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 @@ -425,9 +401,8 @@ otError RadioSpinel::CheckRadioCapabilities(v return error; } -template -otError RadioSpinel::CheckRcpApiVersion(bool aSupportsRcpApiVersion, - bool aSupportsRcpMinHostApiVersion) +template +otError RadioSpinel::CheckRcpApiVersion(bool aSupportsRcpApiVersion, bool aSupportsRcpMinHostApiVersion) { otError error = OT_ERROR_NONE; @@ -476,36 +451,14 @@ otError RadioSpinel::CheckRcpApiVersion(bool return error; } -#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE -template -otError RadioSpinel::RestoreDatasetFromNcp(void) -{ - otError error = OT_ERROR_NONE; - - Instance::Get().template Get().Init(nullptr, 0); - - otLogInfoPlat("Trying to get saved dataset from NCP"); - SuccessOrExit( - error = Get(SPINEL_PROP_THREAD_ACTIVE_DATASET, SPINEL_DATATYPE_VOID_S, &RadioSpinel::ThreadDatasetHandler)); - SuccessOrExit( - error = Get(SPINEL_PROP_THREAD_PENDING_DATASET, SPINEL_DATATYPE_VOID_S, &RadioSpinel::ThreadDatasetHandler)); - -exit: - Instance::Get().template Get().Deinit(); - return error; -} -#endif - -template -void RadioSpinel::Deinit(void) +template void RadioSpinel::Deinit(void) { mSpinelInterface.Deinit(); // This allows implementing pseudo reset. new (this) RadioSpinel(); } -template -void RadioSpinel::HandleReceivedFrame(void) +template void RadioSpinel::HandleReceivedFrame(void) { otError error = OT_ERROR_NONE; uint8_t header; @@ -545,8 +498,8 @@ void RadioSpinel::HandleReceivedFrame(void) UpdateParseErrorCount(error); } -template -void RadioSpinel::HandleNotification(SpinelInterface::RxFrameBuffer &aFrameBuffer) +template +void RadioSpinel::HandleNotification(SpinelInterface::RxFrameBuffer &aFrameBuffer) { spinel_prop_key_t key; spinel_size_t len = 0; @@ -600,8 +553,8 @@ void RadioSpinel::HandleNotification(SpinelIn LogIfFail("Error processing notification", error); } -template -void RadioSpinel::HandleNotification(const uint8_t *aFrame, uint16_t aLength) +template +void RadioSpinel::HandleNotification(const uint8_t *aFrame, uint16_t aLength) { spinel_prop_key_t key; spinel_size_t len = 0; @@ -622,8 +575,8 @@ void RadioSpinel::HandleNotification(const ui LogIfFail("Error processing saved notification", error); } -template -void RadioSpinel::HandleResponse(const uint8_t *aBuffer, uint16_t aLength) +template +void RadioSpinel::HandleResponse(const uint8_t *aBuffer, uint16_t aLength) { spinel_prop_key_t key; uint8_t *data = nullptr; @@ -664,176 +617,11 @@ void RadioSpinel::HandleResponse(const uint8_ LogIfFail("Error processing response", error); } -#if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE -template -otError RadioSpinel::ThreadDatasetHandler(const uint8_t *aBuffer, uint16_t aLength) -{ - otError error = OT_ERROR_NONE; - otOperationalDataset opDataset; - bool isActive = ((mWaitingKey == SPINEL_PROP_THREAD_ACTIVE_DATASET) ? true : false); - Spinel::Decoder decoder; - MeshCoP::Dataset dataset; - - memset(&opDataset, 0, sizeof(otOperationalDataset)); - decoder.Init(aBuffer, aLength); - - while (!decoder.IsAllReadInStruct()) - { - unsigned int propKey; - - SuccessOrExit(error = decoder.OpenStruct()); - SuccessOrExit(error = decoder.ReadUintPacked(propKey)); - - switch (static_cast(propKey)) - { - case SPINEL_PROP_NET_NETWORK_KEY: - { - const uint8_t *key; - uint16_t len; - - SuccessOrExit(error = decoder.ReadData(key, len)); - VerifyOrExit(len == OT_NETWORK_KEY_SIZE, error = OT_ERROR_INVALID_ARGS); - memcpy(opDataset.mNetworkKey.m8, key, len); - opDataset.mComponents.mIsNetworkKeyPresent = true; - break; - } - - case SPINEL_PROP_NET_NETWORK_NAME: - { - const char *name; - size_t len; - - SuccessOrExit(error = decoder.ReadUtf8(name)); - len = StringLength(name, OT_NETWORK_NAME_MAX_SIZE); - memcpy(opDataset.mNetworkName.m8, name, len); - opDataset.mNetworkName.m8[len] = '\0'; - opDataset.mComponents.mIsNetworkNamePresent = true; - break; - } - - case SPINEL_PROP_NET_XPANID: - { - const uint8_t *xpanid; - uint16_t len; - - SuccessOrExit(error = decoder.ReadData(xpanid, len)); - VerifyOrExit(len == OT_EXT_PAN_ID_SIZE, error = OT_ERROR_INVALID_ARGS); - memcpy(opDataset.mExtendedPanId.m8, xpanid, len); - opDataset.mComponents.mIsExtendedPanIdPresent = true; - break; - } - - case SPINEL_PROP_IPV6_ML_PREFIX: - { - const otIp6Address *addr; - uint8_t prefixLen; - - SuccessOrExit(error = decoder.ReadIp6Address(addr)); - SuccessOrExit(error = decoder.ReadUint8(prefixLen)); - VerifyOrExit(prefixLen == OT_IP6_PREFIX_BITSIZE, error = OT_ERROR_INVALID_ARGS); - memcpy(opDataset.mMeshLocalPrefix.m8, addr, OT_MESH_LOCAL_PREFIX_SIZE); - opDataset.mComponents.mIsMeshLocalPrefixPresent = true; - break; - } - - case SPINEL_PROP_DATASET_DELAY_TIMER: - { - SuccessOrExit(error = decoder.ReadUint32(opDataset.mDelay)); - opDataset.mComponents.mIsDelayPresent = true; - break; - } - - case SPINEL_PROP_MAC_15_4_PANID: - { - SuccessOrExit(error = decoder.ReadUint16(opDataset.mPanId)); - opDataset.mComponents.mIsPanIdPresent = true; - break; - } - - case SPINEL_PROP_PHY_CHAN: - { - uint8_t channel; - - SuccessOrExit(error = decoder.ReadUint8(channel)); - opDataset.mChannel = channel; - opDataset.mComponents.mIsChannelPresent = true; - break; - } - - case SPINEL_PROP_NET_PSKC: - { - const uint8_t *psk; - uint16_t len; - - SuccessOrExit(error = decoder.ReadData(psk, len)); - VerifyOrExit(len == OT_PSKC_MAX_SIZE, error = OT_ERROR_INVALID_ARGS); - memcpy(opDataset.mPskc.m8, psk, OT_PSKC_MAX_SIZE); - opDataset.mComponents.mIsPskcPresent = true; - break; - } - - case SPINEL_PROP_DATASET_SECURITY_POLICY: - { - uint8_t flags[2]; - uint8_t flagsLength = 1; - - SuccessOrExit(error = decoder.ReadUint16(opDataset.mSecurityPolicy.mRotationTime)); - SuccessOrExit(error = decoder.ReadUint8(flags[0])); - if (otThreadGetVersion() >= OT_THREAD_VERSION_1_2 && decoder.GetRemainingLengthInStruct() > 0) - { - SuccessOrExit(error = decoder.ReadUint8(flags[1])); - ++flagsLength; - } - static_cast(opDataset.mSecurityPolicy).SetFlags(flags, flagsLength); - opDataset.mComponents.mIsSecurityPolicyPresent = true; - break; - } - - case SPINEL_PROP_PHY_CHAN_SUPPORTED: - { - uint8_t channel; - - opDataset.mChannelMask = 0; - - while (!decoder.IsAllReadInStruct()) - { - SuccessOrExit(error = decoder.ReadUint8(channel)); - VerifyOrExit(channel <= 31, error = OT_ERROR_INVALID_ARGS); - opDataset.mChannelMask |= (1UL << channel); - } - opDataset.mComponents.mIsChannelMaskPresent = true; - break; - } - - default: - break; - } - - SuccessOrExit(error = decoder.CloseStruct()); - } - - /* - * Initially set Active Timestamp to 0. This is to allow the node to join the network - * yet retrieve the full Active Dataset from a neighboring device if one exists. - */ - memset(&opDataset.mActiveTimestamp, 0, sizeof(opDataset.mActiveTimestamp)); - opDataset.mComponents.mIsActiveTimestampPresent = true; - - SuccessOrExit(error = dataset.SetFrom(static_cast(opDataset))); - SuccessOrExit(error = Instance::Get().template Get().Set( - isActive ? SettingsBase::kKeyActiveDataset : SettingsBase::kKeyPendingDataset, dataset.GetBytes(), - dataset.GetSize())); - -exit: - return error; -} -#endif // #if !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE - -template -void RadioSpinel::HandleWaitingResponse(uint32_t aCommand, - spinel_prop_key_t aKey, - const uint8_t *aBuffer, - uint16_t aLength) +template +void RadioSpinel::HandleWaitingResponse(uint32_t aCommand, + spinel_prop_key_t aKey, + const uint8_t *aBuffer, + uint16_t aLength) { if (aKey == SPINEL_PROP_LAST_STATUS) { @@ -898,10 +686,8 @@ void RadioSpinel::HandleWaitingResponse(uint3 LogIfFail("Error processing result", mError); } -template -void RadioSpinel::HandleValueIs(spinel_prop_key_t aKey, - const uint8_t *aBuffer, - uint16_t aLength) +template +void RadioSpinel::HandleValueIs(spinel_prop_key_t aKey, const uint8_t *aBuffer, uint16_t aLength) { otError error = OT_ERROR_NONE; spinel_ssize_t unpacked; @@ -1006,11 +792,11 @@ void RadioSpinel::HandleValueIs(spinel_prop_k LogIfFail("Failed to handle ValueIs", error); } -template -otError RadioSpinel::ParseRadioFrame(otRadioFrame &aFrame, - const uint8_t *aBuffer, - uint16_t aLength, - spinel_ssize_t &aUnpacked) +template +otError RadioSpinel::ParseRadioFrame(otRadioFrame &aFrame, + const uint8_t *aBuffer, + uint16_t aLength, + spinel_ssize_t &aUnpacked) { otError error = OT_ERROR_NONE; uint16_t flags = 0; @@ -1079,8 +865,7 @@ otError RadioSpinel::ParseRadioFrame(otRadioF return error; } -template -void RadioSpinel::ProcessFrameQueue(void) +template void RadioSpinel::ProcessFrameQueue(void) { uint8_t *frame = nullptr; uint16_t length; @@ -1093,8 +878,7 @@ void RadioSpinel::ProcessFrameQueue(void) mRxFrameBuffer.ClearSavedFrames(); } -template -void RadioSpinel::RadioReceive(void) +template void RadioSpinel::RadioReceive(void) { if (!mIsPromiscuous) { @@ -1126,10 +910,8 @@ void RadioSpinel::RadioReceive(void) return; } -template -void RadioSpinel::TransmitDone(otRadioFrame *aFrame, - otRadioFrame *aAckFrame, - otError aError) +template +void RadioSpinel::TransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError) { #if OPENTHREAD_CONFIG_DIAG_ENABLE if (otPlatDiagModeGet()) @@ -1143,8 +925,7 @@ void RadioSpinel::TransmitDone(otRadioFrame * } } -template -void RadioSpinel::ProcessRadioStateMachine(void) +template void RadioSpinel::ProcessRadioStateMachine(void) { if (mState == kStateTransmitDone) { @@ -1161,8 +942,7 @@ void RadioSpinel::ProcessRadioStateMachine(vo } } -template -void RadioSpinel::Process(const ProcessContextType &aContext) +template void RadioSpinel::Process(const void *aContext) { if (mRxFrameBuffer.HasSavedFrame()) { @@ -1184,8 +964,7 @@ void RadioSpinel::Process(const ProcessContex CalcRcpTimeOffset(); } -template -otError RadioSpinel::SetPromiscuous(bool aEnable) +template otError RadioSpinel::SetPromiscuous(bool aEnable) { otError error; @@ -1197,8 +976,7 @@ otError RadioSpinel::SetPromiscuous(bool aEna return error; } -template -otError RadioSpinel::SetShortAddress(uint16_t aAddress) +template otError RadioSpinel::SetShortAddress(uint16_t aAddress) { otError error = OT_ERROR_NONE; @@ -1210,12 +988,12 @@ otError RadioSpinel::SetShortAddress(uint16_t return error; } -template -otError RadioSpinel::SetMacKey(uint8_t aKeyIdMode, - uint8_t aKeyId, - const otMacKeyMaterial *aPrevKey, - const otMacKeyMaterial *aCurrKey, - const otMacKeyMaterial *aNextKey) +template +otError RadioSpinel::SetMacKey(uint8_t aKeyIdMode, + uint8_t aKeyId, + const otMacKeyMaterial *aPrevKey, + const otMacKeyMaterial *aCurrKey, + const otMacKeyMaterial *aNextKey) { otError error; size_t aKeySize; @@ -1253,8 +1031,8 @@ otError RadioSpinel::SetMacKey(uint8_t return error; } -template -otError RadioSpinel::SetMacFrameCounter(uint32_t aMacFrameCounter, bool aSetIfLarger) +template +otError RadioSpinel::SetMacFrameCounter(uint32_t aMacFrameCounter, bool aSetIfLarger) { otError error; @@ -1265,16 +1043,15 @@ otError RadioSpinel::SetMacFrameCounter(uint3 return error; } -template -otError RadioSpinel::GetIeeeEui64(uint8_t *aIeeeEui64) +template otError RadioSpinel::GetIeeeEui64(uint8_t *aIeeeEui64) { memcpy(aIeeeEui64, mIeeeEui64.m8, sizeof(mIeeeEui64.m8)); return OT_ERROR_NONE; } -template -otError RadioSpinel::SetExtendedAddress(const otExtAddress &aExtAddress) +template +otError RadioSpinel::SetExtendedAddress(const otExtAddress &aExtAddress) { otError error; @@ -1285,8 +1062,7 @@ otError RadioSpinel::SetExtendedAddress(const return error; } -template -otError RadioSpinel::SetPanId(uint16_t aPanId) +template otError RadioSpinel::SetPanId(uint16_t aPanId) { otError error = OT_ERROR_NONE; @@ -1298,14 +1074,12 @@ otError RadioSpinel::SetPanId(uint16_t aPanId return error; } -template -otError RadioSpinel::EnableSrcMatch(bool aEnable) +template otError RadioSpinel::EnableSrcMatch(bool aEnable) { return Set(SPINEL_PROP_MAC_SRC_MATCH_ENABLED, SPINEL_DATATYPE_BOOL_S, aEnable); } -template -otError RadioSpinel::AddSrcMatchShortEntry(uint16_t aShortAddress) +template otError RadioSpinel::AddSrcMatchShortEntry(uint16_t aShortAddress) { otError error; @@ -1329,8 +1103,8 @@ otError RadioSpinel::AddSrcMatchShortEntry(ui return error; } -template -otError RadioSpinel::AddSrcMatchExtEntry(const otExtAddress &aExtAddress) +template +otError RadioSpinel::AddSrcMatchExtEntry(const otExtAddress &aExtAddress) { otError error; @@ -1355,8 +1129,7 @@ otError RadioSpinel::AddSrcMatchExtEntry(cons return error; } -template -otError RadioSpinel::ClearSrcMatchShortEntry(uint16_t aShortAddress) +template otError RadioSpinel::ClearSrcMatchShortEntry(uint16_t aShortAddress) { otError error; @@ -1378,8 +1151,8 @@ otError RadioSpinel::ClearSrcMatchShortEntry( return error; } -template -otError RadioSpinel::ClearSrcMatchExtEntry(const otExtAddress &aExtAddress) +template +otError RadioSpinel::ClearSrcMatchExtEntry(const otExtAddress &aExtAddress) { otError error; @@ -1402,8 +1175,7 @@ otError RadioSpinel::ClearSrcMatchExtEntry(co return error; } -template -otError RadioSpinel::ClearSrcMatchShortEntries(void) +template otError RadioSpinel::ClearSrcMatchShortEntries(void) { otError error; @@ -1417,8 +1189,7 @@ otError RadioSpinel::ClearSrcMatchShortEntrie return error; } -template -otError RadioSpinel::ClearSrcMatchExtEntries(void) +template otError RadioSpinel::ClearSrcMatchExtEntries(void) { otError error; @@ -1432,8 +1203,7 @@ otError RadioSpinel::ClearSrcMatchExtEntries( return error; } -template -otError RadioSpinel::GetTransmitPower(int8_t &aPower) +template otError RadioSpinel::GetTransmitPower(int8_t &aPower) { otError error = Get(SPINEL_PROP_PHY_TX_POWER, SPINEL_DATATYPE_INT8_S, &aPower); @@ -1441,8 +1211,7 @@ otError RadioSpinel::GetTransmitPower(int8_t return error; } -template -otError RadioSpinel::GetCcaEnergyDetectThreshold(int8_t &aThreshold) +template otError RadioSpinel::GetCcaEnergyDetectThreshold(int8_t &aThreshold) { otError error = Get(SPINEL_PROP_PHY_CCA_THRESHOLD, SPINEL_DATATYPE_INT8_S, &aThreshold); @@ -1450,8 +1219,7 @@ otError RadioSpinel::GetCcaEnergyDetectThresh return error; } -template -otError RadioSpinel::GetFemLnaGain(int8_t &aGain) +template otError RadioSpinel::GetFemLnaGain(int8_t &aGain) { otError error = Get(SPINEL_PROP_PHY_FEM_LNA_GAIN, SPINEL_DATATYPE_INT8_S, &aGain); @@ -1459,8 +1227,7 @@ otError RadioSpinel::GetFemLnaGain(int8_t &aG return error; } -template -int8_t RadioSpinel::GetRssi(void) +template int8_t RadioSpinel::GetRssi(void) { int8_t rssi = OT_RADIO_RSSI_INVALID; otError error = Get(SPINEL_PROP_PHY_RSSI, SPINEL_DATATYPE_INT8_S, &rssi); @@ -1470,8 +1237,7 @@ int8_t RadioSpinel::GetRssi(void) } #if OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE -template -otError RadioSpinel::SetCoexEnabled(bool aEnabled) +template otError RadioSpinel::SetCoexEnabled(bool aEnabled) { otError error; @@ -1486,8 +1252,7 @@ otError RadioSpinel::SetCoexEnabled(bool aEna return error; } -template -bool RadioSpinel::IsCoexEnabled(void) +template bool RadioSpinel::IsCoexEnabled(void) { bool enabled; otError error = Get(SPINEL_PROP_RADIO_COEX_ENABLE, SPINEL_DATATYPE_BOOL_S, &enabled); @@ -1496,8 +1261,7 @@ bool RadioSpinel::IsCoexEnabled(void) return enabled; } -template -otError RadioSpinel::GetCoexMetrics(otRadioCoexMetrics &aCoexMetrics) +template otError RadioSpinel::GetCoexMetrics(otRadioCoexMetrics &aCoexMetrics) { otError error; @@ -1537,8 +1301,7 @@ otError RadioSpinel::GetCoexMetrics(otRadioCo } #endif -template -otError RadioSpinel::SetTransmitPower(int8_t aPower) +template otError RadioSpinel::SetTransmitPower(int8_t aPower) { otError error; @@ -1554,8 +1317,7 @@ otError RadioSpinel::SetTransmitPower(int8_t return error; } -template -otError RadioSpinel::SetCcaEnergyDetectThreshold(int8_t aThreshold) +template otError RadioSpinel::SetCcaEnergyDetectThreshold(int8_t aThreshold) { otError error; @@ -1571,8 +1333,7 @@ otError RadioSpinel::SetCcaEnergyDetectThresh return error; } -template -otError RadioSpinel::SetFemLnaGain(int8_t aGain) +template otError RadioSpinel::SetFemLnaGain(int8_t aGain) { otError error; @@ -1588,8 +1349,8 @@ otError RadioSpinel::SetFemLnaGain(int8_t aGa return error; } -template -otError RadioSpinel::EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration) +template +otError RadioSpinel::EnergyScan(uint8_t aScanChannel, uint16_t aScanDuration) { otError error; @@ -1611,8 +1372,8 @@ otError RadioSpinel::EnergyScan(uint8_t aScan return error; } -template -otError RadioSpinel::Get(spinel_prop_key_t aKey, const char *aFormat, ...) +template +otError RadioSpinel::Get(spinel_prop_key_t aKey, const char *aFormat, ...) { otError error; @@ -1634,12 +1395,12 @@ otError RadioSpinel::Get(spinel_prop_key_t aK } // This is not a normal use case for VALUE_GET command and should be only used to get RCP timestamp with dummy payload -template -otError RadioSpinel::GetWithParam(spinel_prop_key_t aKey, - const uint8_t *aParam, - spinel_size_t aParamSize, - const char *aFormat, - ...) +template +otError RadioSpinel::GetWithParam(spinel_prop_key_t aKey, + const uint8_t *aParam, + spinel_size_t aParamSize, + const char *aFormat, + ...) { otError error; @@ -1661,8 +1422,8 @@ otError RadioSpinel::GetWithParam(spinel_prop return error; } -template -otError RadioSpinel::Set(spinel_prop_key_t aKey, const char *aFormat, ...) +template +otError RadioSpinel::Set(spinel_prop_key_t aKey, const char *aFormat, ...) { otError error; @@ -1684,8 +1445,8 @@ otError RadioSpinel::Set(spinel_prop_key_t aK return error; } -template -otError RadioSpinel::Insert(spinel_prop_key_t aKey, const char *aFormat, ...) +template +otError RadioSpinel::Insert(spinel_prop_key_t aKey, const char *aFormat, ...) { otError error; @@ -1707,8 +1468,8 @@ otError RadioSpinel::Insert(spinel_prop_key_t return error; } -template -otError RadioSpinel::Remove(spinel_prop_key_t aKey, const char *aFormat, ...) +template +otError RadioSpinel::Remove(spinel_prop_key_t aKey, const char *aFormat, ...) { otError error; @@ -1730,8 +1491,7 @@ otError RadioSpinel::Remove(spinel_prop_key_t return error; } -template -otError RadioSpinel::WaitResponse(bool aHandleRcpTimeout) +template otError RadioSpinel::WaitResponse(bool aHandleRcpTimeout) { uint64_t end = otPlatTimeGet() + kMaxWaitTime * US_PER_MS; @@ -1761,8 +1521,7 @@ otError RadioSpinel::WaitResponse(bool aHandl return mError; } -template -spinel_tid_t RadioSpinel::GetNextTid(void) +template spinel_tid_t RadioSpinel::GetNextTid(void) { spinel_tid_t tid = mCmdNextTid; @@ -1786,8 +1545,7 @@ spinel_tid_t RadioSpinel::GetNextTid(void) return tid; } -template -otError RadioSpinel::SendReset(uint8_t aResetType) +template otError RadioSpinel::SendReset(uint8_t aResetType) { otError error = OT_ERROR_NONE; uint8_t buffer[kMaxSpinelFrame]; @@ -1806,12 +1564,12 @@ otError RadioSpinel::SendReset(uint8_t aReset return error; } -template -otError RadioSpinel::SendCommand(uint32_t aCommand, - spinel_prop_key_t aKey, - spinel_tid_t tid, - const char *aFormat, - va_list args) +template +otError RadioSpinel::SendCommand(uint32_t aCommand, + spinel_prop_key_t aKey, + spinel_tid_t tid, + const char *aFormat, + va_list args) { otError error = OT_ERROR_NONE; uint8_t buffer[kMaxSpinelFrame]; @@ -1842,11 +1600,11 @@ otError RadioSpinel::SendCommand(uint32_t return error; } -template -otError RadioSpinel::RequestV(uint32_t command, - spinel_prop_key_t aKey, - const char *aFormat, - va_list aArgs) +template +otError RadioSpinel::RequestV(uint32_t command, + spinel_prop_key_t aKey, + const char *aFormat, + va_list aArgs) { otError error = OT_ERROR_NONE; spinel_tid_t tid = GetNextTid(); @@ -1874,11 +1632,8 @@ otError RadioSpinel::RequestV(uint32_t return error; } -template -otError RadioSpinel::Request(uint32_t aCommand, - spinel_prop_key_t aKey, - const char *aFormat, - ...) +template +otError RadioSpinel::Request(uint32_t aCommand, spinel_prop_key_t aKey, const char *aFormat, ...) { va_list args; va_start(args, aFormat); @@ -1887,12 +1642,12 @@ otError RadioSpinel::Request(uint32_t return status; } -template -otError RadioSpinel::RequestWithPropertyFormat(const char *aPropertyFormat, - uint32_t aCommand, - spinel_prop_key_t aKey, - const char *aFormat, - ...) +template +otError RadioSpinel::RequestWithPropertyFormat(const char *aPropertyFormat, + uint32_t aCommand, + spinel_prop_key_t aKey, + const char *aFormat, + ...) { otError error; va_list args; @@ -1904,12 +1659,12 @@ otError RadioSpinel::RequestWithPropertyForma return error; } -template -otError RadioSpinel::RequestWithPropertyFormatV(const char *aPropertyFormat, - uint32_t aCommand, - spinel_prop_key_t aKey, - const char *aFormat, - va_list aArgs) +template +otError RadioSpinel::RequestWithPropertyFormatV(const char *aPropertyFormat, + uint32_t aCommand, + spinel_prop_key_t aKey, + const char *aFormat, + va_list aArgs) { otError error; @@ -1920,12 +1675,12 @@ otError RadioSpinel::RequestWithPropertyForma return error; } -template -otError RadioSpinel::RequestWithExpectedCommandV(uint32_t aExpectedCommand, - uint32_t aCommand, - spinel_prop_key_t aKey, - const char *aFormat, - va_list aArgs) +template +otError RadioSpinel::RequestWithExpectedCommandV(uint32_t aExpectedCommand, + uint32_t aCommand, + spinel_prop_key_t aKey, + const char *aFormat, + va_list aArgs) { otError error; @@ -1936,11 +1691,11 @@ otError RadioSpinel::RequestWithExpectedComma return error; } -template -void RadioSpinel::HandleTransmitDone(uint32_t aCommand, - spinel_prop_key_t aKey, - const uint8_t *aBuffer, - uint16_t aLength) +template +void RadioSpinel::HandleTransmitDone(uint32_t aCommand, + spinel_prop_key_t aKey, + const uint8_t *aBuffer, + uint16_t aLength) { otError error = OT_ERROR_NONE; spinel_status_t status = SPINEL_STATUS_OK; @@ -2002,8 +1757,7 @@ void RadioSpinel::HandleTransmitDone(uint32_t LogIfFail("Handle transmit done failed", error); } -template -otError RadioSpinel::Transmit(otRadioFrame &aFrame) +template otError RadioSpinel::Transmit(otRadioFrame &aFrame) { otError error = OT_ERROR_INVALID_STATE; @@ -2045,8 +1799,7 @@ otError RadioSpinel::Transmit(otRadioFrame &a return error; } -template -otError RadioSpinel::Receive(uint8_t aChannel) +template otError RadioSpinel::Receive(uint8_t aChannel) { otError error = OT_ERROR_NONE; @@ -2077,8 +1830,7 @@ otError RadioSpinel::Receive(uint8_t aChannel return error; } -template -otError RadioSpinel::Sleep(void) +template otError RadioSpinel::Sleep(void) { otError error = OT_ERROR_NONE; @@ -2103,8 +1855,7 @@ otError RadioSpinel::Sleep(void) return error; } -template -otError RadioSpinel::Enable(otInstance *aInstance) +template otError RadioSpinel::Enable(otInstance *aInstance) { otError error = OT_ERROR_NONE; @@ -2129,8 +1880,7 @@ otError RadioSpinel::Enable(otInstance *aInst return error; } -template -otError RadioSpinel::Disable(void) +template otError RadioSpinel::Disable(void) { otError error = OT_ERROR_NONE; @@ -2146,10 +1896,8 @@ otError RadioSpinel::Disable(void) } #if OPENTHREAD_CONFIG_DIAG_ENABLE -template -otError RadioSpinel::PlatDiagProcess(const char *aString, - char *aOutput, - size_t aOutputMaxLen) +template +otError RadioSpinel::PlatDiagProcess(const char *aString, char *aOutput, size_t aOutputMaxLen) { otError error; @@ -2165,8 +1913,7 @@ otError RadioSpinel::PlatDiagProcess(const ch } #endif -template -uint32_t RadioSpinel::GetRadioChannelMask(bool aPreferred) +template uint32_t RadioSpinel::GetRadioChannelMask(bool aPreferred) { uint8_t maskBuffer[kChannelMaskBufferSize]; otError error = OT_ERROR_NONE; @@ -2199,8 +1946,7 @@ uint32_t RadioSpinel::GetRadioChannelMask(boo return channelMask; } -template -otRadioState RadioSpinel::GetState(void) const +template otRadioState RadioSpinel::GetState(void) const { static const otRadioState sOtRadioStateMap[] = { OT_RADIO_STATE_DISABLED, OT_RADIO_STATE_SLEEP, OT_RADIO_STATE_RECEIVE, @@ -2210,8 +1956,7 @@ otRadioState RadioSpinel::GetState(void) cons return sOtRadioStateMap[mState]; } -template -void RadioSpinel::CalcRcpTimeOffset(void) +template void RadioSpinel::CalcRcpTimeOffset(void) { #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 otError error = OT_ERROR_NONE; @@ -2272,20 +2017,17 @@ void RadioSpinel::CalcRcpTimeOffset(void) #endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 } -template -uint64_t RadioSpinel::GetNow(void) +template uint64_t RadioSpinel::GetNow(void) { return (mIsTimeSynced) ? (otPlatTimeGet() + mRadioTimeOffset) : UINT64_MAX; } -template -uint32_t RadioSpinel::GetBusSpeed(void) const +template uint32_t RadioSpinel::GetBusSpeed(void) const { return mSpinelInterface.GetBusSpeed(); } -template -void RadioSpinel::HandleRcpUnexpectedReset(spinel_status_t aStatus) +template void RadioSpinel::HandleRcpUnexpectedReset(spinel_status_t aStatus) { OT_UNUSED_VARIABLE(aStatus); @@ -2301,8 +2043,7 @@ void RadioSpinel::HandleRcpUnexpectedReset(sp #endif } -template -void RadioSpinel::HandleRcpTimeout(void) +template void RadioSpinel::HandleRcpTimeout(void) { mRadioSpinelMetrics.mRcpTimeoutCount++; @@ -2321,8 +2062,7 @@ void RadioSpinel::HandleRcpTimeout(void) #endif } -template -void RadioSpinel::RecoverFromRcpFailure(void) +template void RadioSpinel::RecoverFromRcpFailure(void) { #if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 constexpr int16_t kMaxFailureCount = OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT; @@ -2403,8 +2143,7 @@ void RadioSpinel::RecoverFromRcpFailure(void) } #if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 -template -void RadioSpinel::RestoreProperties(void) +template void RadioSpinel::RestoreProperties(void) { Settings::NetworkInfo networkInfo; @@ -2488,8 +2227,8 @@ void RadioSpinel::RestoreProperties(void) } #endif // OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0 -template -otError RadioSpinel::SetChannelMaxTransmitPower(uint8_t aChannel, int8_t aMaxPower) +template +otError RadioSpinel::SetChannelMaxTransmitPower(uint8_t aChannel, int8_t aMaxPower) { otError error = OT_ERROR_NONE; VerifyOrExit(aChannel >= Radio::kChannelMin && aChannel <= Radio::kChannelMax, error = OT_ERROR_INVALID_ARGS); @@ -2500,8 +2239,7 @@ otError RadioSpinel::SetChannelMaxTransmitPow return error; } -template -otError RadioSpinel::SetRadioRegion(uint16_t aRegionCode) +template otError RadioSpinel::SetRadioRegion(uint16_t aRegionCode) { otError error; @@ -2521,8 +2259,7 @@ otError RadioSpinel::SetRadioRegion(uint16_t return error; } -template -otError RadioSpinel::GetRadioRegion(uint16_t *aRegionCode) +template otError RadioSpinel::GetRadioRegion(uint16_t *aRegionCode) { otError error = OT_ERROR_NONE; @@ -2534,10 +2271,10 @@ otError RadioSpinel::GetRadioRegion(uint16_t } #if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE -template -otError RadioSpinel::ConfigureEnhAckProbing(otLinkMetrics aLinkMetrics, - const otShortAddress aShortAddress, - const otExtAddress &aExtAddress) +template +otError RadioSpinel::ConfigureEnhAckProbing(otLinkMetrics aLinkMetrics, + const otShortAddress aShortAddress, + const otExtAddress &aExtAddress) { otError error = OT_ERROR_NONE; uint8_t flags = 0; @@ -2571,8 +2308,7 @@ otError RadioSpinel::ConfigureEnhAckProbing(o #endif #if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE || OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE -template -uint8_t RadioSpinel::GetCslAccuracy(void) +template uint8_t RadioSpinel::GetCslAccuracy(void) { uint8_t accuracy = UINT8_MAX; otError error = Get(SPINEL_PROP_RCP_CSL_ACCURACY, SPINEL_DATATYPE_UINT8_S, &accuracy); @@ -2583,8 +2319,7 @@ uint8_t RadioSpinel::GetCslAccuracy(void) #endif #if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE -template -uint8_t RadioSpinel::GetCslUncertainty(void) +template uint8_t RadioSpinel::GetCslUncertainty(void) { uint8_t uncertainty = UINT8_MAX; otError error = Get(SPINEL_PROP_RCP_CSL_UNCERTAINTY, SPINEL_DATATYPE_UINT8_S, &uncertainty); @@ -2595,11 +2330,11 @@ uint8_t RadioSpinel::GetCslUncertainty(void) #endif #if OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE -template -otError RadioSpinel::AddCalibratedPower(uint8_t aChannel, - int16_t aActualPower, - const uint8_t *aRawPowerSetting, - uint16_t aRawPowerSettingLength) +template +otError RadioSpinel::AddCalibratedPower(uint8_t aChannel, + int16_t aActualPower, + const uint8_t *aRawPowerSetting, + uint16_t aRawPowerSettingLength) { otError error; @@ -2612,14 +2347,13 @@ otError RadioSpinel::AddCalibratedPower(uint8 return error; } -template -otError RadioSpinel::ClearCalibratedPowers(void) +template otError RadioSpinel::ClearCalibratedPowers(void) { return Set(SPINEL_PROP_PHY_CALIBRATED_POWER, nullptr); } -template -otError RadioSpinel::SetChannelTargetPower(uint8_t aChannel, int16_t aTargetPower) +template +otError RadioSpinel::SetChannelTargetPower(uint8_t aChannel, int16_t aTargetPower) { otError error = OT_ERROR_NONE; VerifyOrExit(aChannel >= Radio::kChannelMin && aChannel <= Radio::kChannelMax, error = OT_ERROR_INVALID_ARGS); @@ -2631,8 +2365,8 @@ otError RadioSpinel::SetChannelTargetPower(ui } #endif // OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE -template -uint32_t RadioSpinel::Snprintf(char *aDest, uint32_t aSize, const char *aFormat, ...) +template +uint32_t RadioSpinel::Snprintf(char *aDest, uint32_t aSize, const char *aFormat, ...) { int len; va_list args; @@ -2644,8 +2378,8 @@ uint32_t RadioSpinel::Snprintf(char *aDest, u return (len < 0) ? 0 : Min(static_cast(len), aSize - 1); } -template -void RadioSpinel::LogSpinelFrame(const uint8_t *aFrame, uint16_t aLength, bool aTx) +template +void RadioSpinel::LogSpinelFrame(const uint8_t *aFrame, uint16_t aLength, bool aTx) { otError error = OT_ERROR_NONE; char buf[OPENTHREAD_CONFIG_LOG_MAX_SIZE] = {0}; diff --git a/src/lib/spinel/radio_spinel_metrics.h b/src/lib/spinel/radio_spinel_metrics.h index 91d4d76da07..e2500879e07 100644 --- a/src/lib/spinel/radio_spinel_metrics.h +++ b/src/lib/spinel/radio_spinel_metrics.h @@ -40,7 +40,7 @@ extern "C" { #endif /** - * This structure represents the radio spinel metrics. + * Represents the radio spinel metrics. * */ typedef struct otRadioSpinelMetrics diff --git a/src/lib/spinel/spi_frame.hpp b/src/lib/spinel/spi_frame.hpp new file mode 100644 index 00000000000..a606c089680 --- /dev/null +++ b/src/lib/spinel/spi_frame.hpp @@ -0,0 +1,246 @@ +/* + * 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 + * This file contains definitions of the SPI frame. + */ + +#ifndef SPINEL_SPI_FRAME_HPP_ +#define SPINEL_SPI_FRAME_HPP_ + +#include + +#include "common/encoding.hpp" + +namespace ot { +namespace Spinel { + +/* + * SPI Framing Protocol + * + * Each SPI frame starts with a 5-byte frame header: + * + * +---------+-----+----------+----------+ + * | Octets: | 1 | 2 | 2 | + * +---------+-----+----------+----------+ + * | Fields: | HDR | RECV_LEN | DATA_LEN | + * +---------+-----+----------+----------+ + * + * - "HDR": The first byte is the header byte (defined below) + * - "RECV_LEN": The second and third bytes indicate the largest frame + * size that that device is ready to receive. If zero, then the + * other device must not send any data. (Little endian) + * - "DATA_LEN": The fourth and fifth bytes indicate the size of the + * pending data frame to be sent to the other device. If this value + * is equal-to or less-than the number of bytes that the other device + * is willing to receive, then the data of the frame is immediately + * after the header. (Little Endian) + * + * The "HDR" byte is defined as: + * + * 0 1 2 3 4 5 6 7 + * +---+---+---+---+---+---+---+---+ + * |RST|CRC|CCF| RESERVED |PATTERN| + * +---+---+---+---+---+---+---+---+ + * + * - "RST": This bit is set when that device has been reset since the + * last time `CS` (chip select) was asserted. + * - "CRC": This bit is set when that device supports writing a 16-bit + * CRC at the end of the data. The CRC length is NOT included in + * DATA_LEN. + * - "CCF": "CRC Check Failure". Set if the CRC check on the last + * received frame failed, cleared to zero otherwise. This bit is + * only used if both sides support CRC. + * - "RESERVED": These bits are all reserved for future used. They + * MUST be cleared to zero and MUST be ignored if set. + * - "PATTERN": These bits are set to a fixed value to help distinguish + * valid SPI frames from garbage (by explicitly making "0xFF" and + * "0x00" invalid values). Bit 6 MUST be set to be one and bit 7 + * MUST be cleared (0). A frame received that has any other values + * for these bits MUST be dropped. + * + * Prior to a sending or receiving a frame, the master MAY send a + * 5-octet frame with zeros for both the max receive frame size and the + * the contained frame length. This will induce the slave device to + * indicate the length of the frame it wants to send (if any) and + * indicate the largest frame it is capable of receiving at the moment. + * This allows the master to calculate the size of the next transaction. + * Alternatively, if the master has a frame to send it can just go ahead + * and send a frame of that length and determine if the frame was + * accepted by checking that the "RECV_LEN" from the slave frame is + * larger than the frame the master just tried to send. If the + * "RECV_LEN" is smaller then the frame wasn't accepted and will need to + * be transmitted again. + * + * This protocol can be used either unidirectionally or bidirectionally, + * determined by the behavior of the master and the slave. + * + * If the the master notices "PATTERN" is not set correctly, the master + * should consider the transaction to have failed and try again after 10 + * milliseconds, retrying up to 200 times. After unsuccessfully trying + * 200 times in a row, the master MAY take appropriate remedial action + * (like a NCP hardware reset, or indicating a communication failure to + * a user interface). + * + * At the end of the data of a frame is an optional 16-bit CRC, support + * for which is indicated by the "CRC" bit of the "HDR" byte being set. + * If these bits are set for both the master and slave frames, then CRC + * checking is enabled on both sides, effectively requiring that frame + * sizes be two bytes longer than would be otherwise required. The CRC + * is calculated using the same mechanism used for the CRC calculation + * in HDLC-Lite (See Appendix A.1.2). When both of the "CRC" bits are + * set, both sides must verify that the "CRC" is valid before accepting + * the frame. If not enough bytes were clocked out for the CRC to be + * read, then the frame must be ignored. If enough bytes were clocked + * out to perform a CRC check, but the CRC check fails, then the frame + * must be rejected and the "CRC_FAIL" bit on the next frame (and ONLY + * the next frame) MUST be set. + */ + +/** + * Defines a SPI frame. + * + */ +class SpiFrame +{ +public: + enum + { + kHeaderSize = 5, ///< SPI header size (in bytes). + }; + + /** + * Initializes an `SpiFrame` instance. + * + * @param[in] aBuffer Pointer to buffer containing the frame. + * + */ + explicit SpiFrame(uint8_t *aBuffer) + : mBuffer(aBuffer) + { + } + + /** + * Gets a pointer to data portion in the SPI frame skipping the header. + * + * @returns A pointer to data in the SPI frame. + * + */ + uint8_t *GetData(void) { return mBuffer + kHeaderSize; } + + /** + * Indicates whether or not the frame is valid. + * + * In a valid frame the flag byte should contain the pattern bits. + * + * @returns TRUE if the frame is valid, FALSE otherwise. + * + */ + bool IsValid(void) const { return ((mBuffer[kIndexFlagByte] & kFlagPatternMask) == kFlagPattern); } + + /** + * Indicates whether or not the "RST" bit is set. + * + * @returns TRUE if the "RST" bit is set, FALSE otherwise. + * + */ + bool IsResetFlagSet(void) const { return ((mBuffer[kIndexFlagByte] & kFlagReset) == kFlagReset); } + + /** + * Sets the "flag byte" field in the SPI frame header. + * + * @param[in] aResetFlag The status of reset flag (TRUE to set the flag, FALSE to clear flag). + * + */ + void SetHeaderFlagByte(bool aResetFlag) { mBuffer[kIndexFlagByte] = kFlagPattern | (aResetFlag ? kFlagReset : 0); } + + /** + * Gets the "flag byte" field in the SPI frame header. + * + * @returns The flag byte. + * + */ + uint8_t GetHeaderFlagByte(void) const { return mBuffer[kIndexFlagByte]; } + + /** + * Sets the "accept len" field in the SPI frame header. + * + * "accept len" specifies number of bytes the sender of the SPI frame can receive. + * + * @param[in] aAcceptLen The accept length in bytes. + * + */ + void SetHeaderAcceptLen(uint16_t aAcceptLen) + { + Encoding::LittleEndian::WriteUint16(aAcceptLen, mBuffer + kIndexAcceptLen); + } + + /** + * Gets the "accept len" field in the SPI frame header. + * + * @returns The accept length in bytes. + * + */ + uint16_t GetHeaderAcceptLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexAcceptLen); } + + /** + * Sets the "data len" field in the SPI frame header. + * + * "Data len" specifies number of data bytes in the transmitted SPI frame. + * + * @param[in] aDataLen The data length in bytes. + * + */ + void SetHeaderDataLen(uint16_t aDataLen) { Encoding::LittleEndian::WriteUint16(aDataLen, mBuffer + kIndexDataLen); } + + /** + * Gets the "data len" field in the SPI frame header. + * + * @returns The data length in bytes. + * + */ + uint16_t GetHeaderDataLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexDataLen); } + +private: + enum + { + kIndexFlagByte = 0, // flag byte (uint8_t). + kIndexAcceptLen = 1, // accept len (uint16_t little-endian encoding). + kIndexDataLen = 3, // data len (uint16_t little-endian encoding). + + kFlagReset = (1 << 7), // Flag byte RESET bit. + kFlagPattern = 0x02, // Flag byte PATTERN bits. + kFlagPatternMask = 0x03, // Flag byte PATTERN mask. + }; + + uint8_t *mBuffer; +}; + +} // namespace Spinel +} // namespace ot +#endif // SPINEL_SPI_FRAME_HPP_ diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h index d2a3644e911..3dce172b06a 100644 --- a/src/lib/spinel/spinel.h +++ b/src/lib/spinel/spinel.h @@ -5041,9 +5041,9 @@ SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_unpack(const uint8_t *data_in, const char *pack_format, ...); /** - * This function parses spinel data similar to sscanf(). + * Parses spinel data similar to sscanf(). * - * This function actually calls spinel_datatype_vunpack_in_place() to parse data. + * Actually calls spinel_datatype_vunpack_in_place() to parse data. * * @param[in] data_in A pointer to the data to parse. * @param[in] data_len The length of @p data_in in bytes. @@ -5073,7 +5073,7 @@ SPINEL_API_EXTERN spinel_ssize_t spinel_datatype_vunpack(const uint8_t *data_in, const char *pack_format, va_list args); /** - * This function parses spinel data similar to vsscanf(). + * Parses spinel data similar to vsscanf(). * * @param[in] data_in A pointer to the data to parse. * @param[in] data_len The length of @p data_in in bytes. diff --git a/src/lib/spinel/spinel_buffer.hpp b/src/lib/spinel/spinel_buffer.hpp index fecdb645c55..965c87e3acc 100644 --- a/src/lib/spinel/spinel_buffer.hpp +++ b/src/lib/spinel/spinel_buffer.hpp @@ -41,7 +41,7 @@ namespace ot { namespace Spinel { /** - * This class implements a buffer/queue for storing Ncp frames. + * Implements a buffer/queue for storing Ncp frames. * * A frame can consist of a sequence of data bytes and/or the content of an `otMessage` or a combination of the two. * `Buffer` implements priority FIFO logic for storing and reading frames. Two priority levels of high and low @@ -117,7 +117,7 @@ class Buffer typedef void (*BufferCallback)(void *aContext, FrameTag aTag, Priority aPriority, Buffer *aBuffer); /** - * This constructor initializes an NCP frame buffer. + * Initializes an NCP frame buffer. * * @param[in] aBuffer A pointer to a buffer which will be used by NCP frame buffer. * @param[in] aBufferLength The buffer size (in bytes). @@ -126,13 +126,13 @@ class Buffer Buffer(uint8_t *aBuffer, uint16_t aBufferLength); /** - * This method clears the NCP frame buffer. All the frames are cleared/removed. + * Clears the NCP frame buffer. All the frames are cleared/removed. * */ void Clear(void); /** - * This method sets the FrameAdded callback and its context. + * Sets the FrameAdded callback and its context. * * Subsequent calls to this method will overwrite the previous callback and its context. * @@ -143,7 +143,7 @@ class Buffer void SetFrameAddedCallback(BufferCallback aFrameAddedCallback, void *aFrameAddedContext); /** - * This method sets the FrameRemoved callback and its context. + * Sets the FrameRemoved callback and its context. * * Subsequent calls to this method will overwrite the previous callback and its context. * @@ -154,7 +154,7 @@ class Buffer void SetFrameRemovedCallback(BufferCallback aFrameRemovedCallback, void *aFrameRemovedContext); /** - * This method begins a new input frame (InFrame) to be added/written to the frame buffer. + * Begins a new input frame (InFrame) to be added/written to the frame buffer. * If there is a previous frame being written (for which `InFrameEnd()` has not yet been called), calling * `InFrameBegin()` will discard and clear the previous unfinished frame. @@ -165,7 +165,7 @@ class Buffer void InFrameBegin(Priority aPriority); /** - * This method adds a single byte to current input frame. + * Adds a single byte to current input frame. * * Before using this method `InFrameBegin()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -183,7 +183,7 @@ class Buffer otError InFrameFeedByte(uint8_t aByte); /** - * This method adds data to the current input frame. + * Adds data to the current input frame. * * Before using this method `InFrameBegin()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -203,7 +203,7 @@ class Buffer #if OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE /** - * This method adds a message to the current input frame. + * Adds a message to the current input frame. * * Before using this method `InFrameBegin()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -229,7 +229,7 @@ class Buffer #endif /** - * This method gets the current write position in the input frame. + * Gets the current write position in the input frame. * * The write position is returned in @p aPosition. The saved position can later be used to overwrite the frame * content (using `InFrameOverwrite()`) or discard a portion of written frame and move the write pointer back to @@ -244,13 +244,13 @@ class Buffer otError InFrameGetPosition(WritePosition &aPosition); /** - * This method overwrites the previously written content in the current input frame at a given write position. + * Overwrites the previously written content in the current input frame at a given write position. * * The write position @p aPostion must belong to the same input frame saved earlier with `InFrameGetPosition()`. - * This method does not allow writing beyond the current end of the input frame (i.e., it can only write over + * Does not allow writing beyond the current end of the input frame (i.e., it can only write over * previously added content). If writing @p aDataBufferLength bytes from write position @p aPosition goes beyond * the end, this method does not change the input frame and returns error status `OT_ERROR_INVALID_ARGS`. - * This method cannot be used if the input frame has an added `otMessage` (i.e., a previous call to + * Cannot be used if the input frame has an added `otMessage` (i.e., a previous call to * `InFrameFeedMessage()`). * * @param[in] aPosition A reference to the write position. @@ -267,11 +267,11 @@ class Buffer otError InFrameOverwrite(const WritePosition &aPosition, const uint8_t *aDataBuffer, uint16_t aDataBufferLength); /** - * This method resets the write position of input frame back to a previously saved position. Any previously + * Resets the write position of input frame back to a previously saved position. Any previously * added content after the write position is discarded. * * The write position @p aPosition must belong to the same input frame saved earlier with `InFrameGetPosition()`. - * This method cannot be used if the input frame has an added `otMessage` (i.e., a previous call to + * Cannot be used if the input frame has an added `otMessage` (i.e., a previous call to * `InFrameFeedMessage()`). * * @param[in] aPosition A reference to write position @@ -285,10 +285,10 @@ class Buffer otError InFrameReset(const WritePosition &aPosition); /** - * This method gets the distance (number of bytes) from a given saved position to current end of frame. + * Gets the distance (number of bytes) from a given saved position to current end of frame. * * The write position @p aPosition must belong to the same input frame saved earlier with `InFrameGetPosition()`. - * This method cannot be used if the input frame has an added `otMessage` (i.e., a previous call to + * Cannot be used if the input frame has an added `otMessage` (i.e., a previous call to * `InFrameFeedMessage()`). In case of invalid argument, this method returns zero. * * @param[in] aPosition A reference to write position @@ -300,7 +300,7 @@ class Buffer uint16_t InFrameGetDistance(const WritePosition &aPosition) const; /** - * This method finalizes/ends the current input frame being written to the buffer. + * Finalizes/ends the current input frame being written to the buffer. * * Before using this method `InFrameBegin()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -316,7 +316,7 @@ class Buffer otError InFrameEnd(void); /** - * This method returns the tag assigned to last successfully written/added frame to NcpBuffer (i.e., last input + * Returns the tag assigned to last successfully written/added frame to NcpBuffer (i.e., last input * frame for which `InFrameEnd()` was called and returned success status). The tag is a unique value (within * currently queued frames) associated with a frame in the `Buffer`. The tag can be used to identify the * same frame when it is read and removed from the NcpBuffer. Tags can be compared using operator `==`. @@ -326,7 +326,7 @@ class Buffer FrameTag InFrameGetLastTag(void) const; /** - * This method checks if the buffer is empty. A non-empty buffer contains at least one full frame for reading. + * Checks if the buffer is empty. A non-empty buffer contains at least one full frame for reading. * * @retval TRUE Buffer is not empty and contains at least one full frame for reading. * @retval FALSE Buffer is empty and contains no frame for reading. @@ -335,7 +335,7 @@ class Buffer bool IsEmpty(void) const; /** - * This method begins/prepares an output frame to be read from the frame buffer if there is no current active output + * Begins/prepares an output frame to be read from the frame buffer if there is no current active output * frame, or resets the read offset if there is a current active output frame. * * The NCP buffer maintains a read offset for the current frame being read. Before reading any bytes from the frame @@ -353,7 +353,7 @@ class Buffer otError OutFrameBegin(void); /** - * This method checks if the current output frame (being read) has ended. + * Checks if the current output frame (being read) has ended. * * The NCP buffer maintains a read offset for the current output frame being read. This method returns `true` if * the read offset has reached the end of the frame and there are no more bytes available to read, or if there is @@ -367,7 +367,7 @@ class Buffer bool OutFrameHasEnded(void); /** - * This method reads and returns the next byte from the current output frame. + * Reads and returns the next byte from the current output frame. * * The NCP buffer maintains a read offset for the current output frame being read. This method reads and returns * the next byte from the current frame and moves the read offset forward. If read offset is already at the end @@ -380,7 +380,7 @@ class Buffer uint8_t OutFrameReadByte(void); /** - * This method reads and copies bytes from the current output frame into a given buffer. + * Reads and copies bytes from the current output frame into a given buffer. * * The NCP buffer maintains a read offset for the current output frame being read. This method attempts to read * the given number of bytes (@p aReadLength) from the current frame and copies the bytes into the given @@ -397,7 +397,7 @@ class Buffer uint16_t OutFrameRead(uint16_t aReadLength, uint8_t *aDataBuffer); /** - * This method removes the current or front output frame from the buffer. + * Removes the current or front output frame from the buffer. * * If there is an active output from being read (an output frame was prepared earlier with a successful call to * `OutFrameBegin()`), this method removes the current active output frame. If there is no current active frame, @@ -415,7 +415,7 @@ class Buffer otError OutFrameRemove(void); /** - * This method returns the number of bytes (length) of current or front frame in the NCP frame buffer. + * Returns the number of bytes (length) of current or front frame in the NCP frame buffer. * * If there is an active output from being read (an output frame was prepared earlier with successful call to * `OutFrameBegin()`), this method returns the length of the current output frame. If there is no current active @@ -429,7 +429,7 @@ class Buffer uint16_t OutFrameGetLength(void); /** - * This method returns the tag value associated to current or front frame in the NCP frame buffer. + * Returns the tag value associated to current or front frame in the NCP frame buffer. * * If there is an active output from being read (an output frame was prepared earlier with successful call to * `OutFrameBegin()`), this method returns the tag associated with current output frame. If there is no current diff --git a/src/lib/spinel/spinel_decoder.hpp b/src/lib/spinel/spinel_decoder.hpp index bdd386198be..96aea6b5c05 100644 --- a/src/lib/spinel/spinel_decoder.hpp +++ b/src/lib/spinel/spinel_decoder.hpp @@ -44,7 +44,7 @@ namespace ot { namespace Spinel { /** - * This class defines a spinel decoder. + * Defines a spinel decoder. * */ class Decoder @@ -56,13 +56,13 @@ class Decoder }; /** - * This constructor initializes a `Decoder` object. + * Initializes a `Decoder` object. * */ Decoder(void); /** - * This method initializes the decoder to start decoding a new frame. + * Initializes the decoder to start decoding a new frame. * * It sets the read position to the start of the frame and also erases/voids any saved positions (see * `SavePosition()` and `ResetToSaved()` methods). @@ -74,7 +74,7 @@ class Decoder void Init(const uint8_t *aFrame, uint16_t aLength); /** - * This method returns the pointer to the start of the frame. + * Returns the pointer to the start of the frame. * * @returns A pointer to buffer containing current frame being decoded. * @@ -82,7 +82,7 @@ class Decoder const uint8_t *GetFrame(void) const { return mFrame; } /** - * This method returns the total length of current frame being decoded. + * Returns the total length of current frame being decoded. * * @returns The length of current frame being decoded. * @@ -90,7 +90,7 @@ class Decoder uint16_t GetLength(void) const { return mLength; } /** - * This method returns the number of bytes that are already read/decoded from the frame. + * Returns the number of bytes that are already read/decoded from the frame. * * @returns The number of bytes already read from frame. * @@ -98,7 +98,7 @@ class Decoder uint16_t GetReadLength(void) const { return mIndex; } /** - * This method returns the number of remaining (not yet read/decoded) bytes in the frame. + * Returns the number of remaining (not yet read/decoded) bytes in the frame. * * @returns The number of remaining unread bytes in the frame. * @@ -106,7 +106,7 @@ class Decoder uint16_t GetRemainingLength(void) const { return mLength - mIndex; } /** - * This method indicates whether or not all the bytes in the frame are read. + * Indicates whether or not all the bytes in the frame are read. * * @returns TRUE if all the bytes in the buffer are read, FALSE otherwise. * @@ -114,14 +114,14 @@ class Decoder bool IsAllRead(void) const { return (mIndex == mLength); } /** - * This method resets the read position to beginning of frame. It will also void/erase any previously saved + * Resets the read position to beginning of frame. It will also void/erase any previously saved * position using `SavePosition()` method. * */ void Reset(void); /** - * This method decodes and reads a boolean value form the frame. + * Decodes and reads a boolean value form the frame. * * On success, the read position gets updated. * @@ -134,7 +134,7 @@ class Decoder otError ReadBool(bool &aBool); /** - * This method decodes and reads an `int8_t` value form the frame. + * Decodes and reads an `int8_t` value form the frame. * * On success, the read position get updated. * @@ -147,7 +147,7 @@ class Decoder otError ReadInt8(int8_t &aInt8); /** - * This method decodes and reads an `uint8_t` value form the frame. + * Decodes and reads an `uint8_t` value form the frame. * * On success, the read position gets updated. * @@ -160,7 +160,7 @@ class Decoder otError ReadUint8(uint8_t &aUint8); /** - * This method decodes and reads an `int16_t` value form the frame. + * Decodes and reads an `int16_t` value form the frame. * * On success, the read position gets updated. * @@ -173,7 +173,7 @@ class Decoder otError ReadInt16(int16_t &aInt16); /** - * This method decodes and reads an `uint16_t` value form the frame. + * Decodes and reads an `uint16_t` value form the frame. * * On success, the read position gets updated. * @@ -186,7 +186,7 @@ class Decoder otError ReadUint16(uint16_t &aUint16); /** - * This method decodes and reads an `int32_t` value form the frame. + * Decodes and reads an `int32_t` value form the frame. * * On success, the read position gets updated. * @@ -199,7 +199,7 @@ class Decoder otError ReadInt32(int32_t &aInt32); /** - * This method decodes and reads an `uint32_t` value form the frame. + * Decodes and reads an `uint32_t` value form the frame. * * On success, the read position gets updated. * @@ -212,7 +212,7 @@ class Decoder otError ReadUint32(uint32_t &aUint32); /** - * This method decodes and reads an `int64_t` value form the frame. + * Decodes and reads an `int64_t` value form the frame. * * On success, the read position gets updated. * @@ -225,7 +225,7 @@ class Decoder otError ReadInt64(int64_t &aInt64); /** - * This method decodes and reads an `uint64_t` value form the frame. + * Decodes and reads an `uint64_t` value form the frame. * * On success, the read position gets updated. * @@ -238,7 +238,7 @@ class Decoder otError ReadUint64(uint64_t &aUint64); /** - * This method decodes (using spinel packed integer format) and reads an unsigned integer value form the frame. + * Decodes (using spinel packed integer format) and reads an unsigned integer value form the frame. * * On success, the read position gets updated. * @@ -251,7 +251,7 @@ class Decoder otError ReadUintPacked(unsigned int &aUint); /** - * This method decodes and reads an IPv6 address form the frame. + * Decodes and reads an IPv6 address form the frame. * * On success, the read position gets updated. * @@ -268,7 +268,7 @@ class Decoder } /** - * This method decodes and reads an IPv6 address form the frame. + * Decodes and reads an IPv6 address form the frame. * * On success, the read position gets updated. * @@ -285,7 +285,7 @@ class Decoder } /** - * This method decodes and reads an IPv6 address form the frame. + * Decodes and reads an IPv6 address form the frame. * * On success, the read position gets updated. * @@ -302,7 +302,7 @@ class Decoder } /** - * This method decodes and reads an IPv6 address form the frame. + * Decodes and reads an IPv6 address form the frame. * * On success, the read position gets updated and the IP address is copied into the given output variable. * @@ -316,7 +316,7 @@ class Decoder otError ReadIp6Address(spinel_ipv6addr_t &aIp6Addr); /** - * This method decodes and reads an IPv6 address form the frame. + * Decodes and reads an IPv6 address form the frame. * * On success, the read position gets updated and the IP address is copied into the given output variable. * @@ -330,7 +330,7 @@ class Decoder otError ReadIp6Address(otIp6Address &aIp6Addr); /** - * This method decodes and reads an EUI64 value form the frame. + * Decodes and reads an EUI64 value form the frame. * * On success, the read position gets updated. * @@ -347,7 +347,7 @@ class Decoder } /** - * This method decodes and reads an EUI64 value form the frame. + * Decodes and reads an EUI64 value form the frame. * * On success, the read position gets updated. * @@ -364,7 +364,7 @@ class Decoder } /** - * This method decodes and reads an EUI64 value form the frame. + * Decodes and reads an EUI64 value form the frame. * * On success, the read position gets updated. * @@ -378,7 +378,7 @@ class Decoder otError ReadEui64(const uint8_t *&aEui64BufPtr) { return ReadItem(&aEui64BufPtr, sizeof(spinel_eui64_t)); } /** - * This method decodes and reads an EUI64 value form the frame. + * Decodes and reads an EUI64 value form the frame. * * On success, the read position gets updated and the EUI64 value is copied into the given output variable. * @@ -392,7 +392,7 @@ class Decoder otError ReadEui64(spinel_eui64_t &aEui64); /** - * This method decodes and reads an EUI64 value form the frame. + * Decodes and reads an EUI64 value form the frame. * * On success, the read position gets updated and the EUI64 value is copied into the given output variable. * @@ -406,7 +406,7 @@ class Decoder otError ReadEui64(otExtAddress &aEui64); /** - * This method decodes and reads an EUI48 value form the frame. + * Decodes and reads an EUI48 value form the frame. * * On success, the read position gets updated. * @@ -423,7 +423,7 @@ class Decoder } /** - * This method decodes and reads an EUI48 value form the frame. + * Decodes and reads an EUI48 value form the frame. * * On success, the read position gets updated. * @@ -437,7 +437,7 @@ class Decoder otError ReadEui48(const uint8_t *&aEui48BufPtr) { return ReadItem(&aEui48BufPtr, sizeof(spinel_eui48_t)); } /** - * This method decodes and reads an EUI48 value form the frame. + * Decodes and reads an EUI48 value form the frame. * * On success, the read position gets updated and the EUI48 value is copied into the given output variable. * @@ -451,7 +451,7 @@ class Decoder otError ReadEui48(spinel_eui48_t &aEui48); /** - * This method decodes and reads a UTF8 string form the frame. + * Decodes and reads a UTF8 string form the frame. * * On success, the read position gets updated. * @@ -465,7 +465,7 @@ class Decoder otError ReadUtf8(const char *&aUtf8); /** - * This method decodes and reads a data blob (sequence of bytes) form the frame. + * Decodes and reads a data blob (sequence of bytes) form the frame. * * On success, the read position gets updated. * @@ -480,7 +480,7 @@ class Decoder otError ReadData(const uint8_t *&aData, uint16_t &aDataLen); /** - * This method decodes and reads a data blob (sequence of bytes) with data length. + * Decodes and reads a data blob (sequence of bytes) with data length. * * The data length is assumed to be prepended before the data content (encoded as a `uint16_t`). The size of the * length field should not be included in the length value. This method corresponds to `SPINEL_DATATYPE_DATA_WLEN` @@ -497,7 +497,7 @@ class Decoder otError ReadDataWithLen(const uint8_t *&aData, uint16_t &aDataLen); /** - * This method opens a struct in the frame. + * Opens a struct in the frame. * * After a successful call to this method, all the subsequent `Read{SomeType}()` methods decode and read the * field/value from the current open struct until the struct is closed using `CloseStruct()` method. Structures can @@ -511,7 +511,7 @@ class Decoder otError OpenStruct(void); /** - * This method closes the most recently opened struct (using `OpenStruct()`) in the frame. + * Closes the most recently opened struct (using `OpenStruct()`) in the frame. * * On success, the read position is moved to end of the struct skipping any unread bytes within the struct. * @@ -522,7 +522,7 @@ class Decoder otError CloseStruct(void); /** - * This method returns the number of remaining/unread bytes in the current inner-most open structure. + * Returns the number of remaining/unread bytes in the current inner-most open structure. * * If there is no currently open structure the number of remaining bytes in whole frame is returned instead. * @@ -532,7 +532,7 @@ class Decoder uint16_t GetRemainingLengthInStruct(void) const { return mEnd - mIndex; } /** - * This method indicates whether or not all the bytes in inner-most open structure are read. + * Indicates whether or not all the bytes in inner-most open structure are read. * * If there is no currently open structure, the whole frame is considered instead. * @@ -542,7 +542,7 @@ class Decoder bool IsAllReadInStruct(void) const { return (mIndex == mEnd); } /** - * This method saves the current read position in the frame. + * Saves the current read position in the frame. * * A subsequent call to `SavePosition()` will overwrite the previously saved position. The saved position can be * used to move the read position back (using `ResetToSaved()`) and re-read the same content. @@ -555,7 +555,7 @@ class Decoder void SavePosition(void); /** - * This method resets/moves the read position to a previously saved position. + * Resets/moves the read position to a previously saved position. * * The saved position remembers its enclosing structure. When `ResetToSaved()` is called, the current open * structure will be the same as when position was saved. diff --git a/src/lib/spinel/spinel_encoder.hpp b/src/lib/spinel/spinel_encoder.hpp index 214e8136d2d..6b9ea983d8c 100644 --- a/src/lib/spinel/spinel_encoder.hpp +++ b/src/lib/spinel/spinel_encoder.hpp @@ -46,14 +46,14 @@ namespace ot { namespace Spinel { /** - * This class defines a spinel encoder. + * Defines a spinel encoder. * */ class Encoder { public: /** - * This constructor initializes a `Encoder` object. + * Initializes a `Encoder` object. * * @param[in] aNcpBuffer A reference to a `Spinel::Buffer` where the frames are written. * @@ -66,7 +66,7 @@ class Encoder } /** - * This method begins a new frame to be added/written to the frame buffer. + * Begins a new frame to be added/written to the frame buffer. * * If there is a previous frame being written (for which `EndFrame()` has not yet been called), calling * `BeginFrame()` will discard and clear the previous unfinished frame. @@ -80,7 +80,7 @@ class Encoder otError BeginFrame(Spinel::Buffer::Priority aPriority); /** - * This method begins a new spinel command frame to be added/written to the frame buffer. + * Begins a new spinel command frame to be added/written to the frame buffer. * * If there is a previous frame being written (for which `EndFrame()` has not yet been called), calling * `BeginFrame()` will discard and clear the previous unfinished frame. @@ -98,7 +98,7 @@ class Encoder otError BeginFrame(uint8_t aHeader, unsigned int aCommand); /** - * This method begins a new spinel property update command frame to be added/written to the frame buffer. + * Begins a new spinel property update command frame to be added/written to the frame buffer. * * If there is a previous frame being written (for which `EndFrame()` has not yet been called), calling * `BeginFrame()` will discard and clear the previous unfinished frame. @@ -106,7 +106,7 @@ class Encoder * The spinel transaction ID (TID) in the given spinel header is used to determine the priority level of the new * frame. Non-zero TID value indicates that the frame is a response and therefore it uses higher priority level. * - * This method saves the write position before the property key (see also `SavePosition()`) so that if fetching the + * Saves the write position before the property key (see also `SavePosition()`) so that if fetching the * property fails and the property key should be switched to `LAST_STATUS` with an error status, the saved * position can be used to update the property key in the frame (see also `OverwriteWithLastStatusError()`) * @@ -121,12 +121,12 @@ class Encoder otError BeginFrame(uint8_t aHeader, unsigned int aCommand, spinel_prop_key_t aKey); /** - * This method overwrites the property key with `LAST_STATUS` in a property update command frame. + * Overwrites the property key with `LAST_STATUS` in a property update command frame. * - * This method should be only used after a successful `BeginFrame(aHeader, aCommand, aPropertyKey)`, otherwise, its + * Should be only used after a successful `BeginFrame(aHeader, aCommand, aPropertyKey)`, otherwise, its * behavior is undefined. * - * This method moves the write position back to saved position by `BeginFrame()` and replaces the property key + * Moves the write position back to saved position by `BeginFrame()` and replaces the property key * `SPINEL_PROP_LAST_STATUS` and writes the given spinel status error. * * @param[in] aStatus Spinel error status @@ -138,7 +138,7 @@ class Encoder otError OverwriteWithLastStatusError(spinel_status_t aStatus); /** - * This method finalizes/ends the current frame being written to the buffer. + * Finalizes/ends the current frame being written to the buffer. * * Before using this method `BeginFrame()` must be called to start and prepare a new frame. Otherwise, this method * does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -146,7 +146,7 @@ class Encoder * If no buffer space is available, this method will discard and clear the frame and return error status * `OT_ERROR_NO_BUFS`. * - * This method ensures to close any open structure (previously opened using `OpenStruct()` but not closed using + * Ensures to close any open structure (previously opened using `OpenStruct()` but not closed using * `CloseStruct()`). * * @retval OT_ERROR_NONE Successfully ended the input frame. @@ -157,7 +157,7 @@ class Encoder otError EndFrame(void); /** - * This method encodes and writes a boolean value to current input frame. + * Encodes and writes a boolean value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -175,7 +175,7 @@ class Encoder otError WriteBool(bool aBool) { return mNcpBuffer.InFrameFeedByte(aBool ? 0x01 : 0x00); } /** - * This method encodes and writes a `uint8_t` value to current input frame. + * Encodes and writes a `uint8_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -193,7 +193,7 @@ class Encoder otError WriteUint8(uint8_t aUint8) { return mNcpBuffer.InFrameFeedByte(aUint8); } /** - * This method encodes and writes an `int8_t` value to current input frame. + * Encodes and writes an `int8_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -211,7 +211,7 @@ class Encoder otError WriteInt8(int8_t aInt8) { return WriteUint8(static_cast(aInt8)); } /** - * This method encodes and writes a `uint16_t` value to current input frame. + * Encodes and writes a `uint16_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -229,7 +229,7 @@ class Encoder otError WriteUint16(uint16_t aUint16); /** - * This method encodes and writes an `int16_t` value to current input frame. + * Encodes and writes an `int16_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -247,7 +247,7 @@ class Encoder otError WriteInt16(int16_t aInt16) { return WriteUint16(static_cast(aInt16)); } /** - * This method encodes and writes a `uint32_t` value to current input frame. + * Encodes and writes a `uint32_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -265,7 +265,7 @@ class Encoder otError WriteUint32(uint32_t aUint32); /** - * This method encodes and writes an `int32_t` value to current input frame. + * Encodes and writes an `int32_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -283,7 +283,7 @@ class Encoder otError WriteInt32(int32_t aInt32) { return WriteUint32(static_cast(aInt32)); } /** - * This method encodes and writes a `uint64_t` value to current input frame. + * Encodes and writes a `uint64_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -301,7 +301,7 @@ class Encoder otError WriteUint64(uint64_t aUint64); /** - * This method encodes and writes an `int64_t` value to current input frame. + * Encodes and writes an `int64_t` value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -319,7 +319,7 @@ class Encoder otError WriteInt64(int64_t aInt64) { return WriteUint64(static_cast(aInt64)); } /** - * This method encodes (using spinel packed integer format) and writes a value to current input frame. + * Encodes (using spinel packed integer format) and writes a value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -337,7 +337,7 @@ class Encoder otError WriteUintPacked(unsigned int aUint); /** - * This method encodes and writes an IPv6 address to current input frame. + * Encodes and writes an IPv6 address to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -355,7 +355,7 @@ class Encoder otError WriteIp6Address(const spinel_ipv6addr_t &aIp6Addr) { return WriteIp6Address(aIp6Addr.bytes); } /** - * This method encodes and writes an IPv6 address to current input frame. + * Encodes and writes an IPv6 address to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -373,7 +373,7 @@ class Encoder otError WriteIp6Address(const otIp6Address &aIp6Addr) { return WriteIp6Address(aIp6Addr.mFields.m8); } /** - * This method encodes and writes an IPv6 address to current input frame. + * Encodes and writes an IPv6 address to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -391,7 +391,7 @@ class Encoder otError WriteIp6Address(const uint8_t *aIp6AddrBuf) { return WriteData(aIp6AddrBuf, sizeof(spinel_ipv6addr_t)); } /** - * This method encodes and writes an EUI64 value to current input frame. + * Encodes and writes an EUI64 value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -409,7 +409,7 @@ class Encoder otError WriteEui64(const spinel_eui64_t &aEui64) { return WriteEui64(aEui64.bytes); } /** - * This method encodes and writes an EUI64 value to current input frame. + * Encodes and writes an EUI64 value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -427,7 +427,7 @@ class Encoder otError WriteEui64(const otExtAddress &aExtAddress) { return WriteEui64(aExtAddress.m8); } /** - * This method encodes and writes an EUI64 value to current input frame. + * Encodes and writes an EUI64 value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -445,7 +445,7 @@ class Encoder otError WriteEui64(const uint8_t *aEui64) { return WriteData(aEui64, sizeof(spinel_eui64_t)); } /** - * This method encodes and writes an EUI48 value to current input frame. + * Encodes and writes an EUI48 value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -463,7 +463,7 @@ class Encoder otError WriteEui48(const spinel_eui48_t &aEui48) { return WriteEui48(aEui48.bytes); } /** - * This method encodes and writes an EUI48 value to current input frame. + * Encodes and writes an EUI48 value to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -481,7 +481,7 @@ class Encoder otError WriteEui48(const uint8_t *aEui48) { return WriteData(aEui48, sizeof(spinel_eui48_t)); } /** - * This method encodes and writes a UTF8 string to current input frame. + * Encodes and writes a UTF8 string to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -499,7 +499,7 @@ class Encoder otError WriteUtf8(const char *aUtf8); /** - * This method encodes and writes a sequence of bytes to current input frame. + * Encodes and writes a sequence of bytes to current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -518,7 +518,7 @@ class Encoder otError WriteData(const uint8_t *aData, uint16_t aDataLen) { return mNcpBuffer.InFrameFeedData(aData, aDataLen); } /** - * This method encodes and writes a data blob (sequence of bytes) with its length prepended before the data. + * Encodes and writes a data blob (sequence of bytes) with its length prepended before the data. * * The length of the data (in bytes) is prepended (with the length encoded as a `uint16`). The size of the length * field is not included in the length. This is similar to `SPINEL_DATATYPE_DATA_WLEN` type. @@ -541,7 +541,7 @@ class Encoder #if OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE /** - * This method adds a message to the current input frame. + * Adds a message to the current input frame. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this * method does nothing and returns error status `OT_ERROR_INVALID_STATE`. @@ -567,7 +567,7 @@ class Encoder #endif /** - * This method encodes and writes a set of variables to the current input frame using a given spinel packing format + * Encodes and writes a set of variables to the current input frame using a given spinel packing format * string. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this @@ -590,7 +590,7 @@ class Encoder otError WritePacked(const char *aPackFormat, ...); /** - * This method encodes and writes a set of variables to the current input frame using a given spinel packing format + * Encodes and writes a set of variables to the current input frame using a given spinel packing format * string. * * Before using this method `BeginFrame()` must be called to start and prepare a new input frame. Otherwise, this @@ -613,7 +613,7 @@ class Encoder otError WriteVPacked(const char *aPackFormat, va_list aArgs); /** - * This method opens a struct in the current input frame. + * Opens a struct in the current input frame. * * After a successful call to this method, all the subsequent `Write()` methods add the field/value to * the current open struct until the struct is closed using `CloseStruct()` method. Structures can be nested. Up to @@ -634,7 +634,7 @@ class Encoder otError OpenStruct(void); /** - * This method closes the most recently opened struct (using `OpenStruct()`) in the current input frame. + * Closes the most recently opened struct (using `OpenStruct()`) in the current input frame. * * Each call to `CloseStruct()` must correspond to an earlier successfully opened struct. If a frame is ended using * `EndFrame()` with remaining open structs, the `EndFrame()` method will close all the remaining structs. @@ -650,7 +650,7 @@ class Encoder otError CloseStruct(void); /** - * This method saves the current write position in the input frame. + * Saves the current write position in the input frame. * * The saved position can later be used to discard a portion of written/encoded frame and move the write pointer * back to the saved position (using `ResetToSaved()`). @@ -662,7 +662,7 @@ class Encoder otError SavePosition(void); /** - * This method resets the write position of input frame back to a previously saved position. Any added content + * Resets the write position of input frame back to a previously saved position. Any added content * after the write position is discarded. * * The saved position must belong to the same input frame saved earlier with `SavePosition()`. This method cannot diff --git a/src/lib/spinel/spinel_encrypter.hpp b/src/lib/spinel/spinel_encrypter.hpp index 989bbc58601..1bc52d8847c 100644 --- a/src/lib/spinel/spinel_encrypter.hpp +++ b/src/lib/spinel/spinel_encrypter.hpp @@ -34,7 +34,7 @@ namespace SpinelEncrypter { /** * Encrypts spinel frames before sending to AP/NCP. * - * This method encrypts outbound frames in both directions, i.e. from AP to NCP and from NCP to AP. + * Encrypts outbound frames in both directions, i.e. from AP to NCP and from NCP to AP. * * @param[in,out] aFrameBuf Pointer to buffer containing the frame, also where the encrypted frame will be placed. * @param[in] aFrameSize Max number of bytes in frame buffer (max length of spinel frame + additional data for @@ -48,7 +48,7 @@ bool EncryptOutbound(unsigned char *aFrameBuf, size_t aFrameSize, size_t *aFrame /** * Decrypts spinel frames received from AP/NCP. * - * This method decrypts inbound frames in both directions, i.e. from AP to NCP and from NCP to AP. + * Decrypts inbound frames in both directions, i.e. from AP to NCP and from NCP to AP. * * @param[in,out] aFrameBuf Pointer to buffer containing encrypted frame, also where the decrypted frame will be placed. * @param[in] aFrameSize Max number of bytes in frame buffer (max length of spinel frame + additional data for diff --git a/src/lib/spinel/spinel_interface.hpp b/src/lib/spinel/spinel_interface.hpp index b67b423d96d..f968beddd2e 100644 --- a/src/lib/spinel/spinel_interface.hpp +++ b/src/lib/spinel/spinel_interface.hpp @@ -32,11 +32,12 @@ * */ -#ifndef POSIX_APP_SPINEL_INTERFACE_HPP_ -#define POSIX_APP_SPINEL_INTERFACE_HPP_ +#ifndef SPINEL_SPINEL_INTERFACE_HPP_ +#define SPINEL_SPINEL_INTERFACE_HPP_ -#include "lib/hdlc/hdlc.hpp" +#include "lib/spinel/multi_frame_buffer.hpp" #include "lib/spinel/spinel.h" +#include "lib/url/url.hpp" namespace ot { namespace Spinel { @@ -50,18 +51,103 @@ class SpinelInterface }; /** - * This type defines a receive frame buffer to store received spinel frame(s). + * Defines a receive frame buffer to store received spinel frame(s). * - * @note The receive frame buffer is an `Hdlc::MultiFrameBuffer` and therefore it is capable of storing multiple + * @note The receive frame buffer is an `Spinel::MultiFrameBuffer` and therefore it is capable of storing multiple * frames in a FIFO queue manner. * */ - typedef Hdlc::MultiFrameBuffer RxFrameBuffer; + typedef MultiFrameBuffer RxFrameBuffer; typedef void (*ReceiveFrameCallback)(void *aContext); /** - * This method indicates whether or not the frame is the Spinel SPINEL_CMD_RESET frame. + * Initializes the interface to the Radio Co-processor (RCP) + * + * @note This method should be called before reading and sending spinel frames to the interface. + * + * @param[in] aRadioUrl RadioUrl parsed from radio url. + * + * @retval OT_ERROR_NONE The interface is initialized successfully + * @retval OT_ERROR_ALREADY The interface is already initialized. + * @retval OT_ERROR_INVALID_ARGS The UART device or executable cannot be found or failed to open/run. + * + */ + virtual otError Init(const Url::Url &aRadioUrl) = 0; + + /** + * Deinitializes the interface to the RCP. + * + */ + virtual void Deinit(void) = 0; + + /** + * Encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. + * + * @param[in] aFrame A pointer to buffer containing the spinel frame to send. + * @param[in] aLength The length (number of bytes) in the frame. + * + * @retval OT_ERROR_NONE Successfully encoded and sent the spinel frame. + * @retval OT_ERROR_BUSY Failed due to another operation is on going. + * @retval OT_ERROR_NO_BUFS Insufficient buffer space available to encode the frame. + * @retval OT_ERROR_FAILED Failed to call the SPI driver to send the frame. + * + */ + virtual otError SendFrame(const uint8_t *aFrame, uint16_t aLength) = 0; + + /** + * Waits for receiving part or all of spinel frame within specified interval. + * + * @param[in] aTimeout The timeout value in microseconds. + * + * @retval OT_ERROR_NONE Part or all of spinel frame is received. + * @retval OT_ERROR_RESPONSE_TIMEOUT No spinel frame is received within @p aTimeout. + * + */ + virtual otError WaitForFrame(uint64_t aTimeoutUs) = 0; + + /** + * Updates the file descriptor sets with file descriptors used by the radio driver. + * + * @param[in,out] aMainloopContext A pointer to the mainloop context. + * + */ + virtual void UpdateFdSet(void *aMainloopContext) = 0; + + /** + * Performs radio driver processing. + * + * @param[in] aMainloopContext A pointer to the mainloop context. + * + */ + virtual void Process(const void *aMainloopContext) = 0; + + /** + * Returns the bus speed between the host and the radio. + * + * @returns Bus speed in bits/second. + * + */ + virtual uint32_t GetBusSpeed(void) const = 0; + + /** + * Hardware resets the RCP. + * + * @retval OT_ERROR_NONE Successfully reset the RCP. + * @retval OT_ERROR_NOT_IMPLEMENT The hardware reset is not implemented. + * + */ + virtual otError HardwareReset(void) = 0; + + /** + * Marks destructor virtual method. + * + */ + virtual ~SpinelInterface() = default; + +protected: + /** + * Indicates whether or not the frame is the Spinel SPINEL_CMD_RESET frame. * * @param[in] aFrame A pointer to buffer containing the spinel frame. * @param[in] aLength The length (number of bytes) in the frame. @@ -70,7 +156,7 @@ class SpinelInterface * @retval false If the frame is not a Spinel SPINEL_CMD_RESET frame. * */ - static bool IsSpinelResetCommand(const uint8_t *aFrame, uint16_t aLength) + bool IsSpinelResetCommand(const uint8_t *aFrame, uint16_t aLength) { const uint8_t kSpinelResetCommandLength = 2; @@ -95,4 +181,4 @@ class SpinelInterface } // namespace Spinel } // namespace ot -#endif // POSIX_APP_SPINEL_INTERFACE_HPP_ +#endif // SPINEL_SPINEL_INTERFACE_HPP_ diff --git a/src/lib/url/url.hpp b/src/lib/url/url.hpp index fbcff4a72ff..c336e2ae4f0 100644 --- a/src/lib/url/url.hpp +++ b/src/lib/url/url.hpp @@ -34,7 +34,7 @@ /** * @struct otUrl * - * This structure represents a URL. + * Represents a URL. * */ struct otUrl @@ -49,14 +49,14 @@ namespace ot { namespace Url { /** - * This class implements the URL processing. + * Implements the URL processing. * */ class Url : public otUrl { public: /** - * This method initializes the URL. + * Initializes the URL. * * @param[in] aUrl A buffer stores the null-terminated URL string. * @@ -67,7 +67,7 @@ class Url : public otUrl otError Init(char *aUrl); /** - * This method gets the path in URL. + * Gets the path in URL. * * @returns The path in URL. * @@ -75,7 +75,7 @@ class Url : public otUrl const char *GetPath(void) const { return mPath; } /** - * This method gets the value of parameter @p aName. + * Gets the value of parameter @p aName. * * @param[in] aName The parameter name. * @param[in] aLastValue The last iterated parameter value, nullptr for the first value. @@ -86,7 +86,7 @@ class Url : public otUrl const char *GetValue(const char *aName, const char *aLastValue = nullptr) const; /** - * This method returns the URL protocol. + * Returns the URL protocol. * * @returns The URL protocol. * diff --git a/src/ncp/changed_props_set.hpp b/src/ncp/changed_props_set.hpp index 0b7040c5849..1f4451aa937 100644 --- a/src/ncp/changed_props_set.hpp +++ b/src/ncp/changed_props_set.hpp @@ -65,7 +65,7 @@ class ChangedPropsSet }; /** - * This constructor initializes the set. + * Initializes the set. * */ ChangedPropsSet(void) @@ -75,13 +75,13 @@ class ChangedPropsSet } /** - * This method clears the set. + * Clears the set. * */ void Clear(void) { mChangedSet = 0; } /** - * This method indicates if the set is empty or not. + * Indicates if the set is empty or not. * * @returns TRUE if the set if empty, FALSE otherwise. * @@ -89,7 +89,7 @@ class ChangedPropsSet bool IsEmpty(void) const { return (mChangedSet == 0); } /** - * This method adds a property to the set. The property added must be in the list of supported properties + * Adds a property to the set. The property added must be in the list of supported properties * capable of sending unsolicited update, otherwise the input is ignored. * * Note that if the property is already in the set, adding it again does not change the set. @@ -100,7 +100,7 @@ class ChangedPropsSet void AddProperty(spinel_prop_key_t aPropKey) { Add(aPropKey, SPINEL_STATUS_OK); } /** - * This method adds a `LAST_STATUS` update to the set. The update must be in list of supported entries. + * Adds a `LAST_STATUS` update to the set. The update must be in list of supported entries. * * @param[in] aStatus The spinel status update to be added to set. * @@ -108,7 +108,7 @@ class ChangedPropsSet void AddLastStatus(spinel_status_t aStatus) { Add(SPINEL_PROP_LAST_STATUS, aStatus); } /** - * This method returns a pointer to array of entries of supported property/status updates. The list includes + * Returns a pointer to array of entries of supported property/status updates. The list includes * all properties that can generate unsolicited update. * * @param[out] aNumEntries A reference to output the number of entries in the list. @@ -123,7 +123,7 @@ class ChangedPropsSet } /** - * This method returns a pointer to the entry associated with a given index. + * Returns a pointer to the entry associated with a given index. * * @param[in] aIndex The index to an entry. * @@ -136,7 +136,7 @@ class ChangedPropsSet } /** - * This method indicates if the entry associated with an index is in the set (i.e., it has been changed and + * Indicates if the entry associated with an index is in the set (i.e., it has been changed and * requires an unsolicited update). * * @param[in] aIndex The index to an entry. @@ -147,7 +147,7 @@ class ChangedPropsSet bool IsEntryChanged(uint8_t aIndex) const { return IsBitSet(mChangedSet, aIndex); } /** - * This method removes an entry associated with an index in the set. + * Removes an entry associated with an index in the set. * * Note that if the property/entry is not in the set, removing it simply does nothing. * @@ -157,7 +157,7 @@ class ChangedPropsSet void RemoveEntry(uint8_t aIndex) { ClearBit(mChangedSet, aIndex); } /** - * This method enables/disables filtering of a given property. + * Enables/disables filtering of a given property. * * @param[in] aPropKey The property key to filter. * @param[in] aEnable TRUE to enable filtering, FALSE to disable. @@ -169,7 +169,7 @@ class ChangedPropsSet otError EnablePropertyFilter(spinel_prop_key_t aPropKey, bool aEnable); /** - * This method determines whether filtering is enabled for an entry associated with an index. + * Determines whether filtering is enabled for an entry associated with an index. * * @param[in] aIndex Index of entry to be checked. * @@ -179,7 +179,7 @@ class ChangedPropsSet bool IsEntryFiltered(uint8_t aIndex) const { return IsBitSet(mFilterSet, aIndex); } /** - * This method determines whether filtering is enabled for a given property key. + * Determines whether filtering is enabled for a given property key. * * @param[in] aPropKey The property key to check. * @@ -190,7 +190,7 @@ class ChangedPropsSet bool IsPropertyFiltered(spinel_prop_key_t aPropKey) const; /** - * This method clears the filter. + * Clears the filter. * */ void ClearFilter(void) { mFilterSet = 0; } diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index fa79b0aef80..eee2d275fd6 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -2776,7 +2776,7 @@ void otNcpRegisterPeekPoke(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpD if (ncp != nullptr) { - ncp->RegisterPeekPoke(aAllowPeekDelegate, aAllowPokeDelegate); + ncp->RegisterPeekPokeDelegates(aAllowPeekDelegate, aAllowPokeDelegate); } } #endif // OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE diff --git a/src/ncp/ncp_base.hpp b/src/ncp/ncp_base.hpp index baf48d38215..849ed969816 100644 --- a/src/ncp/ncp_base.hpp +++ b/src/ncp/ncp_base.hpp @@ -75,7 +75,7 @@ class NcpBase }; /** - * This constructor creates and initializes an NcpBase instance. + * Creates and initializes an NcpBase instance. * * @param[in] aInstance The OpenThread instance structure. * @@ -83,7 +83,7 @@ class NcpBase explicit NcpBase(Instance *aInstance); /** - * This static method returns the pointer to the single NCP instance. + * Returns the pointer to the single NCP instance. * * @returns Pointer to the single NCP instance. * @@ -91,7 +91,7 @@ class NcpBase static NcpBase *GetNcpInstance(void); /** - * This method returns the IID of the current spinel command. + * Returns the IID of the current spinel command. * * @returns IID. * @@ -99,7 +99,7 @@ class NcpBase spinel_iid_t GetCurCommandIid(void) const; /** - * This method sends data to host via specific stream. + * Sends data to host via specific stream. * * * @param[in] aStreamId A numeric identifier for the stream to write to. @@ -117,7 +117,7 @@ class NcpBase otError StreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen); /** - * This method send an OpenThread log message to host via `SPINEL_PROP_STREAM_LOG` property. + * Send an OpenThread log message to host via `SPINEL_PROP_STREAM_LOG` property. * * @param[in] aLogLevel The log level * @param[in] aLogRegion The log region @@ -128,7 +128,7 @@ class NcpBase #if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE /** - * This method registers peek/poke delegate functions with NCP module. + * Registers peek/poke delegate functions with NCP module. * * @param[in] aAllowPeekDelegate Delegate function pointer for peek operation. * @param[in] aAllowPokeDelegate Delegate function pointer for poke operation. @@ -139,7 +139,7 @@ class NcpBase #endif /** - * This method is called by the framer whenever a framing error is detected. + * Is called by the framer whenever a framing error is detected. */ void IncrementFrameErrorCounter(void); @@ -162,7 +162,7 @@ class NcpBase typedef otError (NcpBase::*PropertyHandler)(void); /** - * This enumeration represents the `ResponseEntry` type. + * Represents the `ResponseEntry` type. * */ enum ResponseType @@ -173,7 +173,7 @@ class NcpBase }; /** - * This struct represents a spinel response entry. + * Represents a spinel response entry. * */ struct ResponseEntry @@ -471,7 +471,7 @@ class NcpBase #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK /** - * This method defines a vendor "command handler" hook to process vendor-specific spinel commands. + * Defines a vendor "command handler" hook to process vendor-specific spinel commands. * * @param[in] aHeader The spinel frame header. * @param[in] aCommand The spinel command key. @@ -483,7 +483,7 @@ class NcpBase otError VendorCommandHandler(uint8_t aHeader, unsigned int aCommand); /** - * This method is a callback which mirrors `NcpBase::HandleFrameRemovedFromNcpBuffer()`. It is called when a + * Is a callback which mirrors `NcpBase::HandleFrameRemovedFromNcpBuffer()`. It is called when a * spinel frame is sent and removed from NCP buffer. * * (a) This can be used to track and verify that a vendor spinel frame response is delivered to the host (tracking @@ -498,7 +498,7 @@ class NcpBase void VendorHandleFrameRemovedFromNcpBuffer(Spinel::Buffer::FrameTag aFrameTag); /** - * This method defines a vendor "get property handler" hook to process vendor spinel properties. + * Defines a vendor "get property handler" hook to process vendor spinel properties. * * The vendor handler should return `OT_ERROR_NOT_FOUND` status if it does not support "get" operation for the * given property key. Otherwise, the vendor handler should behave like other property get handlers, i.e., it @@ -515,7 +515,7 @@ class NcpBase otError VendorGetPropertyHandler(spinel_prop_key_t aPropKey); /** - * This method defines a vendor "set property handler" hook to process vendor spinel properties. + * Defines a vendor "set property handler" hook to process vendor spinel properties. * * The vendor handler should return `OT_ERROR_NOT_FOUND` status if it does not support "set" operation for the * given property key. Otherwise, the vendor handler should behave like other property set handlers, i.e., it diff --git a/src/ncp/ncp_base_mtd.cpp b/src/ncp/ncp_base_mtd.cpp index 48a92705502..78141dbfcd9 100644 --- a/src/ncp/ncp_base_mtd.cpp +++ b/src/ncp/ncp_base_mtd.cpp @@ -1047,7 +1047,7 @@ template <> otError NcpBase::HandlePropertyRemove mHdlcBuffer; - Hdlc::Encoder mFrameEncoder; - Hdlc::Decoder mFrameDecoder; - HdlcTxState mState; - uint8_t mByte; - Hdlc::FrameBuffer mRxBuffer; - bool mHdlcSendImmediate; - Tasklet mHdlcSendTask; + Spinel::FrameBuffer mHdlcBuffer; + Hdlc::Encoder mFrameEncoder; + Hdlc::Decoder mFrameDecoder; + HdlcTxState mState; + uint8_t mByte; + Spinel::FrameBuffer mRxBuffer; + bool mHdlcSendImmediate; + Tasklet mHdlcSendTask; #if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER BufferEncrypterReader mTxFrameBufferEncrypterReader; diff --git a/src/ncp/ncp_spi.cpp b/src/ncp/ncp_spi.cpp index 9b2a4729cda..1cd4f9aab3e 100644 --- a/src/ncp/ncp_spi.cpp +++ b/src/ncp/ncp_spi.cpp @@ -49,7 +49,7 @@ #if OPENTHREAD_CONFIG_DIAG_ENABLE static_assert(OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE - ot::Ncp::NcpBase::kSpinelCmdHeaderSize - - ot::Ncp::NcpBase::kSpinelPropIdSize - ot::Ncp::SpiFrame::kHeaderSize, + ot::Ncp::NcpBase::kSpinelPropIdSize - ot::Spinel::SpiFrame::kHeaderSize, "diag output should be smaller than NCP SPI tx buffer"); static_assert(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE, "diag command line should be smaller than NCP SPI rx buffer"); @@ -58,6 +58,8 @@ static_assert(OPENTHREAD_CONFIG_DIAG_CMD_LINE_BUFFER_SIZE <= OPENTHREAD_CONFIG_N namespace ot { namespace Ncp { +using Spinel::SpiFrame; + #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK == 0 static OT_DEFINE_ALIGNED_VAR(sNcpRaw, sizeof(NcpSpi), uint64_t); diff --git a/src/ncp/ncp_spi.hpp b/src/ncp/ncp_spi.hpp index 43c80dbcb7e..66be6e48426 100644 --- a/src/ncp/ncp_spi.hpp +++ b/src/ncp/ncp_spi.hpp @@ -35,217 +35,17 @@ #include "openthread-core-config.h" +#include "lib/spinel/spi_frame.hpp" #include "ncp/ncp_base.hpp" -/* - * SPI Framing Protocol - * - * Each SPI frame starts with a 5-byte frame header: - * - * +---------+-----+----------+----------+ - * | Octets: | 1 | 2 | 2 | - * +---------+-----+----------+----------+ - * | Fields: | HDR | RECV_LEN | DATA_LEN | - * +---------+-----+----------+----------+ - * - * - "HDR": The first byte is the header byte (defined below) - * - "RECV_LEN": The second and third bytes indicate the largest frame - * size that that device is ready to receive. If zero, then the - * other device must not send any data. (Little endian) - * - "DATA_LEN": The fourth and fifth bytes indicate the size of the - * pending data frame to be sent to the other device. If this value - * is equal-to or less-than the number of bytes that the other device - * is willing to receive, then the data of the frame is immediately - * after the header. (Little Endian) - * - * The "HDR" byte is defined as: - * - * 0 1 2 3 4 5 6 7 - * +---+---+---+---+---+---+---+---+ - * |RST|CRC|CCF| RESERVED |PATTERN| - * +---+---+---+---+---+---+---+---+ - * - * - "RST": This bit is set when that device has been reset since the - * last time `CS` (chip select) was asserted. - * - "CRC": This bit is set when that device supports writing a 16-bit - * CRC at the end of the data. The CRC length is NOT included in - * DATA_LEN. - * - "CCF": "CRC Check Failure". Set if the CRC check on the last - * received frame failed, cleared to zero otherwise. This bit is - * only used if both sides support CRC. - * - "RESERVED": These bits are all reserved for future used. They - * MUST be cleared to zero and MUST be ignored if set. - * - "PATTERN": These bits are set to a fixed value to help distinguish - * valid SPI frames from garbage (by explicitly making "0xFF" and - * "0x00" invalid values). Bit 6 MUST be set to be one and bit 7 - * MUST be cleared (0). A frame received that has any other values - * for these bits MUST be dropped. - * - * Prior to a sending or receiving a frame, the master MAY send a - * 5-octet frame with zeros for both the max receive frame size and the - * the contained frame length. This will induce the slave device to - * indicate the length of the frame it wants to send (if any) and - * indicate the largest frame it is capable of receiving at the moment. - * This allows the master to calculate the size of the next transaction. - * Alternatively, if the master has a frame to send it can just go ahead - * and send a frame of that length and determine if the frame was - * accepted by checking that the "RECV_LEN" from the slave frame is - * larger than the frame the master just tried to send. If the - * "RECV_LEN" is smaller then the frame wasn't accepted and will need to - * be transmitted again. - * - * This protocol can be used either unidirectionally or bidirectionally, - * determined by the behavior of the master and the slave. - * - * If the the master notices "PATTERN" is not set correctly, the master - * should consider the transaction to have failed and try again after 10 - * milliseconds, retrying up to 200 times. After unsuccessfully trying - * 200 times in a row, the master MAY take appropriate remedial action - * (like a NCP hardware reset, or indicating a communication failure to - * a user interface). - * - * At the end of the data of a frame is an optional 16-bit CRC, support - * for which is indicated by the "CRC" bit of the "HDR" byte being set. - * If these bits are set for both the master and slave frames, then CRC - * checking is enabled on both sides, effectively requiring that frame - * sizes be two bytes longer than would be otherwise required. The CRC - * is calculated using the same mechanism used for the CRC calculation - * in HDLC-Lite (See Appendix A.1.2). When both of the "CRC" bits are - * set, both sides must verify that the "CRC" is valid before accepting - * the frame. If not enough bytes were clocked out for the CRC to be - * read, then the frame must be ignored. If enough bytes were clocked - * out to perform a CRC check, but the CRC check fails, then the frame - * must be rejected and the "CRC_FAIL" bit on the next frame (and ONLY - * the next frame) MUST be set. - */ - namespace ot { namespace Ncp { -/** - * This class defines a SPI frame. - * - */ -class SpiFrame -{ -public: - enum - { - kHeaderSize = 5, ///< SPI header size (in bytes). - }; - - /** - * This constructor initializes an `SpiFrame` instance. - * - * @param[in] aBuffer Pointer to buffer containing the frame. - * - */ - explicit SpiFrame(uint8_t *aBuffer) - : mBuffer(aBuffer) - { - } - - /** - * This method gets a pointer to data portion in the SPI frame skipping the header. - * - * @returns A pointer to data in the SPI frame. - * - */ - uint8_t *GetData(void) { return mBuffer + kHeaderSize; } - - /** - * This method indicates whether or not the frame is valid. - * - * In a valid frame the flag byte should contain the pattern bits. - * - * @returns TRUE if the frame is valid, FALSE otherwise. - * - */ - bool IsValid(void) const { return ((mBuffer[kIndexFlagByte] & kFlagPatternMask) == kFlagPattern); } - - /** - * This method indicates whether or not the "RST" bit is set. - * - * @returns TRUE if the "RST" bit is set, FALSE otherwise. - * - */ - bool IsResetFlagSet(void) const { return ((mBuffer[kIndexFlagByte] & kFlagReset) == kFlagReset); } - - /** - * This method sets the "flag byte" field in the SPI frame header. - * - * @param[in] aResetFlag The status of reset flag (TRUE to set the flag, FALSE to clear flag). - * - */ - void SetHeaderFlagByte(bool aResetFlag) { mBuffer[kIndexFlagByte] = kFlagPattern | (aResetFlag ? kFlagReset : 0); } - - /** - * This method gets the "flag byte" field in the SPI frame header. - * - * @returns The flag byte. - * - */ - uint8_t GetHeaderFlagByte(void) const { return mBuffer[kIndexFlagByte]; } - - /** - * This method sets the "accept len" field in the SPI frame header. - * - * "accept len" specifies number of bytes the sender of the SPI frame can receive. - * - * @param[in] aAcceptLen The accept length in bytes. - * - */ - void SetHeaderAcceptLen(uint16_t aAcceptLen) - { - Encoding::LittleEndian::WriteUint16(aAcceptLen, mBuffer + kIndexAcceptLen); - } - - /** - * This method gets the "accept len" field in the SPI frame header. - * - * @returns The accept length in bytes. - * - */ - uint16_t GetHeaderAcceptLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexAcceptLen); } - - /** - * This method sets the "data len" field in the SPI frame header. - * - * "Data len" specifies number of data bytes in the transmitted SPI frame. - * - * @param[in] aDataLen The data length in bytes. - * - */ - void SetHeaderDataLen(uint16_t aDataLen) { Encoding::LittleEndian::WriteUint16(aDataLen, mBuffer + kIndexDataLen); } - - /** - * This method gets the "data len" field in the SPI frame header. - * - * @returns The data length in bytes. - * - */ - uint16_t GetHeaderDataLen(void) const { return Encoding::LittleEndian::ReadUint16(mBuffer + kIndexDataLen); } - -private: - enum - { - kIndexFlagByte = 0, // flag byte (uint8_t). - kIndexAcceptLen = 1, // accept len (uint16_t little-endian encoding). - kIndexDataLen = 3, // data len (uint16_t little-endian encoding). - - kFlagReset = (1 << 7), // Flag byte RESET bit. - kFlagPattern = 0x02, // Flag byte PATTERN bits. - kFlagPatternMask = 0x03, // Flag byte PATTERN mask. - }; - - uint8_t *mBuffer; -}; - class NcpSpi : public NcpBase { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aInstance A pointer to the OpenThread instance structure. * @@ -265,7 +65,7 @@ class NcpSpi : public NcpBase * Size of the SPI header (in bytes). * */ - kSpiHeaderSize = SpiFrame::kHeaderSize, + kSpiHeaderSize = Spinel::SpiFrame::kHeaderSize, }; enum TxState diff --git a/src/posix/client.cpp b/src/posix/client.cpp index e57516e6617..632e9c966bf 100644 --- a/src/posix/client.cpp +++ b/src/posix/client.cpp @@ -238,7 +238,7 @@ static bool ShouldEscape(char aChar) Config ParseArg(int &aArgCount, char **&aArgVector) { - Config config = {"wpan0"}; + Config config = {OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME}; optind = 1; diff --git a/src/posix/main.c b/src/posix/main.c index 8800ac0c1b5..0f989dfb5e7 100644 --- a/src/posix/main.c +++ b/src/posix/main.c @@ -71,7 +71,7 @@ #include "lib/platform/reset_util.h" /** - * This function initializes NCP app. + * Initializes NCP app. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -79,13 +79,13 @@ void otAppNcpInit(otInstance *aInstance); /** - * This function deinitializes NCP app. + * Deinitializes NCP app. * */ void otAppNcpUpdate(otSysMainloopContext *aContext); /** - * This function updates the file descriptor sets with file descriptors used by console. + * Updates the file descriptor sets with file descriptors used by console. * * @param[in,out] aMainloop A pointer to the mainloop context. * @@ -93,7 +93,7 @@ void otAppNcpUpdate(otSysMainloopContext *aContext); void otAppNcpProcess(const otSysMainloopContext *aContext); /** - * This function initializes CLI app. + * Initializes CLI app. * * @param[in] aInstance A pointer to the OpenThread instance. * @@ -101,13 +101,13 @@ void otAppNcpProcess(const otSysMainloopContext *aContext); void otAppCliInit(otInstance *aInstance); /** - * This function deinitializes CLI app. + * Deinitializes CLI app. * */ void otAppCliDeinit(void); /** - * This function updates the file descriptor sets with file descriptors used by console. + * Updates the file descriptor sets with file descriptors used by console. * * @param[in,out] aMainloop A pointer to the mainloop context. * @@ -115,7 +115,7 @@ void otAppCliDeinit(void); void otAppCliUpdate(otSysMainloopContext *aMainloop); /** - * This function performs console driver processing. + * Performs console driver processing. * * @param[in] aMainloop A pointer to the mainloop context. * @@ -131,7 +131,7 @@ typedef struct PosixConfig } PosixConfig; /** - * This enumeration defines the argument return values. + * Defines the argument return values. * */ enum @@ -197,6 +197,7 @@ static void ParseArg(int aArgCount, char *aArgVector[], PosixConfig *aConfig) aConfig->mPlatformConfig.mPersistentInterface = false; aConfig->mPlatformConfig.mSpeedUpFactor = 1; aConfig->mLogLevel = OT_LOG_LEVEL_CRIT; + aConfig->mPlatformConfig.mInterfaceName = OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME; #ifdef __linux__ aConfig->mPlatformConfig.mRealTimeSignal = SIGRTMIN; #endif diff --git a/src/posix/platform/config_file.hpp b/src/posix/platform/config_file.hpp index c0a74ca448a..067124a7ac0 100644 --- a/src/posix/platform/config_file.hpp +++ b/src/posix/platform/config_file.hpp @@ -37,14 +37,14 @@ namespace ot { namespace Posix { /** - * This class provides read/write/clear methods for key/value configuration files. + * Provides read/write/clear methods for key/value configuration files. * */ class ConfigFile { public: /** - * This method initializes the configuration file path. + * Initializes the configuration file path. * * @param[in] aFilePath A pointer to the null-terminated file path. * @@ -52,7 +52,7 @@ class ConfigFile explicit ConfigFile(const char *aFilePath); /** - * This method gets a configuration from the configuration file. + * Gets a configuration from the configuration file. * * @param[in] aKey The key string associated with the requested configuration. * @param[in,out] aIterator A reference to an iterator. MUST be initialized to 0 or the behavior is undefined. @@ -68,7 +68,7 @@ class ConfigFile otError Get(const char *aKey, int &aIterator, char *aValue, int aValueLength); /** - * This method adds a configuration to the configuration file. + * Adds a configuration to the configuration file. * * @param[in] aKey The key string associated with the requested configuration. * @param[in] aValue A pointer to where the new value string of the configuration should be written. @@ -80,7 +80,7 @@ class ConfigFile otError Add(const char *aKey, const char *aValue); /** - * This function removes all configurations with the same key string from the configuration file. + * Removes all configurations with the same key string from the configuration file. * * @param[in] aKey The key string associated with the requested configuration. * diff --git a/src/posix/platform/daemon.cpp b/src/posix/platform/daemon.cpp index 731b4f2b780..bb7b0d2dd60 100644 --- a/src/posix/platform/daemon.cpp +++ b/src/posix/platform/daemon.cpp @@ -60,9 +60,10 @@ typedef char(Filename)[sizeof(sockaddr_un::sun_path)]; void GetFilename(Filename &aFilename, const char *aPattern) { - int rval; + int rval; + const char *netIfName = strlen(gNetifName) > 0 ? gNetifName : OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME; - rval = snprintf(aFilename, sizeof(aFilename), aPattern, gNetifName); + rval = snprintf(aFilename, sizeof(aFilename), aPattern, netIfName); if (rval < 0 && static_cast(rval) >= sizeof(aFilename)) { DieNow(OT_EXIT_INVALID_ARGUMENTS); diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index a37427e5785..b1fb297f86a 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -49,6 +49,7 @@ #endif #include #include +#include #include #include #include @@ -116,18 +117,18 @@ #define B4000000 4000000 #endif +#ifndef IOSSIOSPEED +#define IOSSIOSPEED 0x80045402 +#endif + #endif // __APPLE__ #if OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_UART -using ot::Spinel::SpinelInterface; - namespace ot { namespace Posix { -HdlcInterface::HdlcInterface(SpinelInterface::ReceiveFrameCallback aCallback, - void *aCallbackContext, - SpinelInterface::RxFrameBuffer &aFrameBuffer) +HdlcInterface::HdlcInterface(ReceiveFrameCallback aCallback, void *aCallbackContext, RxFrameBuffer &aFrameBuffer) : mReceiveFrameCallback(aCallback) , mReceiveFrameContext(aCallbackContext) , mReceiveFrameBuffer(aFrameBuffer) @@ -198,9 +199,9 @@ void HdlcInterface::Decode(const uint8_t *aBuffer, uint16_t aLength) { mHdlcDeco otError HdlcInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) { - otError error = OT_ERROR_NONE; - Hdlc::FrameBuffer encoderBuffer; - Hdlc::Encoder hdlcEncoder(encoderBuffer); + otError error = OT_ERROR_NONE; + Spinel::FrameBuffer encoderBuffer; + Hdlc::Encoder hdlcEncoder(encoderBuffer); SuccessOrExit(error = hdlcEncoder.BeginFrame()); SuccessOrExit(error = hdlcEncoder.Encode(aFrame, aLength)); @@ -209,7 +210,7 @@ otError HdlcInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) error = Write(encoderBuffer.GetFrame(), encoderBuffer.GetLength()); exit: - if ((error == OT_ERROR_NONE) && ot::Spinel::SpinelInterface::IsSpinelResetCommand(aFrame, aLength)) + if ((error == OT_ERROR_NONE) && IsSpinelResetCommand(aFrame, aLength)) { mHdlcDecoder.Reset(); error = ResetConnection(); @@ -334,25 +335,44 @@ otError HdlcInterface::WaitForFrame(uint64_t aTimeoutUs) return error; } -void HdlcInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout) +void HdlcInterface::UpdateFdSet(void *aMainloopContext) { - OT_UNUSED_VARIABLE(aWriteFdSet); - OT_UNUSED_VARIABLE(aTimeout); + otSysMainloopContext *context = reinterpret_cast(aMainloopContext); + + assert(context != nullptr); - FD_SET(mSockFd, &aReadFdSet); + FD_SET(mSockFd, &context->mReadFdSet); - if (aMaxFd < mSockFd) + if (context->mMaxFd < mSockFd) { - aMaxFd = mSockFd; + context->mMaxFd = mSockFd; } } -void HdlcInterface::Process(const RadioProcessContext &aContext) +void HdlcInterface::Process(const void *aMainloopContext) { - if (FD_ISSET(mSockFd, aContext.mReadFdSet)) +#if OPENTHREAD_POSIX_VIRTUAL_TIME + /** + * Process read data (decode the data). + * + * Is intended only for virtual time simulation. Its behavior is similar to `Read()` but instead of + * reading the data from the radio socket, it uses the given data in @p `event`. + */ + const VirtualTimeEvent *event = reinterpret_cast(aMainloopContext); + + assert(event != nullptr); + + Decode(event->mData, event->mDataLength); +#else + const otSysMainloopContext *context = reinterpret_cast(aMainloopContext); + + assert(context != nullptr); + + if (FD_ISSET(mSockFd, &context->mReadFdSet)) { Read(); } +#endif } otError HdlcInterface::WaitForWritable(void) @@ -577,7 +597,21 @@ int HdlcInterface::OpenFile(const Url::Url &aRadioUrl) } VerifyOrExit((rval = cfsetspeed(&tios, static_cast(speed))) == 0, perror("cfsetspeed")); - VerifyOrExit((rval = tcsetattr(fd, TCSANOW, &tios)) == 0, perror("tcsetattr")); + rval = tcsetattr(fd, TCSANOW, &tios); + +#ifdef __APPLE__ + if (rval) + { + struct termios orig_tios; + VerifyOrExit((rval = tcgetattr(fd, &orig_tios)) == 0, perror("tcgetattr")); + VerifyOrExit((rval = cfsetispeed(&tios, cfgetispeed(&orig_tios))) == 0, perror("cfsetispeed")); + VerifyOrExit((rval = cfsetospeed(&tios, cfgetospeed(&orig_tios))) == 0, perror("cfsetospeed")); + VerifyOrExit((rval = tcsetattr(fd, TCSANOW, &tios)) == 0, perror("tcsetattr")); + VerifyOrExit((rval = ioctl(fd, IOSSIOSPEED, &speed)) == 0, perror("ioctl IOSSIOSPEED")); + } +#else // __APPLE__ + VerifyOrExit(rval == 0, perror("tcsetattr")); +#endif // __APPLE__ VerifyOrExit((rval = tcflush(fd, TCIOFLUSH)) == 0); } diff --git a/src/posix/platform/hdlc_interface.hpp b/src/posix/platform/hdlc_interface.hpp index dc9fbf89a14..04266a6670f 100644 --- a/src/posix/platform/hdlc_interface.hpp +++ b/src/posix/platform/hdlc_interface.hpp @@ -37,32 +37,29 @@ #include "openthread-posix-config.h" #include "platform-posix.h" #include "lib/hdlc/hdlc.hpp" +#include "lib/spinel/multi_frame_buffer.hpp" #include "lib/spinel/openthread-spinel-config.h" #include "lib/spinel/spinel_interface.hpp" -#if OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_UART - namespace ot { namespace Posix { /** - * This class defines an HDLC interface to the Radio Co-processor (RCP) + * Defines an HDLC interface to the Radio Co-processor (RCP) * */ -class HdlcInterface +class HdlcInterface : public ot::Spinel::SpinelInterface { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aCallback Callback on frame received * @param[in] aCallbackContext Callback context * @param[in] aFrameBuffer A reference to a `RxFrameBuffer` object. * */ - HdlcInterface(Spinel::SpinelInterface::ReceiveFrameCallback aCallback, - void *aCallbackContext, - Spinel::SpinelInterface::RxFrameBuffer &aFrameBuffer); + HdlcInterface(ReceiveFrameCallback aCallback, void *aCallbackContext, RxFrameBuffer &aFrameBuffer); /** * This destructor deinitializes the object. @@ -71,7 +68,7 @@ class HdlcInterface ~HdlcInterface(void); /** - * This method initializes the interface to the Radio Co-processor (RCP) + * Initializes the interface to the Radio Co-processor (RCP) * * @note This method should be called before reading and sending spinel frames to the interface. * @@ -85,13 +82,13 @@ class HdlcInterface otError Init(const Url::Url &aRadioUrl); /** - * This method deinitializes the interface to the RCP. + * Deinitializes the interface to the RCP. * */ void Deinit(void); /** - * This method encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. + * Encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. * * This is blocking call, i.e., if the socket is not writable, this method waits for it to become writable for * up to `kMaxWaitTime` interval. @@ -107,7 +104,7 @@ class HdlcInterface otError SendFrame(const uint8_t *aFrame, uint16_t aLength); /** - * This method waits for receiving part or all of spinel frame within specified interval. + * Waits for receiving part or all of spinel frame within specified interval. * * @param[in] aTimeout The timeout value in microseconds. * @@ -118,39 +115,23 @@ class HdlcInterface otError WaitForFrame(uint64_t aTimeoutUs); /** - * This method updates the file descriptor sets with file descriptors used by the radio driver. + * Updates the file descriptor sets with file descriptors used by the radio driver. * - * @param[in,out] aReadFdSet A reference to the read file descriptors. - * @param[in,out] aWriteFdSet A reference to the write file descriptors. - * @param[in,out] aMaxFd A reference to the max file descriptor. - * @param[in,out] aTimeout A reference to the timeout. + * @param[in,out] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout); + void UpdateFdSet(void *aMainloopContext); /** - * This method performs radio driver processing. + * Performs radio driver processing. * - * @param[in] aContext The context containing fd_sets. + * @param[in] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void Process(const RadioProcessContext &aContext); + void Process(const void *aMainloopContext); -#if OPENTHREAD_POSIX_VIRTUAL_TIME /** - * This method process read data (decode the data). - * - * This method is intended only for virtual time simulation. Its behavior is similar to `Read()` but instead of - * reading the data from the radio socket, it uses the given data in @p `aEvent`. - * - * @param[in] aEvent The data event. - * - */ - void Process(const VirtualTimeEvent &aEvent) { Decode(aEvent.mData, aEvent.mDataLength); } -#endif - - /** - * This method returns the bus speed between the host and the radio. + * Returns the bus speed between the host and the radio. * * @returns Bus speed in bits/second. * @@ -158,7 +139,7 @@ class HdlcInterface uint32_t GetBusSpeed(void) const { return mBaudRate; } /** - * This method hardware resets the RCP. + * Hardware resets the RCP. * * @retval OT_ERROR_NONE Successfully reset the RCP. * @retval OT_ERROR_NOT_IMPLEMENT The hardware reset is not implemented. @@ -167,7 +148,7 @@ class HdlcInterface otError HardwareReset(void) { return OT_ERROR_NOT_IMPLEMENTED; } /** - * This method returns the RCP interface metrics. + * Returns the RCP interface metrics. * * @returns The RCP interface metrics. * @@ -176,13 +157,13 @@ class HdlcInterface private: /** - * This method is called when RCP is reset to recreate the connection with it. + * Is called when RCP is reset to recreate the connection with it. * */ otError ResetConnection(void); /** - * This method instructs `HdlcInterface` to read and decode data from radio over the socket. + * Instructs `HdlcInterface` to read and decode data from radio over the socket. * * If a full HDLC frame is decoded while reading data, this method invokes the `HandleReceivedFrame()` (on the * `aCallback` object from constructor) to pass the received frame to be processed. @@ -191,7 +172,7 @@ class HdlcInterface void Read(void); /** - * This method waits for the socket file descriptor associated with the HDLC interface to become writable within + * Waits for the socket file descriptor associated with the HDLC interface to become writable within * `kMaxWaitTime` interval. * * @retval OT_ERROR_NONE Socket is writable. @@ -201,7 +182,7 @@ class HdlcInterface otError WaitForWritable(void); /** - * This method writes a given frame to the socket. + * Writes a given frame to the socket. * * This is blocking call, i.e., if the socket is not writable, this method waits for it to become writable for * up to `kMaxWaitTime` interval. @@ -216,7 +197,7 @@ class HdlcInterface otError Write(const uint8_t *aFrame, uint16_t aLength); /** - * This method performs HDLC decoding on received data. + * Performs HDLC decoding on received data. * * If a full HDLC frame is decoded while reading data, this method invokes the `HandleReceivedFrame()` (on the * `aCallback` object from constructor) to pass the received frame to be processed. @@ -231,7 +212,7 @@ class HdlcInterface void HandleHdlcFrame(otError aError); /** - * This method opens file specified by aRadioUrl. + * Opens file specified by aRadioUrl. * * @param[in] aRadioUrl A reference to object containing path to file and data for configuring * the connection with tty type file. @@ -241,7 +222,7 @@ class HdlcInterface int OpenFile(const Url::Url &aRadioUrl); /** - * This method closes file associated with the file descriptor. + * Closes file associated with the file descriptor. * */ void CloseFile(void); @@ -252,7 +233,6 @@ class HdlcInterface enum { - kMaxFrameSize = Spinel::SpinelInterface::kMaxFrameSize, kMaxWaitTime = 2000, ///< Maximum wait time in Milliseconds for socket to become writable (see `SendFrame`). kResetTimeout = 5000, ///< Maximum wait time in Milliseconds for file to become ready (see `ResetConnection`). kOpenFileDelay = 500, ///< Delay between open file calls, in Milliseconds (see `ResetConnection`). @@ -260,9 +240,9 @@ class HdlcInterface 2000, ///< Delay for removing RCP device from host OS after hard reset (see `ResetConnection`). }; - Spinel::SpinelInterface::ReceiveFrameCallback mReceiveFrameCallback; - void *mReceiveFrameContext; - Spinel::SpinelInterface::RxFrameBuffer &mReceiveFrameBuffer; + ReceiveFrameCallback mReceiveFrameCallback; + void *mReceiveFrameContext; + RxFrameBuffer &mReceiveFrameBuffer; int mSockFd; uint32_t mBaudRate; @@ -278,6 +258,4 @@ class HdlcInterface } // namespace Posix } // namespace ot - -#endif // OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_UART #endif // POSIX_APP_HDLC_INTERFACE_HPP_ diff --git a/src/posix/platform/include/openthread/openthread-system.h b/src/posix/platform/include/openthread/openthread-system.h index 35ae715011a..e3b02fc5a62 100644 --- a/src/posix/platform/include/openthread/openthread-system.h +++ b/src/posix/platform/include/openthread/openthread-system.h @@ -52,7 +52,7 @@ extern "C" { #endif /** - * This enumeration represents default parameters for the SPI interface. + * Represents default parameters for the SPI interface. * */ enum @@ -60,7 +60,7 @@ enum OT_PLATFORM_CONFIG_SPI_DEFAULT_MODE = 0, ///< Default SPI Mode: CPOL=0, CPHA=0. OT_PLATFORM_CONFIG_SPI_DEFAULT_SPEED_HZ = 1000000, ///< Default SPI speed in hertz. OT_PLATFORM_CONFIG_SPI_DEFAULT_CS_DELAY_US = 20, ///< Default delay after SPI C̅S̅ assertion, in µsec. - OT_PLATFORM_CONFIG_SPI_DEFAULT_RESET_DELAY_MS = 0, ///< Default delay after R̅E̅S̅E̅T̅ assertion, in miliseconds. + OT_PLATFORM_CONFIG_SPI_DEFAULT_RESET_DELAY_MS = 0, ///< Default delay after R̅E̅S̅E̅T̅ assertion, in milliseconds. OT_PLATFORM_CONFIG_SPI_DEFAULT_ALIGN_ALLOWANCE = 16, ///< Default maximum number of 0xFF bytes to clip from start of MISO frame. OT_PLATFORM_CONFIG_SPI_DEFAULT_SMALL_PACKET_SIZE = @@ -69,7 +69,7 @@ enum }; /** - * This structure represents platform specific configurations. + * Represents platform specific configurations. * */ typedef struct otPlatformConfig @@ -86,7 +86,7 @@ typedef struct otPlatformConfig } otPlatformConfig; /** - * This structure represents RCP interface metrics. + * Represents RCP interface metrics. * */ typedef struct otRcpInterfaceMetrics @@ -102,7 +102,7 @@ typedef struct otRcpInterfaceMetrics } otRcpInterfaceMetrics; /** - * This function performs all platform-specific initialization of OpenThread's drivers and initializes the OpenThread + * Performs all platform-specific initialization of OpenThread's drivers and initializes the OpenThread * instance. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function @@ -116,7 +116,7 @@ typedef struct otRcpInterfaceMetrics otInstance *otSysInit(otPlatformConfig *aPlatformConfig); /** - * This function finalizes the OpenThread instance and performs all platform-specific deinitialization for OpenThread's + * Finalizes the OpenThread instance and performs all platform-specific deinitialization for OpenThread's * drivers. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function @@ -126,7 +126,7 @@ otInstance *otSysInit(otPlatformConfig *aPlatformConfig); void otSysDeinit(void); /** - * This structure represents a context for a select() based mainloop. + * Represents a context for a select() based mainloop. * */ typedef struct otSysMainloopContext @@ -139,7 +139,7 @@ typedef struct otSysMainloopContext } otSysMainloopContext; /** - * This function updates the file descriptor sets with file descriptors used by OpenThread drivers. + * Updates the file descriptor sets with file descriptors used by OpenThread drivers. * * @param[in] aInstance The OpenThread instance structure. * @param[in,out] aMainloop A pointer to the mainloop context. @@ -148,7 +148,7 @@ typedef struct otSysMainloopContext void otSysMainloopUpdate(otInstance *aInstance, otSysMainloopContext *aMainloop); /** - * This function polls OpenThread's mainloop. + * Polls OpenThread's mainloop. * * @param[in,out] aMainloop A pointer to the mainloop context. * @@ -158,7 +158,7 @@ void otSysMainloopUpdate(otInstance *aInstance, otSysMainloopContext *aMainloop) int otSysMainloopPoll(otSysMainloopContext *aMainloop); /** - * This function performs all platform-specific processing for OpenThread's example applications. + * Performs all platform-specific processing for OpenThread's example applications. * * @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function * in the main loop when processing OpenThread's drivers is most appropriate. @@ -170,7 +170,7 @@ int otSysMainloopPoll(otSysMainloopContext *aMainloop); void otSysMainloopProcess(otInstance *aInstance, const otSysMainloopContext *aMainloop); /** - * This method returns the radio url help string. + * Returns the radio url help string. * * @returns the radio url help string. * @@ -180,7 +180,7 @@ const char *otSysGetRadioUrlHelpString(void); extern otPlatResetReason gPlatResetReason; /** - * This method returns the Thread network interface name. + * Returns the Thread network interface name. * * @returns The Thread network interface name. * @@ -188,7 +188,7 @@ extern otPlatResetReason gPlatResetReason; const char *otSysGetThreadNetifName(void); /** - * This method returns the Thread network interface index. + * Returns the Thread network interface index. * * @returns The Thread network interface index. * @@ -196,7 +196,7 @@ const char *otSysGetThreadNetifName(void); unsigned int otSysGetThreadNetifIndex(void); /** - * This method returns the infrastructure network interface name. + * Returns the infrastructure network interface name. * * @returns The infrastructure network interface name, or `nullptr` if not specified. * @@ -204,7 +204,7 @@ unsigned int otSysGetThreadNetifIndex(void); const char *otSysGetInfraNetifName(void); /** - * This method returns the radio spinel metrics. + * Returns the radio spinel metrics. * * @returns The radio spinel metrics. * @@ -212,7 +212,7 @@ const char *otSysGetInfraNetifName(void); const otRadioSpinelMetrics *otSysGetRadioSpinelMetrics(void); /** - * This method returns the RCP interface metrics. + * Returns the RCP interface metrics. * * @returns The RCP interface metrics. * @@ -220,7 +220,7 @@ const otRadioSpinelMetrics *otSysGetRadioSpinelMetrics(void); const otRcpInterfaceMetrics *otSysGetRcpInterfaceMetrics(void); /** - * This function returns the ifr_flags of the infrastructure network interface. + * Returns the ifr_flags of the infrastructure network interface. * * @returns The ifr_flags of infrastructure network interface. * diff --git a/src/posix/platform/include/openthread/platform/secure_settings.h b/src/posix/platform/include/openthread/platform/secure_settings.h index 288ad4ff205..e69d4b86793 100644 --- a/src/posix/platform/include/openthread/platform/secure_settings.h +++ b/src/posix/platform/include/openthread/platform/secure_settings.h @@ -52,7 +52,7 @@ extern "C" { */ /** - * This function performs any initialization for the secure settings subsystem, if necessary. + * Performs any initialization for the secure settings subsystem, if necessary. * * @param[in] aInstance The OpenThread instance structure. * @@ -60,7 +60,7 @@ extern "C" { void otPosixSecureSettingsInit(otInstance *aInstance); /** - * This function performs any de-initialization for the secure settings subsystem, if necessary. + * Performs any de-initialization for the secure settings subsystem, if necessary. * * @param[in] aInstance The OpenThread instance structure. * @@ -68,11 +68,11 @@ void otPosixSecureSettingsInit(otInstance *aInstance); void otPosixSecureSettingsDeinit(otInstance *aInstance); /** - * This function fetches the value of the setting identified by aKey and write it to the memory pointed to by aValue. + * Fetches the value of the setting identified by aKey and write it to the memory pointed to by aValue. * It then writes the length to the integer pointed to by aValueLength. The initial value of aValueLength is the * maximum number of bytes to be written to aValue. * - * This function can be used to check for the existence of a key without fetching the value by setting aValue and + * Can be used to check for the existence of a key without fetching the value by setting aValue and * aValueLength to NULL. You can also check the length of the setting without fetching it by setting only aValue * to NULL. * @@ -101,7 +101,7 @@ otError otPosixSecureSettingsGet(otInstance *aInstance, uint16_t *aValueLength); /** - * This function sets or replaces the value of a setting identified by aKey. If there was more than one value + * Sets or replaces the value of a setting identified by aKey. If there was more than one value * previously associated with aKey, then they are all deleted and replaced with this single entry. * * Calling this function successfully may cause unrelated settings with multiple values to be reordered. @@ -120,7 +120,7 @@ otError otPosixSecureSettingsGet(otInstance *aInstance, otError otPosixSecureSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This function adds the value to a setting identified by aKey, without replacing any existing values. + * Adds the value to a setting identified by aKey, without replacing any existing values. * * Note that the underlying implementation is not required to maintain the order of the items associated with a * specific key. The added value may be added to the end, the beginning, or even somewhere in the middle. The order @@ -142,7 +142,7 @@ otError otPosixSecureSettingsSet(otInstance *aInstance, uint16_t aKey, const uin otError otPosixSecureSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This function deletes a specific value from the setting identified by aKey from the secure settings store. + * Deletes a specific value from the setting identified by aKey from the secure settings store. * * Note that the underlying implementation is not required to maintain the order of the items associated with a * specific key. @@ -159,7 +159,7 @@ otError otPosixSecureSettingsAdd(otInstance *aInstance, uint16_t aKey, const uin otError otPosixSecureSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex); /** - * This function deletes all settings from the secure settings store, resetting it to its initial factory state. + * Deletes all settings from the secure settings store, resetting it to its initial factory state. * * @param[in] aInstance The OpenThread instance structure. * diff --git a/src/posix/platform/infra_if.hpp b/src/posix/platform/infra_if.hpp index 03146fa2747..b0be452f640 100644 --- a/src/posix/platform/infra_if.hpp +++ b/src/posix/platform/infra_if.hpp @@ -46,14 +46,14 @@ namespace ot { namespace Posix { /** - * This class manages infrastructure network interface. + * Manages infrastructure network interface. * */ class InfraNetif : public Mainloop::Source, private NonCopyable { public: /** - * This method updates the fd_set and timeout for mainloop. + * Updates the fd_set and timeout for mainloop. * * @param[in,out] aContext A reference to the mainloop context. * @@ -61,7 +61,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void Update(otSysMainloopContext &aContext) override; /** - * This method performs infrastructure network interface processing. + * Performs infrastructure network interface processing. * * @param[in] aContext A reference to the mainloop context. * @@ -69,7 +69,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void Process(const otSysMainloopContext &aContext) override; /** - * This method initializes the infrastructure network interface. + * Initializes the infrastructure network interface. * * @note This method is called before OpenThread instance is created. * @@ -79,7 +79,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void Init(const char *aIfName); /** - * This method sets up the infrastructure network interface. + * Sets up the infrastructure network interface. * * @note This method is called after OpenThread instance is created. * @@ -87,7 +87,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void SetUp(void); /** - * This method tears down the infrastructure network interface. + * Tears down the infrastructure network interface. * * @note This method is called before OpenThread instance is destructed. * @@ -95,7 +95,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void TearDown(void); /** - * This method deinitializes the infrastructure network interface. + * Deinitializes the infrastructure network interface. * * @note This method is called after OpenThread instance is destructed. * @@ -103,13 +103,13 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void Deinit(void); /** - * This method checks whether the infrastructure network interface is running. + * Checks whether the infrastructure network interface is running. * */ bool IsRunning(void) const; /** - * This method returns the ifr_flags of the infrastructure network interface. + * Returns the ifr_flags of the infrastructure network interface. * * @returns The ifr_flags of the infrastructure network interface. * @@ -125,7 +125,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable void CountAddresses(otSysInfraNetIfAddressCounters &aAddressCounters) const; /** - * This method sends an ICMPv6 Neighbor Discovery message on given infrastructure interface. + * Sends an ICMPv6 Neighbor Discovery message on given infrastructure interface. * * See RFC 4861: https://tools.ietf.org/html/rfc4861. * @@ -148,7 +148,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable uint16_t aBufferLength); /** - * This method sends an asynchronous address lookup for the well-known host name "ipv4only.arpa" + * Sends an asynchronous address lookup for the well-known host name "ipv4only.arpa" * to discover the NAT64 prefix. * * @param[in] aInfraIfIndex The index of the infrastructure interface the address look-up is sent to. @@ -160,7 +160,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable otError DiscoverNat64Prefix(uint32_t aInfraIfIndex); /** - * This method gets the infrastructure network interface name. + * Gets the infrastructure network interface name. * * @returns The infrastructure network interface name, or `nullptr` if not specified. * @@ -168,7 +168,7 @@ class InfraNetif : public Mainloop::Source, private NonCopyable const char *GetNetifName(void) const { return (mInfraIfIndex != 0) ? mInfraIfName : nullptr; } /** - * This function gets the infrastructure network interface singleton. + * Gets the infrastructure network interface singleton. * * @returns The singleton object. * diff --git a/src/posix/platform/ip6_utils.hpp b/src/posix/platform/ip6_utils.hpp index 15d4ef6343f..39c7bc168f1 100644 --- a/src/posix/platform/ip6_utils.hpp +++ b/src/posix/platform/ip6_utils.hpp @@ -54,7 +54,7 @@ class Ip6AddressString } /** - * This method returns the string as a null-terminated C string. + * Returns the string as a null-terminated C string. * * @returns The null-terminated C string. * diff --git a/src/posix/platform/mainloop.hpp b/src/posix/platform/mainloop.hpp index fd2989b66e5..6e11e56455e 100644 --- a/src/posix/platform/mainloop.hpp +++ b/src/posix/platform/mainloop.hpp @@ -41,7 +41,7 @@ namespace Posix { namespace Mainloop { /** - * This class is the base for all mainloop event sources. + * Is the base for all mainloop event sources. * */ class Source @@ -50,7 +50,7 @@ class Source public: /** - * This method registers events in the mainloop. + * Registers events in the mainloop. * * @param[in,out] aContext A reference to the mainloop context. * @@ -58,7 +58,7 @@ class Source virtual void Update(otSysMainloopContext &aContext) = 0; /** - * This method processes the mainloop events. + * Processes the mainloop events. * * @param[in] aContext A reference to the mainloop context. * @@ -66,7 +66,7 @@ class Source virtual void Process(const otSysMainloopContext &aContext) = 0; /** - * This method marks destructor virtual method. + * Marks destructor virtual method. * */ virtual ~Source() = default; @@ -76,14 +76,14 @@ class Source }; /** - * This class manages mainloop. + * Manages mainloop. * */ class Manager { public: /** - * This method updates event polls in the mainloop context. + * Updates event polls in the mainloop context. * * @param[in,out] aContext A reference to the mainloop context. * @@ -91,7 +91,7 @@ class Manager void Update(otSysMainloopContext &aContext); /** - * This method processes events in the mainloop context. + * Processes events in the mainloop context. * * @param[in] aContext A reference to the mainloop context. * @@ -99,7 +99,7 @@ class Manager void Process(const otSysMainloopContext &aContext); /** - * This method adds a new event source into the mainloop. + * Adds a new event source into the mainloop. * * @param[in] aSource A reference to the event source. * @@ -107,7 +107,7 @@ class Manager void Add(Source &aSource); /** - * This method removes an event source from the mainloop. + * Removes an event source from the mainloop. * * @param[in] aSource A reference to the event source. * @@ -115,7 +115,7 @@ class Manager void Remove(Source &aSource); /** - * This function returns the Mainloop singleton. + * Returns the Mainloop singleton. * * @returns A reference to the Mainloop singleton. * diff --git a/src/posix/platform/netif.cpp b/src/posix/platform/netif.cpp index 3b2e90830da..3b98fe354ee 100644 --- a/src/posix/platform/netif.cpp +++ b/src/posix/platform/netif.cpp @@ -146,6 +146,7 @@ extern int #include #include #include +#include #include #include "common/code_utils.hpp" @@ -156,7 +157,9 @@ extern int unsigned int gNetifIndex = 0; char gNetifName[IFNAMSIZ]; -otIp4Cidr gNat64Cidr; +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE +static otIp4Cidr sActiveNat64Cidr; +#endif const char *otSysGetThreadNetifName(void) { return gNetifName; } @@ -896,24 +899,55 @@ static void processAddressChange(const otIp6AddressInfo *aAddressInfo, bool aIsA } #if defined(__linux__) && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE -void processNat64StateChange(otNat64State aNewState) +static bool isSameIp4Cidr(const otIp4Cidr &aCidr1, const otIp4Cidr &aCidr2) +{ + bool res = true; + + VerifyOrExit(aCidr1.mLength == aCidr2.mLength, res = false); + + // The higher (32 - length) bits must be the same, host bits are ignored. + VerifyOrExit(((ntohl(aCidr1.mAddress.mFields.m32) ^ ntohl(aCidr2.mAddress.mFields.m32)) >> (32 - aCidr1.mLength)) == + 0, + res = false); + +exit: + return res; +} + +static void processNat64StateChange(void) { - // If the interface is not up and we are enabling NAT64, the route will be added when we bring up the route. - // Also, the route will be deleted by the kernel when we shutting down the interface. - // We should try to add route first, since otNat64SetEnabled never fails. - if (otIp6IsEnabled(gInstance)) + otIp4Cidr translatorCidr; + + // Skip if NAT64 translator has not been configured with a CIDR. + SuccessOrExit(otNat64GetCidr(gInstance, &translatorCidr)); + + if (!isSameIp4Cidr(translatorCidr, sActiveNat64Cidr)) // Someone sets a new CIDR for NAT64. { - if (aNewState == OT_NAT64_STATE_ACTIVE) - { - AddIp4Route(gNat64Cidr, kNat64RoutePriority); - otLogInfoPlat("[netif] Adding route for NAT64"); - } - else + char cidrString[OT_IP4_CIDR_STRING_SIZE]; + + if (sActiveNat64Cidr.mLength != 0) { - DeleteIp4Route(gNat64Cidr); - otLogInfoPlat("[netif] Deleting route for NAT64"); + DeleteIp4Route(sActiveNat64Cidr); } + sActiveNat64Cidr = translatorCidr; + + otIp4CidrToString(&translatorCidr, cidrString, sizeof(cidrString)); + otLogInfoPlat("[netif] NAT64 CIDR updated to %s.", cidrString); + } + + if (otNat64GetTranslatorState(gInstance) == OT_NAT64_STATE_ACTIVE) + { + AddIp4Route(sActiveNat64Cidr, kNat64RoutePriority); + otLogInfoPlat("[netif] Adding route for NAT64"); } + else if (sActiveNat64Cidr.mLength > 0) // Translator is not active. + { + DeleteIp4Route(sActiveNat64Cidr); + otLogInfoPlat("[netif] Deleting route for NAT64"); + } + +exit: + return; } #endif // defined(__linux__) && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE @@ -936,9 +970,9 @@ void platformNetifStateChange(otInstance *aInstance, otChangedFlags aFlags) #endif } #if defined(__linux__) && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE - if (OT_CHANGED_NAT64_TRANSLATOR_STATE & aFlags) + if ((OT_CHANGED_NAT64_TRANSLATOR_STATE | OT_CHANGED_THREAD_NETIF_STATE) & aFlags) { - processNat64StateChange(otNat64GetTranslatorState(aInstance)); + processNat64StateChange(); } #endif } @@ -988,6 +1022,71 @@ static void processReceive(otMessage *aMessage, void *aContext) } } +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE || OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +static constexpr uint8_t kIpVersion4 = 4; +static constexpr uint8_t kIpVersion6 = 6; + +static uint8_t getIpVersion(const uint8_t *data) +{ + assert(data != nullptr); + + // Mute compiler warnings. + OT_UNUSED_VARIABLE(kIpVersion4); + OT_UNUSED_VARIABLE(kIpVersion6); + + return (static_cast(data[0]) >> 4) & 0x0F; +} +#endif + +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + +/** + * Returns nullptr if data does not point to a valid ICMPv6 RA message. + * + */ +static const uint8_t *getIcmp6RaMessage(const uint8_t *data, ssize_t length) +{ + const uint8_t *ret = nullptr; + otIcmp6Header icmpHeader; + + VerifyOrExit(length >= OT_IP6_HEADER_SIZE + OT_ICMP6_ROUTER_ADVERT_MIN_SIZE); + VerifyOrExit(getIpVersion(data) == kIpVersion6); + VerifyOrExit(data[OT_IP6_HEADER_PROTO_OFFSET] == OT_IP6_PROTO_ICMP6); + + ret = data + OT_IP6_HEADER_SIZE; + memcpy(&icmpHeader, ret, sizeof(icmpHeader)); + VerifyOrExit(icmpHeader.mType == OT_ICMP6_TYPE_ROUTER_ADVERT, ret = nullptr); + VerifyOrExit(icmpHeader.mCode == 0, ret = nullptr); + +exit: + return ret; +} + +/** + * Returns false if the message is not an ICMPv6 RA message. + * + */ +static otError tryProcessIcmp6RaMessage(otInstance *aInstance, const uint8_t *data, ssize_t length) +{ + otError error = OT_ERROR_NONE; + const uint8_t *ra = getIcmp6RaMessage(data, length); + ssize_t raLength; + + VerifyOrExit(ra != nullptr, error = OT_ERROR_INVALID_ARGS); + +#if OPENTHREAD_POSIX_LOG_TUN_PACKETS + otLogInfoPlat("[netif] RA to BorderRouting (%hu bytes)", static_cast(length)); + otDumpInfoPlat("", data, static_cast(length)); +#endif + + raLength = length + (ra - data); + otPlatBorderRoutingProcessIcmp6Ra(aInstance, ra, raLength); + +exit: + return error; +} +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + static void processTransmit(otInstance *aInstance) { otMessage *message = nullptr; @@ -1013,13 +1112,20 @@ static void processTransmit(otInstance *aInstance) } #endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + if (tryProcessIcmp6RaMessage(aInstance, reinterpret_cast(&packet[offset]), rval) == OT_ERROR_NONE) + { + ExitNow(); + } +#endif + { otMessageSettings settings; settings.mLinkSecurityEnabled = (otThreadGetDeviceRole(aInstance) != OT_DEVICE_ROLE_DISABLED); settings.mPriority = OT_MESSAGE_PRIORITY_LOW; #if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE - isIp4 = (packet[offset] & 0xf0) == 0x40; + isIp4 = (getIpVersion(reinterpret_cast(&packet[offset])) == kIpVersion4); message = isIp4 ? otIp4NewMessage(aInstance, &settings) : otIp6NewMessage(aInstance, &settings); #else message = otIp6NewMessage(aInstance, &settings); @@ -1207,10 +1313,10 @@ static void processNetifLinkEvent(otInstance *aInstance, struct nlmsghdr *aNetli } #if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE - if (isUp && gNat64Cidr.mLength > 0) + if (isUp && sActiveNat64Cidr.mLength > 0) { - SuccessOrExit(error = otNat64SetIp4Cidr(gInstance, &gNat64Cidr)); - otLogInfoPlat("[netif] Succeeded to enable NAT64"); + // Recover NAT64 route. + AddIp4Route(sActiveNat64Cidr, kNat64RoutePriority); } #endif @@ -1653,7 +1759,7 @@ static void SetAddrGenModeToNone(void) char buf[512]; } req; - const enum in6_addr_gen_mode mode = IN6_ADDR_GEN_MODE_NONE; + const uint8_t mode = IN6_ADDR_GEN_MODE_NONE; memset(&req, 0, sizeof(req)); @@ -1886,6 +1992,22 @@ void platformNetifInit(otPlatformConfig *aPlatformConfig) #endif } +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE +void nat64Init(void) +{ + otIp4Cidr cidr; + + if (otIp4CidrFromString(OPENTHREAD_POSIX_CONFIG_NAT64_CIDR, &cidr) == OT_ERROR_NONE && cidr.mLength != 0) + { + otNat64SetIp4Cidr(gInstance, &cidr); + } + else + { + otLogInfoPlat("[netif] No default NAT64 CIDR provided."); + } +} +#endif + void platformNetifSetUp(void) { OT_ASSERT(gInstance != nullptr); @@ -1905,6 +2027,9 @@ void platformNetifSetUp(void) #if OPENTHREAD_POSIX_MULTICAST_PROMISCUOUS_REQUIRED otIp6SetMulticastPromiscuousEnabled(aInstance, true); #endif +#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE + nat64Init(); +#endif #if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE gResolver.Init(); #endif @@ -1947,93 +2072,92 @@ void platformNetifDeinit(void) gNetifIndex = 0; } -void platformNetifUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aErrorFdSet, int *aMaxFd) +void platformNetifUpdateFdSet(otSysMainloopContext *aContext) { - OT_UNUSED_VARIABLE(aWriteFdSet); - VerifyOrExit(gNetifIndex > 0); + assert(aContext != nullptr); assert(sTunFd >= 0); assert(sNetlinkFd >= 0); assert(sIpFd >= 0); - FD_SET(sTunFd, aReadFdSet); - FD_SET(sTunFd, aErrorFdSet); - FD_SET(sNetlinkFd, aReadFdSet); - FD_SET(sNetlinkFd, aErrorFdSet); + FD_SET(sTunFd, &aContext->mReadFdSet); + FD_SET(sTunFd, &aContext->mErrorFdSet); + FD_SET(sNetlinkFd, &aContext->mReadFdSet); + FD_SET(sNetlinkFd, &aContext->mErrorFdSet); #if OPENTHREAD_POSIX_USE_MLD_MONITOR - FD_SET(sMLDMonitorFd, aReadFdSet); - FD_SET(sMLDMonitorFd, aErrorFdSet); + FD_SET(sMLDMonitorFd, &aContext->mReadFdSet); + FD_SET(sMLDMonitorFd, &aContext->mErrorFdSet); #endif #if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE - gResolver.UpdateFdSet(aReadFdSet, aErrorFdSet, aMaxFd); + gResolver.UpdateFdSet(*aContext); #endif - if (sTunFd > *aMaxFd) + if (sTunFd > aContext->mMaxFd) { - *aMaxFd = sTunFd; + aContext->mMaxFd = sTunFd; } - if (sNetlinkFd > *aMaxFd) + if (sNetlinkFd > aContext->mMaxFd) { - *aMaxFd = sNetlinkFd; + aContext->mMaxFd = sNetlinkFd; } #if OPENTHREAD_POSIX_USE_MLD_MONITOR - if (sMLDMonitorFd > *aMaxFd) + if (sMLDMonitorFd > aContext->mMaxFd) { - *aMaxFd = sMLDMonitorFd; + aContext->mMaxFd = sMLDMonitorFd; } #endif exit: return; } -void platformNetifProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, const fd_set *aErrorFdSet) +void platformNetifProcess(const otSysMainloopContext *aContext) { - OT_UNUSED_VARIABLE(aWriteFdSet); + assert(aContext != nullptr); VerifyOrExit(gNetifIndex > 0); - if (FD_ISSET(sTunFd, aErrorFdSet)) + if (FD_ISSET(sTunFd, &aContext->mErrorFdSet)) { close(sTunFd); DieNow(OT_EXIT_FAILURE); } - if (FD_ISSET(sNetlinkFd, aErrorFdSet)) + if (FD_ISSET(sNetlinkFd, &aContext->mErrorFdSet)) { close(sNetlinkFd); DieNow(OT_EXIT_FAILURE); } #if OPENTHREAD_POSIX_USE_MLD_MONITOR - if (FD_ISSET(sMLDMonitorFd, aErrorFdSet)) + if (FD_ISSET(sMLDMonitorFd, &aContext->mErrorFdSet)) { close(sMLDMonitorFd); DieNow(OT_EXIT_FAILURE); } #endif - if (FD_ISSET(sTunFd, aReadFdSet)) + if (FD_ISSET(sTunFd, &aContext->mReadFdSet)) { processTransmit(gInstance); } - if (FD_ISSET(sNetlinkFd, aReadFdSet)) + if (FD_ISSET(sNetlinkFd, &aContext->mReadFdSet)) { processNetlinkEvent(gInstance); } #if OPENTHREAD_POSIX_USE_MLD_MONITOR - if (FD_ISSET(sMLDMonitorFd, aReadFdSet)) + if (FD_ISSET(sMLDMonitorFd, &aContext->mReadFdSet)) { processMLDEvent(gInstance); } #endif #if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE - gResolver.Process(aReadFdSet, aErrorFdSet); + gResolver.Process(*aContext); #endif exit: diff --git a/src/posix/platform/openthread-posix-config.h b/src/posix/platform/openthread-posix-config.h index 170f24f85e8..3b727c9fd7f 100644 --- a/src/posix/platform/openthread-posix-config.h +++ b/src/posix/platform/openthread-posix-config.h @@ -166,7 +166,7 @@ /** * @def OPENTHREAD_POSIX_CONFIG_OMR_ROUTES_PRIORITY * - * This macro defines the priority of OMR routes added to kernel. The larger the number, the lower the priority. We + * Defines the priority of OMR routes added to kernel. The larger the number, the lower the priority. We * need to assign a high priority to such routes so that kernel prefers the Thread link rather than infrastructure. * Otherwise we may unnecessarily transmit packets via infrastructure, which potentially causes looping issue. * @@ -178,7 +178,7 @@ /** * @def OPENTHREAD_POSIX_CONFIG_MAX_OMR_ROUTES_NUM * - * This macro defines the max number of OMR routes that can be added to kernel. + * Defines the max number of OMR routes that can be added to kernel. * */ #ifndef OPENTHREAD_POSIX_CONFIG_MAX_OMR_ROUTES_NUM @@ -198,7 +198,7 @@ /** * @def OPENTHREAD_POSIX_CONFIG_EXTERNAL_ROUTE_PRIORITY * - * This macro defines the priority of external routes added to kernel. The larger the number, the lower the priority. We + * Defines the priority of external routes added to kernel. The larger the number, the lower the priority. We * need to assign a low priority to such routes so that kernel prefers the infra link rather than thread. Otherwise we * may unnecessarily transmit packets via thread, which potentially causes performance issue. In linux, normally infra * link routes' metric value is not greater than 1024, hence 65535 should be big enough. @@ -211,7 +211,7 @@ /** * @def OPENTHREAD_POSIX_CONFIG_MAX_EXTERNAL_ROUTE_NUM * - * This macro defines the max number of external routes that can be added to kernel. + * Defines the max number of external routes that can be added to kernel. * */ #ifndef OPENTHREAD_POSIX_CONFIG_MAX_EXTERNAL_ROUTE_NUM @@ -252,6 +252,16 @@ #endif #endif +/** + * @def OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME + * + * Define the Thread default network interface name. + * + */ +#ifndef OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME +#define OPENTHREAD_POSIX_CONFIG_THREAD_NETIF_DEFAULT_NAME "wpan0" +#endif + #ifdef __APPLE__ /** diff --git a/src/posix/platform/platform-posix.h b/src/posix/platform/platform-posix.h index 8c36122efca..8f05602a27a 100644 --- a/src/posix/platform/platform-posix.h +++ b/src/posix/platform/platform-posix.h @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -94,14 +93,8 @@ struct VirtualTimeEvent uint8_t mData[OT_EVENT_DATA_MAX_SIZE]; } OT_TOOL_PACKED_END; -struct RadioProcessContext -{ - const fd_set *mReadFdSet; - const fd_set *mWriteFdSet; -}; - /** - * This function initializes the alarm service used by OpenThread. + * Initializes the alarm service used by OpenThread. * * @param[in] aSpeedUpFactor The speed up factor. * @param[in] aRealTimeSignal The real time signal for microsecond alarms. @@ -110,7 +103,7 @@ struct RadioProcessContext void platformAlarmInit(uint32_t aSpeedUpFactor, int aRealTimeSignal); /** - * This function retrieves the time remaining until the alarm fires. + * Retrieves the time remaining until the alarm fires. * * @param[out] aTimeval A pointer to the timeval struct. * @@ -118,7 +111,7 @@ void platformAlarmInit(uint32_t aSpeedUpFactor, int aRealTimeSignal); void platformAlarmUpdateTimeout(struct timeval *tv); /** - * This function performs alarm driver processing. + * Performs alarm driver processing. * * @param[in] aInstance The OpenThread instance structure. * @@ -126,7 +119,7 @@ void platformAlarmUpdateTimeout(struct timeval *tv); void platformAlarmProcess(otInstance *aInstance); /** - * This function returns the next alarm event time. + * Returns the next alarm event time. * * @returns The next alarm fire time. * @@ -147,7 +140,7 @@ int32_t platformAlarmGetNext(void); #endif /** - * This function advances the alarm time by @p aDelta. + * Advances the alarm time by @p aDelta. * * @param[in] aDelta The amount of time to advance. * @@ -155,7 +148,7 @@ int32_t platformAlarmGetNext(void); void platformAlarmAdvanceNow(uint64_t aDelta); /** - * This function initializes the radio service used by OpenThread. + * Initializes the radio service used by OpenThread. * * @note Even when @p aPlatformConfig->mResetRadio is false, a reset event (i.e. a PROP_LAST_STATUS between * [SPINEL_STATUS_RESET__BEGIN, SPINEL_STATUS_RESET__END]) is still expected from RCP. @@ -166,13 +159,13 @@ void platformAlarmAdvanceNow(uint64_t aDelta); void platformRadioInit(const char *aUrl); /** - * This function shuts down the radio service used by OpenThread. + * Shuts down the radio service used by OpenThread. * */ void platformRadioDeinit(void); /** - * This function inputs a received radio frame. + * Inputs a received radio frame. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aBuf A pointer to the received radio frame. @@ -182,34 +175,29 @@ void platformRadioDeinit(void); void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLength); /** - * This function updates the file descriptor sets with file descriptors used by the radio driver. + * Updates the file descriptor sets with file descriptors used by the radio driver. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aMaxFd A pointer to the max file descriptor. - * @param[in,out] aTimeout A pointer to the timeout. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd, struct timeval *aTimeout); +void platformRadioUpdateFdSet(otSysMainloopContext *aContext); /** - * This function performs radio driver processing. + * Performs radio driver processing. * - * @param[in] aInstance A pointer to the OpenThread instance. - * @param[in] aReadFdSet A pointer to the read file descriptors. - * @param[in] aWriteFdSet A pointer to the write file descriptors. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet); +void platformRadioProcess(otInstance *aInstance, const otSysMainloopContext *aContext); /** - * This function initializes the random number service used by OpenThread. + * Initializes the random number service used by OpenThread. * */ void platformRandomInit(void); /** - * This function initializes the logging service used by OpenThread. + * Initializes the logging service used by OpenThread. * * @param[in] aName A name string which will be prefixed to each log line. * @@ -217,27 +205,23 @@ void platformRandomInit(void); void platformLoggingInit(const char *aName); /** - * This function updates the file descriptor sets with file descriptors used by the UART driver. + * Updates the file descriptor sets with file descriptors used by the UART driver. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aMaxFd A pointer to the max file descriptor. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aErrorFdSet, int *aMaxFd); +void platformUartUpdateFdSet(otSysMainloopContext *aContext); /** - * This function performs radio driver processing. + * Performs radio driver processing. * - * @param[in] aReadFdSet A pointer to the read file descriptors. - * @param[in] aWriteFdSet A pointer to the write file descriptors. - * @param[in] aErrorFdSet A pointer to the error file descriptors. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformUartProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, const fd_set *aErrorFdSet); +void platformUartProcess(const otSysMainloopContext *aContext); /** - * This function initializes platform netif. + * Initializes platform netif. * * @note This function is called before OpenThread instance is created. * @@ -247,7 +231,7 @@ void platformUartProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, co void platformNetifInit(otPlatformConfig *aPlatformConfig); /** - * This function sets up platform netif. + * Sets up platform netif. * * @note This function is called after OpenThread instance is created. * @@ -257,7 +241,7 @@ void platformNetifInit(otPlatformConfig *aPlatformConfig); void platformNetifSetUp(void); /** - * This function tears down platform netif. + * Tears down platform netif. * * @note This function is called before OpenThread instance is destructed. * @@ -265,7 +249,7 @@ void platformNetifSetUp(void); void platformNetifTearDown(void); /** - * This function deinitializes platform netif. + * Deinitializes platform netif. * * @note This function is called after OpenThread instance is destructed. * @@ -273,28 +257,23 @@ void platformNetifTearDown(void); void platformNetifDeinit(void); /** - * This function updates the file descriptor sets with file descriptors used by platform netif module. + * Updates the file descriptor sets with file descriptors used by platform netif module. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aErrorFdSet A pointer to the error file descriptors. - * @param[in,out] aMaxFd A pointer to the max file descriptor. + * @param[in,out] aContext A pointer to the mainloop context. * */ -void platformNetifUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aErrorFdSet, int *aMaxFd); +void platformNetifUpdateFdSet(otSysMainloopContext *aContext); /** - * This function performs platform netif processing. + * Performs platform netif processing. * - * @param[in] aReadFdSet A pointer to the read file descriptors. - * @param[in] aWriteFdSet A pointer to the write file descriptors. - * @param[in] aErrorFdSet A pointer to the error file descriptors. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformNetifProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, const fd_set *aErrorFdSet); +void platformNetifProcess(const otSysMainloopContext *aContext); /** - * This function performs notifies state changes to platform netif. + * Performs notifies state changes to platform netif. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aFlags Flags that denote the state change events. @@ -303,7 +282,7 @@ void platformNetifProcess(const fd_set *aReadFdSet, const fd_set *aWriteFdSet, c void platformNetifStateChange(otInstance *aInstance, otChangedFlags aFlags); /** - * This function initialize virtual time simulation. + * Initialize virtual time simulation. * * @params[in] aNodeId Node id of this simulated device. * @@ -311,43 +290,30 @@ void platformNetifStateChange(otInstance *aInstance, otChangedFlags aFlags); void virtualTimeInit(uint16_t aNodeId); /** - * This function deinitialize virtual time simulation. + * Deinitialize virtual time simulation. * */ void virtualTimeDeinit(void); /** - * This function performs virtual time simulation processing. + * Performs virtual time simulation processing. * - * @param[in] aInstance A pointer to the OpenThread instance. - * @param[in] aReadFdSet A pointer to the read file descriptors. - * @param[in] aWriteFdSet A pointer to the write file descriptors. + * @param[in] aContext A pointer to the mainloop context. * */ -void virtualTimeProcess(otInstance *aInstance, - const fd_set *aReadFdSet, - const fd_set *aWriteFdSet, - const fd_set *aErrorFdSet); +void virtualTimeProcess(otInstance *aInstance, const otSysMainloopContext *aContext); /** - * This function updates the file descriptor sets with file descriptors + * Updates the file descriptor sets with file descriptors * used by the virtual time simulation. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aErrorFdSet A pointer to the error file descriptors. - * @param[in,out] aMaxFd A pointer to the max file descriptor. - * @param[in,out] aTimeout A pointer to the timeout. + * @param[in,out] aContext A pointer to the mainloop context. * */ -void virtualTimeUpdateFdSet(fd_set *aReadFdSet, - fd_set *aWriteFdSet, - fd_set *aErrorFdSet, - int *aMaxFd, - struct timeval *aTimeout); +void virtualTimeUpdateFdSet(otSysMainloopContext *aContext); /** - * This function sends radio spinel event of virtual time simulation. + * Sends radio spinel event of virtual time simulation. * * @param[in] aData A pointer to the spinel frame. * @param[in] aLength Length of the spinel frame. @@ -356,7 +322,7 @@ void virtualTimeUpdateFdSet(fd_set *aReadFdSet, void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength); /** - * This function receives an event of virtual time simulation. + * Receives an event of virtual time simulation. * * @param[out] aEvent A pointer to the event receiving the event. * @@ -364,7 +330,7 @@ void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength void virtualTimeReceiveEvent(struct VirtualTimeEvent *aEvent); /** - * This function sends sleep event through virtual time simulation. + * Sends sleep event through virtual time simulation. * * @param[in] aTimeout A pointer to the time sleeping. * @@ -372,7 +338,7 @@ void virtualTimeReceiveEvent(struct VirtualTimeEvent *aEvent); void virtualTimeSendSleepEvent(const struct timeval *aTimeout); /** - * This function performs radio spinel processing of virtual time simulation. + * Performs radio spinel processing of virtual time simulation. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aEvent A pointer to the current event. @@ -387,7 +353,7 @@ enum SocketBlockOption }; /** - * This function initializes platform TREL UDP6 driver. + * Initializes platform TREL UDP6 driver. * * @param[in] aTrelUrl The TREL URL (configuration for TREL platform). * @@ -395,34 +361,29 @@ enum SocketBlockOption void platformTrelInit(const char *aTrelUrl); /** - * This function shuts down the platform TREL UDP6 platform driver. + * Shuts down the platform TREL UDP6 platform driver. * */ void platformTrelDeinit(void); /** - * This function updates the file descriptor sets with file descriptors used by the TREL driver. + * Updates the file descriptor sets with file descriptors used by the TREL driver. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aMaxFd A pointer to the max file descriptor. - * @param[in,out] aTimeout A pointer to the timeout. + * @param[in,out] aContext A pointer to the mainloop context. * */ -void platformTrelUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd, struct timeval *aTimeout); +void platformTrelUpdateFdSet(otSysMainloopContext *aContext); /** - * This function performs TREL driver processing. + * Performs TREL driver processing. * - * @param[in] aInstance A pointer to the OpenThread instance. - * @param[in] aReadFdSet A pointer to the read file descriptors. - * @param[in] aWriteFdSet A pointer to the write file descriptors. + * @param[in] aContext A pointer to the mainloop context. * */ -void platformTrelProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet); +void platformTrelProcess(otInstance *aInstance, const otSysMainloopContext *aContext); /** - * This function creates a socket with SOCK_CLOEXEC flag set. + * Creates a socket with SOCK_CLOEXEC flag set. * * @param[in] aDomain The communication domain. * @param[in] aType The semantics of communication. @@ -449,12 +410,7 @@ extern char gNetifName[IFNAMSIZ]; extern unsigned int gNetifIndex; /** - * The CIDR for NAT64 - */ -extern otIp4Cidr gNat64Cidr; - -/** - * This function initializes platform Backbone network. + * Initializes platform Backbone network. * * @note This function is called before OpenThread instance is created. * @@ -464,7 +420,7 @@ extern otIp4Cidr gNat64Cidr; void platformBackboneInit(const char *aInterfaceName); /** - * This function sets up platform Backbone network. + * Sets up platform Backbone network. * * @note This function is called after OpenThread instance is created. * @@ -474,7 +430,7 @@ void platformBackboneInit(const char *aInterfaceName); void platformBackboneSetUp(void); /** - * This function tears down platform Backbone network. + * Tears down platform Backbone network. * * @note This function is called before OpenThread instance is destructed. * @@ -482,7 +438,7 @@ void platformBackboneSetUp(void); void platformBackboneTearDown(void); /** - * This function shuts down the platform Backbone network. + * Shuts down the platform Backbone network. * * @note This function is called after OpenThread instance is destructed. * @@ -490,7 +446,7 @@ void platformBackboneTearDown(void); void platformBackboneDeinit(void); /** - * This function performs notifies state changes to platform Backbone network. + * Performs notifies state changes to platform Backbone network. * * @param[in] aInstance A pointer to the OpenThread instance. * @param[in] aFlags Flags that denote the state change events. @@ -517,7 +473,7 @@ extern char gBackboneNetifName[IFNAMSIZ]; extern unsigned int gBackboneNetifIndex; /** - * This function tells if the infrastructure interface is running. + * Tells if the infrastructure interface is running. * * @returns TRUE if the infrastructure interface is running, FALSE if not. * @@ -525,7 +481,7 @@ extern unsigned int gBackboneNetifIndex; bool platformInfraIfIsRunning(void); /** - * This function initializes backtrace module. + * Initializes backtrace module. * */ void platformBacktraceInit(void); diff --git a/src/posix/platform/power.hpp b/src/posix/platform/power.hpp index dbc92e05e40..4edbcb2d544 100644 --- a/src/posix/platform/power.hpp +++ b/src/posix/platform/power.hpp @@ -46,7 +46,7 @@ class Domain Domain(void) { m8[0] = '\0'; } /** - * This method sets the regulatory domain from a given null terminated C string. + * Sets the regulatory domain from a given null terminated C string. * * @param[in] aDomain A regulatory domain name C string. * @@ -57,7 +57,7 @@ class Domain otError Set(const char *aDomain); /** - * This method overloads operator `==` to evaluate whether or not two `Domain` instances are equal. + * Overloads operator `==` to evaluate whether or not two `Domain` instances are equal. * * @param[in] aOther The other `Domain` instance to compare with. * @@ -68,7 +68,7 @@ class Domain bool operator==(const Domain &aOther) const { return strcmp(m8, aOther.m8) == 0; } /** - * This method overloads operator `!=` to evaluate whether or not the `Domain` is unequal to a given C string. + * Overloads operator `!=` to evaluate whether or not the `Domain` is unequal to a given C string. * * @param[in] aCString A C string to compare with. Can be `nullptr` which then returns 'TRUE'. * @@ -79,7 +79,7 @@ class Domain bool operator!=(const char *aCString) const { return (aCString == nullptr) ? true : strcmp(m8, aCString) != 0; } /** - * This method gets the regulatory domain as a null terminated C string. + * Gets the regulatory domain as a null terminated C string. * * @returns The regulatory domain as a null terminated C string array. * @@ -98,7 +98,7 @@ class TargetPower typedef String InfoString; /** - * This method parses an target power string. + * Parses an target power string. * * The string MUST follow the format: ",,". * For example, "11,26,2000" @@ -112,7 +112,7 @@ class TargetPower otError FromString(char *aString); /** - * This method returns the start channel. + * Returns the start channel. * * @returns The channel. * @@ -120,7 +120,7 @@ class TargetPower uint8_t GetChannelStart(void) const { return mChannelStart; } /** - * This method returns the end channel. + * Returns the end channel. * * @returns The channel. * @@ -128,7 +128,7 @@ class TargetPower uint8_t GetChannelEnd(void) const { return mChannelEnd; } /** - * This method returns the target power. + * Returns the target power. * * @returns The target power, in 0.01 dBm. * @@ -136,7 +136,7 @@ class TargetPower int16_t GetTargetPower(void) const { return mTargetPower; } /** - * This method converts the target power into a human-readable string. + * Converts the target power into a human-readable string. * * @returns An `InfoString` object representing the target power. * @@ -157,7 +157,7 @@ class RawPowerSetting typedef String InfoString; /** - * This method sets the raw power setting from a given null terminated hex C string. + * Sets the raw power setting from a given null terminated hex C string. * * @param[in] aRawPowerSetting A raw power setting hex C string. * @@ -168,7 +168,7 @@ class RawPowerSetting otError Set(const char *aRawPowerSetting); /** - * This method converts the raw power setting into a human-readable string. + * Converts the raw power setting into a human-readable string. * * @returns An `InfoString` object representing the calibrated power. * @@ -193,7 +193,7 @@ class CalibratedPower typedef String InfoString; /** - * This method parses an calibrated power string. + * Parses an calibrated power string. * * The string MUST follow the format: ",,,". * For example, "11,26,2000,1122aabb" @@ -207,7 +207,7 @@ class CalibratedPower otError FromString(char *aString); /** - * This method returns the start channel. + * Returns the start channel. * * @returns The channel. * @@ -215,7 +215,7 @@ class CalibratedPower uint8_t GetChannelStart(void) const { return mChannelStart; } /** - * This method sets the start channel. + * Sets the start channel. * * @param[in] aChannelStart The start channel. * @@ -223,7 +223,7 @@ class CalibratedPower void SetChannelStart(uint8_t aChannelStart) { mChannelStart = aChannelStart; } /** - * This method returns the end channel. + * Returns the end channel. * * @returns The channel. * @@ -231,7 +231,7 @@ class CalibratedPower uint8_t GetChannelEnd(void) const { return mChannelEnd; } /** - * This method sets the end channel. + * Sets the end channel. * * @param[in] aChannelEnd The end channel. * @@ -239,7 +239,7 @@ class CalibratedPower void SetChannelEnd(uint8_t aChannelEnd) { mChannelEnd = aChannelEnd; } /** - * This method returns the actual power. + * Returns the actual power. * * @returns The actual measured power, in 0.01 dBm. * @@ -247,7 +247,7 @@ class CalibratedPower int16_t GetActualPower(void) const { return mActualPower; } /** - * This method sets the actual channel. + * Sets the actual channel. * * @param[in] aActualPower The actual power in 0.01 dBm. * @@ -255,7 +255,7 @@ class CalibratedPower void SetActualPower(int16_t aActualPower) { mActualPower = aActualPower; } /** - * This method returns the raw power setting. + * Returns the raw power setting. * * @returns A reference to the raw power setting. * @@ -263,7 +263,7 @@ class CalibratedPower const RawPowerSetting &GetRawPowerSetting(void) const { return mRawPowerSetting; } /** - * This method sets the raw power setting. + * Sets the raw power setting. * * @param[in] aRawPowerSetting The raw power setting. * @@ -271,7 +271,7 @@ class CalibratedPower void SetRawPowerSetting(const RawPowerSetting &aRawPowerSetting) { mRawPowerSetting = aRawPowerSetting; } /** - * This method converts the calibrated power into a human-readable string. + * Converts the calibrated power into a human-readable string. * * @returns An `InfoString` object representing the calibrated power. * diff --git a/src/posix/platform/power_updater.hpp b/src/posix/platform/power_updater.hpp index fb12c23855a..f20e67d605b 100644 --- a/src/posix/platform/power_updater.hpp +++ b/src/posix/platform/power_updater.hpp @@ -48,7 +48,7 @@ namespace ot { namespace Posix { /** - * This class updates the target power table and calibrated power table to the RCP. + * Updates the target power table and calibrated power table to the RCP. * */ class PowerUpdater diff --git a/src/posix/platform/radio.cpp b/src/posix/platform/radio.cpp index b16d4afcf99..69fff97989d 100644 --- a/src/posix/platform/radio.cpp +++ b/src/posix/platform/radio.cpp @@ -46,20 +46,15 @@ #if OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_UART #include "hdlc_interface.hpp" -#if OPENTHREAD_POSIX_VIRTUAL_TIME -static ot::Spinel::RadioSpinel sRadioSpinel; -#else -static ot::Spinel::RadioSpinel sRadioSpinel; -#endif // OPENTHREAD_POSIX_VIRTUAL_TIME - +static ot::Spinel::RadioSpinel sRadioSpinel; #elif OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_SPI #include "spi_interface.hpp" -static ot::Spinel::RadioSpinel sRadioSpinel; +static ot::Spinel::RadioSpinel sRadioSpinel; #elif OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_VENDOR #include "vendor_interface.hpp" -static ot::Spinel::RadioSpinel sRadioSpinel; +static ot::Spinel::RadioSpinel sRadioSpinel; #else #error "OPENTHREAD_POSIX_CONFIG_RCP_BUS only allows OT_POSIX_RCP_BUS_UART, OT_POSIX_RCP_BUS_SPI and " \ "OT_POSIX_RCP_BUS_VENDOR!" @@ -124,8 +119,14 @@ void Radio::Init(void) } #endif + if (restoreDataset) + { + otLogCritPlat("The argument \"ncp-dataset\" is no longer supported"); + DieNow(OT_ERROR_FAILED); + } + SuccessOrDie(sRadioSpinel.GetSpinelInterface().Init(mRadioUrl)); - sRadioSpinel.Init(resetRadio, restoreDataset, skipCompatibilityCheck, iid); + sRadioSpinel.Init(resetRadio, skipCompatibilityCheck, iid); parameterValue = mRadioUrl.GetValue("fem-lnagain"); if (parameterValue != nullptr) @@ -324,7 +325,7 @@ bool otPlatRadioGetPromiscuous(otInstance *aInstance) return sRadioSpinel.IsPromiscuous(); } -void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd, struct timeval *aTimeout) +void platformRadioUpdateFdSet(otSysMainloopContext *aContext) { uint64_t now = otPlatTimeGet(); uint64_t deadline = sRadioSpinel.GetNextRadioTimeRecalcStart(); @@ -343,24 +344,25 @@ void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMax { uint64_t remain = deadline - now; - if (remain < (static_cast(aTimeout->tv_sec) * US_PER_S + static_cast(aTimeout->tv_usec))) + if (remain < (static_cast(aContext->mTimeout.tv_sec) * US_PER_S + + static_cast(aContext->mTimeout.tv_usec))) { - aTimeout->tv_sec = static_cast(remain / US_PER_S); - aTimeout->tv_usec = static_cast(remain % US_PER_S); + aContext->mTimeout.tv_sec = static_cast(remain / US_PER_S); + aContext->mTimeout.tv_usec = static_cast(remain % US_PER_S); } } else { - aTimeout->tv_sec = 0; - aTimeout->tv_usec = 0; + aContext->mTimeout.tv_sec = 0; + aContext->mTimeout.tv_usec = 0; } - sRadioSpinel.GetSpinelInterface().UpdateFdSet(*aReadFdSet, *aWriteFdSet, *aMaxFd, *aTimeout); + sRadioSpinel.GetSpinelInterface().UpdateFdSet(aContext); if (sRadioSpinel.HasPendingFrame() || sRadioSpinel.IsTransmitDone()) { - aTimeout->tv_sec = 0; - aTimeout->tv_usec = 0; + aContext->mTimeout.tv_sec = 0; + aContext->mTimeout.tv_usec = 0; } } @@ -368,15 +370,14 @@ void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMax void virtualTimeRadioSpinelProcess(otInstance *aInstance, const struct VirtualTimeEvent *aEvent) { OT_UNUSED_VARIABLE(aInstance); - sRadioSpinel.Process(*aEvent); + sRadioSpinel.Process(aEvent); } #else -void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet) +void platformRadioProcess(otInstance *aInstance, const otSysMainloopContext *aContext) { OT_UNUSED_VARIABLE(aInstance); - RadioProcessContext context = {aReadFdSet, aWriteFdSet}; - sRadioSpinel.Process(context); + sRadioSpinel.Process(aContext); } #endif // OPENTHREAD_POSIX_VIRTUAL_TIME diff --git a/src/posix/platform/radio.hpp b/src/posix/platform/radio.hpp index 6a3d549567d..50ca95d39d8 100644 --- a/src/posix/platform/radio.hpp +++ b/src/posix/platform/radio.hpp @@ -35,14 +35,14 @@ namespace ot { namespace Posix { /** - * This class manages Thread radio. + * Manages Thread radio. * */ class Radio { public: /** - * This method creates the radio manager. + * Creates the radio manager. * * @param[in] aUrl A pointer to the null-terminated URL. * @@ -50,13 +50,13 @@ class Radio explicit Radio(const char *aUrl); /** - * This method initialize the Thread radio. + * Initialize the Thread radio. * */ void Init(void); /** - * This method acts as an accessor to the spinel instance used by the radio. + * Acts as an accessor to the spinel instance used by the radio. * * @returns A pointer to the radio's spinel interface instance. * diff --git a/src/posix/platform/radio_url.cpp b/src/posix/platform/radio_url.cpp index a78ce65ffa3..56076202d46 100644 --- a/src/posix/platform/radio_url.cpp +++ b/src/posix/platform/radio_url.cpp @@ -102,7 +102,6 @@ const char *otSysGetRadioUrlHelpString(void) " enable-coex[=1|0] If not specified, RCP coex operates with its default configuration.\n" " Disable coex with 0, and enable it with other values.\n" " fem-lnagain[=dbm] Set the Rx LNA gain in dBm of the external FEM.\n" - " ncp-dataset Retrieve dataset from ncp.\n" " no-reset Do not send Spinel reset command to RCP on initialization.\n" " skip-rcp-compatibility-check Skip checking RCP API version and capabilities during initialization.\n" #if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE diff --git a/src/posix/platform/radio_url.hpp b/src/posix/platform/radio_url.hpp index 2445989a9ea..32b2c4c16ab 100644 --- a/src/posix/platform/radio_url.hpp +++ b/src/posix/platform/radio_url.hpp @@ -40,14 +40,14 @@ namespace ot { namespace Posix { /** - * This class implements the radio URL processing. + * Implements the radio URL processing. * */ class RadioUrl : public ot::Url::Url { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aUrl The null-terminated URL string. * diff --git a/src/posix/platform/resolver.cpp b/src/posix/platform/resolver.cpp index 85eda40c91e..c8d80e294a9 100644 --- a/src/posix/platform/resolver.cpp +++ b/src/posix/platform/resolver.cpp @@ -257,30 +257,30 @@ void Resolver::CloseTransaction(Transaction *aTxn) aTxn->mThreadTxn = nullptr; } -void Resolver::UpdateFdSet(fd_set *aReadFdSet, fd_set *aErrorFdSet, int *aMaxFd) +void Resolver::UpdateFdSet(otSysMainloopContext &aContext) { for (Transaction &txn : mUpstreamTransaction) { if (txn.mThreadTxn != nullptr) { - FD_SET(txn.mUdpFd, aReadFdSet); - FD_SET(txn.mUdpFd, aErrorFdSet); - if (txn.mUdpFd > *aMaxFd) + FD_SET(txn.mUdpFd, &aContext.mReadFdSet); + FD_SET(txn.mUdpFd, &aContext.mErrorFdSet); + if (txn.mUdpFd > aContext.mMaxFd) { - *aMaxFd = txn.mUdpFd; + aContext.mMaxFd = txn.mUdpFd; } } } } -void Resolver::Process(const fd_set *aReadFdSet, const fd_set *aErrorFdSet) +void Resolver::Process(const otSysMainloopContext &aContext) { for (Transaction &txn : mUpstreamTransaction) { if (txn.mThreadTxn != nullptr) { // Note: On Linux, we can only get the error via read, so they should share the same logic. - if (FD_ISSET(txn.mUdpFd, aErrorFdSet) || FD_ISSET(txn.mUdpFd, aReadFdSet)) + if (FD_ISSET(txn.mUdpFd, &aContext.mErrorFdSet) || FD_ISSET(txn.mUdpFd, &aContext.mReadFdSet)) { ForwardResponse(&txn); CloseTransaction(&txn); diff --git a/src/posix/platform/resolver.hpp b/src/posix/platform/resolver.hpp index ea7da3bb456..8446a4763df 100644 --- a/src/posix/platform/resolver.hpp +++ b/src/posix/platform/resolver.hpp @@ -29,6 +29,7 @@ #ifndef POSIX_PLATFORM_RESOLVER_HPP_ #define POSIX_PLATFORM_RESOLVER_HPP_ +#include #include #include @@ -47,7 +48,7 @@ class Resolver constexpr static ssize_t kMaxUpstreamServerCount = 3; /** - * This method initialize the upstream DNS resolver. + * Initialize the upstream DNS resolver. * */ void Init(void); @@ -78,7 +79,7 @@ class Resolver * @param[in,out] aTimeout A reference to the timeout. * */ - void UpdateFdSet(fd_set *aReadFdSet, fd_set *aErrorFdSet, int *aMaxFd); + void UpdateFdSet(otSysMainloopContext &aContext); /** * Handles the result of select. @@ -87,7 +88,7 @@ class Resolver * @param[in] aErrorFdSet A reference to the error file descriptors. * */ - void Process(const fd_set *aReadFdSet, const fd_set *aErrorFdSet); + void Process(const otSysMainloopContext &aContext); private: static constexpr uint64_t kDnsServerListNullCacheTimeoutMs = 1 * 60 * 1000; // 1 minute diff --git a/src/posix/platform/settings.cpp b/src/posix/platform/settings.cpp index f807ebc0864..73925fe2150 100644 --- a/src/posix/platform/settings.cpp +++ b/src/posix/platform/settings.cpp @@ -107,7 +107,7 @@ static int swapOpen(otInstance *aInstance) } /** - * This function reads @p aLength bytes from the data file and appends to the swap file. + * Reads @p aLength bytes from the data file and appends to the swap file. * * @param[in] aFd The file descriptor of the current swap file. * @param[in] aLength Number of bytes to copy. diff --git a/src/posix/platform/settings.hpp b/src/posix/platform/settings.hpp index 6afb0f75458..d2009aa375c 100644 --- a/src/posix/platform/settings.hpp +++ b/src/posix/platform/settings.hpp @@ -33,7 +33,7 @@ namespace ot { namespace Posix { /** - * This function gets a setting from the persisted file. + * Gets a setting from the persisted file. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aKey The key associated with the requested setting. @@ -48,7 +48,7 @@ namespace Posix { otError PlatformSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength); /** - * This function sets a setting in the persisted file. + * Sets a setting in the persisted file. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aKey The key associated with the requested setting. @@ -59,7 +59,7 @@ otError PlatformSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, ui void PlatformSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This function adds a setting to the persisted file. + * Adds a setting to the persisted file. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aKey The key associated with the requested setting. @@ -70,7 +70,7 @@ void PlatformSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *aV void PlatformSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength); /** - * This function removes a setting either from swap file or persisted file. + * Removes a setting either from swap file or persisted file. * * @param[in] aInstance The OpenThread instance structure. * @param[in] aKey The key associated with the requested setting. @@ -88,7 +88,7 @@ void PlatformSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aV otError PlatformSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex, int *aSwapFd); /** - * This function gets the sensitive keys that should be stored in the secure area. + * Gets the sensitive keys that should be stored in the secure area. * * @param[in] aInstance The OpenThread instance structure. * @param[out] aKeys A pointer to where the pointer to the array containing sensitive keys should be written. diff --git a/src/posix/platform/spi_interface.cpp b/src/posix/platform/spi_interface.cpp index d3bf52e3628..c8a7f0ce74c 100644 --- a/src/posix/platform/spi_interface.cpp +++ b/src/posix/platform/spi_interface.cpp @@ -59,14 +59,10 @@ #include #include -using ot::Spinel::SpinelInterface; - namespace ot { namespace Posix { -SpiInterface::SpiInterface(SpinelInterface::ReceiveFrameCallback aCallback, - void *aCallbackContext, - SpinelInterface::RxFrameBuffer &aFrameBuffer) +SpiInterface::SpiInterface(ReceiveFrameCallback aCallback, void *aCallbackContext, RxFrameBuffer &aFrameBuffer) : mReceiveFrameCallback(aCallback) , mReceiveFrameContext(aCallbackContext) , mRxFrameBuffer(aFrameBuffer) @@ -104,7 +100,7 @@ otError SpiInterface::HardwareReset(void) // If the `INT` pin is set to low during the restart of the RCP chip, which triggers continuous invalid SPI // transactions by the host, it will cause the function `PushPullSpi()` to output lots of invalid warn log - // messages. Adding the delay here is used to wait for the RCP chip starts up to avoid outputing invalid + // messages. Adding the delay here is used to wait for the RCP chip starts up to avoid outputting invalid // log messages. usleep(static_cast(mSpiResetDelay) * kUsecPerMsec); @@ -406,16 +402,16 @@ otError SpiInterface::DoSpiTransfer(uint8_t *aSpiRxFrameBuffer, uint32_t aTransf otError SpiInterface::PushPullSpi(void) { - otError error = OT_ERROR_FAILED; - uint16_t spiTransferBytes = 0; - uint8_t successfulExchanges = 0; - bool discardRxFrame = true; - uint8_t *spiRxFrameBuffer; - uint8_t *spiRxFrame; - uint8_t slaveHeader; - uint16_t slaveAcceptLen; - Ncp::SpiFrame txFrame(mSpiTxFrameBuffer); - uint16_t skipAlignAllowanceLength; + otError error = OT_ERROR_FAILED; + uint16_t spiTransferBytes = 0; + uint8_t successfulExchanges = 0; + bool discardRxFrame = true; + uint8_t *spiRxFrameBuffer; + uint8_t *spiRxFrame; + uint8_t slaveHeader; + uint16_t slaveAcceptLen; + Spinel::SpiFrame txFrame(mSpiTxFrameBuffer); + uint16_t skipAlignAllowanceLength; if (mInterfaceMetrics.mTransferredValidFrameCount == 0) { @@ -493,7 +489,7 @@ otError SpiInterface::PushPullSpi(void) spiRxFrame = GetRealRxFrameStart(spiRxFrameBuffer, mSpiAlignAllowance, skipAlignAllowanceLength); { - Ncp::SpiFrame rxFrame(spiRxFrame); + Spinel::SpiFrame rxFrame(spiRxFrame); otLogDebgPlat("spi_transfer TX: H:%02X ACCEPT:%" PRIu16 " DATA:%" PRIu16, txFrame.GetHeaderFlagByte(), txFrame.GetHeaderAcceptLen(), txFrame.GetHeaderDataLen()); @@ -629,12 +625,13 @@ bool SpiInterface::CheckInterrupt(void) return (mIntGpioValueFd >= 0) ? (GetGpioValue(mIntGpioValueFd) == kGpioIntAssertState) : true; } -void SpiInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout) +void SpiInterface::UpdateFdSet(void *aMainloopContext) { - struct timeval timeout = {kSecPerDay, 0}; - struct timeval pollingTimeout = {0, kSpiPollPeriodUs}; + struct timeval timeout = {kSecPerDay, 0}; + struct timeval pollingTimeout = {0, kSpiPollPeriodUs}; + otSysMainloopContext *context = reinterpret_cast(aMainloopContext); - OT_UNUSED_VARIABLE(aWriteFdSet); + assert(context != nullptr); if (mSpiTxIsReady) { @@ -645,9 +642,9 @@ void SpiInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMa if (mIntGpioValueFd >= 0) { - if (aMaxFd < mIntGpioValueFd) + if (context->mMaxFd < mIntGpioValueFd) { - aMaxFd = mIntGpioValueFd; + context->mMaxFd = mIntGpioValueFd; } if (CheckInterrupt()) @@ -661,7 +658,7 @@ void SpiInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMa { // The interrupt pin was not asserted, so we wait for the interrupt pin to be asserted by adding it to the // read set. - FD_SET(mIntGpioValueFd, &aReadFdSet); + FD_SET(mIntGpioValueFd, &context->mReadFdSet); } } else if (timercmp(&pollingTimeout, &timeout, <)) @@ -721,19 +718,19 @@ void SpiInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMa mDidPrintRateLimitLog = false; } - if (timercmp(&timeout, &aTimeout, <)) + if (timercmp(&timeout, &context->mTimeout, <)) { - aTimeout = timeout; + context->mTimeout = timeout; } } -void SpiInterface::Process(const RadioProcessContext &aContext) { Process(aContext.mReadFdSet, aContext.mWriteFdSet); } - -void SpiInterface::Process(const fd_set *aReadFdSet, const fd_set *aWriteFdSet) +void SpiInterface::Process(const void *aMainloopContext) { - OT_UNUSED_VARIABLE(aWriteFdSet); + const otSysMainloopContext *context = reinterpret_cast(aMainloopContext); + + assert(context != nullptr); - if (FD_ISSET(mIntGpioValueFd, aReadFdSet)) + if (FD_ISSET(mIntGpioValueFd, &context->mReadFdSet)) { struct gpioevent_data event; @@ -761,25 +758,23 @@ otError SpiInterface::WaitForFrame(uint64_t aTimeoutUs) while (now < end) { - fd_set readFdSet; - fd_set writeFdSet; - int maxFds = -1; - struct timeval timeout; - int ret; + otSysMainloopContext context; + int ret; - timeout.tv_sec = static_cast((end - now) / US_PER_S); - timeout.tv_usec = static_cast((end - now) % US_PER_S); + context.mMaxFd = -1; + context.mTimeout.tv_sec = static_cast((end - now) / US_PER_S); + context.mTimeout.tv_usec = static_cast((end - now) % US_PER_S); - FD_ZERO(&readFdSet); - FD_ZERO(&writeFdSet); + FD_ZERO(&context.mReadFdSet); + FD_ZERO(&context.mWriteFdSet); - UpdateFdSet(readFdSet, writeFdSet, maxFds, timeout); + UpdateFdSet(&context); - ret = select(maxFds + 1, &readFdSet, &writeFdSet, nullptr, &timeout); + ret = select(context.mMaxFd + 1, &context.mReadFdSet, &context.mWriteFdSet, nullptr, &context.mTimeout); if (ret >= 0) { - Process(&readFdSet, &writeFdSet); + Process(&context); if (mDidRxFrame) { @@ -806,7 +801,7 @@ otError SpiInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) VerifyOrExit(aLength < (kMaxFrameSize - kSpiFrameHeaderSize), error = OT_ERROR_NO_BUFS); - if (ot::Spinel::SpinelInterface::IsSpinelResetCommand(aFrame, aLength)) + if (IsSpinelResetCommand(aFrame, aLength)) { ResetStates(); } diff --git a/src/posix/platform/spi_interface.hpp b/src/posix/platform/spi_interface.hpp index 0f3242e35e6..cd0ee2033ae 100644 --- a/src/posix/platform/spi_interface.hpp +++ b/src/posix/platform/spi_interface.hpp @@ -38,35 +38,31 @@ #include "platform-posix.h" #include "lib/hdlc/hdlc.hpp" +#include "lib/spinel/multi_frame_buffer.hpp" +#include "lib/spinel/spi_frame.hpp" #include "lib/spinel/spinel_interface.hpp" #include -#if OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_SPI - -#include "ncp/ncp_spi.hpp" - namespace ot { namespace Posix { /** - * This class defines an SPI interface to the Radio Co-processor (RCP). + * Defines an SPI interface to the Radio Co-processor (RCP). * */ -class SpiInterface +class SpiInterface : public ot::Spinel::SpinelInterface { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aCallback A reference to a `Callback` object. * @param[in] aCallbackContext The context pointer passed to the callback. * @param[in] aFrameBuffer A reference to a `RxFrameBuffer` object. * */ - SpiInterface(Spinel::SpinelInterface::ReceiveFrameCallback aCallback, - void *aCallbackContext, - Spinel::SpinelInterface::RxFrameBuffer &aFrameBuffer); + SpiInterface(ReceiveFrameCallback aCallback, void *aCallbackContext, RxFrameBuffer &aFrameBuffer); /** * This destructor deinitializes the object. @@ -75,7 +71,7 @@ class SpiInterface ~SpiInterface(void); /** - * This method initializes the interface to the Radio Co-processor (RCP). + * Initializes the interface to the Radio Co-processor (RCP). * * @note This method should be called before reading and sending spinel frames to the interface. * @@ -89,13 +85,13 @@ class SpiInterface otError Init(const Url::Url &aRadioUrl); /** - * This method deinitializes the interface to the RCP. + * Deinitializes the interface to the RCP. * */ void Deinit(void); /** - * This method encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. + * Encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. * * @param[in] aFrame A pointer to buffer containing the spinel frame to send. * @param[in] aLength The length (number of bytes) in the frame. @@ -109,7 +105,7 @@ class SpiInterface otError SendFrame(const uint8_t *aFrame, uint16_t aLength); /** - * This method waits for receiving part or all of spinel frame within specified interval. + * Waits for receiving part or all of spinel frame within specified interval. * * @param[in] aTimeout The timeout value in microseconds. * @@ -120,26 +116,23 @@ class SpiInterface otError WaitForFrame(uint64_t aTimeoutUs); /** - * This method updates the file descriptor sets with file descriptors used by the radio driver. + * Updates the file descriptor sets with file descriptors used by the radio driver. * - * @param[in,out] aReadFdSet A reference to the read file descriptors. - * @param[in,out] aWriteFdSet A reference to the write file descriptors. - * @param[in,out] aMaxFd A reference to the max file descriptor. - * @param[in,out] aTimeout A reference to the timeout. + * @param[in,out] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout); + void UpdateFdSet(void *aMainloopContext); /** - * This method performs radio driver processing. + * Performs radio driver processing. * - * @param[in] aContext The context containing fd_sets. + * @param[in] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void Process(const RadioProcessContext &aContext); + void Process(const void *aMainloopContext); /** - * This method returns the bus speed between the host and the radio. + * Returns the bus speed between the host and the radio. * * @returns Bus speed in bits/second. * @@ -147,7 +140,7 @@ class SpiInterface uint32_t GetBusSpeed(void) const { return ((mSpiDevFd >= 0) ? mSpiSpeedHz : 0); } /** - * This method hardware resets the RCP. + * Hardware resets the RCP. * * @retval OT_ERROR_NONE Successfully reset the RCP. * @retval OT_ERROR_NOT_IMPLEMENT The hardware reset is not implemented. @@ -156,7 +149,7 @@ class SpiInterface otError HardwareReset(void); /** - * This method returns the RCP interface metrics. + * Returns the RCP interface metrics. * * @returns The RCP interface metrics. * @@ -178,7 +171,6 @@ class SpiInterface uint8_t *GetRealRxFrameStart(uint8_t *aSpiRxFrameBuffer, uint8_t aAlignAllowance, uint16_t &aSkipLength); otError DoSpiTransfer(uint8_t *aSpiRxFrameBuffer, uint32_t aTransferLength); otError PushPullSpi(void); - void Process(const fd_set *aReadFdSet, const fd_set *aWriteFdSet); bool CheckInterrupt(void); void LogStats(void); @@ -212,14 +204,9 @@ class SpiInterface kSlowRetryTimeoutUs = 33 * kUsecPerMsec, }; - enum - { - kMaxFrameSize = Spinel::SpinelInterface::kMaxFrameSize, - }; - - Spinel::SpinelInterface::ReceiveFrameCallback mReceiveFrameCallback; - void *mReceiveFrameContext; - Spinel::SpinelInterface::RxFrameBuffer &mRxFrameBuffer; + ReceiveFrameCallback mReceiveFrameCallback; + void *mReceiveFrameContext; + RxFrameBuffer &mRxFrameBuffer; int mSpiDevFd; int mResetGpioValueFd; @@ -256,5 +243,4 @@ class SpiInterface } // namespace Posix } // namespace ot -#endif // OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_SPI #endif // POSIX_APP_SPI_INTERFACE_HPP_ diff --git a/src/posix/platform/system.cpp b/src/posix/platform/system.cpp index 6f11db7277f..c52dea1255d 100644 --- a/src/posix/platform/system.cpp +++ b/src/posix/platform/system.cpp @@ -148,13 +148,6 @@ void platformInit(otPlatformConfig *aPlatformConfig) gNetifName[0] = '\0'; -#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE - if (otIp4CidrFromString(OPENTHREAD_POSIX_CONFIG_NAT64_CIDR, &gNat64Cidr) != OT_ERROR_NONE) - { - gNat64Cidr.mLength = 0; - } -#endif - #if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE platformNetifInit(aPlatformConfig); #endif @@ -290,31 +283,28 @@ void otSysDeinit(void) #if OPENTHREAD_POSIX_VIRTUAL_TIME /** - * This function try selecting the given file descriptors in nonblocking mode. + * Try selecting the given file descriptors in nonblocking mode. * - * @param[in,out] aReadFdSet A pointer to the read file descriptors. - * @param[in,out] aWriteFdSet A pointer to the write file descriptors. - * @param[in,out] aErrorFdSet A pointer to the error file descriptors. - * @param[in] aMaxFd The max file descriptor. + * @param[in,out] aContext A reference to the mainloop context. * * @returns The value returned from select(). * */ -static int trySelect(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aErrorFdSet, int aMaxFd) +static int trySelect(otSysMainloopContext &aContext) { struct timeval timeout = {0, 0}; - fd_set originReadFdSet = *aReadFdSet; - fd_set originWriteFdSet = *aWriteFdSet; - fd_set originErrorFdSet = *aErrorFdSet; + fd_set originReadFdSet = aContext.mReadFdSet; + fd_set originWriteFdSet = aContext.mWriteFdSet; + fd_set originErrorFdSet = aContext.mErrorFdSet; int rval; - rval = select(aMaxFd + 1, aReadFdSet, aWriteFdSet, aErrorFdSet, &timeout); + rval = select(aContext.mMaxFd + 1, &aContext.mReadFdSet, &aContext.mWriteFdSet, &aContext.mErrorFdSet, &timeout); if (rval == 0) { - *aReadFdSet = originReadFdSet; - *aWriteFdSet = originWriteFdSet; - *aErrorFdSet = originErrorFdSet; + aContext.mReadFdSet = originReadFdSet; + aContext.mWriteFdSet = originWriteFdSet; + aContext.mErrorFdSet = originErrorFdSet; } return rval; @@ -327,17 +317,15 @@ void otSysMainloopUpdate(otInstance *aInstance, otSysMainloopContext *aMainloop) platformAlarmUpdateTimeout(&aMainloop->mTimeout); #if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE - platformNetifUpdateFdSet(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mErrorFdSet, - &aMainloop->mMaxFd); + platformNetifUpdateFdSet(aMainloop); #endif #if OPENTHREAD_POSIX_VIRTUAL_TIME - virtualTimeUpdateFdSet(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mErrorFdSet, &aMainloop->mMaxFd, - &aMainloop->mTimeout); + virtualTimeUpdateFdSet(aMainloop); #else - platformRadioUpdateFdSet(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mMaxFd, &aMainloop->mTimeout); + platformRadioUpdateFdSet(aMainloop); #endif #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - platformTrelUpdateFdSet(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mMaxFd, &aMainloop->mTimeout); + platformTrelUpdateFdSet(aMainloop); #endif if (otTaskletsArePending(aInstance)) @@ -355,7 +343,7 @@ int otSysMainloopPoll(otSysMainloopContext *aMainloop) if (timerisset(&aMainloop->mTimeout)) { // Make sure there are no data ready in UART - rval = trySelect(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mErrorFdSet, aMainloop->mMaxFd); + rval = trySelect(*aMainloop); if (rval == 0) { @@ -395,16 +383,16 @@ void otSysMainloopProcess(otInstance *aInstance, const otSysMainloopContext *aMa ot::Posix::Mainloop::Manager::Get().Process(*aMainloop); #if OPENTHREAD_POSIX_VIRTUAL_TIME - virtualTimeProcess(aInstance, &aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mErrorFdSet); + virtualTimeProcess(aInstance, aMainloop); #else - platformRadioProcess(aInstance, &aMainloop->mReadFdSet, &aMainloop->mWriteFdSet); + platformRadioProcess(aInstance, aMainloop); #endif #if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE - platformTrelProcess(aInstance, &aMainloop->mReadFdSet, &aMainloop->mWriteFdSet); + platformTrelProcess(aInstance, aMainloop); #endif platformAlarmProcess(aInstance); #if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE - platformNetifProcess(&aMainloop->mReadFdSet, &aMainloop->mWriteFdSet, &aMainloop->mErrorFdSet); + platformNetifProcess(aMainloop); #endif } diff --git a/src/posix/platform/system.hpp b/src/posix/platform/system.hpp index 871226a432f..25c047b2d8a 100644 --- a/src/posix/platform/system.hpp +++ b/src/posix/platform/system.hpp @@ -33,7 +33,7 @@ */ /* - * This method returns if the system will run in dry-run mode. + * Returns if the system will run in dry-run mode. * * @returns If the system runs in dry-run mode. * diff --git a/src/posix/platform/trel.cpp b/src/posix/platform/trel.cpp index 4b7cd50e302..2ddab4bdc39 100644 --- a/src/posix/platform/trel.cpp +++ b/src/posix/platform/trel.cpp @@ -388,24 +388,20 @@ OT_TOOL_WEAK void trelDnssdRemoveService(void) // advertising TREL service after this call. } -OT_TOOL_WEAK void trelDnssdUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd, struct timeval *aTimeout) +OT_TOOL_WEAK void trelDnssdUpdateFdSet(otSysMainloopContext *aContext) { // This function can be used to update the file descriptor sets // by DNS-SD layer (if needed). - OT_UNUSED_VARIABLE(aReadFdSet); - OT_UNUSED_VARIABLE(aWriteFdSet); - OT_UNUSED_VARIABLE(aMaxFd); - OT_UNUSED_VARIABLE(aTimeout); + OT_UNUSED_VARIABLE(aContext); } -OT_TOOL_WEAK void trelDnssdProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet) +OT_TOOL_WEAK void trelDnssdProcess(otInstance *aInstance, const otSysMainloopContext *aContext) { // This function performs processing by DNS-SD (if needed). OT_UNUSED_VARIABLE(aInstance); - OT_UNUSED_VARIABLE(aReadFdSet); - OT_UNUSED_VARIABLE(aWriteFdSet); + OT_UNUSED_VARIABLE(aContext); } //--------------------------------------------------------------------------------------------------------------------- @@ -525,45 +521,45 @@ void platformTrelDeinit(void) return; } -void platformTrelUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd, struct timeval *aTimeout) +void platformTrelUpdateFdSet(otSysMainloopContext *aContext) { - assert((aReadFdSet != NULL) && (aWriteFdSet != NULL) && (aMaxFd != NULL) && (aTimeout != NULL)); + assert(aContext != nullptr); VerifyOrExit(sEnabled); - FD_SET(sSocket, aReadFdSet); + FD_SET(sSocket, &aContext->mReadFdSet); - if (sTxPacketQueueTail != NULL) + if (sTxPacketQueueTail != nullptr) { - FD_SET(sSocket, aWriteFdSet); + FD_SET(sSocket, &aContext->mWriteFdSet); } - if (*aMaxFd < sSocket) + if (aContext->mMaxFd < sSocket) { - *aMaxFd = sSocket; + aContext->mMaxFd = sSocket; } - trelDnssdUpdateFdSet(aReadFdSet, aWriteFdSet, aMaxFd, aTimeout); + trelDnssdUpdateFdSet(aContext); exit: return; } -void platformTrelProcess(otInstance *aInstance, const fd_set *aReadFdSet, const fd_set *aWriteFdSet) +void platformTrelProcess(otInstance *aInstance, const otSysMainloopContext *aContext) { VerifyOrExit(sEnabled); - if (FD_ISSET(sSocket, aWriteFdSet)) + if (FD_ISSET(sSocket, &aContext->mWriteFdSet)) { SendQueuedPackets(); } - if (FD_ISSET(sSocket, aReadFdSet)) + if (FD_ISSET(sSocket, &aContext->mReadFdSet)) { ReceivePacket(sSocket, aInstance); } - trelDnssdProcess(aInstance, aReadFdSet, aWriteFdSet); + trelDnssdProcess(aInstance, aContext); exit: return; diff --git a/src/posix/platform/utils.hpp b/src/posix/platform/utils.hpp index c3f9dda725e..21d4449f79d 100644 --- a/src/posix/platform/utils.hpp +++ b/src/posix/platform/utils.hpp @@ -35,7 +35,7 @@ namespace ot { namespace Posix { /** - * This method formats a system command to execute. + * Formats a system command to execute. * * @param[in] aFormat A pointer to the format string. * @param[in] ... Arguments for the format specification. diff --git a/src/posix/platform/vendor_interface.hpp b/src/posix/platform/vendor_interface.hpp index 8c82c204d29..75bc794dc11 100644 --- a/src/posix/platform/vendor_interface.hpp +++ b/src/posix/platform/vendor_interface.hpp @@ -41,20 +41,18 @@ #include "platform-posix.h" #include "lib/spinel/spinel_interface.hpp" -#if OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_VENDOR - namespace ot { namespace Posix { /** - * This class defines a vendor interface to the Radio Co-processor (RCP). + * Defines a vendor interface to the Radio Co-processor (RCP). * */ -class VendorInterface +class VendorInterface : public ot::Spinel::SpinelInterface { public: /** - * This constructor initializes the object. + * Initializes the object. * * @param[in] aCallback A reference to a `Callback` object. * @param[in] aCallbackContext The context pointer passed to the callback. @@ -72,7 +70,7 @@ class VendorInterface ~VendorInterface(void); /** - * This method initializes the interface to the Radio Co-processor (RCP). + * Initializes the interface to the Radio Co-processor (RCP). * * @note This method should be called before reading and sending spinel frames to the interface. * @@ -86,13 +84,13 @@ class VendorInterface otError Init(const Url::Url &aRadioUrl); /** - * This method deinitializes the interface to the RCP. + * Deinitializes the interface to the RCP. * */ void Deinit(void); /** - * This method encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. + * Encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. * * @param[in] aFrame A pointer to buffer containing the spinel frame to send. * @param[in] aLength The length (number of bytes) in the frame. @@ -106,7 +104,7 @@ class VendorInterface otError SendFrame(const uint8_t *aFrame, uint16_t aLength); /** - * This method waits for receiving part or all of spinel frame within specified interval. + * Waits for receiving part or all of spinel frame within specified interval. * * @param[in] aTimeoutUs The timeout value in microseconds. * @@ -117,26 +115,23 @@ class VendorInterface otError WaitForFrame(uint64_t aTimeoutUs); /** - * This method updates the file descriptor sets with file descriptors used by the radio driver. + * Updates the file descriptor sets with file descriptors used by the radio driver. * - * @param[in,out] aReadFdSet A reference to the read file descriptors. - * @param[in,out] aWriteFdSet A reference to the write file descriptors. - * @param[in,out] aMaxFd A reference to the max file descriptor. - * @param[in,out] aTimeout A reference to the timeout. + * @param[in,out] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout); + void UpdateFdSet(void *aMainloopContext); /** - * This method performs radio driver processing. + * Performs radio driver processing. * - * @param[in] aContext The context containing fd_sets. + * @param[in] aMainloopContext A pointer to the mainloop context containing fd_sets. * */ - void Process(const RadioProcessContext &aContext); + void Process(const void *aMainloopContext); /** - * This method returns the bus speed between the host and the radio. + * Returns the bus speed between the host and the radio. * * @returns Bus speed in bits/second. * @@ -144,7 +139,7 @@ class VendorInterface uint32_t GetBusSpeed(void) const; /** - * This method hardware resets the RCP. + * Hardware resets the RCP. * * @retval OT_ERROR_NONE Successfully reset the RCP. * @retval OT_ERROR_NOT_IMPLEMENT The hardware reset is not implemented. @@ -153,16 +148,15 @@ class VendorInterface otError HardwareReset(void); /** - * This method returns the RCP interface metrics. + * Returns the RCP interface metrics. * * @returns The RCP interface metrics. * */ - const otRcpInterfaceMetrics *GetRcpInterfaceMetrics(void); + const otRcpInterfaceMetrics *GetRcpInterfaceMetrics(void) const; }; } // namespace Posix } // namespace ot -#endif // OPENTHREAD_POSIX_CONFIG_RCP_BUS == OT_POSIX_RCP_BUS_VENDOR #endif // POSIX_APP_VENDOR_INTERFACE_HPP_ diff --git a/src/posix/platform/vendor_interface_example.cpp b/src/posix/platform/vendor_interface_example.cpp index ebf6b786903..2b03c5dc3bd 100644 --- a/src/posix/platform/vendor_interface_example.cpp +++ b/src/posix/platform/vendor_interface_example.cpp @@ -43,7 +43,7 @@ namespace Posix { using ot::Spinel::SpinelInterface; /** - * This class defines the vendor implementation object. + * Defines the vendor implementation object. * */ class VendorInterfaceImpl @@ -108,19 +108,16 @@ otError VendorInterface::HardwareReset(void) return OT_ERROR_NOT_IMPLEMENTED; } -void VendorInterface::UpdateFdSet(fd_set &aReadFdSet, fd_set &aWriteFdSet, int &aMaxFd, struct timeval &aTimeout) +void VendorInterface::UpdateFdSet(void *aMainloopContext) { - OT_UNUSED_VARIABLE(aReadFdSet); - OT_UNUSED_VARIABLE(aWriteFdSet); - OT_UNUSED_VARIABLE(aMaxFd); - OT_UNUSED_VARIABLE(aTimeout); + OT_UNUSED_VARIABLE(aMainloopContext); // TODO: Implement vendor code here. } -void VendorInterface::Process(const RadioProcessContext &aContext) +void VendorInterface::Process(const void *aMainloopContext) { - OT_UNUSED_VARIABLE(aContext); + OT_UNUSED_VARIABLE(aMainloopContext); // TODO: Implement vendor code here. } @@ -144,7 +141,7 @@ otError VendorInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) return OT_ERROR_NONE; } -const otRcpInterfaceMetrics *VendorInterface::GetRcpInterfaceMetrics(void) +const otRcpInterfaceMetrics *VendorInterface::GetRcpInterfaceMetrics(void) const { // TODO: Implement vendor code here. diff --git a/src/posix/platform/virtual_time.cpp b/src/posix/platform/virtual_time.cpp index 963c1d9f112..e278ed45c91 100644 --- a/src/posix/platform/virtual_time.cpp +++ b/src/posix/platform/virtual_time.cpp @@ -159,37 +159,24 @@ void virtualTimeSendRadioSpinelWriteEvent(const uint8_t *aData, uint16_t aLength virtualTimeSendEvent(&event, offsetof(struct VirtualTimeEvent, mData) + event.mDataLength); } -void virtualTimeUpdateFdSet(fd_set *aReadFdSet, - fd_set *aWriteFdSet, - fd_set *aErrorFdSet, - int *aMaxFd, - struct timeval *aTimeout) +void virtualTimeUpdateFdSet(otSysMainloopContext *aContext) { - OT_UNUSED_VARIABLE(aWriteFdSet); - OT_UNUSED_VARIABLE(aErrorFdSet); - OT_UNUSED_VARIABLE(aTimeout); - - FD_SET(sSockFd, aReadFdSet); - if (*aMaxFd < sSockFd) + FD_SET(sSockFd, &aContext->mReadFdSet); + if (aContext->mMaxFd < sSockFd) { - *aMaxFd = sSockFd; + aContext->mMaxFd = sSockFd; } } -void virtualTimeProcess(otInstance *aInstance, - const fd_set *aReadFdSet, - const fd_set *aWriteFdSet, - const fd_set *aErrorFdSet) +void virtualTimeProcess(otInstance *aInstance, const otSysMainloopContext *aContext) { struct VirtualTimeEvent event; memset(&event, 0, sizeof(event)); OT_UNUSED_VARIABLE(aInstance); - OT_UNUSED_VARIABLE(aWriteFdSet); - OT_UNUSED_VARIABLE(aErrorFdSet); - if (FD_ISSET(sSockFd, aReadFdSet)) + if (FD_ISSET(sSockFd, &aContext->mReadFdSet)) { virtualTimeReceiveEvent(&event); } diff --git a/tests/scripts/expect/_common.exp b/tests/scripts/expect/_common.exp index 820a0c674e3..4214299b77f 100644 --- a/tests/scripts/expect/_common.exp +++ b/tests/scripts/expect/_common.exp @@ -213,11 +213,23 @@ proc get_rloc16 {} { } proc setup_default_network {} { - send "channel 11\n" + send "dataset init new\n" + expect_line "Done" + send "dataset channel 11\n" + expect_line "Done" + send "dataset extpanid 000db80000000000\n" expect_line "Done" - send "panid 0xface\n" + send "dataset meshlocalprefix fd00:db8::\n" + expect_line "Done" + send "dataset networkkey 00112233445566778899aabbccddeeff\n" expect_line "Done" - send "networkkey 00112233445566778899aabbccddeeff\n" + send "dataset networkname OpenThread-face\n" + expect_line "Done" + send "dataset panid 0xface\n" + expect_line "Done" + send "dataset pskc c23a76e98f1a6483639b1ac1271e2e27\n" + expect_line "Done" + send "dataset commit active\n" expect_line "Done" } diff --git a/tests/scripts/expect/cli-macfilter.exp b/tests/scripts/expect/cli-macfilter.exp index 21456b35a44..1827a6ed268 100755 --- a/tests/scripts/expect/cli-macfilter.exp +++ b/tests/scripts/expect/cli-macfilter.exp @@ -114,7 +114,7 @@ send "macfilter\n" expect "Address Mode: Disabled" expect "RssIn List:" expect -re {aabbccddeeff0011 : rss -?\d+ \(lqi 3\)} -expect -re {Default rss : -?\d+ \(lqi 2\)} +expect -re {Default rss: -?\d+ \(lqi 2\)} expect_line "Done" send "macfilter rss remove *\n" diff --git a/tests/scripts/expect/cli-misc.exp b/tests/scripts/expect/cli-misc.exp index 8b8b4d5eef6..522a0faacd5 100755 --- a/tests/scripts/expect/cli-misc.exp +++ b/tests/scripts/expect/cli-misc.exp @@ -86,6 +86,10 @@ send "ifconfig\n" expect "up" expect_line "Done" +send "instanceid\n" +expect -re {\d+} +expect_line "Done" + send "ipaddr add ::\n" expect_line "Done" send "ipaddr del ::\n" diff --git a/tests/scripts/expect/cli-multicast-loop.exp b/tests/scripts/expect/cli-multicast-loop.exp index 14f07bd6059..8883d639df8 100755 --- a/tests/scripts/expect/cli-multicast-loop.exp +++ b/tests/scripts/expect/cli-multicast-loop.exp @@ -41,9 +41,6 @@ setup_default_network set timeout 1 -send "panid 0xface\n" -expect_line "Done" - attach set extaddr1 [get_extaddr] @@ -53,9 +50,6 @@ get_rloc16 spawn_node 2 cli setup_default_network -send "panid 0xface\n" -expect_line "Done" - attach "router" sleep 3 @@ -65,9 +59,6 @@ get_rloc16 spawn_node 3 cli setup_default_network -send "panid 0xface\n" -expect_line "Done" - send "macfilter addr add ${extaddr1}\n" expect_line "Done" @@ -85,9 +76,6 @@ get_rloc16 spawn_node 4 cli setup_default_network -send "panid 0xface\n" -expect_line "Done" - send "mode rn\n" expect_line "Done" diff --git a/tests/scripts/expect/cli-networkname.exp b/tests/scripts/expect/cli-networkname.exp index fc4edb140a7..6f1289ff751 100755 --- a/tests/scripts/expect/cli-networkname.exp +++ b/tests/scripts/expect/cli-networkname.exp @@ -30,10 +30,15 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 +setup_default_network spawn_node 2 switch_node 1 -send "networkname Thread\\ Network\n" +send "dataset init active\n" +expect_line "Done" +send "dataset networkname Thread\\ Network\n" +expect_line "Done" +send "dataset commit active\n" expect_line "Done" send "ifconfig up\n" expect_line "Done" @@ -52,7 +57,11 @@ expect_line "Done" switch_node 1 send "thread stop\n" expect_line "Done" -send "networkname Thread\\ 网络\n" +send "dataset init active\n" +expect_line "Done" +send "dataset networkname Thread\\ 网络\n" +expect_line "Done" +send "dataset commit active\n" expect_line "Done" send "thread start\n" expect_line "Done" @@ -67,7 +76,11 @@ expect_line "Done" switch_node 1 send "thread stop\n" expect_line "Done" -send "networkname スレッド\n" +send "dataset init active\n" +expect_line "Done" +send "dataset networkname スレッド\n" +expect_line "Done" +send "dataset commit active\n" expect_line "Done" send "thread start\n" expect_line "Done" diff --git a/tests/scripts/expect/cli-reset.exp b/tests/scripts/expect/cli-reset.exp index 64420888016..b4306971708 100755 --- a/tests/scripts/expect/cli-reset.exp +++ b/tests/scripts/expect/cli-reset.exp @@ -30,10 +30,16 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 +setup_default_network -send "ifconfig up\n" +send "dataset init active\n" +expect_line "Done" +send "dataset panid 0xabcd\n" +expect_line "Done" +send "dataset commit active\n" expect_line "Done" -send "panid 0xabcd\n" + +send "ifconfig up\n" expect_line "Done" send "thread start\n" expect_line "Done" diff --git a/tests/scripts/expect/cli_non_rcp-radiostats.exp b/tests/scripts/expect/cli_non_rcp-radiostats.exp new file mode 100755 index 00000000000..2dcdabdf92a --- /dev/null +++ b/tests/scripts/expect/cli_non_rcp-radiostats.exp @@ -0,0 +1,57 @@ +#!/usr/bin/expect -f +# +# 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. +# + +source "tests/scripts/expect/_common.exp" +source "tests/scripts/expect/_multinode.exp" + +setup_two_nodes "-" + +switch_node 2 +set addr [get_ipaddr mleid] +send "pollperiod 3000\n" +expect_line "Done" +send "radio stats clear\n" +expect_line "Done" + +switch_node 1 +for {set i 1} {$i <= 10} {incr i} { + send "ping $addr\n" + sleep 3 + expect "16 bytes from $addr: icmp_seq=" +} + +switch_node 2 +send "radio stats\n" +expect_line "Radio Statistics:" +expect -re {Total Time: \d+\.\d+s} +expect -re {Tx Time: \d+\.\d+s \(\d+\.\d+%\)} +expect -re {Rx Time: \d+\.\d+s \(\d+\.\d+%\)} +expect -re {Sleep Time: \d+\.\d+s \(\d+\.\d+%\)} +expect -re {Disabled Time: \d+\.\d+s \(\d+\.\d+%\)} +dispose_all diff --git a/tests/scripts/expect/posix-rcp-restoration.exp b/tests/scripts/expect/posix-rcp-restoration.exp index 1d3fac22759..d745474cc70 100755 --- a/tests/scripts/expect/posix-rcp-restoration.exp +++ b/tests/scripts/expect/posix-rcp-restoration.exp @@ -251,6 +251,7 @@ try { puts "While energy scanning" spawn_node 1 "rcp" "spinel+hdlc_uart://$host_pty" + setup_default_network attach send "scan energy 100\n" diff --git a/tests/scripts/expect/tun-dns-client.exp b/tests/scripts/expect/tun-dns-client.exp index 3a2ac644d7c..b349bc69980 100755 --- a/tests/scripts/expect/tun-dns-client.exp +++ b/tests/scripts/expect/tun-dns-client.exp @@ -30,9 +30,8 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 +setup_default_network -send "panid 0xface\n" -expect_line "Done" send "ifconfig up\n" expect_line "Done" send "thread start\n" diff --git a/tests/scripts/expect/tun-sntp.exp b/tests/scripts/expect/tun-sntp.exp index fe91233d0dc..eebbf127ec8 100755 --- a/tests/scripts/expect/tun-sntp.exp +++ b/tests/scripts/expect/tun-sntp.exp @@ -32,9 +32,8 @@ source "tests/scripts/expect/_common.exp" skip_on_macos spawn_node 1 +setup_default_network -send "panid 0xface\n" -expect_line "Done" attach send "sntp query ::1 123\n" diff --git a/tests/scripts/expect/tun-udp.exp b/tests/scripts/expect/tun-udp.exp index 53cff14e7eb..65c5b227cf8 100755 --- a/tests/scripts/expect/tun-udp.exp +++ b/tests/scripts/expect/tun-udp.exp @@ -32,12 +32,10 @@ source "tests/scripts/expect/_common.exp" spawn_node 1 +setup_default_network set timeout 1 -send "panid 0xface\n" -expect_line "Done" - attach send "udp open\n" diff --git a/tests/scripts/thread-cert/Cert_5_3_03_AddressQuery.py b/tests/scripts/thread-cert/Cert_5_3_03_AddressQuery.py index 233764d44b2..403a39784c5 100755 --- a/tests/scripts/thread-cert/Cert_5_3_03_AddressQuery.py +++ b/tests/scripts/thread-cert/Cert_5_3_03_AddressQuery.py @@ -118,7 +118,7 @@ def test(self): self.assertTrue(self.nodes[MED1].ping(router3_mleid)) # 3 - # Wait the finish of address resolution traffic triggerred by previous + # Wait the finish of address resolution traffic triggered by previous # ping. self.simulator.go(5) @@ -126,7 +126,7 @@ def test(self): self.assertTrue(self.nodes[ROUTER1].ping(med1_mleid)) # 4 - # Wait the finish of address resolution traffic triggerred by previous + # Wait the finish of address resolution traffic triggered by previous # ping. self.simulator.go(5) diff --git a/tests/scripts/thread-cert/Cert_5_3_09_AddressQuery.py b/tests/scripts/thread-cert/Cert_5_3_09_AddressQuery.py index 6e1ca9d2170..74608b38b67 100755 --- a/tests/scripts/thread-cert/Cert_5_3_09_AddressQuery.py +++ b/tests/scripts/thread-cert/Cert_5_3_09_AddressQuery.py @@ -155,7 +155,7 @@ def test(self): self.assertTrue(self.nodes[SED1].ping(router3_addr)) self.simulator.go(1) - # 6 DUT_ROUTER2: Power off ROUTER3 and wait 580s to alow LEADER to + # 6 DUT_ROUTER2: Power off ROUTER3 and wait 580s to allow LEADER to # expire its Router ID self.nodes[ROUTER3].stop() self.simulator.go(580) @@ -233,7 +233,7 @@ def verify(self, pv): must_next() # Step 3: Router_1 sends an ICMPv6 Echo Request to SED using GUA 2001:: - # addresss + # address # The DUT MUST respond to the Address Query Request with a properly # formatted Address Notification Message: # CoAP URI-Path diff --git a/tests/scripts/thread-cert/Cert_5_3_10_AddressQuery.py b/tests/scripts/thread-cert/Cert_5_3_10_AddressQuery.py index 775ee5f8ce3..8a63548040b 100755 --- a/tests/scripts/thread-cert/Cert_5_3_10_AddressQuery.py +++ b/tests/scripts/thread-cert/Cert_5_3_10_AddressQuery.py @@ -239,7 +239,7 @@ def verify(self, pv): must_next() # Step 4: Border Router sends an ICMPv6 Echo Request to MED using GUA 2003:: - # addresss + # address # The DUT MUST respond to the Address Query Request with a properly # formatted Address Notification Message: # CoAP URI-Path diff --git a/tests/scripts/thread-cert/Cert_5_7_03_CoapDiagCommands.py b/tests/scripts/thread-cert/Cert_5_7_03_CoapDiagCommands.py index 36b5b98c906..bf24826735b 100755 --- a/tests/scripts/thread-cert/Cert_5_7_03_CoapDiagCommands.py +++ b/tests/scripts/thread-cert/Cert_5_7_03_CoapDiagCommands.py @@ -175,7 +175,7 @@ def verify(self, pv): # TLV Type 8 – IPv6 address list # TLV Type 17 – Channel Pagesi # - # if DUT is Router, contianing the following as well: + # if DUT is Router, containing the following as well: # TLV Type 4 – Connectivity # TLV Type 5 – Route64 # TLV Type 16 – Child Table diff --git a/tests/scripts/thread-cert/Cert_5_8_04_SecurityPolicyTLV.py b/tests/scripts/thread-cert/Cert_5_8_04_SecurityPolicyTLV.py index 37f5506e3f7..8620314c5c6 100755 --- a/tests/scripts/thread-cert/Cert_5_8_04_SecurityPolicyTLV.py +++ b/tests/scripts/thread-cert/Cert_5_8_04_SecurityPolicyTLV.py @@ -49,7 +49,7 @@ # requires an External Commissioner which is currently not part of Thread # Certification. # -# Notes: Due to the packet parsing compatiable issue for supporting Thread 1.2 +# Notes: Due to the packet parsing compatible issue for supporting Thread 1.2 # and 1.1, the security policy values can be fetched only in the unknown # field. # diff --git a/tests/scripts/thread-cert/backbone/test_bmlr.py b/tests/scripts/thread-cert/backbone/test_bmlr.py index 990038c859a..335d9056eb0 100755 --- a/tests/scripts/thread-cert/backbone/test_bmlr.py +++ b/tests/scripts/thread-cert/backbone/test_bmlr.py @@ -161,7 +161,7 @@ def verify(self, pv: PacketVerifier): and ipv6.src.is_link_local """) - # Commissioner registers MA3 with deafult timeout + # Commissioner registers MA3 with default timeout pkts.filter_wpan_src64(COMMISSIONER).filter_coap_request('/n/mr').must_next().must_verify(f""" thread_meshcop.tlv.ipv6_addr == ['{MA3}'] and thread_bl.tlv.timeout is null diff --git a/tests/scripts/thread-cert/backbone/test_dua_routing.py b/tests/scripts/thread-cert/backbone/test_dua_routing.py index 3c3c2498e67..fd469e1baf4 100755 --- a/tests/scripts/thread-cert/backbone/test_dua_routing.py +++ b/tests/scripts/thread-cert/backbone/test_dua_routing.py @@ -211,7 +211,7 @@ def verify(self, pv: PacketVerifier): PBBR_ETH = pv.vars['PBBR_ETH'] PBBR2_ETH = pv.vars['PBBR2_ETH'] - # Verify that SBBR should not foward any Ping Request to the Thread network. + # Verify that SBBR should not forward any Ping Request to the Thread network. # Use `ipv6.hlim == 63` to avoid false fails because SBBR might still forward Ping Request from PBBR to ROUTER1 pkts.filter_wpan_src64(SBBR).filter_ping_request().filter('ipv6.hlim == 63').must_not_next() diff --git a/tests/scripts/thread-cert/border_router/nat64/test_single_border_router.py b/tests/scripts/thread-cert/border_router/nat64/test_single_border_router.py index 4a69b2a9370..82f27ebd111 100755 --- a/tests/scripts/thread-cert/border_router/nat64/test_single_border_router.py +++ b/tests/scripts/thread-cert/border_router/nat64/test_single_border_router.py @@ -63,6 +63,9 @@ # So the BR will remove the random-generated one. LARGE_NAT64_PREFIX = "ff00:00:00:01:00:00::/96" +DEFAULT_NAT64_CIDR = ipaddress.IPv4Network("192.168.255.0/24") +UPDATED_NAT64_CIDR = ipaddress.IPv4Network("100.64.64.0/24") + class Nat64SingleBorderRouter(thread_cert.TestCase): USE_MESSAGE_FACTORY = False @@ -99,7 +102,7 @@ def receive_from(self, sock, timeout_seconds): if ready[0]: return sock.recv(1024) else: - raise AssertionError("No data recevied") + raise AssertionError("No data received") def listen_udp(self, addr, port): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -235,7 +238,16 @@ def test(self): self.assertEqual(counters['protocol']['ICMP']['6to4']['packets'], 2) # - # Case 6. Disable and re-enable ethernet on the border router. + # Case 6. Change the CIDR used by NAT64 during runtime + # + self.assertEqual(br.nat64_cidr, DEFAULT_NAT64_CIDR) + + br.nat64_cidr = UPDATED_NAT64_CIDR + self.assertEqual(br.nat64_cidr, UPDATED_NAT64_CIDR) + self.assertTrue(router.ping(ipaddr=host_ip)) + + # + # Case 7. Disable and re-enable ethernet on the border router. # Note: disable_ether will remove default route but enable_ether won't add it back, # NAT64 connectivity tests will fail after this. # TODO: Add a default IPv4 route after enable_ether. diff --git a/tests/scripts/thread-cert/border_router/test_dnssd_server_multi_border_routers.py b/tests/scripts/thread-cert/border_router/test_dnssd_server_multi_border_routers.py index 46178480b81..71166ef7d48 100755 --- a/tests/scripts/thread-cert/border_router/test_dnssd_server_multi_border_routers.py +++ b/tests/scripts/thread-cert/border_router/test_dnssd_server_multi_border_routers.py @@ -155,6 +155,7 @@ def test(self): def is_int(x): return isinstance(x, int) + # 1. Check hosts & services published by Advertising Proxy. # check if AAAA query works dig_result = host.dns_dig(br2_addr, host1_full_name, 'AAAA') self._assert_dig_result_matches(dig_result, { @@ -219,7 +220,64 @@ def is_int(x): ], }]) - # check some invalid queries + # 2. Check the host & service published by a WiFi host. + # check if AAAA query works + wifi_host_linklocal_address = 'fe80::1234' + wifi_host_routable_address = '2402::abcd' + wifi_host_full_name = f'wifi-host.{DOMAIN}' + wifi_service_instance_full_name = f'wifi-service._host._tcp.{DOMAIN}' + host.publish_mdns_host('wifi-host', [wifi_host_linklocal_address, wifi_host_routable_address]) + host.publish_mdns_service('wifi-service', '_host._tcp', 12345, 'wifi-host', {'k1': 'v1', 'k2': 'v2'}) + dig_result = host.dns_dig(br2_addr, wifi_host_full_name, 'AAAA') + self._assert_dig_result_matches( + dig_result, { + 'QUESTION': [(wifi_host_full_name, 'IN', 'AAAA')], + 'ANSWER': [(wifi_host_full_name, 'IN', 'AAAA', wifi_host_routable_address),], + }) + + # check if SRV query works + dig_result = host.dns_dig(br2_addr, wifi_service_instance_full_name, 'SRV') + self._assert_dig_result_matches( + dig_result, { + 'QUESTION': [(wifi_service_instance_full_name, 'IN', 'SRV')], + 'ANSWER': [(wifi_service_instance_full_name, 'IN', 'SRV', is_int, is_int, 12345, wifi_host_full_name), + ], + 'ADDITIONAL': [(wifi_host_full_name, 'IN', 'AAAA', wifi_host_routable_address),], + }) + + # check if TXT query works + dig_result = host.dns_dig(br2_addr, wifi_service_instance_full_name, 'TXT') + self._assert_dig_result_matches( + dig_result, { + 'QUESTION': [(wifi_service_instance_full_name, 'IN', 'TXT')], + 'ANSWER': [(wifi_service_instance_full_name, 'IN', 'TXT', { + 'k1': 'v1', + 'k2': 'v2' + })], + }) + + # check if PTR query works + dig_result = host.dns_dig(br2_addr, f'_host._tcp.{DOMAIN}', 'PTR') + + self._assert_dig_result_matches_any(dig_result, [{ + 'QUESTION': [(f'_host._tcp.{DOMAIN}', 'IN', 'PTR')], + 'ANSWER': [(f'_host._tcp.{DOMAIN}', 'IN', 'PTR', wifi_service_instance_full_name)], + 'ADDITIONAL': [ + (wifi_service_instance_full_name, 'IN', 'SRV', is_int, is_int, 12345, wifi_host_full_name), + (wifi_service_instance_full_name, 'IN', 'TXT', { + 'k1': 'v1', + 'k2': 'v2' + }), + (wifi_host_full_name, 'IN', 'AAAA', wifi_host_routable_address), + ], + }]) + + host.bash('pkill avahi-publish') + + # 3. Verify Discovery Proxy works for _meshcop._udp published by BR. + self._verify_discovery_proxy_meshcop(br2_addr, br2.get_network_name(), host) + + # 4. Check some invalid queries for qtype in ['A', 'CNAME']: dig_result = host.dns_dig(br2_addr, host1_full_name, qtype) self._assert_dig_result_matches(dig_result, { @@ -232,9 +290,6 @@ def is_int(x): 'status': 'NXDOMAIN', }) - # verify Discovery Proxy works for _meshcop._udp - self._verify_discovery_proxy_meshcop(br2_addr, br2.get_network_name(), host) - def _verify_discovery_proxy_meshcop(self, server_addr, network_name, digger): dp_service_name = '_meshcop._udp.default.service.arpa.' dp_hostname = lambda x: x.endswith('.default.service.arpa.') @@ -300,7 +355,8 @@ def _config_srp_client_services(self, client, instancename, hostname, port, prio client.srp_client_set_host_address(*addrs) client.srp_client_add_service(instancename, SERVICE, port, priority, weight) - self.simulator.go(5) + self.simulator.go(10) + self.assertEqual(client.srp_client_get_host_state(), 'Registered') def _assert_have_question(self, dig_result, question): diff --git a/tests/scripts/thread-cert/border_router/test_multi_thread_networks.py b/tests/scripts/thread-cert/border_router/test_multi_thread_networks.py index bc2bb38a80d..4e0823b0aa3 100755 --- a/tests/scripts/thread-cert/border_router/test_multi_thread_networks.py +++ b/tests/scripts/thread-cert/border_router/test_multi_thread_networks.py @@ -33,7 +33,7 @@ import thread_cert # Test description: -# This test verifies bi-directional connectivity accross multiple Thread networks. +# This test verifies bi-directional connectivity across multiple Thread networks. # # Topology: # -------------(eth)---------------- diff --git a/tests/scripts/thread-cert/border_router/test_publish_meshcop_service.py b/tests/scripts/thread-cert/border_router/test_publish_meshcop_service.py index afc8d33499b..d0dafad0a33 100755 --- a/tests/scripts/thread-cert/border_router/test_publish_meshcop_service.py +++ b/tests/scripts/thread-cert/border_router/test_publish_meshcop_service.py @@ -26,6 +26,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +import binascii import ipaddress import logging import unittest @@ -82,8 +83,8 @@ def test(self): br2.disable_br() # Use different network names to distinguish meshcop services - br1.set_network_name('ot-br1') - br2.set_network_name('ot-br2') + br1.set_active_dataset(updateExisting=True, network_name='ot-br1') + br2.set_active_dataset(updateExisting=True, network_name='ot-br2') host.start(start_radvd=False) self.simulator.go(20) @@ -101,13 +102,13 @@ def test(self): self.check_meshcop_service(br1, host) br1.stop() - br1.set_network_name('ot-br1-1') + br1.set_active_dataset(updateExisting=True, network_name='ot-br1-1') br1.start() self.simulator.go(config.BORDER_ROUTER_STARTUP_DELAY) self.check_meshcop_service(br1, host) # verify that there are two meshcop services - br2.set_network_name('ot-br2-1') + br2.set_active_dataset(updateExisting=True, network_name='ot-br2-1') br2.start() br2.disable_backbone_router() br2.enable_br() @@ -131,7 +132,22 @@ def test(self): self.check_meshcop_service(br2, host) br1.factory_reset() - br1.set_network_name('ot-br-1-3') + + dataset = { + 'timestamp': 1, + 'channel': config.CHANNEL, + 'channel_mask': config.CHANNEL_MASK, + 'extended_panid': config.EXTENDED_PANID, + 'mesh_local_prefix': config.MESH_LOCAL_PREFIX.split('/')[0], + 'network_key': binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode(), + 'network_name': 'ot-br-1-3', + 'panid': config.PANID, + 'pskc': config.PSKC, + 'security_policy': config.SECURITY_POLICY, + } + + br1.set_active_dataset(**dataset) + self.assertEqual(len(host.browse_mdns_services('_meshcop._udp')), 2) self.check_meshcop_service(br1, host) self.check_meshcop_service(br2, host) diff --git a/tests/scripts/thread-cert/coap.py b/tests/scripts/thread-cert/coap.py index 6fec6f2ef6c..337e91c1cc4 100644 --- a/tests/scripts/thread-cert/coap.py +++ b/tests/scripts/thread-cert/coap.py @@ -61,7 +61,7 @@ class CoapOptionsTypes(IntEnum): class CoapOptionHeader(object): - """ Class representing CoAP optiona header. """ + """ Class representing CoAP optional header. """ def __init__(self, delta, length): self._delta = delta diff --git a/tests/scripts/thread-cert/command.py b/tests/scripts/thread-cert/command.py index e1944932baa..419840f0212 100644 --- a/tests/scripts/thread-cert/command.py +++ b/tests/scripts/thread-cert/command.py @@ -682,7 +682,7 @@ def check_joiner_router_commissioning_messages(commissioning_messages): def check_payload_same(tp1, tp2): - """Verfiy two payloads are totally the same. + """Verify two payloads are totally the same. A payload is a tuple of tlvs. """ assert len(tp1) == len(tp2) diff --git a/tests/scripts/thread-cert/config.py b/tests/scripts/thread-cert/config.py index cf04cbe7458..ffb4dc6b454 100644 --- a/tests/scripts/thread-cert/config.py +++ b/tests/scripts/thread-cert/config.py @@ -123,7 +123,14 @@ class ADDRESS_TYPE(Enum): } SNIFFER_ID = int(os.getenv('SNIFFER_ID', 34)) + +CHANNEL = 11 +CHANNEL_MASK = 0x07fff800 +EXTENDED_PANID = 'dead00beef00cafe' +NETWORK_NAME = 'OpenThread' PANID = 0xface +PSKC = 'c23a76e98f1a6483639b1ac1271e2e27' +SECURITY_POLICY = [672, 'onrc'] LEADER_STARTUP_DELAY = 12 ROUTER_STARTUP_DELAY = 10 @@ -330,7 +337,7 @@ def create_deafult_network_tlvs_factories(): network_layer.TlvType.XTAL_ACCURACY: network_layer.XtalAccuracyFactory(), # Routing information are distributed in a Thread network by MLE Routing TLV - # which is in fact MLE Route64 TLV. Thread specificaton v1.1. - Chapter 5.20 + # which is in fact MLE Route64 TLV. Thread specification v1.1. - Chapter 5.20 network_layer.TlvType.MLE_ROUTING: create_default_mle_tlv_route64_factory(), network_layer.TlvType.IPv6_ADDRESSES: diff --git a/tests/scripts/thread-cert/ipv6.py b/tests/scripts/thread-cert/ipv6.py index ab00a26e91d..f4915742aff 100644 --- a/tests/scripts/thread-cert/ipv6.py +++ b/tests/scripts/thread-cert/ipv6.py @@ -622,7 +622,7 @@ class FragmentHeader(ExtensionHeader): | Next Header | Reserved | Fragment Offset | Res | M | Identification | +-------------+----------+-----------------+-----+---+----------------+ - Fragment extention header consists of: + Fragment extension header consists of: - next_header type (8 bit) - fragment offset which is multiple of 8 (13 bit) - more_flag to indicate further data (1 bit) @@ -1010,7 +1010,7 @@ def parse(self, data, message_info): hdr_ext_len = ord(data.read(1)) # Note! Two bytes were read (next_header and hdr_ext_len) so they must - # be substracted from header length + # be subtracted from header length hop_by_hop_length = (self._calculate_extension_header_length(hdr_ext_len) - 2) hop_by_hop_data = data.read(hop_by_hop_length) diff --git a/tests/scripts/thread-cert/mcast6.py b/tests/scripts/thread-cert/mcast6.py index b090fd95fb4..8699d5c73c9 100755 --- a/tests/scripts/thread-cert/mcast6.py +++ b/tests/scripts/thread-cert/mcast6.py @@ -57,7 +57,7 @@ def if_indextoname(index): ifname = ctypes.create_string_buffer(32) ifname = libc.if_indextoname(index, ifname) if not ifname: - raise RuntimeError("Inavlid Index") + raise RuntimeError("Invalid Index") return ifname diff --git a/tests/scripts/thread-cert/mle.py b/tests/scripts/thread-cert/mle.py index 0c826ad98fb..2bf6c9313e6 100644 --- a/tests/scripts/thread-cert/mle.py +++ b/tests/scripts/thread-cert/mle.py @@ -332,7 +332,7 @@ def __eq__(self, other): return (self.output == other.output and self.input == other.input and self.route == other.route) def __repr__(self): - return "LinkQualityAndRouteData(ouput={}, input={}, route={})".format(self.output, self.input, self.route) + return "LinkQualityAndRouteData(output={}, input={}, route={})".format(self.output, self.input, self.route) class LinkQualityAndRouteDataFactory: diff --git a/tests/scripts/thread-cert/node.py b/tests/scripts/thread-cert/node.py index 57a41b2d80e..4124cb10cfd 100755 --- a/tests/scripts/thread-cert/node.py +++ b/tests/scripts/thread-cert/node.py @@ -413,6 +413,19 @@ def _process_packet_counters(self, counter): def nat64_set_enabled(self, enable): return self.call_dbus_method('io.openthread.BorderRouter', 'SetNat64Enabled', enable) + @property + def nat64_cidr(self): + self.send_command('nat64 cidr') + cidr = self._expect_command_output()[0].strip() + return ipaddress.IPv4Network(cidr, strict=False) + + @nat64_cidr.setter + def nat64_cidr(self, cidr: ipaddress.IPv4Network): + if not isinstance(cidr, ipaddress.IPv4Network): + raise ValueError("cidr is expected to be an instance of ipaddress.IPv4Network") + self.send_command(f'nat64 cidr {cidr}') + self._expect_done() + @property def nat64_state(self): state = self.get_dbus_property('Nat64State') @@ -749,7 +762,6 @@ def __init__(self, nodeid, name=None, simulator=None, **kwargs): super().__init__(nodeid, **kwargs) - self.set_mesh_local_prefix(config.MESH_LOCAL_PREFIX) self.set_addr64('%016x' % (thread_cert.EXTENDED_ADDRESS_BASE + nodeid)) def _expect(self, pattern, timeout=-1, *args, **kwargs): @@ -2535,38 +2547,68 @@ def set_router_selection_jitter(self, jitter): def set_active_dataset( self, - timestamp, - panid=None, + timestamp=None, channel=None, channel_mask=None, + extended_panid=None, + mesh_local_prefix=None, network_key=None, + network_name=None, + panid=None, + pskc=None, security_policy=[], + updateExisting=False, ): - self.send_command('dataset clear') - self._expect_done() - cmd = 'dataset activetimestamp %d' % timestamp - self.send_command(cmd) + if updateExisting: + self.send_command('dataset init active', go=False) + else: + self.send_command('dataset clear', go=False) self._expect_done() - if panid is not None: - cmd = 'dataset panid %d' % panid - self.send_command(cmd) + if timestamp is not None: + cmd = 'dataset activetimestamp %d' % timestamp + self.send_command(cmd, go=False) self._expect_done() if channel is not None: cmd = 'dataset channel %d' % channel - self.send_command(cmd) + self.send_command(cmd, go=False) self._expect_done() if channel_mask is not None: cmd = 'dataset channelmask %d' % channel_mask - self.send_command(cmd) + self.send_command(cmd, go=False) + self._expect_done() + + if extended_panid is not None: + cmd = 'dataset extpanid %s' % extended_panid + self.send_command(cmd, go=False) + self._expect_done() + + if mesh_local_prefix is not None: + cmd = 'dataset meshlocalprefix %s' % mesh_local_prefix + self.send_command(cmd, go=False) self._expect_done() if network_key is not None: cmd = 'dataset networkkey %s' % network_key - self.send_command(cmd) + self.send_command(cmd, go=False) + self._expect_done() + + if network_name is not None: + cmd = 'dataset networkname %s' % network_name + self.send_command(cmd, go=False) + self._expect_done() + + if panid is not None: + cmd = 'dataset panid %d' % panid + self.send_command(cmd, go=False) + self._expect_done() + + if pskc is not None: + cmd = 'dataset pskc %s' % pskc + self.send_command(cmd, go=False) self._expect_done() if security_policy and len(security_policy) == 2: @@ -2574,14 +2616,10 @@ def set_active_dataset( str(security_policy[0]), security_policy[1], ) - self.send_command(cmd) + self.send_command(cmd, go=False) self._expect_done() - # Set the meshlocal prefix in config.py - self.send_command('dataset meshlocalprefix %s' % config.MESH_LOCAL_PREFIX.split('/')[0]) - self._expect_done() - - self.send_command('dataset commit active') + self.send_command('dataset commit active', go=False) self._expect_done() def set_pending_dataset(self, pendingtimestamp, activetimestamp, panid=None, channel=None, delay=None): @@ -3173,7 +3211,7 @@ def link_metrics_query_forward_tracking_series(self, dst_addr: str, series_id: i def _parse_linkmetrics_query_result(self, lines): """Parse link metrics query result""" - # Exmaple of command output: + # Example of command output: # ['Received Link Metrics Report from: fe80:0:0:0:146e:a00:0:1', # '- PDU Counter: 1 (Count/Summation)', # '- LQI: 0 (Exponential Moving Average)', @@ -3644,6 +3682,30 @@ def ip_neighbors_flush(self): (self.ETH_DEV, self.ETH_DEV)) self.bash(f'ip -6 neigh list dev {self.ETH_DEV}') + def publish_mdns_service(self, instance_name, service_type, port, host_name, txt): + """Publish an mDNS service on the Ethernet. + + :param instance_name: the service instance name. + :param service_type: the service type in format of '.'. + :param port: the port the service is at. + :param host_name: the host name this service points to. The domain + should not be included. + :param txt: a dictionary containing the key-value pairs of the TXT record. + """ + txt_string = ' '.join([f'{key}={value}' for key, value in txt.items()]) + self.bash(f'avahi-publish -s {instance_name} {service_type} {port} -H {host_name}.local {txt_string} &') + + def publish_mdns_host(self, hostname, addresses): + """Publish an mDNS host on the Ethernet + + :param host_name: the host name this service points to. The domain + should not be included. + :param addresses: a list of strings representing the addresses to + be registered with the host. + """ + for address in addresses: + self.bash(f'avahi-publish -a {hostname}.local {address} &') + def browse_mdns_services(self, name, timeout=2): """ Browse mDNS services on the ethernet. diff --git a/tests/scripts/thread-cert/pktverify/utils.py b/tests/scripts/thread-cert/pktverify/utils.py index 7d57ce05ed7..9eeb3ed26b9 100644 --- a/tests/scripts/thread-cert/pktverify/utils.py +++ b/tests/scripts/thread-cert/pktverify/utils.py @@ -140,11 +140,11 @@ def which_mergecap() -> str: def colon_hex(hexstr, interval) -> str: - """ Convert hexstr to colon seperated string every interval + """ Convert hexstr to colon separated string every interval :param hexstr: The hex string to convert. :param interval: The interval number. - :return: The colon seperated string. + :return: The colon separated string. """ assert len(hexstr) % interval == 0 return ':'.join(hexstr[i:i + interval] for i in range(0, len(hexstr), interval)) diff --git a/tests/scripts/thread-cert/thread_cert.py b/tests/scripts/thread-cert/thread_cert.py index 7277d3bb916..9603309ba72 100644 --- a/tests/scripts/thread-cert/thread_cert.py +++ b/tests/scripts/thread-cert/thread_cert.py @@ -64,7 +64,6 @@ 'mode': 'rdn', 'allowlist': None, 'version': ENV_THREAD_VERSION, - 'panid': 0xface, } """Default configurations when creating nodes.""" @@ -179,20 +178,10 @@ def _setUp(self): if node.is_host: continue - self.nodes[i].set_networkkey(binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode()) - self.nodes[i].set_panid(params['panid']) self.nodes[i].set_mode(params['mode']) - if 'extended_panid' in params: - self.nodes[i].set_extpanid(params['extended_panid']) if 'partition_id' in params: self.nodes[i].set_preferred_partition_id(params['partition_id']) - if 'channel' in params: - self.nodes[i].set_channel(params['channel']) - if 'networkkey' in params: - self.nodes[i].set_networkkey(params['networkkey']) - if 'network_name' in params: - self.nodes[i].set_network_name(params['network_name']) if params['is_ftd']: self.nodes[i].set_router_selection_jitter(params['router_selection_jitter']) @@ -209,15 +198,7 @@ def _setUp(self): if 'timeout' in params: self.nodes[i].set_timeout(params['timeout']) - if 'active_dataset' in params: - if 'network_key' not in params['active_dataset']: - params['active_dataset']['network_key'] = binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode() - self.nodes[i].set_active_dataset(params['active_dataset']['timestamp'], - panid=params['active_dataset'].get('panid'), - channel=params['active_dataset'].get('channel'), - channel_mask=params['active_dataset'].get('channel_mask'), - network_key=params['active_dataset'].get('network_key'), - security_policy=params['active_dataset'].get('security_policy')) + self._set_up_active_dataset(self.nodes[i], params) if 'pending_dataset' in params: self.nodes[i].set_pending_dataset(params['pending_dataset']['pendingtimestamp'], @@ -262,6 +243,34 @@ def _setUp(self): self._inspector = debug.Inspector(self) self._collect_test_info_after_setup() + def _set_up_active_dataset(self, node, params): + dataset = { + 'timestamp': 1, + 'channel': config.CHANNEL, + 'channel_mask': config.CHANNEL_MASK, + 'extended_panid': config.EXTENDED_PANID, + 'mesh_local_prefix': config.MESH_LOCAL_PREFIX.split('/')[0], + 'network_key': binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode(), + 'network_name': config.NETWORK_NAME, + 'panid': config.PANID, + 'pskc': config.PSKC, + 'security_policy': config.SECURITY_POLICY, + } + + if 'channel' in params: + dataset['channel'] = params['channel'] + if 'networkkey' in params: + dataset['network_key'] = params['networkkey'] + if 'network_name' in params: + dataset['network_name'] = params['network_name'] + if 'panid' in params: + dataset['panid'] = params['panid'] + + if 'active_dataset' in params: + dataset.update(params['active_dataset']) + + node.set_active_dataset(**dataset) + def inspect(self): self._inspector.inspect() diff --git a/tests/scripts/thread-cert/v1_2_test_domain_unicast_address.py b/tests/scripts/thread-cert/v1_2_test_domain_unicast_address.py index 13c195016fe..7a98680a248 100755 --- a/tests/scripts/thread-cert/v1_2_test_domain_unicast_address.py +++ b/tests/scripts/thread-cert/v1_2_test_domain_unicast_address.py @@ -137,7 +137,7 @@ def __get_iid(self, address): def __check_dua_registration(self, node, iid, dp_cid): ''' Check whether or not the specified Domain Unicast Address is registered in Address - Registraion TLV. + Registration TLV. Args: node (int) : The device id diff --git a/tests/scripts/thread-cert/v1_2_test_domain_unicast_address_registration.py b/tests/scripts/thread-cert/v1_2_test_domain_unicast_address_registration.py index dfbf3140f9b..4053feca023 100755 --- a/tests/scripts/thread-cert/v1_2_test_domain_unicast_address_registration.py +++ b/tests/scripts/thread-cert/v1_2_test_domain_unicast_address_registration.py @@ -165,13 +165,13 @@ def __get_iid(self, address): ''' return ''.join(ipaddress.ip_address(address).exploded.split(':')[4:]) - def __check_dua_registration_tmf(self, node, occurences=1, ml_eid=None): + def __check_dua_registration_tmf(self, node, occurrences=1, ml_eid=None): messages = self.simulator.get_messages_sent_by(node) - for i in range(occurences): + for i in range(occurrences): msg = messages.next_coap_message('0.02', '/n/dr', False) assert msg, 'Expected {}, but {}th not found\n node: {}(extaddr: {})'.format( - occurences, i + 1, node, self.nodes[node].get_addr64()) + occurrences, i + 1, node, self.nodes[node].get_addr64()) if ml_eid: ml_eid_tlv = msg.get_coap_message_tlv(network_layer.MlEid) self.assertEqual(ml_eid, ml_eid_tlv.ml_eid.hex()) diff --git a/tests/scripts/thread-cert/v1_2_test_multicast_listener_registration.py b/tests/scripts/thread-cert/v1_2_test_multicast_listener_registration.py index c6d369e45dc..18875362cf0 100755 --- a/tests/scripts/thread-cert/v1_2_test_multicast_listener_registration.py +++ b/tests/scripts/thread-cert/v1_2_test_multicast_listener_registration.py @@ -891,7 +891,7 @@ def __check_not_send_mlr_req_if_subscribed(self, meds, parent_id): self.simulator.go(WAIT_REDUNDANCE) self.__check_send_mlr_req(parent_id, MA1, should_send=True, expect_mlr_rsp=True) - # Parent should not register MA1 of Child 1 because it's already registerd + # Parent should not register MA1 of Child 1 because it's already registered self.flush_all() self.nodes[meds[0]].add_ipmaddr(MA1) self.simulator.go(PARENT_AGGREGATE_DELAY + WAIT_REDUNDANCE) diff --git a/tests/scripts/thread-cert/v1_2_test_multicast_registration.py b/tests/scripts/thread-cert/v1_2_test_multicast_registration.py index 67537b7eed8..8001261a4fb 100755 --- a/tests/scripts/thread-cert/v1_2_test_multicast_registration.py +++ b/tests/scripts/thread-cert/v1_2_test_multicast_registration.py @@ -144,7 +144,7 @@ def __check_multicast_registration(self, in_address_registration=True): ''' Check whether or not the addition of the multicast address on the specific node would trigger Child Update Request for multicast address registration via Address - Registraion TLV. + Registration TLV. Args: node (int) : The device id diff --git a/tests/toranj/README_CLI.md b/tests/toranj/README_CLI.md index 024a3219d80..358a9b4b1e0 100644 --- a/tests/toranj/README_CLI.md +++ b/tests/toranj/README_CLI.md @@ -14,21 +14,7 @@ To build OpenThread with `toranj` configuration, the `test/toranj/build.sh` script can be used: ```bash -$ ./tests/toranj/build.sh cmake -==================================================================================================== -Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake -==================================================================================================== --- OpenThread Source Directory: /Users/abtink/GitHub/openthread --- OpenThread CMake build type: Debug --- Package Name: OPENTHREAD -... - -``` - -Or to build using autoconf/make we can use: - -```bash -$ ./tests/toranj/build.sh cli +$ ./tests/toranj/build.sh all ==================================================================================================== Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake ==================================================================================================== diff --git a/tests/toranj/build.sh b/tests/toranj/build.sh index 09428132cfd..fb5634853d5 100755 --- a/tests/toranj/build.sh +++ b/tests/toranj/build.sh @@ -34,25 +34,23 @@ display_usage() echo "" echo "Usage: $(basename "$0") [options] " echo " can be:" - echo " ncp : Build OpenThread NCP FTD mode with simulation platform" - echo " ncp-15.4 : Build OpenThread NCP FTD mode with simulation platform - 15.4 radio" - echo " ncp-trel : Build OpenThread NCP FTD mode with simulation platform - TREL radio " - echo " ncp-15.4+trel : Build OpenThread NCP FTD mode with simulation platform - multi radio (15.4+TREL)" - echo " cli : Build OpenThread CLI FTD mode with simulation platform" - echo " cli-15.4 : Build OpenThread CLI FTD mode with simulation platform - 15.4 radio" - echo " cli-trel : Build OpenThread CLI FTD mode with simulation platform - TREL radio " - echo " cli-15.4+trel : Build OpenThread CLI FTD mode with simulation platform - multi radio (15.4+TREL)" + echo " all : Build OpenThread NCP, CLI, and RCP with simulation platform" + echo " ncp : Build OpenThread NCP mode with simulation platform" + echo " ncp-15.4 : Build OpenThread NCP mode with simulation platform - 15.4 radio" + echo " ncp-trel : Build OpenThread NCP mode with simulation platform - TREL radio " + echo " ncp-15.4+trel : Build OpenThread NCP mode with simulation platform - multi radio (15.4+TREL)" + echo " cli : Build OpenThread CLI mode with simulation platform" + echo " cli-15.4 : Build OpenThread CLI mode with simulation platform - 15.4 radio" + echo " cli-trel : Build OpenThread CLI mode with simulation platform - TREL radio " + echo " cli-15.4+trel : Build OpenThread CLI mode with simulation platform - multi radio (15.4+TREL)" echo " rcp : Build OpenThread RCP (NCP in radio mode) with simulation platform" - echo " posix : Build OpenThread POSIX NCP" - echo " posix-15.4 : Build OpenThread POSIX NCP - 15.4 radio" - echo " posix-trel : Build OpenThread POSIX NCP - TREL radio " - echo " posix-15.4+trel : Build OpenThread POSIX NCP - multi radio (15.4+TREL)" - echo " cmake : Configure and build OpenThread using cmake/ninja (RCP and NCP) only" - echo " cmake-posix: : Configure and build OpenThread POSIX using cmake/ninja" + echo " posix : Build OpenThread POSIX" + echo " posix-15.4 : Build OpenThread POSIX - 15.4 radio" + echo " posix-trel : Build OpenThread POSIX - TREL radio " + echo " posix-15.4+trel : Build OpenThread POSIX - multi radio (15.4+TREL)" echo "" echo "Options:" echo " -c/--enable-coverage Enable code coverage" - echo " -t/--enable-tests Enable tests" echo "" } @@ -65,20 +63,15 @@ die() cd "$(dirname "$0")" || die "cd failed" cd ../.. || die "cd failed" -coverage=no -tests=no - ot_coverage=OFF while [ $# -ge 2 ]; do case $1 in -c | --enable-coverage) - coverage=yes ot_coverage=ON shift ;; -t | --enable-tests) - tests=yes shift ;; "") @@ -99,22 +92,6 @@ fi build_config=$1 -ncp_configure_options=( - "--disable-docs" - "--enable-tests=$tests" - "--enable-coverage=$coverage" - "--enable-ftd" - "--enable-ncp" -) - -posix_configure_options=( - "--disable-docs" - "--enable-tests=$tests" - "--enable-coverage=$coverage" - "--enable-ftd" - "--enable-cli" -) - if [ -n "${top_builddir}" ]; then top_srcdir=$(pwd) mkdir -p "${top_builddir}" @@ -126,76 +103,65 @@ fi case ${build_config} in ncp | ncp-) echo "===================================================================================================" - echo "Building OpenThread NCP FTD mode with simulation platform (radios determined by config)" + echo "Building OpenThread NCP with simulation platform (radios determined by config)" echo "===================================================================================================" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"' - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-examples=simulation \ - "${ncp_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ + "${top_srcdir}" || die + ninja || die ;; ncp-15.4) echo "===================================================================================================" - echo "Building OpenThread NCP FTD mode with simulation platform - 15.4 radio" + echo "Building OpenThread NCP with simulation platform - 15.4 radio" echo "===================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=0" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-examples=simulation \ - "${ncp_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=ON -DOT_TREL=OFF \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ + "${top_srcdir}" || die + ninja || die cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-15.4 ;; ncp-trel) echo "===================================================================================================" - echo "Building OpenThread NCP FTD mode with simulation platform - TREL radio" + echo "Building OpenThread NCP with simulation platform - TREL radio" echo "===================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=0" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-examples=simulation \ - "${ncp_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=OFF -DOT_TREL=ON \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ + "${top_srcdir}" || die + ninja || die cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-trel ;; ncp-15.4+trel | ncp-trel+15.4) echo "===================================================================================================" - echo "Building OpenThread NCP FTD mode with simulation platform - multi radio (15.4 + TREL)" + echo "Building OpenThread NCP with simulation platform - multi radio (15.4 + TREL)" echo "===================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-examples=simulation \ - "${ncp_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=ON -DOT_TREL=ON \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ + "${top_srcdir}" || die + ninja || die cp -p ${top_builddir}/examples/apps/ncp/ot-ncp-ftd ${top_builddir}/examples/apps/ncp/ot-ncp-ftd-15.4-trel ;; cli | cli-) echo "===================================================================================================" - echo "Building OpenThread CLI FTD mode with simulation platform (radios determined by config)" + echo "Building OpenThread CLI with simulation platform (radios determined by config)" echo "===================================================================================================" cd "${top_builddir}" || die "cd failed" cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ - -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ "${top_srcdir}" || die ninja || die @@ -203,11 +169,11 @@ case ${build_config} in cli-15.4) echo "===================================================================================================" - echo "Building OpenThread CLI FTD mode with simulation platform - 15.4 radio" + echo "Building OpenThread CLI with simulation platform - 15.4 radio" echo "===================================================================================================" cd "${top_builddir}" || die "cd failed" cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ - -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ -DOT_15_4=ON -DOT_TREL=OFF \ -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ "${top_srcdir}" || die @@ -217,11 +183,11 @@ case ${build_config} in cli-trel) echo "===================================================================================================" - echo "Building OpenThread CLI FTD mode with simulation platform - TREL radio" + echo "Building OpenThread CLI with simulation platform - TREL radio" echo "===================================================================================================" cd "${top_builddir}" || die "cd failed" cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ - -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ -DOT_15_4=OFF -DOT_TREL=ON \ -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ "${top_srcdir}" || die @@ -231,11 +197,11 @@ case ${build_config} in cli-15.4+trel | cli-trel+15.4) echo "===================================================================================================" - echo "Building OpenThread NCP FTD mode with simulation platform - multi radio (15.4 + TREL)" + echo "Building OpenThread NCP with simulation platform - multi radio (15.4 + TREL)" echo "===================================================================================================" cd "${top_builddir}" || die "cd failed" cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ - -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=OFF -DOT_APP_RCP=OFF \ -DOT_15_4=ON -DOT_TREL=ON \ -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ "${top_srcdir}" || die @@ -247,105 +213,77 @@ case ${build_config} in echo "====================================================================================================" echo "Building OpenThread RCP (NCP in radio mode) with simulation platform" echo "====================================================================================================" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-simulation.h\"' - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config " \ - --enable-coverage=${coverage} \ - --enable-ncp \ - --enable-radio-only \ - --with-examples=simulation \ - --disable-docs \ - --enable-tests=$tests || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=OFF -DOT_APP_RCP=ON \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ + "${top_srcdir}" || die + ninja || die ;; - posix | posix-) + posix | posix- | cmake-posix-host | cmake-posix | cmake-p) echo "====================================================================================================" echo "Building OpenThread POSIX (radios determined by config)" echo "====================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"' - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-platform=posix \ - "${posix_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \ + "${top_srcdir}" || die + ninja || die ;; posix-15.4) echo "====================================================================================================" echo "Building OpenThread POSIX - 15.4 radio" echo "====================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=0" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-platform=posix \ - "${posix_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=ON -DOT_TREL=OFF \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \ + "${top_srcdir}" || die + ninja || die ;; posix-trel) echo "====================================================================================================" echo "Building OpenThread POSIX - TREL radio" echo "====================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=0" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-platform=posix \ - "${posix_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=OFF -DOT_TREL=ON \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \ + "${top_srcdir}" || die + ninja || die ;; posix-trel+15.4 | posix-15.4+trel) echo "====================================================================================================" echo "Building OpenThread POSIX - multi radio link (15.4 + TREL)" echo "====================================================================================================" - cppflags_config='-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"../tests/toranj/openthread-core-toranj-config-posix.h\"' - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE=1" - cppflags_config="${cppflags_config} -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1" - ./bootstrap || die "bootstrap failed" cd "${top_builddir}" || die "cd failed" - ${top_srcdir}/configure \ - CPPFLAGS="$cppflags_config" \ - --with-platform=posix \ - "${posix_configure_options[@]}" || die - make -j 8 || die + cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \ + -DOT_15_4=ON -DOT_TREL=ON \ + -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \ + "${top_srcdir}" || die + ninja || die ;; - cmake) + all | cmake) echo "====================================================================================================" echo "Building OpenThread (NCP/CLI for FTD/MTD/RCP mode) with simulation platform using cmake" echo "====================================================================================================" cd "${top_builddir}" || die "cd failed" cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \ - -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=ON \ + -DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=ON \ -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \ "${top_srcdir}" || die ninja || die ;; - cmake-posix-host | cmake-posix | cmake-p) - echo "====================================================================================================" - echo "Building OpenThread POSIX using cmake" - echo "====================================================================================================" - cd "${top_builddir}" || die "cd failed" - cmake -GNinja -DOT_PLATFORM=posix -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_APP_CLI=OFF \ - -DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-posix.h \ - "${top_srcdir}" || die - ninja || die - ;; - *) echo "Error: Unknown configuration \"$1\"" display_usage diff --git a/tests/toranj/cli/cli.py b/tests/toranj/cli/cli.py index fd24205b86b..ee496d646ca 100644 --- a/tests/toranj/cli/cli.py +++ b/tests/toranj/cli/cli.py @@ -411,6 +411,9 @@ def get_netdata_versions(self): leaderdata = Node.parse_list(self.cli('leaderdata')) return (int(leaderdata['Data Version']), int(leaderdata['Stable Data Version'])) + def get_netdata_length(self): + return self._cli_single_output('netdata length') + def add_prefix(self, prefix, flags=None, prf=None): return self._cli_no_output('prefix add', prefix, flags, prf) @@ -423,6 +426,12 @@ def remove_prefix(self, prefix): def register_netdata(self): self._cli_no_output('netdata register') + def get_netdata_full(self): + return self._cli_single_output('netdata full') + + def reset_netdata_full(self): + self._cli_no_output('netdata full reset') + #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ping and counters @@ -708,25 +717,29 @@ def srp_server_get_service(self, instance_name, service_name): # Helper methods def form(self, network_name=None, network_key=None, channel=None, panid=0x1234, xpanid=None): + self._cli_no_output('dataset init new') + self._cli_no_output('dataset panid', panid) if network_name is not None: - self.set_network_name(network_name) + self._cli_no_output('dataset networkname', network_name) if network_key is not None: - self.set_network_key(network_key) + self._cli_no_output('dataset networkkey', network_key) if channel is not None: - self.set_channel(channel) + self._cli_no_output('dataset channel', channel) if xpanid is not None: - self.set_ext_panid(xpanid) + self._cli_no_output('dataset extpanid', xpanid) + self._cli_no_output('dataset commit active') self.set_mode('rdn') - self.set_panid(panid) self.interface_up() self.thread_start() verify_within(_check_node_is_leader, self._WAIT_TIME, arg=self) def join(self, node, type=JOIN_TYPE_ROUTER): - self.set_network_name(node.get_network_name()) - self.set_network_key(node.get_network_key()) - self.set_channel(node.get_channel()) - self.set_panid(node.get_panid()) + self._cli_no_output('dataset clear') + self._cli_no_output('dataset networkname', node.get_network_name()) + self._cli_no_output('dataset networkkey', node.get_network_key()) + self._cli_no_output('dataset channel', node.get_channel()) + self._cli_no_output('dataset panid', node.get_panid()) + self._cli_no_output('dataset commit active') if type == JOIN_TYPE_END_DEVICE: self.set_mode('rn') elif type == JOIN_TYPE_SLEEPY_END_DEVICE: diff --git a/tests/toranj/cli/test-018-next-hop-and-path-cost.py b/tests/toranj/cli/test-018-next-hop-and-path-cost.py index b31b2f87816..ebaca1fc29c 100755 --- a/tests/toranj/cli/test-018-next-hop-and-path-cost.py +++ b/tests/toranj/cli/test-018-next-hop-and-path-cost.py @@ -120,7 +120,7 @@ def parse_nexthop(line): - # Exmaple: "0x5000 cost:3" -> (0x5000, 3). + # Example: "0x5000 cost:3" -> (0x5000, 3). items = line.strip().split(' ', 2) return (int(items[0], 16), int(items[1].split(':')[1])) diff --git a/tests/toranj/cli/test-022-netdata-full.py b/tests/toranj/cli/test-022-netdata-full.py new file mode 100755 index 00000000000..5111fca4300 --- /dev/null +++ b/tests/toranj/cli/test-022-netdata-full.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python3 +# +# 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. + +from cli import verify +from cli import verify_within +import cli +import time + +# ----------------------------------------------------------------------------------------------------------------------- +# Test description: Validate mechanism to detect when Network Data gets full and related callback. +# + +test_name = __file__[:-3] if __file__.endswith('.py') else __file__ +print('-' * 120) +print('Starting \'{}\''.format(test_name)) + +# ----------------------------------------------------------------------------------------------------------------------- +# Creating `cli.Node` instances + +speedup = 40 +cli.Node.set_time_speedup_factor(speedup) + +leader = cli.Node() +r1 = cli.Node() +r2 = cli.Node() +r3 = cli.Node() + +# ----------------------------------------------------------------------------------------------------------------------- +# Form topology + +leader.form('netdata-full') +r1.join(leader) +r2.join(r1) +r3.join(r1) + +verify(leader.get_state() == 'leader') +verify(r1.get_state() == 'router') +verify(r2.get_state() == 'router') +verify(r2.get_state() == 'router') + +# ----------------------------------------------------------------------------------------------------------------------- +# Test Implementation + +verify(leader.get_netdata_full() == 'no') +verify(r1.get_netdata_full() == 'no') +verify(r2.get_netdata_full() == 'no') +verify(r3.get_netdata_full() == 'no') + +# Add 7 routes from `r1` to netdata and make sure they are all +# successfully registered with leader. + +r1.add_route('fd00:1:0:1::/64', 's', 'med') +r1.add_route('fd00:1:0:2::/64', 's', 'med') +r1.add_route('fd00:1:0:3::/64', 's', 'med') +r1.add_route('fd00:1:0:4::/64', 's', 'med') +r1.add_route('fd00:1:0:5::/64', 's', 'med') +r1.add_route('fd00:1:0:6::/64', 's', 'med') +r1.add_route('fd00:1:0:7::/64', 's', 'med') +r1.register_netdata() + + +def check_netdata_after_r1(): + netdata = leader.get_netdata() + verify(len(netdata['routes']) == 7) + + +verify_within(check_netdata_after_r1, 5) + +verify(leader.get_netdata_full() == 'no') +verify(r1.get_netdata_full() == 'no') +verify(r2.get_netdata_full() == 'no') +verify(r3.get_netdata_full() == 'no') + +prev_len = int(leader.get_netdata_length()) + +# Now add 7 new routes from `r2` to netdata and make sure they are all +# successfully registered with leader. + +r2.add_route('fd00:2:0:1::/64', 's', 'med') +r2.add_route('fd00:2:0:2::/64', 's', 'med') +r2.add_route('fd00:2:0:3::/64', 's', 'med') +r2.add_route('fd00:2:0:4::/64', 's', 'med') +r2.add_route('fd00:2:0:5::/64', 's', 'med') +r2.add_route('fd00:2:0:6::/64', 's', 'med') +r2.add_route('fd00:2:0:7::/64', 's', 'med') +r2.register_netdata() + + +def check_netdata_after_r2(): + netdata = leader.get_netdata() + verify(len(netdata['routes']) == 14) + + +verify_within(check_netdata_after_r2, 5) + +verify(leader.get_netdata_full() == 'no') +verify(r1.get_netdata_full() == 'no') +verify(r2.get_netdata_full() == 'no') +verify(r3.get_netdata_full() == 'no') + +verify(int(leader.get_netdata_length()) > prev_len) + +# Try adding 3 routes from `r3`, this should cause netdata to go +# over its size limit. Make sure that both `r3` and `leader` +# detect that + +r3.add_route('fd00:3:0:1::/64', 's', 'med') +r3.add_route('fd00:3:0:2::/64', 's', 'med') +r3.add_route('fd00:3:0:3::/64', 's', 'med') +r3.register_netdata() + + +def check_netdata_after_r3(): + verify(leader.get_netdata_full() == 'yes') + verify(r1.get_netdata_full() == 'no') + verify(r2.get_netdata_full() == 'no') + verify(r3.get_netdata_full() == 'yes') + + +verify_within(check_netdata_after_r3, 5) + +r3.remove_prefix('fd00:3:0:1::/64') +r3.remove_prefix('fd00:3:0:2::/64') +r3.remove_prefix('fd00:3:0:3::/64') +r3.register_netdata() + +leader.reset_netdata_full() +r3.reset_netdata_full() + + +def check_netdata_after_remove_on_r3(): + verify(leader.get_netdata_full() == 'no') + verify(r1.get_netdata_full() == 'no') + verify(r2.get_netdata_full() == 'no') + verify(r3.get_netdata_full() == 'no') + + +verify_within(check_netdata_after_remove_on_r3, 5) + +r2.add_route('fd00:2:0:8::/64', 's', 'med') +r2.add_route('fd00:2:0:9::/64', 's', 'med') +r2.register_netdata() + + +def check_netdata_after_more_routes_on_r2(): + verify(leader.get_netdata_full() == 'yes') + verify(r1.get_netdata_full() == 'no') + verify(r2.get_netdata_full() == 'yes') + verify(r3.get_netdata_full() == 'no') + + +verify_within(check_netdata_after_more_routes_on_r2, 5) + +# ----------------------------------------------------------------------------------------------------------------------- +# Test finished + +cli.Node.finalize_all_nodes() + +print('\'{}\' passed.'.format(test_name)) diff --git a/tests/toranj/cli/test-601-channel-manager-channel-change.py b/tests/toranj/cli/test-601-channel-manager-channel-change.py index cb67d64f675..82be9f70f05 100755 --- a/tests/toranj/cli/test-601-channel-manager-channel-change.py +++ b/tests/toranj/cli/test-601-channel-manager-channel-change.py @@ -154,7 +154,7 @@ def check_channel_on_all_nodes(): r1.cli('channel manager change 17') time.sleep(5 / speedup) verify_within(check_channel_on_all_nodes, 10) -channael = 18 +channel = 18 r2.cli('channel manager change', channel) verify_within(check_channel_on_all_nodes, 10) diff --git a/tests/toranj/ncp/test-030-slaac-address-ncp.py b/tests/toranj/ncp/test-030-slaac-address-ncp.py index cbcc5e20c54..6bca1190c92 100644 --- a/tests/toranj/ncp/test-030-slaac-address-ncp.py +++ b/tests/toranj/ncp/test-030-slaac-address-ncp.py @@ -173,7 +173,7 @@ def check_prefix_and_slaac_address_are_added(): slaac_addrs = [node.find_ip6_address_with_prefix(PREFIX) for node in all_nodes] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Check recovery after reseting r1 and c1 (same SLAAC address to be added) +# Check recovery after resetting r1 and c1 (same SLAAC address to be added) r1.reset() wpan.verify_within(check_prefix_and_slaac_address_are_added, WAIT_INTERVAL) diff --git a/tests/toranj/ncp/wpan.py b/tests/toranj/ncp/wpan.py index 1dc313a7f4f..ffe20a2354f 100644 --- a/tests/toranj/ncp/wpan.py +++ b/tests/toranj/ncp/wpan.py @@ -747,7 +747,7 @@ def perform_async_tx_rx(timeout=20): while asyncore.socket_map: elapsed_time = time.time() - start_time if elapsed_time > timeout: - print('Performing aysnc tx/tx took too long ({}>{} sec)'.format(elapsed_time, timeout)) + print('Performing async tx/tx took too long ({}>{} sec)'.format(elapsed_time, timeout)) raise Node._NodeError('perform_tx_rx timed out ({}>{} sec)'.format(elapsed_time, timeout)) # perform a single asyncore loop asyncore.loop(timeout=0.5, count=1) diff --git a/tests/toranj/openthread-core-toranj-config-simulation.h b/tests/toranj/openthread-core-toranj-config-simulation.h index 04d6d0e566c..026811319c7 100644 --- a/tests/toranj/openthread-core-toranj-config-simulation.h +++ b/tests/toranj/openthread-core-toranj-config-simulation.h @@ -99,4 +99,12 @@ */ #define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1 +/** + * @def OPENTHREAD_CONFIG_RADIO_STATS_ENABLE + * + * Disable the radio statistics. + * + */ +#define OPENTHREAD_CONFIG_RADIO_STATS_ENABLE 0 + #endif /* OPENTHREAD_CORE_TORANJ_CONFIG_SIMULATION_H_ */ diff --git a/tests/toranj/openthread-core-toranj-config.h b/tests/toranj/openthread-core-toranj-config.h index 6f34920d46d..a1b20f07971 100644 --- a/tests/toranj/openthread-core-toranj-config.h +++ b/tests/toranj/openthread-core-toranj-config.h @@ -83,6 +83,14 @@ */ #define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1 +/** + * @def OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + * + * Define to 1 to enable ND handling on Thread interface on host. + * + */ +#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 1 + /** * @def OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE * diff --git a/tests/toranj/start.sh b/tests/toranj/start.sh index 2bc8fa996ec..550acd1f335 100755 --- a/tests/toranj/start.sh +++ b/tests/toranj/start.sh @@ -185,6 +185,7 @@ if [ "$TORANJ_CLI" = 1 ]; then run cli/test-018-next-hop-and-path-cost.py run cli/test-019-netdata-context-id.py run cli/test-020-net-diag-vendor-info.py + run cli/test-022-netdata-full.py run cli/test-400-srp-client-server.py run cli/test-601-channel-manager-channel-change.py # Skip the "channel-select" test on a TREL only radio link, since it diff --git a/tests/unit/test_aes.cpp b/tests/unit/test_aes.cpp index e88b1e20e33..4ed31edd110 100644 --- a/tests/unit/test_aes.cpp +++ b/tests/unit/test_aes.cpp @@ -234,7 +234,7 @@ void TestInPlaceAesCcmProcessing(void) VerifyOrQuit(message->GetLength() == msgLength + kTagLength); - // Decrpt in place + // Decrypt in place aesCcm.Init(kHeaderLength, msgLength - kHeaderLength, kTagLength, kNonce, sizeof(kNonce)); aesCcm.Header(header); aesCcm.Payload(*message, kHeaderLength, msgLength - kHeaderLength, ot::Crypto::AesCcm::kDecrypt); diff --git a/tests/unit/test_checksum.cpp b/tests/unit/test_checksum.cpp index b0b17b5f67e..82e74fdd7e9 100644 --- a/tests/unit/test_checksum.cpp +++ b/tests/unit/test_checksum.cpp @@ -190,7 +190,7 @@ void TestUdpMessageChecksum(void) // Write UDP header with a random payload. - Random::NonCrypto::FillBuffer(reinterpret_cast(&udpHeader), sizeof(udpHeader)); + Random::NonCrypto::Fill(udpHeader); udpHeader.SetChecksum(0); message->Write(0, udpHeader); @@ -258,7 +258,7 @@ void TestIcmp6MessageChecksum(void) // Write ICMP6 header with a random payload. - Random::NonCrypto::FillBuffer(reinterpret_cast(&icmp6Header), sizeof(icmp6Header)); + Random::NonCrypto::Fill(icmp6Header); icmp6Header.SetChecksum(0); message->Write(0, icmp6Header); @@ -332,7 +332,7 @@ void TestTcp4MessageChecksum(void) // Write TCP header with a random payload. - Random::NonCrypto::FillBuffer(reinterpret_cast(&tcpHeader), sizeof(tcpHeader)); + Random::NonCrypto::Fill(tcpHeader); message->Write(0, tcpHeader); if (size > sizeof(tcpHeader)) @@ -387,7 +387,7 @@ void TestUdp4MessageChecksum(void) // Write UDP header with a random payload. - Random::NonCrypto::FillBuffer(reinterpret_cast(&udpHeader), sizeof(udpHeader)); + Random::NonCrypto::Fill(udpHeader); udpHeader.SetChecksum(0); message->Write(0, udpHeader); diff --git a/tests/unit/test_dns.cpp b/tests/unit/test_dns.cpp index 6df6b3bd15f..7a87b25eadf 100644 --- a/tests/unit/test_dns.cpp +++ b/tests/unit/test_dns.cpp @@ -478,6 +478,7 @@ void TestDnsCompressedName(void) static const char kExpectedReadName1[] = "F.ISI.ARPA."; static const char kExpectedReadName2[] = "FOO.F.ISI.ARPA."; static const char kExpectedReadName3[] = "ISI.ARPA."; + static const char kExpectedReadName4[] = "Human.Readable.F.ISI.ARPA."; static const char kBadName[] = "bad.name"; @@ -745,10 +746,12 @@ void TestDnsCompressedName(void) VerifyOrQuit(labelLength == strlen(label), "Name::ReadLabel() returned incorrect label length"); } - // `ReadName()` for name-4 should fails due to first label containing dot char. + // `ReadName()` for name-4 should still succeed since only the first label contains dot char offset = name4Offset; - VerifyOrQuit(Dns::Name::ReadName(*message, offset, name, sizeof(name)) == kErrorParse, - "Name::ReadName() did not fail with invalid label"); + SuccessOrQuit(Dns::Name::ReadName(*message, offset, name, sizeof(name))); + printf("Read name =\"%s\"\n", name); + VerifyOrQuit(strcmp(name, kExpectedReadName4) == 0, "Name::ReadName() did not return expected name"); + VerifyOrQuit(offset == name4Offset + kName4EncodedSize, "Name::ParseName() returned incorrect offset"); offset = name4Offset; @@ -826,9 +829,9 @@ void TestHeaderAndResourceRecords(void) const char kServiceLabels[] = "_service._udp"; const char kServiceName[] = "_service._udp.example.com."; const char kInstance1Label[] = "inst1"; - const char kInstance2Label[] = "instance2"; + const char kInstance2Label[] = "instance.2"; // Instance label includes dot '.' character. const char kInstance1Name[] = "inst1._service._udp.example.com."; - const char kInstance2Name[] = "instance2._service._udp.example.com."; + const char kInstance2Name[] = "instance.2._service._udp.example.com."; const char kHostName[] = "host.example.com."; const uint8_t kTxtData[] = {9, 'k', 'e', 'y', '=', 'v', 'a', 'l', 'u', 'e', 0}; const char kHostAddress[] = "fd00::abcd:"; @@ -988,16 +991,18 @@ void TestHeaderAndResourceRecords(void) VerifyOrQuit(offset == answerSectionOffset, "answer section offset is incorrect"); - for (const char *instanceName : kInstanceNames) + for (const char *instanceLabel : kInstanceLabels) { SuccessOrQuit(Dns::Name::CompareName(*message, offset, kServiceName)); SuccessOrQuit(Dns::ResourceRecord::ReadRecord(*message, offset, ptrRecord)); VerifyOrQuit(ptrRecord.GetTtl() == kTtl, "Read PTR is incorrect"); - SuccessOrQuit(ptrRecord.ReadPtrName(*message, offset, name, sizeof(name))); - VerifyOrQuit(strcmp(name, instanceName) == 0, "Inst1 name is incorrect"); + SuccessOrQuit(ptrRecord.ReadPtrName(*message, offset, label, sizeof(label), name, sizeof(name))); + VerifyOrQuit(strcmp(label, instanceLabel) == 0, "Inst label is incorrect"); + VerifyOrQuit(strcmp(name, kServiceName) == 0); - printf(" \"%s\" PTR %u %d \"%s\"\n", kServiceName, ptrRecord.GetTtl(), ptrRecord.GetLength(), name); + printf(" \"%s\" PTR %u %d \"%s.%s\"\n", kServiceName, ptrRecord.GetTtl(), ptrRecord.GetLength(), label, + name); } VerifyOrQuit(offset == additionalSectionOffset, "offset is incorrect after answer section parse"); @@ -1258,7 +1263,7 @@ void TestDnsTxtEntry(void) const uint8_t kInvalidEncodedTxt1[] = {4, 'a', '=', 'b'}; // Incorrect length // Special encoded txt data with zero strings and string starting - // with '=' (missing key) whcih should be skipped over silently. + // with '=' (missing key) which should be skipped over silently. const uint8_t kSpecialEncodedTxt[] = {0, 0, 3, 'A', '=', 'B', 2, '=', 'C', 3, 'D', '=', 'E', 3, '=', '1', '2'}; const Dns::TxtEntry kTxtEntries[] = { diff --git a/tests/unit/test_dns_client.cpp b/tests/unit/test_dns_client.cpp index 1b27a5904e2..79b70ef0d27 100644 --- a/tests/unit/test_dns_client.cpp +++ b/tests/unit/test_dns_client.cpp @@ -31,6 +31,7 @@ #include "test_platform.h" #include "test_util.hpp" +#include #include #include #include @@ -83,6 +84,8 @@ void AdvanceTime(uint32_t aDuration); extern "C" { +otRadioCaps otPlatRadioGetCaps(otInstance *) { return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF; } + otError otPlatRadioTransmit(otInstance *, otRadioFrame *) { sRadioTxOngoing = true; @@ -191,15 +194,23 @@ void InitTest(void) // Initialize OT instance. sNow = 0; + sAlarmOn = false; sInstance = static_cast(testInitInstance()); memset(&sRadioTxFrame, 0, sizeof(sRadioTxFrame)); sRadioTxFrame.mPsdu = sRadioTxFramePsdu; + sRadioTxOngoing = false; //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Initialize Border Router and start Thread operation. - SuccessOrQuit(otLinkSetPanId(sInstance, 0x1234)); + otOperationalDataset dataset; + otOperationalDatasetTlvs datasetTlvs; + + SuccessOrQuit(otDatasetCreateNewNetwork(sInstance, &dataset)); + SuccessOrQuit(otDatasetConvertToTlvs(&dataset, &datasetTlvs)); + SuccessOrQuit(otDatasetSetActiveTlvs(sInstance, &datasetTlvs)); + SuccessOrQuit(otIp6SetEnabled(sInstance, true)); SuccessOrQuit(otThreadSetEnabled(sInstance, true)); @@ -392,6 +403,9 @@ void BrowseCallback(otError aError, const otDnsBrowseResponse *aResponse, void * //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +static constexpr uint8_t kMaxHostAddresses = 10; +static constexpr uint16_t kMaxTxtBuffer = 256; + struct ResolveServiceInfo { void Reset(void) @@ -407,7 +421,9 @@ struct ResolveServiceInfo Error mError; Dns::Client::ServiceInfo mInfo; char mNameBuffer[Dns::Name::kMaxNameSize]; - uint8_t mTxtBuffer[256]; + uint8_t mTxtBuffer[kMaxTxtBuffer]; + Ip6::Address mHostAddresses[kMaxHostAddresses]; + uint8_t mNumHostAddresses; }; static ResolveServiceInfo sResolveServiceInfo; @@ -432,7 +448,31 @@ void ServiceCallback(otError aError, const otDnsServiceResponse *aResponse, void SuccessOrExit(aError); SuccessOrQuit(response.GetServiceInfo(sResolveServiceInfo.mInfo)); + + for (uint8_t index = 0; index < kMaxHostAddresses; index++) + { + Error error; + uint32_t ttl; + + error = response.GetHostAddress(sResolveServiceInfo.mInfo.mHostNameBuffer, index, + sResolveServiceInfo.mHostAddresses[index], ttl); + + if (error == kErrorNotFound) + { + sResolveServiceInfo.mNumHostAddresses = index; + break; + } + + SuccessOrQuit(error); + } + LogServiceInfo(sResolveServiceInfo.mInfo); + Log(" NumHostAddresses: %u", sResolveServiceInfo.mNumHostAddresses); + + for (uint8_t index = 0; index < sResolveServiceInfo.mNumHostAddresses; index++) + { + Log(" %s", sResolveServiceInfo.mHostAddresses[index].ToString().AsCString()); + } exit: return; @@ -442,6 +482,10 @@ void ServiceCallback(otError aError, const otDnsServiceResponse *aResponse, void void TestDnsClient(void) { + static constexpr uint8_t kNumAddresses = 2; + + static const char *const kAddresses[kNumAddresses] = {"2001::beef:cafe", "fd00:1234:5678:9abc::1"}; + const Dns::Client::QueryConfig::ServiceMode kServiceModes[] = { Dns::Client::QueryConfig::kServiceModeSrv, Dns::Client::QueryConfig::kServiceModeTxt, @@ -450,20 +494,36 @@ void TestDnsClient(void) Dns::Client::QueryConfig::kServiceModeSrvTxtOptimize, }; - Srp::Server *srpServer; - Srp::Client *srpClient; - Srp::Client::Service service1; - Srp::Client::Service service2; - Dns::Client *dnsClient; - Dns::Client::QueryConfig queryConfig; - Dns::ServiceDiscovery::Server *dnsServer; - uint16_t heapAllocations; + Array addresses; + Srp::Server *srpServer; + Srp::Client *srpClient; + Srp::Client::Service service1; + Srp::Client::Service service2; + Dns::Client *dnsClient; + Dns::Client::QueryConfig queryConfig; + Dns::ServiceDiscovery::Server *dnsServer; + uint16_t heapAllocations; Log("--------------------------------------------------------------------------------------------"); Log("TestDnsClient"); InitTest(); + for (const char *addrString : kAddresses) + { + otNetifAddress netifAddr; + + memset(&netifAddr, 0, sizeof(netifAddr)); + SuccessOrQuit(AsCoreType(&netifAddr.mAddress).FromString(addrString)); + netifAddr.mPrefixLength = 64; + netifAddr.mAddressOrigin = OT_ADDRESS_ORIGIN_MANUAL; + netifAddr.mPreferred = true; + netifAddr.mValid = true; + SuccessOrQuit(otIp6AddUnicastAddress(sInstance, &netifAddr)); + + SuccessOrQuit(addresses.PushBack(AsCoreType(&netifAddr.mAddress))); + } + srpServer = &sInstance->Get(); srpClient = &sInstance->Get(); dnsClient = &sInstance->Get(); @@ -539,7 +599,7 @@ void TestDnsClient(void) VerifyOrQuit(sBrowseInfo.mNumInstances == 1); sBrowseInfo.Reset(); - Log("Browse() for unknwon service"); + Log("Browse() for unknown service"); SuccessOrQuit(dnsClient->Browse("_unknown._udp.default.service.arpa.", BrowseCallback, sInstance)); AdvanceTime(100); VerifyOrQuit(sBrowseInfo.mCallbackCount == 1); @@ -580,6 +640,14 @@ void TestDnsClient(void) VerifyOrQuit(sResolveServiceInfo.mInfo.mPort == service1.mPort); VerifyOrQuit(sResolveServiceInfo.mInfo.mWeight == service1.mWeight); VerifyOrQuit(strcmp(sResolveServiceInfo.mInfo.mHostNameBuffer, kHostFullName) == 0); + + VerifyOrQuit(sResolveServiceInfo.mNumHostAddresses == kNumAddresses); + VerifyOrQuit(AsCoreType(&sResolveServiceInfo.mInfo.mHostAddress) == sResolveServiceInfo.mHostAddresses[0]); + + for (uint8_t index = 0; index < kNumAddresses; index++) + { + VerifyOrQuit(addresses.Contains(sResolveServiceInfo.mHostAddresses[index])); + } } if (mode != Dns::Client::QueryConfig::kServiceModeSrv) @@ -624,16 +692,179 @@ void TestDnsClient(void) VerifyOrQuit(sResolveServiceInfo.mCallbackCount == 1); VerifyOrQuit(sResolveServiceInfo.mError != kErrorNone); + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeDisabled); + + //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Validate DNS Client `ResolveService()` using all service modes + // when sever does not provide any RR in the addition data section. + + for (Dns::Client::QueryConfig::ServiceMode mode : kServiceModes) + { + Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); + Log("Set TestMode on server to not include any RR in additional section"); + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeEmptyAdditionalSection); + Log("ResolveService(%s,%s) with ServiceMode: %s", kInstance1Label, kService1FullName, + ServiceModeToString(mode)); + + queryConfig.Clear(); + queryConfig.mServiceMode = static_cast(mode); + + sResolveServiceInfo.Reset(); + SuccessOrQuit( + dnsClient->ResolveService(kInstance1Label, kService1FullName, ServiceCallback, sInstance, &queryConfig)); + AdvanceTime(100); + + VerifyOrQuit(sResolveServiceInfo.mCallbackCount == 1); + SuccessOrQuit(sResolveServiceInfo.mError); + + if (mode != Dns::Client::QueryConfig::kServiceModeTxt) + { + VerifyOrQuit(sResolveServiceInfo.mInfo.mTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mPort == service1.mPort); + VerifyOrQuit(sResolveServiceInfo.mInfo.mWeight == service1.mWeight); + VerifyOrQuit(strcmp(sResolveServiceInfo.mInfo.mHostNameBuffer, kHostFullName) == 0); + } + + if (mode != Dns::Client::QueryConfig::kServiceModeSrv) + { + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataSize != 0); + } + + // Since server is using `kTestModeEmptyAdditionalSection`, there + // should be no AAAA records for host address. + + VerifyOrQuit(AsCoreType(&sResolveServiceInfo.mInfo.mHostAddress).IsUnspecified()); + VerifyOrQuit(sResolveServiceInfo.mNumHostAddresses == 0); + } + + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeDisabled); + + //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // Validate DNS Client `ResolveServiceAndHostAddress()` using all service modes + // with different TestMode configs on server: + // - Normal behavior when server provides AAAA records for host in + // additional section. + // - Server provides no records in additional section. We validate that + // client will send separate query to resolve host address. + + for (Dns::Client::QueryConfig::ServiceMode mode : kServiceModes) + { + for (uint8_t testIter = 0; testIter <= 1; testIter++) + { + Error error; + + Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); + + if (testIter == 1) + { + Log("Set TestMode on server to not include any RR in additional section"); + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeEmptyAdditionalSection); + } + else + { + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeDisabled); + } + + Log("ResolveServiceAndHostAddress(%s,%s) with ServiceMode: %s", kInstance1Label, kService1FullName, + ServiceModeToString(mode)); + + queryConfig.Clear(); + queryConfig.mServiceMode = static_cast(mode); + + sResolveServiceInfo.Reset(); + error = dnsClient->ResolveServiceAndHostAddress(kInstance1Label, kService1FullName, ServiceCallback, + sInstance, &queryConfig); + + if (mode == Dns::Client::QueryConfig::kServiceModeTxt) + { + Log("ResolveServiceAndHostAddress() with ServiceMode: %s failed correctly", ServiceModeToString(mode)); + VerifyOrQuit(error == kErrorInvalidArgs); + continue; + } + + SuccessOrQuit(error); + + AdvanceTime(100); + + VerifyOrQuit(sResolveServiceInfo.mCallbackCount == 1); + SuccessOrQuit(sResolveServiceInfo.mError); + + if (mode != Dns::Client::QueryConfig::kServiceModeTxt) + { + VerifyOrQuit(sResolveServiceInfo.mInfo.mTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mPort == service1.mPort); + VerifyOrQuit(sResolveServiceInfo.mInfo.mWeight == service1.mWeight); + VerifyOrQuit(strcmp(sResolveServiceInfo.mInfo.mHostNameBuffer, kHostFullName) == 0); + + VerifyOrQuit(sResolveServiceInfo.mNumHostAddresses == kNumAddresses); + VerifyOrQuit(AsCoreType(&sResolveServiceInfo.mInfo.mHostAddress) == + sResolveServiceInfo.mHostAddresses[0]); + + for (uint8_t index = 0; index < kNumAddresses; index++) + { + VerifyOrQuit(addresses.Contains(sResolveServiceInfo.mHostAddresses[index])); + } + } + + if (mode != Dns::Client::QueryConfig::kServiceModeSrv) + { + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataSize != 0); + } + } + } + + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeDisabled); + + Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); + Log("Set TestMode on server to not include any RR in additional section AND to only accept single question"); + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeEmptyAdditionalSection + + Dns::ServiceDiscovery::Server::kTestModeSingleQuestionOnly); + + Log("ResolveServiceAndHostAddress(%s,%s) with ServiceMode: %s", kInstance1Label, kService1FullName, + ServiceModeToString(Dns::Client::QueryConfig::kServiceModeSrvTxtOptimize)); + + queryConfig.Clear(); + queryConfig.mServiceMode = static_cast(Dns::Client::QueryConfig::kServiceModeSrvTxtOptimize); + + sResolveServiceInfo.Reset(); + SuccessOrQuit(dnsClient->ResolveServiceAndHostAddress(kInstance1Label, kService1FullName, ServiceCallback, + sInstance, &queryConfig)); + + AdvanceTime(100); + + VerifyOrQuit(sResolveServiceInfo.mCallbackCount == 1); + SuccessOrQuit(sResolveServiceInfo.mError); + + VerifyOrQuit(sResolveServiceInfo.mInfo.mTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mPort == service1.mPort); + VerifyOrQuit(sResolveServiceInfo.mInfo.mWeight == service1.mWeight); + VerifyOrQuit(strcmp(sResolveServiceInfo.mInfo.mHostNameBuffer, kHostFullName) == 0); + + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataTtl != 0); + VerifyOrQuit(sResolveServiceInfo.mInfo.mTxtDataSize != 0); + + VerifyOrQuit(sResolveServiceInfo.mNumHostAddresses == kNumAddresses); + VerifyOrQuit(AsCoreType(&sResolveServiceInfo.mInfo.mHostAddress) == sResolveServiceInfo.mHostAddresses[0]); + + for (uint8_t index = 0; index < kNumAddresses; index++) + { + VerifyOrQuit(addresses.Contains(sResolveServiceInfo.mHostAddresses[index])); + } + + dnsServer->SetTestMode(Dns::ServiceDiscovery::Server::kTestModeDisabled); + Log("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Log("Stop DNS-SD server"); dnsServer->Stop(); Log("ResolveService(%s,%s) with ServiceMode %s", kInstance1Label, kService1FullName, - ServiceModeToString(Dns::Client::QueryConfig::kServiceModeSrv)); + ServiceModeToString(Dns::Client::QueryConfig::kServiceModeSrvTxtSeparate)); queryConfig.Clear(); - queryConfig.mServiceMode = static_cast(Dns::Client::QueryConfig::kServiceModeSrv); + queryConfig.mServiceMode = static_cast(Dns::Client::QueryConfig::kServiceModeSrvTxtSeparate); sResolveServiceInfo.Reset(); SuccessOrQuit( diff --git a/tests/unit/test_hdlc.cpp b/tests/unit/test_hdlc.cpp index f23ae99996d..f9e395c1cd6 100644 --- a/tests/unit/test_hdlc.cpp +++ b/tests/unit/test_hdlc.cpp @@ -31,6 +31,7 @@ #include "common/code_utils.hpp" #include "common/instance.hpp" #include "lib/hdlc/hdlc.hpp" +#include "lib/spinel/multi_frame_buffer.hpp" #include "test_util.h" @@ -60,7 +61,7 @@ static const uint8_t sSkipText[] = "Skip text"; static const uint8_t sHdlcSpecials[] = {kFlagSequence, kFlagXOn, kFlagXOff, kFlagSequence, kEscapeSequence, kFlagSpecial}; -otError WriteToBuffer(const uint8_t *aText, Hdlc::FrameWritePointer &aWritePointer) +otError WriteToBuffer(const uint8_t *aText, Spinel::FrameWritePointer &aWritePointer) { otError error = OT_ERROR_NONE; @@ -75,9 +76,9 @@ otError WriteToBuffer(const uint8_t *aText, Hdlc::FrameWritePointer &aWritePoint void TestHdlcFrameBuffer(void) { - Hdlc::FrameBuffer frameBuffer; + Spinel::FrameBuffer frameBuffer; - printf("Testing Hdlc::FrameBuffer"); + printf("Testing Spinel::FrameBuffer"); VerifyOrQuit(frameBuffer.IsEmpty(), "after constructor"); VerifyOrQuit(frameBuffer.GetLength() == 0, "after constructor"); @@ -123,15 +124,15 @@ void TestHdlcFrameBuffer(void) printf(" -- PASS\n"); } -void TestHdlcMultiFrameBuffer(void) +void TestSpinelMultiFrameBuffer(void) { - Hdlc::MultiFrameBuffer frameBuffer; - uint8_t *frame = nullptr; - uint8_t *newFrame = nullptr; - uint16_t length; - uint16_t newLength; + Spinel::MultiFrameBuffer frameBuffer; + uint8_t *frame = nullptr; + uint8_t *newFrame = nullptr; + uint16_t length; + uint16_t newLength; - printf("Testing Hdlc::MultiFrameBuffer"); + printf("Testing Spinel::MultiFrameBuffer"); //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check state after constructor @@ -447,16 +448,16 @@ void ProcessDecodedFrame(void *aContext, otError aError) void TestEncoderDecoder(void) { - otError error; - uint8_t byte; - Hdlc::MultiFrameBuffer encoderBuffer; - Hdlc::MultiFrameBuffer decoderBuffer; - DecoderContext decoderContext; - Hdlc::Encoder encoder(encoderBuffer); - Hdlc::Decoder decoder(decoderBuffer, ProcessDecodedFrame, &decoderContext); - uint8_t *frame; - uint16_t length; - uint8_t badShortFrame[3] = {kFlagSequence, 0xaa, kFlagSequence}; + otError error; + uint8_t byte; + Spinel::MultiFrameBuffer encoderBuffer; + Spinel::MultiFrameBuffer decoderBuffer; + DecoderContext decoderContext; + Hdlc::Encoder encoder(encoderBuffer); + Hdlc::Decoder decoder(decoderBuffer, ProcessDecodedFrame, &decoderContext); + uint8_t *frame; + uint16_t length; + uint8_t badShortFrame[3] = {kFlagSequence, 0xaa, kFlagSequence}; printf("Testing Hdlc::Encoder and Hdlc::Decoder"); @@ -595,13 +596,13 @@ uint32_t GetRandom(uint32_t max) { return static_cast(rand()) % max; } void TestFuzzEncoderDecoder(void) { - uint16_t length; - uint8_t frame[kMaxFrameLength]; - Hdlc::FrameBuffer encoderBuffer; - Hdlc::FrameBuffer decoderBuffer; - DecoderContext decoderContext; - Hdlc::Encoder encoder(encoderBuffer); - Hdlc::Decoder decoder(decoderBuffer, ProcessDecodedFrame, &decoderContext); + uint16_t length; + uint8_t frame[kMaxFrameLength]; + Spinel::FrameBuffer encoderBuffer; + Spinel::FrameBuffer decoderBuffer; + DecoderContext decoderContext; + Hdlc::Encoder encoder(encoderBuffer); + Hdlc::Decoder decoder(decoderBuffer, ProcessDecodedFrame, &decoderContext); printf("Testing Hdlc::Encoder and Hdlc::Decoder with randomly generated frames"); @@ -647,7 +648,7 @@ void TestFuzzEncoderDecoder(void) int main(void) { ot::Ncp::TestHdlcFrameBuffer(); - ot::Ncp::TestHdlcMultiFrameBuffer(); + ot::Ncp::TestSpinelMultiFrameBuffer(); ot::Ncp::TestEncoderDecoder(); ot::Ncp::TestFuzzEncoderDecoder(); printf("\nAll tests passed.\n"); diff --git a/tests/unit/test_ip_address.cpp b/tests/unit/test_ip_address.cpp index 06cef10d866..153a2c13a2f 100644 --- a/tests/unit/test_ip_address.cpp +++ b/tests/unit/test_ip_address.cpp @@ -28,6 +28,7 @@ #include +#include "common/array.hpp" #include "common/encoding.hpp" #include "common/string.hpp" #include "net/ip4_types.hpp" @@ -581,6 +582,182 @@ void TestIp6Prefix(void) VerifyOrQuit(!PrefixFrom("fe00::", 7).IsUniqueLocal()); } +void TestIp6PrefixTidy(void) +{ + struct TestVector + { + uint8_t originalPrefix[OT_IP6_ADDRESS_SIZE]; + const char *prefixStringAfterTidy[129]; + }; + const TestVector kPrefixes[] = { + { + .originalPrefix = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff}, + .prefixStringAfterTidy = + { + "::/0", + "8000::/1", + "c000::/2", + "e000::/3", + "f000::/4", + "f800::/5", + "fc00::/6", + "fe00::/7", + "ff00::/8", + "ff80::/9", + "ffc0::/10", + "ffe0::/11", + "fff0::/12", + "fff8::/13", + "fffc::/14", + "fffe::/15", + "ffff::/16", + "ffff:8000::/17", + "ffff:c000::/18", + "ffff:e000::/19", + "ffff:f000::/20", + "ffff:f800::/21", + "ffff:fc00::/22", + "ffff:fe00::/23", + "ffff:ff00::/24", + "ffff:ff80::/25", + "ffff:ffc0::/26", + "ffff:ffe0::/27", + "ffff:fff0::/28", + "ffff:fff8::/29", + "ffff:fffc::/30", + "ffff:fffe::/31", + "ffff:ffff::/32", + "ffff:ffff:8000::/33", + "ffff:ffff:c000::/34", + "ffff:ffff:e000::/35", + "ffff:ffff:f000::/36", + "ffff:ffff:f800::/37", + "ffff:ffff:fc00::/38", + "ffff:ffff:fe00::/39", + "ffff:ffff:ff00::/40", + "ffff:ffff:ff80::/41", + "ffff:ffff:ffc0::/42", + "ffff:ffff:ffe0::/43", + "ffff:ffff:fff0::/44", + "ffff:ffff:fff8::/45", + "ffff:ffff:fffc::/46", + "ffff:ffff:fffe::/47", + "ffff:ffff:ffff::/48", + "ffff:ffff:ffff:8000::/49", + "ffff:ffff:ffff:c000::/50", + "ffff:ffff:ffff:e000::/51", + "ffff:ffff:ffff:f000::/52", + "ffff:ffff:ffff:f800::/53", + "ffff:ffff:ffff:fc00::/54", + "ffff:ffff:ffff:fe00::/55", + "ffff:ffff:ffff:ff00::/56", + "ffff:ffff:ffff:ff80::/57", + "ffff:ffff:ffff:ffc0::/58", + "ffff:ffff:ffff:ffe0::/59", + "ffff:ffff:ffff:fff0::/60", + "ffff:ffff:ffff:fff8::/61", + "ffff:ffff:ffff:fffc::/62", + "ffff:ffff:ffff:fffe::/63", + "ffff:ffff:ffff:ffff::/64", + "ffff:ffff:ffff:ffff:8000::/65", + "ffff:ffff:ffff:ffff:c000::/66", + "ffff:ffff:ffff:ffff:e000::/67", + "ffff:ffff:ffff:ffff:f000::/68", + "ffff:ffff:ffff:ffff:f800::/69", + "ffff:ffff:ffff:ffff:fc00::/70", + "ffff:ffff:ffff:ffff:fe00::/71", + "ffff:ffff:ffff:ffff:ff00::/72", + "ffff:ffff:ffff:ffff:ff80::/73", + "ffff:ffff:ffff:ffff:ffc0::/74", + "ffff:ffff:ffff:ffff:ffe0::/75", + "ffff:ffff:ffff:ffff:fff0::/76", + "ffff:ffff:ffff:ffff:fff8::/77", + "ffff:ffff:ffff:ffff:fffc::/78", + "ffff:ffff:ffff:ffff:fffe::/79", + "ffff:ffff:ffff:ffff:ffff::/80", + "ffff:ffff:ffff:ffff:ffff:8000::/81", + "ffff:ffff:ffff:ffff:ffff:c000::/82", + "ffff:ffff:ffff:ffff:ffff:e000::/83", + "ffff:ffff:ffff:ffff:ffff:f000::/84", + "ffff:ffff:ffff:ffff:ffff:f800::/85", + "ffff:ffff:ffff:ffff:ffff:fc00::/86", + "ffff:ffff:ffff:ffff:ffff:fe00::/87", + "ffff:ffff:ffff:ffff:ffff:ff00::/88", + "ffff:ffff:ffff:ffff:ffff:ff80::/89", + "ffff:ffff:ffff:ffff:ffff:ffc0::/90", + "ffff:ffff:ffff:ffff:ffff:ffe0::/91", + "ffff:ffff:ffff:ffff:ffff:fff0::/92", + "ffff:ffff:ffff:ffff:ffff:fff8::/93", + "ffff:ffff:ffff:ffff:ffff:fffc::/94", + "ffff:ffff:ffff:ffff:ffff:fffe::/95", + "ffff:ffff:ffff:ffff:ffff:ffff::/96", + // Note: The result of /97 to /112 does not meet RFC requirements: + // 4.2.2. Handling One 16-Bit 0 Field + // The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field. + "ffff:ffff:ffff:ffff:ffff:ffff:8000::/97", + "ffff:ffff:ffff:ffff:ffff:ffff:c000::/98", + "ffff:ffff:ffff:ffff:ffff:ffff:e000::/99", + "ffff:ffff:ffff:ffff:ffff:ffff:f000::/100", + "ffff:ffff:ffff:ffff:ffff:ffff:f800::/101", + "ffff:ffff:ffff:ffff:ffff:ffff:fc00::/102", + "ffff:ffff:ffff:ffff:ffff:ffff:fe00::/103", + "ffff:ffff:ffff:ffff:ffff:ffff:ff00::/104", + "ffff:ffff:ffff:ffff:ffff:ffff:ff80::/105", + "ffff:ffff:ffff:ffff:ffff:ffff:ffc0::/106", + "ffff:ffff:ffff:ffff:ffff:ffff:ffe0::/107", + "ffff:ffff:ffff:ffff:ffff:ffff:fff0::/108", + "ffff:ffff:ffff:ffff:ffff:ffff:fff8::/109", + "ffff:ffff:ffff:ffff:ffff:ffff:fffc::/110", + "ffff:ffff:ffff:ffff:ffff:ffff:fffe::/111", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff::/112", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000/113", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:c000/114", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:e000/115", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:f000/116", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:f800/117", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fc00/118", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fe00/119", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00/120", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff80/121", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffc0/122", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffe0/123", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0/124", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff8/125", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc/126", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe/127", + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128", + }, + }, + }; + + printf("Tidy Prefixes:\n"); + + for (auto test : kPrefixes) + { + for (uint16_t i = 0; i < ot::GetArrayLength(test.prefixStringAfterTidy); i++) + { + ot::Ip6::Prefix prefix, answer; + + SuccessOrQuit(answer.FromString(test.prefixStringAfterTidy[i])); + prefix.Set(test.originalPrefix, i); + prefix.Tidy(); + + { + ot::Ip6::Prefix::InfoString prefixString = prefix.ToString(); + + printf("Prefix: %-36s TidyResult: %-36s\n", test.prefixStringAfterTidy[i], + prefix.ToString().AsCString()); + + VerifyOrQuit(memcmp(answer.mPrefix.mFields.m8, prefix.mPrefix.mFields.m8, + sizeof(answer.mPrefix.mFields.m8)) == 0); + VerifyOrQuit(prefix.mLength == answer.mLength); + VerifyOrQuit(strcmp(test.prefixStringAfterTidy[i], prefixString.AsCString()) == 0); + } + } + } +} + void TestIp4Ip6Translation(void) { struct TestCase @@ -705,6 +882,7 @@ int main(void) TestIp6AddressFromString(); TestIp6PrefixFromString(); TestIp6Prefix(); + TestIp6PrefixTidy(); TestIp4Ip6Translation(); TestIp4Cidr(); TestIp4CidrFromString(); diff --git a/tests/unit/test_link_quality.cpp b/tests/unit/test_link_quality.cpp index 0f2e9eb7639..8070abe5247 100644 --- a/tests/unit/test_link_quality.cpp +++ b/tests/unit/test_link_quality.cpp @@ -57,7 +57,7 @@ enum #define MAX_RSS(_rss1, _rss2) (((_rss1) < (_rss2)) ? (_rss2) : (_rss1)) #define ABS(value) (((value) >= 0) ? (value) : -(value)) -// This struct contains RSS values and test data for checking link quality info calss. +// This struct contains RSS values and test data for checking link quality info class. struct RssTestData { const int8_t *mRssList; // Array of RSS values. @@ -518,6 +518,13 @@ class UnitTester VerifyOrQuit(LinkMetrics::ScaleRssiToRawValue(1) == 255); VerifyOrQuit(LinkMetrics::ScaleRssiToRawValue(10) == 255); VerifyOrQuit(LinkMetrics::ScaleRssiToRawValue(127) == 255); + + // Test corner case of ScaleRawValueToRssi + for (uint8_t rawValue = 0; rawValue < 2; rawValue++) + { + int8_t rssi = LinkMetrics::ScaleRawValueToRssi(rawValue); + printf("\nRaw Value: %u -> RSSI : %-3d", rawValue, rssi); + } } }; diff --git a/tests/unit/test_lowpan.cpp b/tests/unit/test_lowpan.cpp index c28f8fda84d..67fe5f6b904 100644 --- a/tests/unit/test_lowpan.cpp +++ b/tests/unit/test_lowpan.cpp @@ -99,7 +99,7 @@ void TestIphcVector::GetUncompressedStream(Message &aMessage) } /** - * This function initializes Thread Interface. + * Initializes Thread Interface. * */ static void Init(void) @@ -134,7 +134,7 @@ static void Init(void) } /** - * This function performs compression or/and decompression based on the given test vector. + * Performs compression or/and decompression based on the given test vector. * * @note Performing decompression and compression on the same LOWPAN_IPHC frame may give different result. * This situation may occur when sender does not use the best possible compression, @@ -277,7 +277,7 @@ static const uint8_t sTestPayloadDefault[] = {0x80, 0x00, 0x01, 0x02, 0x03, 0x04 static void TestFullyCompressableLongAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 addresses using long MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 addresses using long MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); @@ -302,7 +302,7 @@ static void TestFullyCompressableLongAddresses(void) static void TestFullyCompressableShortAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 addresses using short MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 addresses using short MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultShort); @@ -327,7 +327,7 @@ static void TestFullyCompressableShortAddresses(void) static void TestFullyCompressableShortLongAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 addresses using short and long MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 addresses using short and long MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultShort); @@ -352,7 +352,7 @@ static void TestFullyCompressableShortLongAddresses(void) static void TestFullyCompressableLongShortAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 addresses using long and short MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 addresses using long and short MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); @@ -505,7 +505,7 @@ static void TestSource16bitDestination16bitAddresses(void) static void TestSourceCompressedDestination16bitAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 source and destination 16-bit using long MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 source and destination 16-bit using long MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); @@ -530,7 +530,7 @@ static void TestSourceCompressedDestination16bitAddresses(void) static void TestSourceCompressedDestination128bitAddresses(void) { - TestIphcVector testVector("Fully compressable IPv6 source and destination inline using long MAC addresses"); + TestIphcVector testVector("Fully compressible IPv6 source and destination inline using long MAC addresses"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); @@ -734,7 +734,7 @@ static void TestStatefulSource16bitDestination16bitContext0(void) static void TestStatefulCompressableLongAddressesContext0(void) { - TestIphcVector testVector("Stateful compression compressable long addresses, context 0"); + TestIphcVector testVector("Stateful compression compressible long addresses, context 0"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); @@ -759,7 +759,7 @@ static void TestStatefulCompressableLongAddressesContext0(void) static void TestStatefulCompressableShortAddressesContext0(void) { - TestIphcVector testVector("Stateful compression compressable short addresses, context 0"); + TestIphcVector testVector("Stateful compression compressible short addresses, context 0"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultShort); @@ -784,7 +784,7 @@ static void TestStatefulCompressableShortAddressesContext0(void) static void TestStatefulCompressableLongShortAddressesContext0(void) { - TestIphcVector testVector("Stateful compression compressable long and short addresses, context 0"); + TestIphcVector testVector("Stateful compression compressible long and short addresses, context 0"); // Setup MAC addresses. testVector.SetMacSource(sTestMacSourceDefaultLong); diff --git a/tests/unit/test_lowpan.hpp b/tests/unit/test_lowpan.hpp index 1625dbc6514..a9542b9e702 100644 --- a/tests/unit/test_lowpan.hpp +++ b/tests/unit/test_lowpan.hpp @@ -68,7 +68,7 @@ class TestIphcVector } /** - * This method sets long MAC source address. + * Sets long MAC source address. * * @param aAddress Pointer to the long MAC address. * @@ -76,7 +76,7 @@ class TestIphcVector void SetMacSource(const uint8_t *aAddress) { mMacAddrs.mSource.SetExtended(aAddress); } /** - * This method sets short MAC source address. + * Sets short MAC source address. * * @param aAddress Short MAC address. * @@ -84,7 +84,7 @@ class TestIphcVector void SetMacSource(uint16_t aAddress) { mMacAddrs.mSource.SetShort(aAddress); } /** - * This method sets long MAC destination address. + * Sets long MAC destination address. * * @param aAddress Pointer to the long MAC address. * @@ -92,7 +92,7 @@ class TestIphcVector void SetMacDestination(const uint8_t *aAddress) { mMacAddrs.mDestination.SetExtended(aAddress); } /** - * This method sets short MAC destination address. + * Sets short MAC destination address. * * @param aAddress Short MAC address. * @@ -100,7 +100,7 @@ class TestIphcVector void SetMacDestination(uint16_t aAddress) { mMacAddrs.mDestination.SetShort(aAddress); } /** - * This method gets the IPv6 header + * Gets the IPv6 header * * @returns the IPv6 header. * @@ -108,7 +108,7 @@ class TestIphcVector const Ip6::Header &GetIpHeader(void) const { return mIpHeader; } /** - * This method initializes IPv6 Header. + * Initializes IPv6 Header. * * @param aVersionClassFlow Value of the Version, Traffic class and Flow control fields. * @param aPayloadLength Value of the payload length field. @@ -134,7 +134,7 @@ class TestIphcVector } /** - * This method initializes IPv6 Encapsulated Header. + * Initializes IPv6 Encapsulated Header. * * @param aVersionClassFlow Value of the Version, Traffic class and Flow control fields. * @param aPayloadLength Value of the payload length field. @@ -160,7 +160,7 @@ class TestIphcVector } /** - * This method initializes IPv6 Extension Header. + * Initializes IPv6 Extension Header. * * @param aExtHeader Pointer to the extension header data. * @param aExtHeaderLength Length of the extension header data. @@ -173,7 +173,7 @@ class TestIphcVector } /** - * This method initializes UDP Header. + * Initializes UDP Header. * * @param aSource Value of the source port. * @param aDestination Value of the destination port. @@ -190,7 +190,7 @@ class TestIphcVector } /** - * This method initializes LOWPAN_IPHC Header. + * Initializes LOWPAN_IPHC Header. * * @param aIphc Pointer to the LOWPAN_IPHC header. * @param aIphcLength Length of the LOWPAN_IPHC header. @@ -203,7 +203,7 @@ class TestIphcVector } /** - * This method sets the expect result of the compression / decompression procedure. + * Sets the expect result of the compression / decompression procedure. * * @param aError Expected result. * @@ -211,7 +211,7 @@ class TestIphcVector void SetError(Error aError) { mError = aError; } /** - * This method initializes IPv6 Payload (uncompressed data). + * Initializes IPv6 Payload (uncompressed data). * * @param aPayload Pointer to the payload data. * @param aLength Length of the payload data. @@ -224,7 +224,7 @@ class TestIphcVector } /** - * This method sets the offset from the beginning of the IPv6 header to the uncompressed + * Sets the offset from the beginning of the IPv6 header to the uncompressed * payload. * * @param aPayloadOffset The offset from the beginning of the IPv6 header to the uncompressed @@ -234,7 +234,7 @@ class TestIphcVector void SetPayloadOffset(uint16_t aPayloadOffset) { mPayloadOffset = aPayloadOffset; } /** - * This method returns compressed LOWPAN_IPHC frame. + * Returns compressed LOWPAN_IPHC frame. * * @returns The compressed stream. * @@ -242,7 +242,7 @@ class TestIphcVector void GetCompressedStream(uint8_t *aIphc, uint16_t &aIphcLength); /** - * This method returns message object with the uncompressed IPv6 packet. + * Returns message object with the uncompressed IPv6 packet. * * @returns The message object with the uncompressed IPv6 packet. * @@ -250,7 +250,7 @@ class TestIphcVector void GetUncompressedStream(Message &aMessage); /** - * This method returns data with the uncompressed IPv6 packet. + * Returns data with the uncompressed IPv6 packet. * * @returns The data with the uncompressed IPv6 packet. * diff --git a/tests/unit/test_mle.cpp b/tests/unit/test_mle.cpp index e7e1748e819..d5b2d3b8a36 100644 --- a/tests/unit/test_mle.cpp +++ b/tests/unit/test_mle.cpp @@ -36,7 +36,8 @@ namespace ot { -#if OPENTHREAD_FTD +#if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) + void TestDefaultDeviceProperties(void) { Instance *instance; @@ -169,13 +170,13 @@ void TestLeaderWeightCalculation(void) printf("TestLeaderWeightCalculation passed\n"); } -#endif // OPENTHREAD_FTD +#endif // #if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) } // namespace ot int main(void) { -#if OPENTHREAD_FTD +#if OPENTHREAD_FTD && (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3_1) ot::TestDefaultDeviceProperties(); ot::TestLeaderWeightCalculation(); #endif diff --git a/tests/unit/test_ndproxy_table.cpp b/tests/unit/test_ndproxy_table.cpp index 4589db93aa9..80f5d13dda9 100644 --- a/tests/unit/test_ndproxy_table.cpp +++ b/tests/unit/test_ndproxy_table.cpp @@ -50,7 +50,7 @@ Ip6::InterfaceIdentifier generateRandomIid(uint16_t aIndex) { Ip6::InterfaceIdentifier iid; - Random::NonCrypto::FillBuffer(iid.mFields.m8, sizeof(iid)); + Random::NonCrypto::Fill(iid); iid.mFields.m16[3] = aIndex; return iid; diff --git a/tests/unit/test_routing_manager.cpp b/tests/unit/test_routing_manager.cpp index 93246fac06c..a4b5cad9105 100644 --- a/tests/unit/test_routing_manager.cpp +++ b/tests/unit/test_routing_manager.cpp @@ -31,7 +31,9 @@ #include "test_platform.h" #include "test_util.hpp" +#include #include +#include #include "border_router/routing_manager.hpp" #include "common/arg_macros.hpp" @@ -59,6 +61,56 @@ static constexpr uint32_t kPreferredLifetime = 1800; static constexpr uint16_t kMaxRaSize = 800; static constexpr uint16_t kMaxDeprecatingPrefixes = 16; +static constexpr otOperationalDataset kDataset = { + .mActiveTimestamp = + { + .mSeconds = 1, + .mTicks = 0, + .mAuthoritative = false, + }, + .mNetworkKey = + { + .m8 = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, + }, + .mNetworkName = {"OpenThread"}, + .mExtendedPanId = + { + .m8 = {0xde, 0xad, 0x00, 0xbe, 0xef, 0x00, 0xca, 0xfe}, + }, + .mMeshLocalPrefix = + { + .m8 = {0xfd, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, + }, + .mPanId = 0x1234, + .mChannel = 11, + .mPskc = + { + .m8 = {0xc2, 0x3a, 0x76, 0xe9, 0x8f, 0x1a, 0x64, 0x83, 0x63, 0x9b, 0x1a, 0xc1, 0x27, 0x1e, 0x2e, 0x27}, + }, + .mSecurityPolicy = + { + .mRotationTime = 672, + .mObtainNetworkKeyEnabled = true, + .mNativeCommissioningEnabled = true, + .mRoutersEnabled = true, + .mExternalCommissioningEnabled = true, + }, + .mChannelMask = 0x07fff800, + .mComponents = + { + .mIsActiveTimestampPresent = true, + .mIsNetworkKeyPresent = true, + .mIsNetworkNamePresent = true, + .mIsExtendedPanIdPresent = true, + .mIsMeshLocalPrefixPresent = true, + .mIsPanIdPresent = true, + .mIsChannelPresent = true, + .mIsPskcPresent = true, + .mIsSecurityPolicyPresent = true, + .mIsChannelMaskPresent = true, + }, +}; + static ot::Instance *sInstance; static uint32_t sNow = 0; @@ -181,6 +233,8 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat extern "C" { +otRadioCaps otPlatRadioGetCaps(otInstance *) { return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF; } + otError otPlatRadioTransmit(otInstance *, otRadioFrame *) { sRadioTxOngoing = true; @@ -466,6 +520,13 @@ void LogRouterAdvert(const Icmp6Packet &aPacket) } } +void LogRouterAdvert(const uint8_t *aBuffer, size_t aLength) +{ + Icmp6Packet packet; + packet.Init(aBuffer, aLength); + LogRouterAdvert(packet); +} + const char *PreferenceToString(int8_t aPreference) { const char *str = ""; @@ -491,9 +552,14 @@ const char *PreferenceToString(int8_t aPreference) return str; } +void SendRouterAdvert(const Ip6::Address &aAddress, const uint8_t *aBuffer, uint16_t aLength) +{ + otPlatInfraIfRecvIcmp6Nd(sInstance, kInfraIfIndex, &aAddress, aBuffer, aLength); +} + void SendRouterAdvert(const Ip6::Address &aAddress, const Icmp6Packet &aPacket) { - otPlatInfraIfRecvIcmp6Nd(sInstance, kInfraIfIndex, &aAddress, aPacket.GetBytes(), aPacket.GetLength()); + SendRouterAdvert(aAddress, aPacket.GetBytes(), aPacket.GetLength()); } void SendNeighborAdvert(const Ip6::Address &aAddress, const Ip6::Nd::NeighborAdvertMessage &aNaMessage) @@ -662,21 +728,22 @@ struct DefaultRoute RoutePreference mPreference; }; -void SendRouterAdvert(const Ip6::Address &aRouterAddress, - const Pio *aPios, - uint16_t aNumPios, - const Rio *aRios, - uint16_t aNumRios, - const DefaultRoute &aDefaultRoute) +template +uint16_t BuildRouterAdvert(uint8_t (&aBuffer)[N], + const Pio *aPios, + uint16_t aNumPios, + const Rio *aRios, + uint16_t aNumRios, + const DefaultRoute &aDefaultRoute) { Ip6::Nd::RouterAdvertMessage::Header header; - uint8_t buffer[kMaxRaSize]; + uint16_t length; header.SetRouterLifetime(aDefaultRoute.mLifetime); header.SetDefaultRouterPreference(aDefaultRoute.mPreference); { - Ip6::Nd::RouterAdvertMessage raMsg(header, buffer); + Ip6::Nd::RouterAdvertMessage raMsg(header, aBuffer); for (; aNumPios > 0; aPios++, aNumPios--) { @@ -689,10 +756,25 @@ void SendRouterAdvert(const Ip6::Address &aRouterAddress, SuccessOrQuit(raMsg.AppendRouteInfoOption(aRios->mPrefix, aRios->mValidLifetime, aRios->mPreference)); } - SendRouterAdvert(aRouterAddress, raMsg.GetAsPacket()); - Log("Sending RA from router %s", aRouterAddress.ToString().AsCString()); - LogRouterAdvert(raMsg.GetAsPacket()); + length = raMsg.GetAsPacket().GetLength(); } + + return length; +} + +void SendRouterAdvert(const Ip6::Address &aRouterAddress, + const Pio *aPios, + uint16_t aNumPios, + const Rio *aRios, + uint16_t aNumRios, + const DefaultRoute &aDefaultRoute) +{ + uint8_t buffer[kMaxRaSize]; + uint16_t length = BuildRouterAdvert(buffer, aPios, aNumPios, aRios, aNumRios, aDefaultRoute); + + SendRouterAdvert(aRouterAddress, buffer, length); + Log("Sending RA from router %s", aRouterAddress.ToString().AsCString()); + LogRouterAdvert(buffer, length); } template @@ -725,6 +807,17 @@ void SendRouterAdvert(const Ip6::Address &aRouterAddress, const DefaultRoute &aD SendRouterAdvert(aRouterAddress, nullptr, 0, nullptr, 0, aDefaultRoute); } +template void SendRouterAdvertToBorderRoutingProcessIcmp6Ra(const Pio (&aPios)[kNumPios]) +{ + uint8_t buffer[kMaxRaSize]; + uint16_t length = + BuildRouterAdvert(buffer, aPios, kNumPios, nullptr, 0, DefaultRoute(0, NetworkData::kRoutePreferenceMedium)); + + otPlatBorderRoutingProcessIcmp6Ra(sInstance, buffer, length); + Log("Passing RA to otPlatBorderRoutingProcessIcmp6Ra"); + LogRouterAdvert(buffer, length); +} + struct OnLinkPrefix : public Pio { OnLinkPrefix(const Ip6::Prefix &aPrefix, @@ -845,13 +938,15 @@ void VerifyPrefixTableIsEmpty(void) { VerifyPrefixTable(nullptr, 0, nullptr, 0); void InitTest(bool aEnablBorderRouting = false, bool aAfterReset = false) { + uint32_t delay = 10000; + //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Initialize OT instance. sNow = 0; + sAlarmOn = false; sInstance = static_cast(testInitInstance()); - uint32_t delay = 10000; if (aAfterReset) { delay += 26000; // leader reset sync delay @@ -859,6 +954,7 @@ void InitTest(bool aEnablBorderRouting = false, bool aAfterReset = false) memset(&sRadioTxFrame, 0, sizeof(sRadioTxFrame)); sRadioTxFrame.mPsdu = sRadioTxFramePsdu; + sRadioTxOngoing = false; SuccessOrQuit(sInfraIfAddress.FromString(kInfraIfAddress)); @@ -867,7 +963,11 @@ void InitTest(bool aEnablBorderRouting = false, bool aAfterReset = false) SuccessOrQuit(otBorderRoutingInit(sInstance, kInfraIfIndex, /* aInfraIfIsRunning */ true)); - SuccessOrQuit(otLinkSetPanId(sInstance, 0x1234)); + otOperationalDatasetTlvs datasetTlvs; + + SuccessOrQuit(otDatasetConvertToTlvs(&kDataset, &datasetTlvs)); + SuccessOrQuit(otDatasetSetActiveTlvs(sInstance, &datasetTlvs)); + SuccessOrQuit(otIp6SetEnabled(sInstance, true)); SuccessOrQuit(otThreadSetEnabled(sInstance, true)); SuccessOrQuit(otBorderRoutingSetEnabled(sInstance, aEnablBorderRouting)); @@ -3118,6 +3218,216 @@ void TestNat64PrefixSelection(void) } #endif // OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE +void VerifyPdOmrPrefix(const Ip6::Prefix &aPrefix) +{ + otBorderRoutingPrefixTableEntry platformPrefixInfo; + + VerifyOrQuit(otBorderRoutingGetPdOmrPrefix(sInstance, &platformPrefixInfo) == OT_ERROR_NONE); + VerifyOrQuit(AsCoreType(&platformPrefixInfo.mPrefix) == aPrefix); +} + +void VerifyNoPdOmrPrefix() +{ + otBorderRoutingPrefixTableEntry platformPrefixInfo; + + VerifyOrQuit(otBorderRoutingGetPdOmrPrefix(sInstance, &platformPrefixInfo) == OT_ERROR_NOT_FOUND); +} + +void TestBorderRoutingProcessPlatfromGeneratedNd(void) +{ + Ip6::Prefix localOmr; + + Log("--------------------------------------------------------------------------------------------"); + Log("TestBorderRoutingProcessPlatfromGeneratedNd"); + + InitTest(/* aEnableBorderRouting */ true); + + otBorderRoutingDhcp6PdSetEnabled(sInstance, true); + + { + SuccessOrQuit(sInstance->Get().GetOmrPrefix(localOmr)); + } + + // 0. Reject invalid RA. + Log("0. Invalid RA message."); + { + { + const uint8_t testInvalidRaMessage[] = { + 0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + otPlatBorderRoutingProcessIcmp6Ra(sInstance, testInvalidRaMessage, sizeof(testInvalidRaMessage)); + VerifyNoPdOmrPrefix(); + } + + { + const uint8_t testInvalidRaMessage[] = { + 0x87, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + otPlatBorderRoutingProcessIcmp6Ra(sInstance, testInvalidRaMessage, sizeof(testInvalidRaMessage)); + VerifyNoPdOmrPrefix(); + } + + { + const uint8_t testRaMessageWithInvalidPrefix[] = { + 0x86, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x04, 0x41, 0xc0, 0x00, 0x00, 0x10, 0xe1, 0x00, 0x00, 0x04, 0xd2, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + otPlatBorderRoutingProcessIcmp6Ra(sInstance, testRaMessageWithInvalidPrefix, + sizeof(testRaMessageWithInvalidPrefix)); + VerifyNoPdOmrPrefix(); + } + } + + // 1. Publish a prefix, and wait until it expired. + Log("1. Simple RA message."); + { + Ip6::Prefix raPrefix = PrefixFromString("2001:db8:dead:beef::", 64); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(raPrefix, kValidLitime, kPreferredLifetime)}); + + sExpectedRios.Add(raPrefix); + AdvanceTime(10000); + + VerifyPdOmrPrefix(raPrefix); + VerifyOrQuit(sExpectedRios.SawAll()); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1500000); + sExpectedRios.Clear(); + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(400000); + // Deprecated prefixes will be removed. + VerifyNoPdOmrPrefix(); + VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); + } + + // 1.1. Publish a prefix, and wait until it expired. + // Multiple prefixes are advertised, only the smallest one will be used. + Log("1.1. RA message with multiple prefixes."); + { + Ip6::Prefix raPrefix = PrefixFromString("2001:db8:dead:beef::", 64); + Ip6::Prefix ulaRaPrefix = PrefixFromString("fd01:db8:deaf:beef::", 64); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(ulaRaPrefix, kValidLitime * 2, kPreferredLifetime * 2), + Pio(raPrefix, kValidLitime, kPreferredLifetime)}); + + sExpectedRios.Add(raPrefix); + AdvanceTime(10000); + + VerifyPdOmrPrefix(raPrefix); + VerifyOrQuit(sExpectedRios.SawAll()); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1500000); + sExpectedRios.Clear(); + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(400000); + // Deprecated prefixes will be removed. + VerifyNoPdOmrPrefix(); + VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); + } + + // 2. Publish a prefix, and renew it before it expired. + Log("2. Renew prefix lifetime."); + { + Ip6::Prefix raPrefix = PrefixFromString("2001:db8:1:2::", 64); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(raPrefix, kValidLitime, kPreferredLifetime)}); + + sExpectedRios.Add(raPrefix); + AdvanceTime(10000); + + VerifyPdOmrPrefix(raPrefix); + VerifyOrQuit(sExpectedRios.SawAll()); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1500000); + sExpectedRios.Clear(); + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(raPrefix, kValidLitime, kPreferredLifetime)}); + + AdvanceTime(400000); + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1500000); + VerifyNoPdOmrPrefix(); + VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); + } + + // 3. Publish a prefix, and publish another prefix to replace it (with goodbye ra). + Log("3. Update prefix."); + { + Ip6::Prefix raPrefix = PrefixFromString("2001:db8:1:2::", 64); + Ip6::Prefix newRaPrefix = PrefixFromString("2001:db8:3:4::", 64); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(raPrefix, kValidLitime, kPreferredLifetime)}); + + sExpectedRios.Add(raPrefix); + sExpectedRios.Clear(); + AdvanceTime(10000); + + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1000000); + VerifyPdOmrPrefix(raPrefix); + + SendRouterAdvertToBorderRoutingProcessIcmp6Ra( + {Pio(raPrefix, 0, 0), Pio(newRaPrefix, kValidLitime, kPreferredLifetime)}); + sExpectedRios.Add(newRaPrefix); + + AdvanceTime(1000000); + VerifyOrQuit(sExpectedRios.SawAll()); + VerifyPdOmrPrefix(newRaPrefix); + + AdvanceTime(1000000); + VerifyNoPdOmrPrefix(); + VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); + } + + // 4. Short prefix will be extended to /64. + Log("Short prefix"); + { + // The prefix will be padded to a /64 prefix. + Ip6::Prefix raPrefix = PrefixFromString("2001:db8:cafe:0::", 64); + Ip6::Prefix realRaPrefix; + + realRaPrefix.Set(raPrefix.GetBytes(), 48); + SendRouterAdvertToBorderRoutingProcessIcmp6Ra({Pio(realRaPrefix, kValidLitime, kPreferredLifetime)}); + + sExpectedRios.Add(raPrefix); + AdvanceTime(10000); + + VerifyPdOmrPrefix(raPrefix); + VerifyOrQuit(sExpectedRios.SawAll()); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(1500000); + sExpectedRios.Clear(); + VerifyPdOmrPrefix(raPrefix); + VerifyOmrPrefixInNetData(raPrefix, /* aDefaultRoute */ false); + + AdvanceTime(400000); + // Deprecated prefixes will be removed. + VerifyNoPdOmrPrefix(); + VerifyOmrPrefixInNetData(localOmr, /* aDefaultRoute */ false); + } + Log("End of TestBorderRoutingProcessPlatfromGeneratedNd"); +} +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + #endif // OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE int main(void) @@ -3143,6 +3453,9 @@ int main(void) #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE TestNat64PrefixSelection(); #endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + TestBorderRoutingProcessPlatfromGeneratedNd(); +#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE printf("All tests passed\n"); #else diff --git a/tests/unit/test_spinel_buffer.cpp b/tests/unit/test_spinel_buffer.cpp index 0fbdb07a421..8d4f3225722 100644 --- a/tests/unit/test_spinel_buffer.cpp +++ b/tests/unit/test_spinel_buffer.cpp @@ -891,7 +891,7 @@ uint32_t GetRandom(uint32_t max) if (kUseTrueRandomNumberGenerator) { - SuccessOrQuit(Random::Crypto::FillBuffer(reinterpret_cast(&value), sizeof(value))); + SuccessOrQuit(Random::Crypto::Fill(value)); } else { diff --git a/tests/unit/test_spinel_encoder.cpp b/tests/unit/test_spinel_encoder.cpp index 7acb0d01539..4b76d4c6bfd 100644 --- a/tests/unit/test_spinel_encoder.cpp +++ b/tests/unit/test_spinel_encoder.cpp @@ -310,7 +310,7 @@ void TestEncoder(void) printf(" -- PASS\n"); printf("\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); - printf("\nTest 5: Test saving position and reseting back to a saved position"); + printf("\nTest 5: Test saving position and resetting back to a saved position"); SuccessOrQuit(encoder.BeginFrame(Spinel::Buffer::kPriorityLow)); SuccessOrQuit(encoder.WriteUint8(kUint8)); diff --git a/tests/unit/test_srp_server.cpp b/tests/unit/test_srp_server.cpp index 34ab9052a01..456d831c294 100644 --- a/tests/unit/test_srp_server.cpp +++ b/tests/unit/test_srp_server.cpp @@ -31,6 +31,7 @@ #include "test_platform.h" #include "test_util.hpp" +#include #include #include #include @@ -80,6 +81,8 @@ void AdvanceTime(uint32_t aDuration); extern "C" { +otRadioCaps otPlatRadioGetCaps(otInstance *) { return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF; } + otError otPlatRadioTransmit(otInstance *, otRadioFrame *) { sRadioTxOngoing = true; @@ -188,15 +191,23 @@ void InitTest(void) // Initialize OT instance. sNow = 0; + sAlarmOn = false; sInstance = static_cast(testInitInstance()); memset(&sRadioTxFrame, 0, sizeof(sRadioTxFrame)); sRadioTxFrame.mPsdu = sRadioTxFramePsdu; + sRadioTxOngoing = false; //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Initialize Border Router and start Thread operation. - SuccessOrQuit(otLinkSetPanId(sInstance, 0x1234)); + otOperationalDataset dataset; + otOperationalDatasetTlvs datasetTlvs; + + SuccessOrQuit(otDatasetCreateNewNetwork(sInstance, &dataset)); + SuccessOrQuit(otDatasetConvertToTlvs(&dataset, &datasetTlvs)); + SuccessOrQuit(otDatasetSetActiveTlvs(sInstance, &datasetTlvs)); + SuccessOrQuit(otIp6SetEnabled(sInstance, true)); SuccessOrQuit(otThreadSetEnabled(sInstance, true)); @@ -283,7 +294,7 @@ static const char kHostName[] = "myhost"; void PrepareService1(Srp::Client::Service &aService) { static const char kServiceName[] = "_srv._udp"; - static const char kInstanceLabel[] = "srv-instance"; + static const char kInstanceLabel[] = "srv.instance"; static const char kSub1[] = "_sub1"; static const char kSub2[] = "_V1234567"; static const char kSub3[] = "_XYZWS"; diff --git a/tests/unit/test_timer.cpp b/tests/unit/test_timer.cpp index b6ecd665193..26b55d8ce96 100644 --- a/tests/unit/test_timer.cpp +++ b/tests/unit/test_timer.cpp @@ -507,7 +507,7 @@ template static void TenTimers(uint32_t aTimeShift) } // given the order in which timers are started, the TimerScheduler should call otPlatAlarmMilliStartAt 2 times. - // one for timer[0] and one for timer[5] which will supercede timer[0]. + // one for timer[0] and one for timer[5] which will supersede timer[0]. VerifyOrQuit(sCallCount[kCallCountIndexAlarmStart] == 2, "TestTenTimer: Start CallCount Failed."); VerifyOrQuit(sCallCount[kCallCountIndexAlarmStop] == 0, "TestTenTimer: Stop CallCount Failed."); VerifyOrQuit(sCallCount[kCallCountIndexTimerHandler] == 0, "TestTenTimer: Handler CallCount Failed."); diff --git a/tests/unit/test_util.h b/tests/unit/test_util.h index 5630a53d8f2..4b3931f20ec 100644 --- a/tests/unit/test_util.h +++ b/tests/unit/test_util.h @@ -39,7 +39,7 @@ extern "C" { #endif /** - * This macro verifies a given error status to be successful (compared against value zero (0)), otherwise, it emits a + * Verifies a given error status to be successful (compared against value zero (0)), otherwise, it emits a * given error messages and exits the program. * * @param[in] aStatus A scalar error status to be evaluated against zero (0). @@ -58,7 +58,7 @@ extern "C" { } while (false) /** - * This macro verifies that a given boolean condition is true, otherwise, it emits a given error message and exits the + * Verifies that a given boolean condition is true, otherwise, it emits a given error message and exits the * program. * * @param[in] aCondition A Boolean expression to be evaluated. diff --git a/tests/unit/test_util.hpp b/tests/unit/test_util.hpp index e561fc2d1c5..6f248d0dfe2 100644 --- a/tests/unit/test_util.hpp +++ b/tests/unit/test_util.hpp @@ -34,7 +34,7 @@ #include "test_util.h" /** - * This function prints the content of a given buffer to screen as a hex dump along with ASCII text translation. + * Prints the content of a given buffer to screen as a hex dump along with ASCII text translation. * * @param[in] aTextMessag A text message to describe the buffer content (printed before the buffer content) * @param[in] aBuffer A pointer to the buffer diff --git a/tools/harness-simulation/harness/Thread_Harness/THCI/OpenThread_Sim.py b/tools/harness-simulation/harness/Thread_Harness/THCI/OpenThread_Sim.py index 18c622ec067..c8e84aeea53 100644 --- a/tools/harness-simulation/harness/Thread_Harness/THCI/OpenThread_Sim.py +++ b/tools/harness-simulation/harness/Thread_Harness/THCI/OpenThread_Sim.py @@ -89,7 +89,7 @@ def __connect(self, device): self.__stdout.channel.setblocking(0) # Some commands such as `udp send -x ` send binary data - # The UDP packet recevier will output the data in binary to stdout + # The UDP packet receiver will output the data in binary to stdout self.__stdout._set_mode('rb') def __disconnect(self, dwCtrlType): diff --git a/tools/harness-sniffer/OT_Sniffer.py b/tools/harness-sniffer/OT_Sniffer.py index 78da15a38e4..2c97d6cc1f5 100644 --- a/tools/harness-sniffer/OT_Sniffer.py +++ b/tools/harness-sniffer/OT_Sniffer.py @@ -43,7 +43,7 @@ def __init__(self, **kwargs): self.is_active = False except Exception as e: - ModuleHelper.WriteIntoDebugLogger('OT_Sniffer: [intialize] --> ' + str(e)) + ModuleHelper.WriteIntoDebugLogger('OT_Sniffer: [initialize] --> ' + str(e)) def discoverSniffer(self): sniffers = [] @@ -148,7 +148,7 @@ def isSnifferCapturing(self): def getSnifferAddress(self): """ - Method to retrun the current sniffer's COM/IP address + Method to return the current sniffer's COM/IP address @return : string """ return self.port diff --git a/tools/harness-thci/OpenThread.py b/tools/harness-thci/OpenThread.py index 2410bc49d89..7bff870fa7a 100644 --- a/tools/harness-thci/OpenThread.py +++ b/tools/harness-thci/OpenThread.py @@ -72,7 +72,7 @@ OT12_VERSION = 'OPENTHREAD' OT13_VERSION = 'OPENTHREAD' -# Supported device capabilites in this THCI implementation +# Supported device capabilities in this THCI implementation OT11_CAPBS = DevCapb.V1_1 OT12_CAPBS = (DevCapb.L_AIO | DevCapb.C_FFD | DevCapb.C_RFD) OT12BR_CAPBS = (DevCapb.C_BBR | DevCapb.C_Host | DevCapb.C_Comm) @@ -255,7 +255,7 @@ def _cliWriteLine(self, line): line str: data send to device """ - # Override the following empty methods in the dervied classes when needed + # Override the following empty methods in the derived classes when needed def _onCommissionStart(self): """Called when commissioning starts""" @@ -442,7 +442,7 @@ def intialize(self, params): self.UIStatusMsg) ModuleHelper.WriteIntoDebugLogger('Err: OpenThread device Firmware not matching..') - # Make this class compatible with Thread referenece 20200818 + # Make this class compatible with Thread reference 20200818 self.__detectReference20200818() def __repr__(self): @@ -880,7 +880,7 @@ def getChannel(self): @API def setMAC(self, xEUI): - """set the extended addresss of Thread device + """set the extended address of Thread device Args: xEUI: extended address in hex format @@ -2369,7 +2369,7 @@ def MGMT_ED_SCAN( Args: sAddr: IPv6 destination address for this message xCommissionerSessionId: commissioner session id - listChannelMask: a channel array to indicate which channels to be scaned + listChannelMask: a channel array to indicate which channels to be scanned xCount: number of IEEE 802.15.4 ED Scans (milliseconds) xPeriod: Period between successive IEEE802.15.4 ED Scans (milliseconds) xScanDuration: ScanDuration when performing an IEEE 802.15.4 ED Scan (milliseconds) diff --git a/tools/harness-thci/OpenThread_BR.py b/tools/harness-thci/OpenThread_BR.py index 83e16bf1b2f..c22557a86c6 100644 --- a/tools/harness-thci/OpenThread_BR.py +++ b/tools/harness-thci/OpenThread_BR.py @@ -708,7 +708,7 @@ def forceSetSlaac(self, slaacAddress): @API def stopListeningToAddr(self, sAddr): """ - Unsubscribe to a given IPv6 address which was subscribed earlier wiht `registerMulticast`. + Unsubscribe to a given IPv6 address which was subscribed earlier with `registerMulticast`. Args: sAddr : str : Multicast address to be unsubscribed. Use an empty string to unsubscribe diff --git a/tools/harness-thci/OpenThread_WpanCtl.py b/tools/harness-thci/OpenThread_WpanCtl.py index 42d8aa9442f..81ce6161002 100644 --- a/tools/harness-thci/OpenThread_WpanCtl.py +++ b/tools/harness-thci/OpenThread_WpanCtl.py @@ -867,7 +867,7 @@ def getChannel(self): return self.__sendCommand(self.wpan_cmd_prefix + 'getprop -v NCP:Channel')[0] def setMAC(self, xEUI): - """set the extended addresss of Thread device + """set the extended address of Thread device Args: xEUI: extended address in hex format @@ -2180,7 +2180,7 @@ def MGMT_ED_SCAN(self, sAddr, xCommissionerSessionId, listChannelMask, xCount, x Args: sAddr: IPv6 destination address for this message xCommissionerSessionId: commissioner session id - listChannelMask: a channel array to indicate which channels to be scaned + listChannelMask: a channel array to indicate which channels to be scanned xCount: number of IEEE 802.15.4 ED Scans (milliseconds) xPeriod: Period between successive IEEE802.15.4 ED Scans (milliseconds) xScanDuration: IEEE 802.15.4 ScanDuration to use when performing an IEEE 802.15.4 ED Scan (milliseconds) diff --git a/tools/ot-fct/cli.hpp b/tools/ot-fct/cli.hpp index e679ef5931d..452299a6758 100644 --- a/tools/ot-fct/cli.hpp +++ b/tools/ot-fct/cli.hpp @@ -47,7 +47,7 @@ namespace Fct { class Cli; /** - * This class implements the factory CLI. + * Implements the factory CLI. * */ class Cli @@ -60,7 +60,7 @@ class Cli } /** - * This method processes a factory command. + * Processes a factory command. * * @param[in] aArgs The arguments of command line. * @param[in] aArgsLength The number of args in @p aArgs. @@ -69,7 +69,7 @@ class Cli void ProcessCommand(Utils::CmdLineParser::Arg aArgs[]); /** - * This method processes the command line. + * Processes the command line. * * @param[in] aLine A pointer to a command line string. * @@ -77,7 +77,7 @@ class Cli void ProcessLine(char *aLine); /** - * This method outputs the prompt. + * Outputs the prompt. * */ void OutputPrompt(void); diff --git a/tools/otci/otci/otci.py b/tools/otci/otci/otci.py index 9a8c2cb22bc..d9d5c1f2541 100644 --- a/tools/otci/otci/otci.py +++ b/tools/otci/otci/otci.py @@ -1975,14 +1975,14 @@ def get_ipmaddr_rlatn(self) -> Ip6Addr: def enable_backbone_router(self): """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. + SRV_DATA.ntf would be triggered for attached device if there is no Backbone Router Service in Thread Network Data. """ self.execute_command('bbr enable') def disable_backbone_router(self): """Disable Backbone Router Service for Thread 1.2 FTD. - SRV_DATA.ntf would be triggerred if Backbone Router is Primary state. + SRV_DATA.ntf would be triggered if Backbone Router is Primary state. """ self.execute_command('bbr disable') @@ -2036,7 +2036,7 @@ def get_primary_backbone_router_info(self) -> Optional[dict]: def register_backbone_router_dataset(self): """Register Backbone Router Service for Thread 1.2 FTD. - SRV_DATA.ntf would be triggerred for attached device. + SRV_DATA.ntf would be triggered for attached device. """ self.execute_command('bbr register') diff --git a/tools/otci/tests/test_otci.py b/tools/otci/tests/test_otci.py index ad4b25f52c6..7366470696d 100644 --- a/tools/otci/tests/test_otci.py +++ b/tools/otci/tests/test_otci.py @@ -41,9 +41,14 @@ logging.basicConfig(level=logging.DEBUG) TEST_CHANNEL = 22 +TEST_CHANNEL_MASK = 0x07fff800 +TEST_EXTENDED_PANID = '000db80000000000' +TEST_MESH_LOCAL_PREFIX = 'fd00:db8::' +TEST_NETWORK_KEY = 'ffeeddccbbaa99887766554433221100' TEST_NETWORK_NAME = 'OT CI' TEST_PANID = 0xeeee -TEST_NETWORKKEY = 'ffeeddccbbaa99887766554433221100' +TEST_PSKC = 'c23a76e98f1a6483639b1ac1271e2e27' +TEST_SECURITY_POLICY = (672, 'onrc') REAL_DEVICE = int(os.getenv('REAL_DEVICE', '0')) @@ -142,8 +147,8 @@ def _test_otci_single_node(self, leader): leader.set_network_name(TEST_NETWORK_NAME) - leader.set_network_key(TEST_NETWORKKEY) - self.assertEqual(TEST_NETWORKKEY, leader.get_network_key()) + leader.set_network_key(TEST_NETWORK_KEY) + self.assertEqual(TEST_NETWORK_KEY, leader.get_network_key()) leader.set_panid(TEST_PANID) self.assertEqual(TEST_PANID, leader.get_panid()) @@ -171,6 +176,7 @@ def _test_otci_single_node(self, leader): leader.set_preferred_partition_id(0xabcddead) self.assertEqual(leader.get_preferred_partition_id(), 0xabcddead) + _setup_default_network(leader) leader.thread_start() leader.wait(10) self.assertEqual('leader', leader.get_state()) @@ -554,19 +560,12 @@ def _test_otci_multi_nodes(self, leader, commissioner, child1, child2): leader.set_extaddr(new_extaddr) self.assertEqual(new_extaddr, leader.get_extaddr()) - leader.set_network_name(TEST_NETWORK_NAME) - - leader.set_network_key(TEST_NETWORKKEY) - self.assertEqual(TEST_NETWORKKEY, leader.get_network_key()) + _setup_default_network(leader) - leader.set_panid(TEST_PANID) - self.assertEqual(TEST_PANID, leader.get_panid()) - - leader.set_channel(TEST_CHANNEL) self.assertEqual(TEST_CHANNEL, leader.get_channel()) - - leader.set_network_name(TEST_NETWORK_NAME) + self.assertEqual(TEST_NETWORK_KEY, leader.get_network_key()) self.assertEqual(TEST_NETWORK_NAME, leader.get_network_name()) + self.assertEqual(TEST_PANID, leader.get_panid()) self.assertEqual('rdn', leader.get_mode()) @@ -579,12 +578,15 @@ def _test_otci_multi_nodes(self, leader, commissioner, child1, child2): leader_id = leader.get_router_id() self.assertEqual(rloc16, leader_id << 10) - commissioner.ifconfig_up() - commissioner.set_channel(TEST_CHANNEL) - commissioner.set_panid(TEST_PANID) - commissioner.set_network_name(TEST_NETWORK_NAME) + commissioner.dataset_clear_buffer() + commissioner.dataset_set_buffer( + channel=TEST_CHANNEL, + network_key=TEST_NETWORK_KEY, + panid=TEST_PANID, + ) + commissioner.dataset_commit_buffer('active') commissioner.set_router_selection_jitter(1) - commissioner.set_network_key(TEST_NETWORKKEY) + commissioner.ifconfig_up() commissioner.thread_start() commissioner.wait(10) @@ -724,5 +726,22 @@ def _test_otci_multi_nodes(self, leader, commissioner, child1, child2): leader.close() +def _setup_default_network(node): + node.dataset_clear_buffer() + node.dataset_set_buffer( + active_timestamp=1, + channel=TEST_CHANNEL, + channel_mask=TEST_CHANNEL_MASK, + extpanid=TEST_EXTENDED_PANID, + mesh_local_prefix=TEST_MESH_LOCAL_PREFIX, + network_key=TEST_NETWORK_KEY, + network_name=TEST_NETWORK_NAME, + panid=TEST_PANID, + pskc=TEST_PSKC, + security_policy=TEST_SECURITY_POLICY, + ) + node.dataset_commit_buffer('active') + + if __name__ == '__main__': unittest.main() diff --git a/tools/spi-hdlc-adapter/spi-hdlc-adapter.c b/tools/spi-hdlc-adapter/spi-hdlc-adapter.c index 0adff6b734d..48c256c9347 100644 --- a/tools/spi-hdlc-adapter/spi-hdlc-adapter.c +++ b/tools/spi-hdlc-adapter/spi-hdlc-adapter.c @@ -1416,7 +1416,7 @@ static void print_help(void) " --spi-mode[=mode] ............ Specify the SPI mode to use (0-3).\n" " --spi-speed[=hertz] .......... Specify the SPI speed in hertz.\n" " --spi-cs-delay[=usec] ........ Specify the delay after C̅S̅ assertion, in µsec\n" - " --spi-reset-delay[=ms] ....... Specify the delay after R̅E̅S̅E̅T̅ assertion, in miliseconds\n" + " --spi-reset-delay[=ms] ....... Specify the delay after R̅E̅S̅E̅T̅ assertion, in milliseconds\n" " --spi-align-allowance[=n] .... Specify the maximum number of 0xFF bytes to\n" " clip from start of MISO frame. Max value is 16.\n" " --spi-small-packet=[n] ....... Specify the smallest packet we can receive\n"