mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 16:17:47 +00:00
[mle] simplify CheckReachablity() (#9989)
This commit simplifies `MleRouter::CheckReachablity()`: - Remove and inline `Mle::CheckReachability()` which is used when `IsChild()`. - Uses local `isReachable` boolean variable.
This commit is contained in:
@@ -3889,22 +3889,6 @@ bool Mle::IsAnycastLocator(const Ip6::Address &aAddress) const
|
||||
|
||||
bool Mle::IsMeshLocalAddress(const Ip6::Address &aAddress) const { return (aAddress.GetPrefix() == mMeshLocalPrefix); }
|
||||
|
||||
Error Mle::CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header)
|
||||
{
|
||||
Error error;
|
||||
|
||||
if ((aMeshDest != GetRloc16()) || Get<ThreadNetif>().HasUnicastAddress(aIp6Header.GetDestination()))
|
||||
{
|
||||
error = kErrorNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
error = kErrorNoRoute;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
void Mle::InformPreviousParent(void)
|
||||
{
|
||||
|
||||
@@ -1240,7 +1240,6 @@ private:
|
||||
void SetAttachState(AttachState aState);
|
||||
void InitNeighbor(Neighbor &aNeighbor, const RxInfo &aRxInfo);
|
||||
void ClearParentCandidate(void) { mParentCandidate.Clear(); }
|
||||
Error CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header);
|
||||
Error SendDataRequest(const Ip6::Address &aDestination);
|
||||
void HandleNotifierEvents(Events aEvents);
|
||||
void SendDelayedResponse(TxMessage &aMessage, const DelayedResponseMetadata &aMetadata);
|
||||
|
||||
@@ -3238,44 +3238,39 @@ exit:
|
||||
|
||||
Error MleRouter::CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
bool isReachable = false;
|
||||
|
||||
if (IsChild())
|
||||
{
|
||||
error = Mle::CheckReachability(aMeshDest, aIp6Header);
|
||||
if (aMeshDest == GetRloc16())
|
||||
{
|
||||
isReachable = Get<ThreadNetif>().HasUnicastAddress(aIp6Header.GetDestination());
|
||||
}
|
||||
else
|
||||
{
|
||||
isReachable = true;
|
||||
}
|
||||
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
if (aMeshDest == Get<Mac::Mac>().GetShortAddress())
|
||||
{
|
||||
if (Get<ThreadNetif>().HasUnicastAddress(aIp6Header.GetDestination()))
|
||||
{
|
||||
// IPv6 destination is this device
|
||||
ExitNow();
|
||||
}
|
||||
else if (mNeighborTable.FindNeighbor(aIp6Header.GetDestination()) != nullptr)
|
||||
{
|
||||
// IPv6 destination is an RFD child
|
||||
ExitNow();
|
||||
}
|
||||
}
|
||||
else if (RouterIdFromRloc16(aMeshDest) == mRouterId)
|
||||
{
|
||||
if (mChildTable.FindChild(aMeshDest, Child::kInStateValidOrRestoring))
|
||||
{
|
||||
// Mesh destination is a child of this device
|
||||
ExitNow();
|
||||
}
|
||||
}
|
||||
else if (GetNextHop(aMeshDest) != Mac::kShortAddrInvalid)
|
||||
if (aMeshDest == GetRloc16())
|
||||
{
|
||||
isReachable = Get<ThreadNetif>().HasUnicastAddress(aIp6Header.GetDestination()) ||
|
||||
(mNeighborTable.FindNeighbor(aIp6Header.GetDestination()) != nullptr);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
error = kErrorNoRoute;
|
||||
if (RouterIdFromRloc16(aMeshDest) == mRouterId)
|
||||
{
|
||||
isReachable = (mChildTable.FindChild(aMeshDest, Child::kInStateValidOrRestoring) != nullptr);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
isReachable = (GetNextHop(aMeshDest) != Mac::kShortAddrInvalid);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return isReachable ? kErrorNone : kErrorNoRoute;
|
||||
}
|
||||
|
||||
Error MleRouter::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
|
||||
Reference in New Issue
Block a user