Skip to content

[mle] add AppendSourceAddressAndLeaderDataTlvs() helper - #12867

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:mle/append-src-addr-leader-data
Apr 11, 2026
Merged

[mle] add AppendSourceAddressAndLeaderDataTlvs() helper#12867
jwhui merged 1 commit into
openthread:mainfrom
abtink:mle/append-src-addr-leader-data

Conversation

@abtink

@abtink abtink commented Apr 9, 2026

Copy link
Copy Markdown
Member

This commit introduces TxMessage::AppendSourceAddressAndLeaderDataTlvs() to consolidate the appending of Source Address and Leader Data TLVs.

This combination is frequently used together across various MLE messages to provide the sender's identity and leader data. Centralizing this into a single helper method improves code consistency.

Additionally, the TxMessage methods in mle.hpp and mle.cpp are organized into "Appending single TLV" and "Appending multiple TLVs" sections for better clarity and maintainability. Existing multi-TLV methods like AppendLinkAndMleFrameCounterTlvs() and AppendActiveAndPendingTimestampTlvs() are moved to the new section.

This commit introduces `TxMessage::AppendSourceAddressAndLeaderDataTlvs()`
to consolidate the appending of `Source Address` and `Leader Data` TLVs.

This combination is frequently used together across various MLE messages
to provide the sender's identity and leader data. Centralizing this
into a single helper method improves code consistency.

Additionally, the `TxMessage` methods in `mle.hpp` and `mle.cpp` are
organized into "Appending single TLV" and "Appending multiple TLVs"
sections for better clarity and maintainability. Existing multi-TLV
methods like `AppendLinkAndMleFrameCounterTlvs()` and
`AppendActiveAndPendingTimestampTlvs()` are moved to the new section.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves code consistency and maintainability within the MLE message handling logic. By centralizing the common pattern of appending Source Address and Leader Data TLVs into a single helper method, the codebase becomes cleaner and less prone to errors. Additionally, the reorganization of the TxMessage methods provides a clearer structure for future development.

Highlights

  • New Helper Method: Introduced TxMessage::AppendSourceAddressAndLeaderDataTlvs() to consolidate the frequent pairing of Source Address and Leader Data TLV appends.
  • Code Organization: Refactored mle.hpp and mle.cpp to categorize TxMessage methods into 'Appending single TLV' and 'Appending multiple TLVs' sections for improved maintainability.
  • Refactoring: Updated multiple call sites across mle.cpp and mle_ftd.cpp to utilize the new helper method, reducing code duplication.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

Merging #12867 into main

name branch text data bss total
ot-cli-ftd 05ad980 482944 860 66540 550344
cbd703e 482880 860 66540 550280
+/- -64 +0 +0 -64
ot-ncp-ftd 05ad980 448804 764 61776 511344
cbd703e 448740 764 61776 511280
+/- -64 +0 +0 -64
ot-cli-mtd 05ad980 375040 764 50972 426776
cbd703e 375056 764 50972 426792
+/- +16 +0 +0 +16
ot-ncp-mtd 05ad980 356180 764 46240 403184
cbd703e 356180 764 46240 403184
+/- +0 +0 +0 +0
ot-cli-ftd-br 05ad980 599848 864 136732 737444
cbd703e 599784 864 136732 737380
+/- -64 +0 +0 -64
ot-rcp 05ad980 63328 568 20804 84700
cbd703e 63328 568 20804 84700
+/- +0 +0 +0 +0
Library files
name branch text data bss total
libopenthread-ftd.a 05ad980 250899 95 40319 291313
cbd703e 250835 95 40319 291249
+/- -64 +0 +0 -64
libopenthread-cli-ftd.a 05ad980 61757 0 8091 69848
cbd703e 61757 0 8091 69848
+/- +0 +0 +0 +0
libopenthread-ncp-ftd.a 05ad980 33583 0 5948 39531
cbd703e 33583 0 5948 39531
+/- +0 +0 +0 +0
libopenthread-mtd.a 05ad980 169243 0 24783 194026
cbd703e 169253 0 24783 194036
+/- +10 +0 +0 +10
libopenthread-cli-mtd.a 05ad980 41454 0 8059 49513
cbd703e 41454 0 8059 49513
+/- +0 +0 +0 +0
libopenthread-ncp-mtd.a 05ad980 25807 0 5948 31755
cbd703e 25807 0 5948 31755
+/- +0 +0 +0 +0
libopenthread-ftd-br.a 05ad980 368807 99 110471 479377
cbd703e 368743 99 110471 479313
+/- -64 +0 +0 -64
libopenthread-cli-ftd-br.a 05ad980 80964 0 8131 89095
cbd703e 80964 0 8131 89095
+/- +0 +0 +0 +0
libopenthread-rcp.a 05ad980 9946 0 5060 15006
cbd703e 9946 0 5060 15006
+/- +0 +0 +0 +0
libopenthread-radio.a 05ad980 19847 0 238 20085
cbd703e 19847 0 238 20085
+/- +0 +0 +0 +0

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the MLE message construction by introducing helper methods to append multiple related TLVs, such as source address and leader data, link and MLE frame counters, and active and pending timestamps. This reduces code duplication across various message-sending functions. The review feedback highlights the need to ensure robustness by calling a length-checking function after processing each TLV in these new helper methods, as per project guidelines.

Comment thread src/core/thread/mle.cpp
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.32%. Comparing base (51353c4) to head (e06cf96).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12867      +/-   ##
==========================================
- Coverage   75.00%   73.32%   -1.68%     
==========================================
  Files         696      696              
  Lines       95432    98534    +3102     
==========================================
+ Hits        71576    72249     +673     
- Misses      23856    26285    +2429     
Files with missing lines Coverage Δ
src/core/thread/mle.cpp 87.67% <100.00%> (+0.64%) ⬆️
src/core/thread/mle.hpp 93.52% <ø> (ø)
src/core/thread/mle_ftd.cpp 83.38% <100.00%> (+0.73%) ⬆️

... and 112 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abtink
abtink marked this pull request as ready for review April 9, 2026 22:31
@jwhui
jwhui merged commit 9feec93 into openthread:main Apr 11, 2026
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants