From fd5734364195ea46dc5b8f28fae655a3a967dd4d Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 29 Oct 2019 09:05:36 -0700 Subject: [PATCH] [neighbor] add methods to check neighbor state (#4280) --- src/core/api/thread_api.cpp | 2 +- src/core/mac/data_poll_sender.cpp | 2 +- src/core/mac/mac.cpp | 4 +- src/core/thread/child_table.cpp | 8 ++-- src/core/thread/indirect_sender.cpp | 2 +- src/core/thread/mle.cpp | 22 +++++------ src/core/thread/mle_router.cpp | 59 ++++++++++++++--------------- src/core/thread/router_table.cpp | 15 ++++---- src/core/thread/topology.hpp | 54 ++++++++++++++++++++++++-- 9 files changed, 105 insertions(+), 63 deletions(-) diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index f9b90074f..3359514c6 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -322,7 +322,7 @@ otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo) aParentInfo->mLinkQualityOut = parent->GetLinkQualityOut(); aParentInfo->mAge = static_cast(Time::MsecToSec(TimerMilli::GetNow() - parent->GetLastHeard())); aParentInfo->mAllocated = true; - aParentInfo->mLinkEstablished = parent->GetState() == Neighbor::kStateValid; + aParentInfo->mLinkEstablished = parent->IsStateValid(); #if !OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE exit: diff --git a/src/core/mac/data_poll_sender.cpp b/src/core/mac/data_poll_sender.cpp index ab4461e7f..fdc83a342 100644 --- a/src/core/mac/data_poll_sender.cpp +++ b/src/core/mac/data_poll_sender.cpp @@ -205,7 +205,7 @@ void DataPollSender::HandlePollSent(Mac::TxFrame &aFrame, otError aError) Get().UpdateNeighborOnSentFrame(aFrame, aError, macDest); } - if (Get().GetParentCandidate()->GetState() == Neighbor::kStateInvalid) + if (Get().GetParentCandidate()->IsStateInvalid()) { StopPolling(); Get().BecomeDetached(); diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 860728ff7..10035f85f 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -1458,7 +1458,7 @@ otError Mac::ProcessReceiveSecurity(RxFrame &aFrame, const Address &aSrcAddr, Ne // the tag/MIC. Such a frame is later filtered in `RxDoneTask` which only allows MAC // Data Request frames from a child being restored. - if (aNeighbor->GetState() == Neighbor::kStateValid) + if (aNeighbor->IsStateValid()) { if (keySequence < aNeighbor->GetKeySequence()) { @@ -1514,7 +1514,7 @@ otError Mac::ProcessReceiveSecurity(RxFrame &aFrame, const Address &aSrcAddr, Ne VerifyOrExit(memcmp(tag, aFrame.GetFooter(), tagLength) == 0, error = OT_ERROR_SECURITY); #endif - if ((keyIdMode == Frame::kKeyIdMode1) && (aNeighbor->GetState() == Neighbor::kStateValid)) + if ((keyIdMode == Frame::kKeyIdMode1) && (aNeighbor->IsStateValid())) { if (aNeighbor->GetKeySequence() != keySequence) { diff --git a/src/core/thread/child_table.cpp b/src/core/thread/child_table.cpp index 2f9c14875..c003af7f5 100644 --- a/src/core/thread/child_table.cpp +++ b/src/core/thread/child_table.cpp @@ -130,7 +130,7 @@ Child *ChildTable::GetNewChild(void) for (uint16_t num = mMaxChildrenAllowed; num != 0; num--, child++) { - if (child->GetState() == Child::kStateInvalid) + if (child->IsStateInvalid()) { child->Clear(); ExitNow(); @@ -253,7 +253,7 @@ bool ChildTable::MatchesFilter(const Child &aChild, StateFilter aFilter) switch (aFilter) { case kInStateValid: - rval = (aChild.GetState() == Child::kStateValid); + rval = aChild.IsStateValid(); break; case kInStateValidOrRestoring: @@ -261,7 +261,7 @@ bool ChildTable::MatchesFilter(const Child &aChild, StateFilter aFilter) break; case kInStateChildIdRequest: - rval = (aChild.GetState() == Child::kStateChildIdRequest); + rval = aChild.IsStateChildIdRequest(); break; case kInStateValidOrAttaching: @@ -269,7 +269,7 @@ bool ChildTable::MatchesFilter(const Child &aChild, StateFilter aFilter) break; case kInStateAnyExceptInvalid: - rval = (aChild.GetState() != Child::kStateInvalid); + rval = !aChild.IsStateInvalid(); break; case kInStateAnyExceptValidOrRestoring: diff --git a/src/core/thread/indirect_sender.cpp b/src/core/thread/indirect_sender.cpp index c6edc8e51..b8b96d138 100644 --- a/src/core/thread/indirect_sender.cpp +++ b/src/core/thread/indirect_sender.cpp @@ -165,7 +165,7 @@ exit: void IndirectSender::HandleChildModeChange(Child &aChild, Mle::DeviceMode aOldMode) { - if (!aChild.IsRxOnWhenIdle() && (aChild.GetState() == Neighbor::kStateValid)) + if (!aChild.IsRxOnWhenIdle() && (aChild.IsStateValid())) { SetChildUseShortAddress(aChild, true); } diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 2adae2ad6..fa560832d 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -1677,7 +1677,7 @@ void Mle::HandleAttachTimer(void) // parent. if ((linkQuality == 3 || mAttachState != kAttachStateParentRequestRouter) && - mParentCandidate.GetState() == Neighbor::kStateParentResponse && + mParentCandidate.IsStateParentResponse() && (mRole != OT_DEVICE_ROLE_CHILD || mReceivedResponseFromParent || mParentRequestMode == kAttachBetter) && SendChildIdRequest() == OT_ERROR_NONE) { @@ -2723,7 +2723,7 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn break; } - if (neighbor != NULL && neighbor->GetState() == Neighbor::kStateValid) + if (neighbor != NULL && neighbor->IsStateValid()) { if (keySequence == neighbor->GetKeySequence()) { @@ -2918,7 +2918,7 @@ otError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo case OT_DEVICE_ROLE_ROUTER: case OT_DEVICE_ROLE_LEADER: - if ((neighbor = Get().GetNeighbor(macAddr)) != NULL && neighbor->GetState() == Neighbor::kStateValid) + if ((neighbor = Get().GetNeighbor(macAddr)) != NULL && neighbor->IsStateValid()) { isNeighbor = true; } @@ -3288,8 +3288,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf // Continue to process the "ParentResponse" if it is from current // parent candidate to update the challenge and frame counters. - if ((mParentCandidate.GetState() == Neighbor::kStateParentResponse) && - (mParentCandidate.GetExtAddress() != extAddress)) + if (mParentCandidate.IsStateParentResponse() && (mParentCandidate.GetExtAddress() != extAddress)) { // if already have a candidate parent, only seek a better parent @@ -3875,11 +3874,11 @@ Neighbor *Mle::GetNeighbor(uint16_t aAddress) { Neighbor *rval = NULL; - if ((mParent.IsStateValidOrRestoring()) && (mParent.GetRloc16() == aAddress)) + if (mParent.IsStateValidOrRestoring() && (mParent.GetRloc16() == aAddress)) { rval = &mParent; } - else if ((mParentCandidate.GetState() == Neighbor::kStateValid) && (mParentCandidate.GetRloc16() == aAddress)) + else if (mParentCandidate.IsStateValid() && (mParentCandidate.GetRloc16() == aAddress)) { rval = &mParentCandidate; } @@ -3891,11 +3890,11 @@ Neighbor *Mle::GetNeighbor(const Mac::ExtAddress &aAddress) { Neighbor *rval = NULL; - if ((mParent.IsStateValidOrRestoring()) && (mParent.GetExtAddress() == aAddress)) + if (mParent.IsStateValidOrRestoring() && (mParent.GetExtAddress() == aAddress)) { rval = &mParent; } - else if ((mParentCandidate.GetState() == Neighbor::kStateValid) && (mParentCandidate.GetExtAddress() == aAddress)) + else if (mParentCandidate.IsStateValid() && (mParentCandidate.GetExtAddress() == aAddress)) { rval = &mParentCandidate; } @@ -3927,8 +3926,7 @@ Neighbor *Mle::GetNeighbor(const Mac::Address &aAddress) uint16_t Mle::GetNextHop(uint16_t aDestination) const { OT_UNUSED_VARIABLE(aDestination); - return (mParent.GetState() == Neighbor::kStateValid) ? mParent.GetRloc16() - : static_cast(Mac::kShortAddrInvalid); + return (mParent.IsStateValid()) ? mParent.GetRloc16() : static_cast(Mac::kShortAddrInvalid); } bool Mle::IsRoutingLocator(const Ip6::Address &aAddress) const @@ -3958,7 +3956,7 @@ Router *Mle::GetParentCandidate(void) { Router *rval; - if (mParentCandidate.GetState() == Neighbor::kStateValid) + if (mParentCandidate.IsStateValid()) { rval = &mParentCandidate; } diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index c78a173df..5915a7b3a 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -495,7 +495,7 @@ otError MleRouter::SendLinkRequest(Neighbor *aNeighbor) case OT_DEVICE_ROLE_ROUTER: case OT_DEVICE_ROLE_LEADER: - if (aNeighbor == NULL || aNeighbor->GetState() != Neighbor::kStateValid) + if (aNeighbor == NULL || !aNeighbor->IsStateValid()) { SuccessOrExit(error = AppendTlvRequest(*message, routerTlvs, sizeof(routerTlvs))); } @@ -526,7 +526,7 @@ otError MleRouter::SendLinkRequest(Neighbor *aNeighbor) } else { - if (aNeighbor->GetState() != Neighbor::kStateValid) + if (!aNeighbor->IsStateValid()) { aNeighbor->GenerateChallenge(); SuccessOrExit(error = AppendChallenge(*message, aNeighbor->GetChallenge(), aNeighbor->GetChallengeSize())); @@ -614,9 +614,9 @@ otError MleRouter::HandleLinkRequest(const Message &aMessage, const Ip6::Message // source is a router neighbor = mRouterTable.GetRouter(GetRouterId(rloc16)); VerifyOrExit(neighbor != NULL, error = OT_ERROR_PARSE); - VerifyOrExit(neighbor->GetState() != Neighbor::kStateLinkRequest, error = OT_ERROR_ALREADY); + VerifyOrExit(!neighbor->IsStateLinkRequest(), error = OT_ERROR_ALREADY); - if (neighbor->GetState() != Neighbor::kStateValid) + if (!neighbor->IsStateValid()) { const otThreadLinkInfo *linkInfo = static_cast(aMessageInfo.GetLinkInfo()); @@ -641,7 +641,7 @@ otError MleRouter::HandleLinkRequest(const Message &aMessage, const Ip6::Message else { // lack of source address indicates router coming out of reset - VerifyOrExit((neighbor = GetNeighbor(macAddr)) != NULL && neighbor->GetState() == Neighbor::kStateValid && + VerifyOrExit((neighbor = GetNeighbor(macAddr)) != NULL && neighbor->IsStateValid() && IsActiveRouter(neighbor->GetRloc16()), error = OT_ERROR_DROP); } @@ -688,9 +688,8 @@ otError MleRouter::SendLinkAccept(const Ip6::MessageInfo &aMessageInfo, Header::Command command; uint8_t linkMargin; - command = (aNeighbor == NULL || aNeighbor->GetState() == Neighbor::kStateValid) - ? Header::kCommandLinkAccept - : Header::kCommandLinkAcceptAndRequest; + command = (aNeighbor == NULL || aNeighbor->IsStateValid()) ? Header::kCommandLinkAccept + : Header::kCommandLinkAcceptAndRequest; VerifyOrExit((message = NewMleMessage()) != NULL, error = OT_ERROR_NO_BUFS); SuccessOrExit(error = AppendHeader(*message, command)); @@ -731,7 +730,7 @@ otError MleRouter::SendLinkAccept(const Ip6::MessageInfo &aMessageInfo, } } - if (aNeighbor != NULL && aNeighbor->GetState() != Neighbor::kStateValid) + if (aNeighbor != NULL && !aNeighbor->IsStateValid()) { aNeighbor->GenerateChallenge(); @@ -1264,7 +1263,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa { router = mRouterTable.GetRouter(routerId); - if (router != NULL && router->GetState() == Neighbor::kStateValid) + if (router != NULL && router->IsStateValid()) { processRouteTlv = true; } @@ -1294,8 +1293,8 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa router = (macAddr == mParent.GetExtAddress()) ? &mParent : mRouterTable.GetRouter(routerId); VerifyOrExit(router != NULL); - if ((router->GetState() == Neighbor::kStateValid) && IsFullThreadDevice() && - (mRouterSelectionJitterTimeout == 0) && (mRouterTable.GetActiveRouterCount() < mRouterUpgradeThreshold)) + if (router->IsStateValid() && IsFullThreadDevice() && (mRouterSelectionJitterTimeout == 0) && + (mRouterTable.GetActiveRouterCount() < mRouterUpgradeThreshold)) { mRouterSelectionJitterTimeout = 1 + Random::NonCrypto::GetUint8InRange(0, mRouterSelectionJitter); ExitNow(); @@ -1344,8 +1343,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa } } } - else if (IsFullThreadDevice() && (router->GetState() != Neighbor::kStateValid) && - (router->GetState() != Neighbor::kStateLinkRequest) && + else if (IsFullThreadDevice() && !router->IsStateValid() && !router->IsStateLinkRequest() && (mRouterTable.GetActiveLinkCount() < OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS)) { router->SetExtAddress(macAddr); @@ -1391,7 +1389,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa VerifyOrExit(router != NULL); // Send link request if no link to router - if ((router->GetState() != Neighbor::kStateValid) && (router->GetState() != Neighbor::kStateLinkRequest) && + if (!router->IsStateValid() && !router->IsStateLinkRequest() && (linkMargin >= OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN)) { router->SetExtAddress(macAddr); @@ -1809,8 +1807,7 @@ void MleRouter::HandleStateUpdateTimer(void) otLogInfoMle("Child timeout expired"); RemoveNeighbor(child); } - else if ((mRole == OT_DEVICE_ROLE_ROUTER || mRole == OT_DEVICE_ROLE_LEADER) && - (child.GetState() == Neighbor::kStateRestored)) + else if ((mRole == OT_DEVICE_ROLE_ROUTER || mRole == OT_DEVICE_ROLE_LEADER) && child.IsStateRestored()) { SendChildUpdateRequest(child); } @@ -1830,7 +1827,7 @@ void MleRouter::HandleStateUpdateTimer(void) age = TimerMilli::GetNow() - router.GetLastHeard(); - if (router.GetState() == Neighbor::kStateValid) + if (router.IsStateValid()) { #if OPENTHREAD_CONFIG_MLE_SEND_LINK_REQUEST_ON_ADV_TIMEOUT == 0 @@ -1859,7 +1856,7 @@ void MleRouter::HandleStateUpdateTimer(void) #endif } - else if (router.GetState() == Neighbor::kStateLinkRequest) + else if (router.IsStateLinkRequest()) { if (age >= kMaxLinkRequestTimeout) { @@ -2161,7 +2158,7 @@ otError MleRouter::HandleChildIdRequest(const Message & aMessage, RemoveNeighbor(*router); } - if (child->GetState() != Neighbor::kStateValid) + if (!child->IsStateValid()) { child->SetState(Neighbor::kStateChildIdRequest); } @@ -2260,7 +2257,7 @@ otError MleRouter::HandleChildUpdateRequest(const Message & aMessage, // Not proceed if the Child Update Request is from the peer which is not the device's child or // which was the device's child but becomes invalid. - if (child == NULL || child->GetState() == Neighbor::kStateInvalid) + if (child == NULL || child->IsStateInvalid()) { // For invalid non-sleepy child, Send Child Update Response with status TLV (error) if (mode.GetMode().IsRxOnWhenIdle()) @@ -2357,7 +2354,7 @@ otError MleRouter::HandleChildUpdateRequest(const Message & aMessage, SetChildStateToValid(*child); child->SetKeySequence(aKeySequence); } - else if (child->GetState() == Neighbor::kStateValid) + else if (child->IsStateValid()) { if (childDidChange) { @@ -2937,7 +2934,7 @@ otError MleRouter::SendChildUpdateRequest(Child &aChild) SuccessOrExit(error = AppendActiveTimestamp(*message)); SuccessOrExit(error = AppendPendingTimestamp(*message)); - if (aChild.GetState() != Neighbor::kStateValid) + if (!aChild.IsStateValid()) { SuccessOrExit(error = AppendTlvRequest(*message, tlvs, sizeof(tlvs))); aChild.GenerateChallenge(); @@ -3171,7 +3168,7 @@ void MleRouter::RemoveNeighbor(Neighbor &aNeighbor) RemoveStoredChild(aNeighbor.GetRloc16()); } - else if (aNeighbor.GetState() == Neighbor::kStateValid) + else if (aNeighbor.IsStateValid()) { Signal(OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED, aNeighbor); mRouterTable.RemoveNeighbor(static_cast(aNeighbor)); @@ -3384,7 +3381,7 @@ uint16_t MleRouter::GetNextHop(uint16_t aDestination) if ((routeCost + GetLinkCost(router->GetNextHop())) < linkCost) { nextHop = mRouterTable.GetRouter(router->GetNextHop()); - VerifyOrExit(nextHop != NULL && nextHop->GetState() != Neighbor::kStateInvalid); + VerifyOrExit(nextHop != NULL && !nextHop->IsStateInvalid()); rval = GetRloc16(router->GetNextHop()); } @@ -3672,7 +3669,7 @@ otError MleRouter::GetNextNeighborInfo(otNeighborInfoIterator &aIterator, otNeig break; } - if (child->GetState() == Neighbor::kStateValid) + if (child->IsStateValid()) { neighbor = child; aNeighInfo.mIsChild = true; @@ -3691,7 +3688,7 @@ otError MleRouter::GetNextNeighborInfo(otNeighborInfoIterator &aIterator, otNeig { Router *router = mRouterTable.GetRouter(static_cast(index)); - if (router != NULL && router->GetState() == Neighbor::kStateValid) + if (router != NULL && router->IsStateValid()) { neighbor = router; aNeighInfo.mIsChild = false; @@ -4266,7 +4263,7 @@ void MleRouter::FillConnectivityTlv(ConnectivityTlv &aTlv) continue; } - if (router.GetState() != Neighbor::kStateValid) + if (!router.IsStateValid()) { // skip non-neighbor routers continue; @@ -4440,7 +4437,7 @@ bool MleRouter::HasMinDowngradeNeighborRouters(void) { Router &router = *iter.GetRouter(); - if (router.GetState() != Neighbor::kStateValid) + if (!router.IsStateValid()) { continue; } @@ -4480,7 +4477,7 @@ bool MleRouter::HasOneNeighborWithComparableConnectivity(const RouteTlv &aRoute, } // check if neighbor is valid - if (router.GetState() == Neighbor::kStateValid) + if (router.IsStateValid()) { // if neighbor is just peer if (router.GetRouterId() == aRouterId) @@ -4534,7 +4531,7 @@ exit: void MleRouter::SetChildStateToValid(Child &aChild) { - VerifyOrExit(aChild.GetState() != Neighbor::kStateValid); + VerifyOrExit(!aChild.IsStateValid()); aChild.SetState(Neighbor::kStateValid); StoreChild(aChild); diff --git a/src/core/thread/router_table.cpp b/src/core/thread/router_table.cpp index 5b08384ec..08517edc4 100644 --- a/src/core/thread/router_table.cpp +++ b/src/core/thread/router_table.cpp @@ -101,7 +101,7 @@ void RouterTable::ClearNeighbors(void) { Router &router = mRouters[index]; - if (router.GetState() == Neighbor::kStateValid) + if (router.IsStateValid()) { Get().Signal(OT_NEIGHBOR_TABLE_EVENT_ROUTER_REMOVED, router); } @@ -335,7 +335,7 @@ uint8_t RouterTable::GetActiveLinkCount(void) const for (const Router *router = GetFirstEntry(); router != NULL; router = GetNextEntry(router)) { - if (router->GetState() == Neighbor::kStateValid) + if (router->IsStateValid()) { activeLinks++; } @@ -352,7 +352,7 @@ Router *RouterTable::GetNeighbor(uint16_t aRloc16) for (router = GetFirstEntry(); router != NULL; router = GetNextEntry(router)) { - if (router->GetState() == Neighbor::kStateValid && router->GetRloc16() == aRloc16) + if (router->IsStateValid() && router->GetRloc16() == aRloc16) { ExitNow(); } @@ -370,7 +370,7 @@ Router *RouterTable::GetNeighbor(const Mac::ExtAddress &aExtAddress) for (router = GetFirstEntry(); router != NULL; router = GetNextEntry(router)) { - if (router->GetState() == Neighbor::kStateValid && router->GetExtAddress() == aExtAddress) + if (router->IsStateValid() && router->GetExtAddress() == aExtAddress) { ExitNow(); } @@ -437,7 +437,7 @@ otError RouterTable::GetRouterInfo(uint16_t aRouterId, otRouterInfo &aRouterInfo aRouterInfo.mExtAddress = router->GetExtAddress(); aRouterInfo.mAllocated = true; aRouterInfo.mNextHop = router->GetNextHop(); - aRouterInfo.mLinkEstablished = router->GetState() == Neighbor::kStateValid; + aRouterInfo.mLinkEstablished = router->IsStateValid(); aRouterInfo.mPathCost = router->GetCost(); aRouterInfo.mLinkQualityIn = router->GetLinkInfo().GetLinkQuality(); aRouterInfo.mLinkQualityOut = router->GetLinkQualityOut(); @@ -463,7 +463,7 @@ uint8_t RouterTable::GetNeighborCount(void) const for (const Router *router = GetFirstEntry(); router != NULL; router = GetNextEntry(router)) { - if (router->GetState() == Neighbor::kStateValid) + if (router->IsStateValid()) { count++; } @@ -476,8 +476,7 @@ uint8_t RouterTable::GetLinkCost(Router &aRouter) { uint8_t rval = Mle::kMaxRouteCost; - VerifyOrExit(aRouter.GetRloc16() != Get().GetRloc16() && - aRouter.GetState() == Neighbor::kStateValid); + VerifyOrExit(aRouter.GetRloc16() != Get().GetRloc16() && aRouter.IsStateValid()); rval = aRouter.GetLinkInfo().GetLinkQuality(); diff --git a/src/core/thread/topology.hpp b/src/core/thread/topology.hpp index 0e1100354..e883a4a61 100644 --- a/src/core/thread/topology.hpp +++ b/src/core/thread/topology.hpp @@ -92,7 +92,39 @@ public: void SetState(State aState) { mState = static_cast(aState); } /** - * This method indicates whether the neighbor/child is being restored. + * This method indicates whether the neighbor is in the Invalid state. + * + * @returns TRUE if the neighbor is in the Invalid state, FALSE otherwise. + * + */ + bool IsStateInvalid(void) const { return (mState == kStateInvalid); } + + /** + * This method indicates whether the neighbor is in the Child ID Request state. + * + * @returns TRUE if the neighbor is in the Child ID Request state, FALSE otherwise. + * + */ + bool IsStateChildIdRequest(void) const { return (mState == kStateChildIdRequest); } + + /** + * This method indicates whether the neighbor is in the Link Request state. + * + * @returns TRUE if the neighbor is in the Link Request state, FALSE otherwise. + * + */ + bool IsStateLinkRequest(void) const { return (mState == kStateLinkRequest); } + + /** + * This method indicates whether the neighbor is in the Parent Response state. + * + * @returns TRUE if the neighbor is in the Parent Response state, FALSE otherwise. + * + */ + bool IsStateParentResponse(void) const { return (mState == kStateParentResponse); } + + /** + * This method indicates whether the neighbor is being restored. * * @returns TRUE if the neighbor is being restored, FALSE otherwise. * @@ -100,9 +132,25 @@ public: bool IsStateRestoring(void) const { return (mState == kStateRestored) || (mState == kStateChildUpdateRequest); } /** - * This method indicates whether the neighbor/child is in valid state or if it is being restored. + * This method indicates whether the neighbor is in the Restored state. * - * When in these states messages can be sent to and/or received from the neighbor/child. + * @returns TRUE if the neighbor is in the Restored state, FALSE otherwise. + * + */ + bool IsStateRestored(void) const { return (mState == kStateRestored); } + + /** + * This method indicates whether the neighbor is valid (frame counters are synchronized). + * + * @returns TRUE if the neighbor is valid, FALSE otherwise. + * + */ + bool IsStateValid(void) const { return (mState == kStateValid); } + + /** + * This method indicates whether the neighbor is in valid state or if it is being restored. + * + * When in these states messages can be sent to and/or received from the neighbor. * * @returns TRUE if the neighbor is in valid, restored, or being restored states, FALSE otherwise. *