mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 16:47:47 +00:00
[mle] add helper RxInfo::IsNeighborStateValid() (#8610)
This commit adds a new helper method in `RxInfo` to check whether or not the `mNeighbor` field (the neighbor from which message was received) is non-null and in valid state.
This commit is contained in:
@@ -2770,7 +2770,7 @@ void Mle::HandleAdvertisement(RxInfo &aRxInfo)
|
||||
|
||||
case kRoleRouter:
|
||||
case kRoleLeader:
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid());
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2792,7 +2792,7 @@ void Mle::HandleDataResponse(RxInfo &aRxInfo)
|
||||
|
||||
Log(kMessageReceive, kTypeDataResponse, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid(), error = kErrorDrop);
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid(), error = kErrorDrop);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
|
||||
{
|
||||
@@ -3299,7 +3299,7 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
|
||||
|
||||
Log(kMessageReceive, kTypeChildIdResponse, aRxInfo.mMessageInfo.GetPeerAddr(), sourceAddress);
|
||||
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid(), error = kErrorSecurity);
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid(), error = kErrorSecurity);
|
||||
|
||||
VerifyOrExit(mAttachState == kAttachStateChildIdRequest);
|
||||
|
||||
|
||||
@@ -1395,6 +1395,16 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether the `mNeighbor` (neighbor from which message was received) is non-null and
|
||||
* in valid state.
|
||||
*
|
||||
* @retval TRUE If `mNeighbor` is non-null and in valid state.
|
||||
* @retval FALSE If `mNeighbor` is `nullptr` or not in valid state.
|
||||
*
|
||||
*/
|
||||
bool IsNeighborStateValid(void) const { return (mNeighbor != nullptr) && mNeighbor->IsStateValid(); }
|
||||
|
||||
RxMessage &mMessage; ///< The MLE message.
|
||||
const Ip6::MessageInfo &mMessageInfo; ///< The `MessageInfo` associated with the message.
|
||||
uint32_t mFrameCounter; ///< The frame counter from aux security header.
|
||||
|
||||
@@ -679,8 +679,7 @@ void MleRouter::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
|
||||
case kErrorNotFound:
|
||||
// lack of source address indicates router coming out of reset
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid() &&
|
||||
IsActiveRouter(aRxInfo.mNeighbor->GetRloc16()),
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid() && IsActiveRouter(aRxInfo.mNeighbor->GetRloc16()),
|
||||
error = kErrorDrop);
|
||||
neighbor = aRxInfo.mNeighbor;
|
||||
break;
|
||||
@@ -1213,7 +1212,7 @@ Error MleRouter::HandleAdvertisement(RxInfo &aRxInfo)
|
||||
}
|
||||
else if (leaderData.GetLeaderRouterId() != GetLeaderId())
|
||||
{
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid());
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid());
|
||||
|
||||
if (!IsChild())
|
||||
{
|
||||
@@ -1232,7 +1231,7 @@ Error MleRouter::HandleAdvertisement(RxInfo &aRxInfo)
|
||||
Get<TimeSync>().HandleTimeSyncMessage(aRxInfo.mMessage);
|
||||
#endif
|
||||
|
||||
if (IsFullThreadDevice() && (aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid()) &&
|
||||
if (IsFullThreadDevice() && aRxInfo.IsNeighborStateValid() &&
|
||||
((mRouterTable.GetActiveRouterCount() == 0) ||
|
||||
SerialNumber::IsGreater(routeTlv.GetRouterIdSequence(), mRouterTable.GetRouterIdSequence())))
|
||||
{
|
||||
@@ -2738,7 +2737,7 @@ void MleRouter::HandleDataRequest(RxInfo &aRxInfo)
|
||||
|
||||
Log(kMessageReceive, kTypeDataRequest, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid(), error = kErrorSecurity);
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid(), error = kErrorSecurity);
|
||||
|
||||
// TLV Request
|
||||
SuccessOrExit(error = aRxInfo.mMessage.ReadTlvRequestTlv(tlvList));
|
||||
@@ -4304,7 +4303,7 @@ void MleRouter::HandleTimeSync(RxInfo &aRxInfo)
|
||||
{
|
||||
Log(kMessageReceive, kTypeTimeSync, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
|
||||
VerifyOrExit(aRxInfo.mNeighbor && aRxInfo.mNeighbor->IsStateValid());
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid());
|
||||
|
||||
aRxInfo.mClass = RxInfo::kPeerMessage;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user