mirror of
https://github.com/espressif/openthread.git
synced 2026-09-20 16:07:36 +00:00
[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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user