mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 14:27:47 +00:00
[mle] enhance RLOC and ALOC address generation (#10391)
This commit enhances the generation of RLOC and ALOC addresses in the
`Mle` class.
Methods retrieving RLOC/ALOC addresses no longer return an `Error` and
are now `void`. The previous check for a valid `GetRloc16()` value,
which returned `kErrorDetach` if unset, is removed because this
scenario only occurred before the device's initial attachment.
Post-attachment, the RLOC16 remains valid even if the device is
detached. This change simplifies the code since RLOC/ALOC address
retrieval happens after the initial attachment.
Additional enhancements include:
- Changing the input parameter order in `GetCommissionerAloc()` to
match `GetServiceAloc()`.
- Using `Ip6::Address::SetToRoutingLocator()` to construct RLOC
addresses, harmonizing address generation and improving code
readability.
This commit is contained in:
@@ -44,16 +44,16 @@ namespace Tmf {
|
||||
|
||||
void MessageInfo::SetSockAddrToRloc(void) { SetSockAddr(Get<Mle::MleRouter>().GetMeshLocalRloc()); }
|
||||
|
||||
Error MessageInfo::SetSockAddrToRlocPeerAddrToLeaderAloc(void)
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToLeaderAloc(void)
|
||||
{
|
||||
SetSockAddrToRloc();
|
||||
return Get<Mle::MleRouter>().GetLeaderAloc(GetPeerAddr());
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(GetPeerAddr());
|
||||
}
|
||||
|
||||
Error MessageInfo::SetSockAddrToRlocPeerAddrToLeaderRloc(void)
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToLeaderRloc(void)
|
||||
{
|
||||
SetSockAddrToRloc();
|
||||
return Get<Mle::MleRouter>().GetLeaderAddress(GetPeerAddr());
|
||||
Get<Mle::MleRouter>().GetLeaderRloc(GetPeerAddr());
|
||||
}
|
||||
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToRealmLocalAllRoutersMulticast(void)
|
||||
@@ -65,8 +65,7 @@ void MessageInfo::SetSockAddrToRlocPeerAddrToRealmLocalAllRoutersMulticast(void)
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrTo(uint16_t aRloc16)
|
||||
{
|
||||
SetSockAddrToRloc();
|
||||
SetPeerAddr(Get<Mle::MleRouter>().GetMeshLocalRloc());
|
||||
GetPeerAddr().GetIid().SetLocator(aRloc16);
|
||||
GetPeerAddr().SetToRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aRloc16);
|
||||
}
|
||||
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrTo(const Ip6::Address &aPeerAddress)
|
||||
|
||||
Reference in New Issue
Block a user