mirror of
https://github.com/espressif/openthread.git
synced 2026-11-09 16:01:31 +00:00
[netdata] resign active commissioner on NetData restore on leader (#9549)
This commit updates `HandleNetworkDataRestoredAfterReset()`, which is called after Network Data is restored on the leader after a leader reset and recovery. We now resign any active Commissioner by clearing the Commissioning Data and adopt the Session ID from the restored Network Data Commissioning Data. This ensures that any stale Commissioning Data is not retained in Network Data for longer after a leader reset.
This commit is contained in:
@@ -62,6 +62,14 @@ public:
|
||||
*/
|
||||
explicit Leader(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* Sets the session ID.
|
||||
*
|
||||
* @param[in] aSessionId The session ID to use.
|
||||
*
|
||||
*/
|
||||
void SetSessionId(uint16_t aSessionId) { mSessionId = aSessionId; }
|
||||
|
||||
/**
|
||||
* Sends a MGMT_DATASET_CHANGED message to commissioner.
|
||||
*
|
||||
|
||||
@@ -1301,6 +1301,7 @@ void Leader::HandleNetworkDataRestoredAfterReset(void)
|
||||
Iterator iterator = kIteratorInit;
|
||||
ChangedFlags flags;
|
||||
uint16_t rloc16;
|
||||
uint16_t sessionId;
|
||||
|
||||
mWaitingForNetDataSync = false;
|
||||
|
||||
@@ -1345,6 +1346,20 @@ void Leader::HandleNetworkDataRestoredAfterReset(void)
|
||||
mContextIds.ScheduleToRemove(context->GetContextId());
|
||||
}
|
||||
}
|
||||
|
||||
// Update Commissioning Data. We adopt the same session ID
|
||||
// (if any) and resign active commissioner (if any) by
|
||||
// clearing the Commissioning Data.
|
||||
|
||||
if (FindCommissioningSessionId(sessionId) == kErrorNone)
|
||||
{
|
||||
Get<MeshCoP::Leader>().SetSessionId(sessionId);
|
||||
}
|
||||
|
||||
if (FindBorderAgentRloc(rloc16) == kErrorNone)
|
||||
{
|
||||
Get<MeshCoP::Leader>().SetEmptyCommissionerData();
|
||||
}
|
||||
}
|
||||
|
||||
void Leader::HandleTimer(void)
|
||||
|
||||
Reference in New Issue
Block a user