mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 04:37:47 +00:00
[mle] rename static method to Rloc16FromRouterId() from GetRloc16() (#4486)
This commit renames the static `Mle` method which derives RLOC16 from a given Router ID to `Rloc16FromRouterId()` from `GetRloc16()`. This helps distinguish this method from other `GetRloc16()` methods.
This commit is contained in:
committed by
Jonathan Hui
parent
5ba6ede53a
commit
05747e7670
@@ -389,7 +389,7 @@ otError MeshForwarder::UpdateIp6RouteFtd(Ip6::Header &ip6Header)
|
||||
|
||||
if (aloc16 == Mle::kAloc16Leader)
|
||||
{
|
||||
mMeshDest = Mle::Mle::GetRloc16(mle.GetLeaderId());
|
||||
mMeshDest = Mle::Mle::Rloc16FromRouterId(mle.GetLeaderId());
|
||||
}
|
||||
else if ((aloc16 >= Mle::kAloc16CommissionerStart) && (aloc16 <= Mle::kAloc16CommissionerEnd))
|
||||
{
|
||||
@@ -406,14 +406,14 @@ otError MeshForwarder::UpdateIp6RouteFtd(Ip6::Header &ip6Header)
|
||||
routerId = Mle::Mle::GetRouterId(agentRloc16);
|
||||
|
||||
// if agent is active router or the child of the device
|
||||
if ((Mle::Mle::IsActiveRouter(agentRloc16)) || (Mle::Mle::GetRloc16(routerId) == mle.GetRloc16()))
|
||||
if ((Mle::Mle::IsActiveRouter(agentRloc16)) || (Mle::Mle::Rloc16FromRouterId(routerId) == mle.GetRloc16()))
|
||||
{
|
||||
mMeshDest = agentRloc16;
|
||||
}
|
||||
else
|
||||
{
|
||||
// use the parent of the ED Agent as Dest
|
||||
mMeshDest = Mle::Mle::GetRloc16(routerId);
|
||||
mMeshDest = Mle::Mle::Rloc16FromRouterId(routerId);
|
||||
}
|
||||
}
|
||||
else if ((aloc16 >= Mle::kAloc16ServiceStart) && (aloc16 <= Mle::kAloc16ServiceEnd))
|
||||
|
||||
@@ -423,7 +423,7 @@ otError Mle::Restore(void)
|
||||
mParent.SetExtAddress(*static_cast<Mac::ExtAddress *>(&parentInfo.mExtAddress));
|
||||
mParent.SetDeviceMode(DeviceMode(DeviceMode::kModeFullThreadDevice | DeviceMode::kModeRxOnWhenIdle |
|
||||
DeviceMode::kModeFullNetworkData | DeviceMode::kModeSecureDataRequest));
|
||||
mParent.SetRloc16(GetRloc16(GetRouterId(networkInfo.mRloc16)));
|
||||
mParent.SetRloc16(Rloc16FromRouterId(GetRouterId(networkInfo.mRloc16)));
|
||||
mParent.SetState(Neighbor::kStateRestored);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
@@ -1013,7 +1013,7 @@ otError Mle::GetLeaderAddress(Ip6::Address &aAddress) const
|
||||
aAddress.mFields.m16[4] = HostSwap16(0x0000);
|
||||
aAddress.mFields.m16[5] = HostSwap16(0x00ff);
|
||||
aAddress.mFields.m16[6] = HostSwap16(0xfe00);
|
||||
aAddress.mFields.m16[7] = HostSwap16(GetRloc16(mLeaderData.GetLeaderRouterId()));
|
||||
aAddress.mFields.m16[7] = HostSwap16(Rloc16FromRouterId(mLeaderData.GetLeaderRouterId()));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -989,14 +989,17 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the RLOC16 of a given Router ID.
|
||||
* This method derives RLOC16 from a given Router ID.
|
||||
*
|
||||
* @param[in] aRouterId The Router ID value.
|
||||
*
|
||||
* @returns The RLOC16 of the given Router ID.
|
||||
* @returns The RLOC16 corresponding to the given Router ID.
|
||||
*
|
||||
*/
|
||||
static uint16_t GetRloc16(uint8_t aRouterId) { return static_cast<uint16_t>(aRouterId << kRouterIdOffset); }
|
||||
static uint16_t Rloc16FromRouterId(uint8_t aRouterId)
|
||||
{
|
||||
return static_cast<uint16_t>(aRouterId << kRouterIdOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method indicates whether or not @p aRloc16 refers to an active router.
|
||||
|
||||
@@ -197,7 +197,7 @@ otError MleRouter::BecomeLeader(void)
|
||||
Get<NetworkData::Leader>().Reset();
|
||||
Get<MeshCoP::Leader>().SetEmptyCommissionerData();
|
||||
|
||||
SetStateLeader(GetRloc16(leaderId));
|
||||
SetStateLeader(Rloc16FromRouterId(leaderId));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -1529,7 +1529,7 @@ void MleRouter::UpdateRoutes(const RouteTlv &aRoute, uint8_t aRouterId)
|
||||
Router &router = *iter.GetRouter();
|
||||
|
||||
otLogInfoMle(" %04x -> %04x, cost:%d %d, lqin:%d, lqout:%d, link:%s", router.GetRloc16(),
|
||||
(router.GetNextHop() == kInvalidRouterId) ? 0xffff : GetRloc16(router.GetNextHop()),
|
||||
(router.GetNextHop() == kInvalidRouterId) ? 0xffff : Rloc16FromRouterId(router.GetNextHop()),
|
||||
router.GetCost(), mRouterTable.GetLinkCost(router), router.GetLinkInfo().GetLinkQuality(),
|
||||
router.GetLinkQualityOut(),
|
||||
router.GetRloc16() == GetRloc16() ? "device" : (router.IsStateValid() ? "yes" : "no"));
|
||||
@@ -3429,11 +3429,11 @@ uint16_t MleRouter::GetNextHop(uint16_t aDestination)
|
||||
nextHop = mRouterTable.GetRouter(router->GetNextHop());
|
||||
VerifyOrExit(nextHop != NULL && !nextHop->IsStateInvalid());
|
||||
|
||||
rval = GetRloc16(router->GetNextHop());
|
||||
rval = Rloc16FromRouterId(router->GetNextHop());
|
||||
}
|
||||
else if (linkCost < kMaxRouteCost)
|
||||
{
|
||||
rval = GetRloc16(destinationId);
|
||||
rval = Rloc16FromRouterId(destinationId);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -3846,7 +3846,7 @@ otError MleRouter::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
if (IsRouterIdValid(mPreviousRouterId))
|
||||
{
|
||||
rlocTlv.Init();
|
||||
rlocTlv.SetRloc16(GetRloc16(mPreviousRouterId));
|
||||
rlocTlv.SetRloc16(Rloc16FromRouterId(mPreviousRouterId));
|
||||
SuccessOrExit(error = rlocTlv.AppendTo(*message));
|
||||
}
|
||||
|
||||
@@ -3892,7 +3892,7 @@ otError MleRouter::SendAddressRelease(void)
|
||||
SuccessOrExit(error = message->SetPayloadMarker());
|
||||
|
||||
rlocTlv.Init();
|
||||
rlocTlv.SetRloc16(GetRloc16(mRouterId));
|
||||
rlocTlv.SetRloc16(Rloc16FromRouterId(mRouterId));
|
||||
SuccessOrExit(error = rlocTlv.AppendTo(*message));
|
||||
|
||||
macAddr64Tlv.Init();
|
||||
@@ -3974,7 +3974,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage,
|
||||
// assign short address
|
||||
SetRouterId(routerId);
|
||||
|
||||
SetStateRouter(GetRloc16(mRouterId));
|
||||
SetStateRouter(Rloc16FromRouterId(mRouterId));
|
||||
mRouterTable.Clear();
|
||||
mRouterTable.ProcessTlv(routerMaskTlv);
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ void RouterTable::UpdateAllocation(void)
|
||||
if (router.GetRouterId() != routerId)
|
||||
{
|
||||
router.Clear();
|
||||
router.SetRloc16(Mle::Mle::GetRloc16(routerId));
|
||||
router.SetRloc16(Mle::Mle::Rloc16FromRouterId(routerId));
|
||||
router.SetNextHop(Mle::kInvalidRouterId);
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ exit:
|
||||
otError RouterTable::Release(uint8_t aRouterId)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint16_t rloc16 = Mle::Mle::GetRloc16(aRouterId);
|
||||
uint16_t rloc16 = Mle::Mle::Rloc16FromRouterId(aRouterId);
|
||||
|
||||
assert(aRouterId <= Mle::kMaxRouterId);
|
||||
|
||||
@@ -383,7 +383,7 @@ exit:
|
||||
const Router *RouterTable::GetRouter(uint8_t aRouterId) const
|
||||
{
|
||||
const Router *router = NULL;
|
||||
uint16_t rloc16 = Mle::Mle::GetRloc16(aRouterId);
|
||||
uint16_t rloc16 = Mle::Mle::Rloc16FromRouterId(aRouterId);
|
||||
|
||||
for (router = GetFirstEntry(); router != NULL; router = GetNextEntry(router))
|
||||
{
|
||||
@@ -433,7 +433,7 @@ otError RouterTable::GetRouterInfo(uint16_t aRouterId, otRouterInfo &aRouterInfo
|
||||
|
||||
memset(&aRouterInfo, 0, sizeof(aRouterInfo));
|
||||
aRouterInfo.mRouterId = routerId;
|
||||
aRouterInfo.mRloc16 = Mle::Mle::GetRloc16(routerId);
|
||||
aRouterInfo.mRloc16 = Mle::Mle::Rloc16FromRouterId(routerId);
|
||||
aRouterInfo.mExtAddress = router->GetExtAddress();
|
||||
aRouterInfo.mAllocated = true;
|
||||
aRouterInfo.mNextHop = router->GetNextHop();
|
||||
|
||||
Reference in New Issue
Block a user