mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 17:37:46 +00:00
MleRouter: Update how CHILD_ADDED/CHILD_REMOVED are signaled. (#1272)
- This commit adds a new method `MleRouter::SetChildStateToValid()` which updates the child state to `kStateValid` and ensures to signal `CHILD_ADDED` and store the child info (only if child was not in valid state before). - It also updates the `RemoveChildren()` to signal `CHILD_REMOVED` if any child is removed.
This commit is contained in:
committed by
Jonathan Hui
parent
7b3ea11ebb
commit
f5141f03f5
@@ -2412,11 +2412,11 @@ ThreadError MleRouter::HandleChildUpdateResponse(const Message &aMessage, const
|
||||
}
|
||||
}
|
||||
|
||||
SetChildStateToValid(child);
|
||||
child->mLastHeard = Timer::GetNow();
|
||||
child->mKeySequence = aKeySequence;
|
||||
child->mLinkInfo.AddRss(mNetif.GetMac().GetNoiseFloor(), threadMessageInfo->mRss);
|
||||
child->mAddSrcMatchEntryShort = true;
|
||||
child->mState = Neighbor::kStateValid;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -2739,9 +2739,7 @@ ThreadError MleRouter::SendChildIdResponse(Child *aChild)
|
||||
SuccessOrExit(error = AppendChildAddresses(*message, *aChild));
|
||||
}
|
||||
|
||||
aChild->mState = Neighbor::kStateValid;
|
||||
mNetif.SetStateChangedFlags(OT_THREAD_CHILD_ADDED);
|
||||
StoreChild(aChild->mValid.mRloc16);
|
||||
SetChildStateToValid(aChild);
|
||||
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.mFields.m16[0] = HostSwap16(0xfe80);
|
||||
@@ -4424,6 +4422,18 @@ exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
void MleRouter::SetChildStateToValid(Child *aChild)
|
||||
{
|
||||
VerifyOrExit(aChild->mState != Neighbor::kStateValid, ;);
|
||||
|
||||
aChild->mState = Neighbor::kStateValid;
|
||||
mNetif.SetStateChangedFlags(OT_THREAD_CHILD_ADDED);
|
||||
StoreChild(aChild->mValid.mRloc16);
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
bool MleRouter::HasChildren(void)
|
||||
{
|
||||
bool hasChildren = false;
|
||||
@@ -4444,11 +4454,20 @@ void MleRouter::RemoveChildren(void)
|
||||
{
|
||||
for (uint8_t i = 0; i < mMaxChildrenAllowed; i++)
|
||||
{
|
||||
if (mChildren[i].mState == Neighbor::kStateRestored ||
|
||||
mChildren[i].mState == Neighbor::kStateChildUpdateRequest ||
|
||||
mChildren[i].mState == Neighbor::kStateValid)
|
||||
switch (mChildren[i].mState)
|
||||
{
|
||||
case Neighbor::kStateValid:
|
||||
mNetif.SetStateChangedFlags(OT_THREAD_CHILD_REMOVED);
|
||||
|
||||
// Fall-through to next case
|
||||
|
||||
case Neighbor::kStateChildUpdateRequest:
|
||||
case Neighbor::kStateRestored:
|
||||
RemoveStoredChild(mChildren[i].mValid.mRloc16);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
mChildren[i].mState = Neighbor::kStateInvalid;
|
||||
|
||||
@@ -787,6 +787,7 @@ private:
|
||||
Child *FindChild(uint16_t aChildId);
|
||||
Child *FindChild(const Mac::ExtAddress &aMacAddr);
|
||||
|
||||
void SetChildStateToValid(Child *aChild);
|
||||
bool HasChildren(void);
|
||||
void RemoveChildren(void);
|
||||
bool HasMinDowngradeNeighborRouters(void);
|
||||
|
||||
Reference in New Issue
Block a user