[netdata] enhance FindContext() methods and Lowpan::Context (#11836)

This commit enhances the `FindContext()` methods and converts the
`Lowpan::Context` struct into a class.

The `FindContext()` methods are updated as follows:
- Renamed to `FindContextForAddress()` and `FindContextForId()` to
  more accurately reflect their function.
- The return type is changed from `Error` to `void`. Success is now
  indicated by checking the `IsValid()` state of the output `Context`
  object (matching how `Lowpan` class uses the `Context`). This
  change simplifies the callers and harmonizes the context check
  across different modules.

The `Lowpan::Context` struct is converted into a class, encapsulating
its members by making them private and introducing public getters.
This commit is contained in:
Abtin Keshavarzian
2025-08-22 14:30:14 -07:00
committed by GitHub
parent 7b59c810d9
commit b6f1252bd8
12 changed files with 164 additions and 110 deletions
+4 -2
View File
@@ -1910,14 +1910,16 @@ Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
IgnoreError(aRxInfo.mMessage.Read(offsetRange, address.GetIid()));
offsetRange.AdvanceOffset(sizeof(Ip6::InterfaceIdentifier));
if (Get<NetworkData::Leader>().GetContext(contextId, context) != kErrorNone)
Get<NetworkData::Leader>().FindContextForId(contextId, context);
if (!context.IsValid())
{
LogWarn("Failed to get context %u for compressed address from child 0x%04x", contextId,
aChild.GetRloc16());
continue;
}
address.SetPrefix(context.mPrefix);
address.SetPrefix(context.GetPrefix());
}
else
{