[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
+5 -4
View File
@@ -294,12 +294,13 @@ void DuaManager::HandleNotifierEvents(Events aEvents)
Mle::Mle &mle = Get<Mle::Mle>();
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (aEvents.Contains(kEventThreadNetdataChanged))
if (aEvents.Contains(kEventThreadNetdataChanged) && Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
{
Lowpan::Context context;
// Remove a stale DUA address if any.
if (Get<ThreadNetif>().HasUnicastAddress(Get<DuaManager>().GetDomainUnicastAddress()) &&
(Get<NetworkData::Leader>().GetContext(Get<DuaManager>().GetDomainUnicastAddress(), context) != kErrorNone))
Get<NetworkData::Leader>().FindContextForAddress(GetDomainUnicastAddress(), context);
if (!context.IsValid())
{
RemoveDomainUnicastAddress();
}