mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 12:47:47 +00:00
[mle] add helper methods to check device mode flags (#2718)
This commit adds helper methods in `Mle` class to check whether different flags are set in device mode, such as `IsRxOnWhenIdle()`, `IsFullThreadDevice()`.
This commit is contained in:
committed by
Jonathan Hui
parent
ff04efc283
commit
c276d0776c
@@ -1806,7 +1806,7 @@ void Mac::HandleReceivedFrame(Frame *aFrame, otError aError)
|
||||
error = OT_ERROR_DESTINATION_ADDRESS_FILTERED);
|
||||
|
||||
// Allow multicasts from neighbor routers if FFD
|
||||
if (neighbor == NULL && dstaddr.IsBroadcast() && (netif.GetMle().GetDeviceMode() & Mle::ModeTlv::kModeFFD))
|
||||
if (neighbor == NULL && dstaddr.IsBroadcast() && netif.GetMle().IsFullThreadDevice())
|
||||
{
|
||||
neighbor = netif.GetMle().GetRxOnlyNeighborRouter(srcaddr);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void JoinerRouter::HandleStateChanged(uint32_t aFlags)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
|
||||
VerifyOrExit(netif.GetMle().GetDeviceMode() & Mle::ModeTlv::kModeFFD);
|
||||
VerifyOrExit(netif.GetMle().IsFullThreadDevice());
|
||||
VerifyOrExit(aFlags & OT_CHANGED_THREAD_NETDATA);
|
||||
|
||||
netif.GetIp6Filter().RemoveUnsecurePort(mSocket.GetSockName().mPort);
|
||||
|
||||
@@ -71,7 +71,7 @@ otError DataPollManager::StartPolling(void)
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
VerifyOrExit(!mEnabled, error = OT_ERROR_ALREADY);
|
||||
VerifyOrExit((GetNetif().GetMle().GetDeviceMode() & Mle::ModeTlv::kModeFFD) == 0, error = OT_ERROR_INVALID_STATE);
|
||||
VerifyOrExit(!GetNetif().GetMle().IsFullThreadDevice(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
mEnabled = true;
|
||||
ScheduleNextPoll(kRecalculatePollPeriod);
|
||||
|
||||
+30
-34
@@ -568,7 +568,7 @@ otError Mle::BecomeChild(AttachMode aMode)
|
||||
|
||||
if (aMode != kAttachBetter)
|
||||
{
|
||||
if (mDeviceMode & ModeTlv::kModeFFD)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
netif.GetMle().StopAdvertiseTimer();
|
||||
}
|
||||
@@ -624,13 +624,13 @@ otError Mle::SetStateChild(uint16_t aRloc16)
|
||||
mChildUpdateAttempts = 0;
|
||||
netif.GetMac().SetBeaconEnabled(false);
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) != 0)
|
||||
if (IsRxOnWhenIdle())
|
||||
{
|
||||
mChildUpdateRequestTimer.Start(TimerMilli::SecToMsec(mTimeout) -
|
||||
static_cast<uint32_t>(kUnicastRetransmissionDelay) * kMaxChildKeepAliveAttempts);
|
||||
}
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) != 0)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
netif.GetMle().HandleChildStart(mParentRequestMode);
|
||||
}
|
||||
@@ -661,7 +661,7 @@ void Mle::InformPreviousChannel(void)
|
||||
VerifyOrExit(mPreviousPanId != Mac::kPanIdBroadcast);
|
||||
VerifyOrExit(mRole == OT_DEVICE_ROLE_CHILD || mRole == OT_DEVICE_ROLE_ROUTER);
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) == 0 || mRole == OT_DEVICE_ROLE_ROUTER ||
|
||||
if (!IsFullThreadDevice() || mRole == OT_DEVICE_ROLE_ROUTER ||
|
||||
GetNetif().GetMle().GetRouterSelectionJitterTimeout() == 0)
|
||||
{
|
||||
mPreviousPanId = Mac::kPanIdBroadcast;
|
||||
@@ -1247,7 +1247,7 @@ otError Mle::AppendAddressRegistration(Message &aMessage)
|
||||
}
|
||||
|
||||
// For sleepy end device, register external multicast addresses to the parent for indirect transmission
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
uint8_t iterator = 0;
|
||||
Ip6::Address address;
|
||||
@@ -1334,7 +1334,7 @@ void Mle::HandleStateChanged(uint32_t aFlags)
|
||||
GetNotifier().SetFlags(OT_CHANGED_THREAD_ML_ADDR);
|
||||
}
|
||||
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && (mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && !IsFullThreadDevice())
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
}
|
||||
@@ -1342,8 +1342,7 @@ void Mle::HandleStateChanged(uint32_t aFlags)
|
||||
|
||||
if ((aFlags & (OT_CHANGED_IP6_MULTICAST_SUBSRCRIBED | OT_CHANGED_IP6_MULTICAST_UNSUBSRCRIBED)) != 0)
|
||||
{
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && (mDeviceMode & ModeTlv::kModeFFD) == 0 &&
|
||||
(mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && !IsFullThreadDevice() && !IsRxOnWhenIdle())
|
||||
{
|
||||
mSendChildUpdateRequest.Post();
|
||||
}
|
||||
@@ -1351,7 +1350,7 @@ void Mle::HandleStateChanged(uint32_t aFlags)
|
||||
|
||||
if ((aFlags & OT_CHANGED_THREAD_NETDATA) != 0)
|
||||
{
|
||||
if (mDeviceMode & ModeTlv::kModeFFD)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
netif.GetMle().HandleNetworkDataUpdateRouter();
|
||||
}
|
||||
@@ -1553,8 +1552,7 @@ bool Mle::PrepareAnnounceState(void)
|
||||
const MeshCoP::ChannelMask0Entry *channelMaskEntry;
|
||||
MeshCoP::Dataset dataset(MeshCoP::Tlv::kActiveTimestamp);
|
||||
|
||||
VerifyOrExit((mRole != OT_DEVICE_ROLE_CHILD) && ((mDeviceMode & ModeTlv::kModeFFD) == 0) &&
|
||||
(mReattachState == kReattachStop));
|
||||
VerifyOrExit((mRole != OT_DEVICE_ROLE_CHILD) && !IsFullThreadDevice() && (mReattachState == kReattachStop));
|
||||
|
||||
SuccessOrExit(GetNetif().GetActiveDataset().Get(dataset));
|
||||
|
||||
@@ -1624,7 +1622,7 @@ uint32_t Mle::Reattach(void)
|
||||
mPreviousPanId = Mac::kPanIdBroadcast;
|
||||
BecomeDetached();
|
||||
}
|
||||
else if ((mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
else if (!IsFullThreadDevice())
|
||||
{
|
||||
BecomeDetached();
|
||||
}
|
||||
@@ -1633,7 +1631,7 @@ uint32_t Mle::Reattach(void)
|
||||
BecomeDetached();
|
||||
}
|
||||
}
|
||||
else if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
else if (!IsRxOnWhenIdle())
|
||||
{
|
||||
// return to sleepy operation
|
||||
netif.GetMeshForwarder().GetDataPollManager().SetAttachMode(false);
|
||||
@@ -1822,7 +1820,7 @@ otError Mle::SendChildIdRequest(void)
|
||||
SuccessOrExit(error = AppendTimeout(*message, mTimeout));
|
||||
SuccessOrExit(error = AppendVersion(*message));
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
if (!IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = AppendAddressRegistration(*message));
|
||||
|
||||
@@ -1843,7 +1841,7 @@ otError Mle::SendChildIdRequest(void)
|
||||
LogMleMessage("Send Child ID Request", destination);
|
||||
;
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
GetNetif().GetMeshForwarder().GetDataPollManager().SetAttachMode(true);
|
||||
GetNetif().GetMeshForwarder().SetRxOnWhenIdle(false);
|
||||
@@ -1883,7 +1881,7 @@ otError Mle::SendDataRequest(const Ip6::Address &aDestination,
|
||||
SuccessOrExit(error = SendMessage(*message, aDestination));
|
||||
LogMleMessage("Send Data Request", aDestination);
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
GetNetif().GetMeshForwarder().GetDataPollManager().SendFastPolls(DataPollManager::kDefaultFastPolls);
|
||||
}
|
||||
@@ -1957,7 +1955,7 @@ otError Mle::SendChildUpdateRequest(void)
|
||||
SuccessOrExit(error = AppendHeader(*message, Header::kCommandChildUpdateRequest));
|
||||
SuccessOrExit(error = AppendMode(*message, mDeviceMode));
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
if (!IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = AppendAddressRegistration(*message));
|
||||
}
|
||||
@@ -1989,7 +1987,7 @@ otError Mle::SendChildUpdateRequest(void)
|
||||
|
||||
LogMleMessage("Send Child Update Request to parent", destination);
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
netif.GetMeshForwarder().GetDataPollManager().SetAttachMode(true);
|
||||
netif.GetMeshForwarder().SetRxOnWhenIdle(false);
|
||||
@@ -2029,7 +2027,7 @@ otError Mle::SendChildUpdateResponse(const uint8_t *aTlvs, uint8_t aNumTlvs, con
|
||||
break;
|
||||
|
||||
case Tlv::kAddressRegistration:
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
if (!IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = AppendAddressRegistration(*message));
|
||||
}
|
||||
@@ -2533,7 +2531,7 @@ otError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo
|
||||
|
||||
if (mRole != OT_DEVICE_ROLE_DETACHED)
|
||||
{
|
||||
if (mDeviceMode & ModeTlv::kModeFFD)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = netif.GetMle().HandleAdvertisement(aMessage, aMessageInfo));
|
||||
}
|
||||
@@ -2568,8 +2566,8 @@ otError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo
|
||||
{
|
||||
SetLeaderData(leaderData.GetPartitionId(), leaderData.GetWeighting(), leaderData.GetLeaderRouterId());
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) &&
|
||||
(Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == OT_ERROR_NONE) && route.IsValid())
|
||||
if (IsFullThreadDevice() && (Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == OT_ERROR_NONE) &&
|
||||
route.IsValid())
|
||||
{
|
||||
// Overwrite Route Data
|
||||
netif.GetMle().ProcessRouteTlv(route);
|
||||
@@ -2656,7 +2654,7 @@ otError Mle::HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &a
|
||||
{
|
||||
int8_t diff;
|
||||
|
||||
if (mDeviceMode & ModeTlv::kModeFullNetworkData)
|
||||
if (IsFullNetworkData())
|
||||
{
|
||||
diff = static_cast<int8_t>(leaderData.GetDataVersion() - netif.GetNetworkDataLeader().GetVersion());
|
||||
}
|
||||
@@ -2713,9 +2711,9 @@ otError Mle::HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &a
|
||||
|
||||
if (Tlv::GetOffset(aMessage, Tlv::kNetworkData, networkDataOffset) == OT_ERROR_NONE)
|
||||
{
|
||||
error = netif.GetNetworkDataLeader().SetNetworkData(
|
||||
leaderData.GetDataVersion(), leaderData.GetStableDataVersion(),
|
||||
(mDeviceMode & ModeTlv::kModeFullNetworkData) == 0, aMessage, networkDataOffset);
|
||||
error =
|
||||
netif.GetNetworkDataLeader().SetNetworkData(leaderData.GetDataVersion(), leaderData.GetStableDataVersion(),
|
||||
!IsFullNetworkData(), aMessage, networkDataOffset);
|
||||
SuccessOrExit(error);
|
||||
}
|
||||
else
|
||||
@@ -2882,7 +2880,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
|
||||
VerifyOrExit(connectivity.IsValid(), error = OT_ERROR_PARSE);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) && (mRole != OT_DEVICE_ROLE_DETACHED))
|
||||
if (IsFullThreadDevice() && (mRole != OT_DEVICE_ROLE_DETACHED))
|
||||
{
|
||||
int8_t diff =
|
||||
static_cast<int8_t>(connectivity.GetIdSequence() - netif.GetMle().GetRouterTable().GetRouterIdSequence());
|
||||
@@ -2914,7 +2912,7 @@ otError Mle::HandleParentResponse(const Message &aMessage, const Ip6::MessageInf
|
||||
{
|
||||
int compare = 0;
|
||||
|
||||
if (mDeviceMode & ModeTlv::kModeFFD)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
compare = netif.GetMle().ComparePartitions(connectivity.GetActiveRouters() <= 1, leaderData,
|
||||
mParentIsSingleton, mParentLeaderData);
|
||||
@@ -3055,7 +3053,7 @@ otError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::MessageIn
|
||||
|
||||
SetLeaderData(leaderData.GetPartitionId(), leaderData.GetWeighting(), leaderData.GetLeaderRouterId());
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
netif.GetMeshForwarder().GetDataPollManager().SetAttachMode(false);
|
||||
netif.GetMeshForwarder().SetRxOnWhenIdle(false);
|
||||
@@ -3066,8 +3064,7 @@ otError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::MessageIn
|
||||
}
|
||||
|
||||
// Route
|
||||
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == OT_ERROR_NONE) &&
|
||||
(mDeviceMode & ModeTlv::kModeFFD))
|
||||
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == OT_ERROR_NONE) && IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = netif.GetMle().ProcessRouteTlv(route));
|
||||
}
|
||||
@@ -3078,8 +3075,7 @@ otError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::MessageIn
|
||||
mParent.SetRloc16(sourceAddress.GetRloc16());
|
||||
|
||||
netif.GetNetworkDataLeader().SetNetworkData(leaderData.GetDataVersion(), leaderData.GetStableDataVersion(),
|
||||
(mDeviceMode & ModeTlv::kModeFullNetworkData) == 0, aMessage,
|
||||
networkDataOffset);
|
||||
!IsFullNetworkData(), aMessage, networkDataOffset);
|
||||
|
||||
netif.GetActiveDataset().ApplyConfiguration();
|
||||
|
||||
@@ -3237,7 +3233,7 @@ otError Mle::HandleChildUpdateResponse(const Message &aMessage, const Ip6::Messa
|
||||
mTimeout = timeout.GetTimeout();
|
||||
}
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!IsRxOnWhenIdle())
|
||||
{
|
||||
netif.GetMeshForwarder().GetDataPollManager().SetAttachMode(false);
|
||||
netif.GetMeshForwarder().SetRxOnWhenIdle(false);
|
||||
|
||||
+41
-9
@@ -629,6 +629,47 @@ public:
|
||||
*/
|
||||
uint8_t GetDeviceMode(void) const { return mDeviceMode; }
|
||||
|
||||
/**
|
||||
* This method sets the Device Mode as reported in the Mode TLV.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Mode TLV.
|
||||
* @retval OT_ERROR_INVALID_ARGS The mode combination specified in @p aMode is invalid.
|
||||
*
|
||||
*/
|
||||
otError SetDeviceMode(uint8_t aMode);
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the device is rx-on-when-idle.
|
||||
*
|
||||
* @returns TRUE if rx-on-when-idle, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsRxOnWhenIdle(void) const { return (mDeviceMode & ModeTlv::kModeRxOnWhenIdle) != 0; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the device is a Full Thread Device.
|
||||
*
|
||||
* @returns TRUE if a Full Thread Device, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsFullThreadDevice(void) const { return (mDeviceMode & ModeTlv::kModeFFD) != 0; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the device uses secure IEEE 802.15.4 Data Request messages.
|
||||
*
|
||||
* @returns TRUE if using secure IEEE 802.15.4 Data Request messages, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsSecureDataRequest(void) const { return (mDeviceMode & ModeTlv::kModeSecureDataRequest) != 0; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the device requests Full Network Data.
|
||||
*
|
||||
* @returns TRUE if requests Full Network Data, FALSE otherwise.
|
||||
*
|
||||
*/
|
||||
bool IsFullNetworkData(void) const { return (mDeviceMode & ModeTlv::kModeFullNetworkData) != 0; }
|
||||
|
||||
/**
|
||||
* This method indicates whether or not the device is a Minimal End Device.
|
||||
*
|
||||
@@ -641,15 +682,6 @@ public:
|
||||
(ModeTlv::kModeFFD | ModeTlv::kModeRxOnWhenIdle);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the Device Mode as reported in the Mode TLV.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully set the Mode TLV.
|
||||
* @retval OT_ERROR_INVALID_ARGS The mode combination specified in @p aMode is invalid.
|
||||
*
|
||||
*/
|
||||
otError SetDeviceMode(uint8_t aMode);
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the Mesh Local Prefix.
|
||||
*
|
||||
|
||||
@@ -101,7 +101,7 @@ void MleRouter::HandlePartitionChange(void)
|
||||
|
||||
bool MleRouter::IsRouterRoleEnabled(void) const
|
||||
{
|
||||
return mRouterRoleEnabled && (mDeviceMode & ModeTlv::kModeFFD);
|
||||
return mRouterRoleEnabled && IsFullThreadDevice();
|
||||
}
|
||||
|
||||
void MleRouter::SetRouterRoleEnabled(bool aEnabled)
|
||||
@@ -374,7 +374,7 @@ bool MleRouter::HandleAdvertiseTimer(TrickleTimer &aTimer)
|
||||
|
||||
bool MleRouter::HandleAdvertiseTimer(void)
|
||||
{
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) == 0)
|
||||
if (!IsFullThreadDevice())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1035,7 +1035,7 @@ bool MleRouter::IsSingleton(void)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
if (IsAttached() && ((mDeviceMode & ModeTlv::kModeFFD) != 0))
|
||||
if (IsAttached() && IsFullThreadDevice())
|
||||
{
|
||||
// not a singleton if any other routers exist
|
||||
if (mRouterTable.GetActiveRouterCount() > 1)
|
||||
@@ -1150,14 +1150,14 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
|
||||
VerifyOrExit(linkMargin >= OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN, error = OT_ERROR_LINK_MARGIN_LOW);
|
||||
|
||||
if (route.IsValid() && (mDeviceMode & ModeTlv::kModeFFD) && (mPreviousPartitionIdTimeout > 0) &&
|
||||
if (route.IsValid() && IsFullThreadDevice() && (mPreviousPartitionIdTimeout > 0) &&
|
||||
(partitionId == mPreviousPartitionId))
|
||||
{
|
||||
VerifyOrExit((static_cast<int8_t>(route.GetRouterIdSequence() - mPreviousPartitionRouterIdSequence) > 0),
|
||||
error = OT_ERROR_DROP);
|
||||
}
|
||||
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && (mParent.GetExtAddress() == macAddr || !(mDeviceMode & ModeTlv::kModeFFD)))
|
||||
if (mRole == OT_DEVICE_ROLE_CHILD && (mParent.GetExtAddress() == macAddr || !IsFullThreadDevice()))
|
||||
{
|
||||
ExitNow();
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
VerifyOrExit(IsActiveRouter(sourceAddress.GetRloc16()) && route.IsValid());
|
||||
routerId = GetRouterId(sourceAddress.GetRloc16());
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) &&
|
||||
if (IsFullThreadDevice() &&
|
||||
static_cast<int8_t>(route.GetRouterIdSequence() - mRouterTable.GetRouterIdSequence()) > 0)
|
||||
{
|
||||
bool processRouteTlv = false;
|
||||
@@ -1234,7 +1234,7 @@ 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) && (mDeviceMode & ModeTlv::kModeFFD) &&
|
||||
if ((router->GetState() == Neighbor::kStateValid) && IsFullThreadDevice() &&
|
||||
(mRouterSelectionJitterTimeout == 0) && (mRouterTable.GetActiveRouterCount() < mRouterUpgradeThreshold))
|
||||
{
|
||||
mRouterSelectionJitterTimeout = 1 + Random::GetUint8InRange(0, mRouterSelectionJitter);
|
||||
@@ -1249,7 +1249,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
ExitNow(error = OT_ERROR_NO_ROUTE);
|
||||
}
|
||||
|
||||
if (mDeviceMode & ModeTlv::kModeFFD)
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
for (uint8_t i = 0, routeCount = 0; i <= kMaxRouterId; i++)
|
||||
{
|
||||
@@ -1284,7 +1284,7 @@ otError MleRouter::HandleAdvertisement(const Message &aMessage, const Ip6::Messa
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((mDeviceMode & ModeTlv::kModeFFD) && (router->GetState() != Neighbor::kStateValid) &&
|
||||
else if (IsFullThreadDevice() && (router->GetState() != Neighbor::kStateValid) &&
|
||||
(router->GetState() != Neighbor::kStateLinkRequest))
|
||||
{
|
||||
router->SetExtAddress(macAddr);
|
||||
@@ -2510,7 +2510,7 @@ otError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Me
|
||||
LogMleMessage("Receive Discovery Request", aMessageInfo.GetPeerAddr());
|
||||
|
||||
// only Routers and REEDs respond
|
||||
VerifyOrExit((mDeviceMode & ModeTlv::kModeFFD) != 0, error = OT_ERROR_INVALID_STATE);
|
||||
VerifyOrExit(IsFullThreadDevice(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
// find MLE Discovery TLV
|
||||
VerifyOrExit(Tlv::GetOffset(aMessage, Tlv::kDiscovery, offset) == OT_ERROR_NONE, error = OT_ERROR_PARSE);
|
||||
|
||||
@@ -345,8 +345,7 @@ otError Local::SendServerDataNotification(void)
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
// Don't send this Server Data Notification if the device is going to upgrade to Router
|
||||
if ((mle.GetDeviceMode() & Mle::ModeTlv::kModeFFD) != 0 && (mle.IsRouterRoleEnabled()) &&
|
||||
(mle.GetRole() < OT_DEVICE_ROLE_ROUTER) &&
|
||||
if (mle.IsFullThreadDevice() && mle.IsRouterRoleEnabled() && (mle.GetRole() < OT_DEVICE_ROLE_ROUTER) &&
|
||||
(mle.GetRouterTable().GetActiveRouterCount() < mle.GetRouterUpgradeThreshold()))
|
||||
{
|
||||
ExitNow(error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
@@ -317,7 +317,7 @@ otError NetworkDiagnostic::FillRequestedTlvs(Message & aRequest,
|
||||
|
||||
case NetworkDiagnosticTlv::kTimeout:
|
||||
{
|
||||
if ((netif.GetMle().GetDeviceMode() & ModeTlv::kModeRxOnWhenIdle) == 0)
|
||||
if (!netif.GetMle().IsRxOnWhenIdle())
|
||||
{
|
||||
TimeoutTlv tlv;
|
||||
tlv.Init();
|
||||
|
||||
Reference in New Issue
Block a user