mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
a84fc2e50b
This commit introduces `Message::ReadAndAdvance()` and its template flavor to the `Message` class. This helper method reads data from a `Message` at a given `OffsetRange` and advances the `OffsetRange` by the number of bytes read upon success. Sequential parsing of structured data (such as TLVs or protocol headers) is a common pattern across the OpenThread codebase. Previously, this required two separate calls: one to `Read()` and another to `AdvanceOffset()`. The new `ReadAndAdvance()` method consolidates these into a single, safer operation that ensures the offset is only advanced if the read operation succeeds. This commit updates numerous call sites across the core stack (MLE, BBR, DatasetManager, NetworkDiagnostic, DHCPv6, etc.) to use the new helper, improving code clarity and reducing boilerplate.