mirror of
https://github.com/espressif/openthread.git
synced 2026-06-16 10:24:59 +00:00
[mle] update Mle::GetParent() to return reference (#4419)
This commit is contained in:
committed by
Jonathan Hui
parent
bf4c7370bf
commit
1996d42d9d
@@ -311,7 +311,7 @@ otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().GetRole() == OT_DEVICE_ROLE_CHILD, error = OT_ERROR_INVALID_STATE);
|
||||
#endif
|
||||
|
||||
parent = instance.Get<Mle::MleRouter>().GetParent();
|
||||
parent = &instance.Get<Mle::MleRouter>().GetParent();
|
||||
|
||||
aParentInfo->mExtAddress = parent->GetExtAddress();
|
||||
aParentInfo->mRloc16 = parent->GetRloc16();
|
||||
@@ -334,12 +334,10 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
Router * parent;
|
||||
|
||||
assert(aParentRssi != NULL);
|
||||
|
||||
parent = instance.Get<Mle::MleRouter>().GetParent();
|
||||
*aParentRssi = parent->GetLinkInfo().GetAverageRss();
|
||||
*aParentRssi = instance.Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetAverageRss();
|
||||
|
||||
VerifyOrExit(*aParentRssi != OT_RADIO_RSSI_INVALID, error = OT_ERROR_FAILED);
|
||||
|
||||
@@ -351,12 +349,10 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
Router * parent;
|
||||
|
||||
assert(aLastRssi != NULL);
|
||||
|
||||
parent = instance.Get<Mle::MleRouter>().GetParent();
|
||||
*aLastRssi = parent->GetLinkInfo().GetLastRss();
|
||||
*aLastRssi = instance.Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetLastRss();
|
||||
|
||||
VerifyOrExit(*aLastRssi != OT_RADIO_RSSI_INVALID, error = OT_ERROR_FAILED);
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ otError DataPollSender::GetPollDestinationAddress(Mac::Address &aDest) const
|
||||
|
||||
VerifyOrExit((parent != NULL) && parent->IsStateValidOrRestoring(), error = OT_ERROR_ABORT);
|
||||
|
||||
if ((Get<Mac::Mac>().GetShortAddress() == Mac::kShortAddrInvalid) || (parent != Get<Mle::MleRouter>().GetParent()))
|
||||
if ((Get<Mac::Mac>().GetShortAddress() == Mac::kShortAddrInvalid) || (parent != &Get<Mle::MleRouter>().GetParent()))
|
||||
{
|
||||
aDest.SetExtended(parent->GetExtAddress());
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ otError KeyManager::SetMasterKey(const MasterKey &aKey)
|
||||
ComputeKey(mKeySequence, mKey);
|
||||
|
||||
// reset parent frame counters
|
||||
parent = Get<Mle::MleRouter>().GetParent();
|
||||
parent = &Get<Mle::MleRouter>().GetParent();
|
||||
parent->SetKeySequence(0);
|
||||
parent->SetLinkFrameCounter(0);
|
||||
parent->SetMleFrameCounter(0);
|
||||
|
||||
@@ -3959,11 +3959,6 @@ bool Mle::IsMeshLocalAddress(const Ip6::Address &aAddress) const
|
||||
return aAddress.PrefixMatch(GetMeshLocal16()) >= Ip6::Address::kMeshLocalPrefixLength;
|
||||
}
|
||||
|
||||
Router *Mle::GetParent(void)
|
||||
{
|
||||
return &mParent;
|
||||
}
|
||||
|
||||
Router *Mle::GetParentCandidate(void)
|
||||
{
|
||||
Router *rval;
|
||||
|
||||
@@ -747,12 +747,12 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the parent when operating in End Device mode.
|
||||
* This method gets the parent when operating in End Device mode.
|
||||
*
|
||||
* @returns A pointer to the parent.
|
||||
* @returns A reference to the parent.
|
||||
*
|
||||
*/
|
||||
Router *GetParent(void);
|
||||
Router &GetParent(void) { return mParent; }
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the parent candidate or parent.
|
||||
|
||||
@@ -209,7 +209,7 @@ void SupervisionListener::UpdateOnReceive(const Mac::Address &aSourceAddress, bo
|
||||
// If listener is enabled and device is a child and it received a secure frame from its parent, restart the timer.
|
||||
|
||||
VerifyOrExit(mTimer.IsRunning() && aIsSecure && (Get<Mle::MleRouter>().GetRole() == OT_DEVICE_ROLE_CHILD) &&
|
||||
(Get<Mle::MleRouter>().GetNeighbor(aSourceAddress) == Get<Mle::MleRouter>().GetParent()));
|
||||
(Get<Mle::MleRouter>().GetNeighbor(aSourceAddress) == &Get<Mle::MleRouter>().GetParent()));
|
||||
|
||||
RestartTimer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user