[mle] refactor MleRouter and Mle classes into a single Mle class (#11411)

This commit refactors the `Mle` modules and combines the `MleRouter`
and `Mle` classes into a single `Mle` class which now handles both
FTD and MTD functionalities.

The `MleRouter` and `Mle` classes were originally intended as
sub-classes, where the base class `Mle` would provide MTD and common
behaviors, and `MleRouter` would implement FTD-specific behaviors.
However, over the years and as new features were implemented, these
two classes became more intertwined, and the `Mle` class began to
include many FTD-related functions and interactions with `MleRouter`
private variables and methods.

This commit simplifies the code by combining the two into a single
class. The previous `mle_router.cpp` file is also renamed to
`mle_ftd.cpp` to indicate that it implements FTD-specific MLE
behaviors.
This commit is contained in:
Abtin Keshavarzian
2025-04-18 14:28:47 -07:00
committed by GitHub
parent f70749d21d
commit 0c1dfa0796
67 changed files with 1135 additions and 1255 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
{
Ip6::Address address;
if (sInstance->Get<Mle::MleRouter>().IsMeshLocalAddress(aAddressList[index]))
if (sInstance->Get<Mle::Mle>().IsMeshLocalAddress(aAddressList[index]))
{
SuccessOrQuit(aChild.GetMeshLocalIp6Address(address));
VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address");
@@ -127,7 +127,7 @@ void TestChildIp6Address(void)
numAddresses = 0;
// First addresses uses the mesh local prefix (mesh-local address).
addresses[numAddresses] = sInstance->Get<Mle::MleRouter>().GetMeshLocalEid();
addresses[numAddresses] = sInstance->Get<Mle::Mle>().GetMeshLocalEid();
addresses[numAddresses].SetIid(meshLocalIid);
numAddresses++;
+1 -1
View File
@@ -104,7 +104,7 @@ static void Init(void)
otMeshLocalPrefix meshLocalPrefix = {{0xfd, 0x00, 0xca, 0xfe, 0xfa, 0xce, 0x12, 0x34}};
OffsetRange offsetRange;
sInstance->Get<Mle::MleRouter>().SetMeshLocalPrefix(static_cast<Ip6::NetworkPrefix &>(meshLocalPrefix));
sInstance->Get<Mle::Mle>().SetMeshLocalPrefix(static_cast<Ip6::NetworkPrefix &>(meshLocalPrefix));
// Emulate global prefixes with contextes.
uint8_t mockNetworkData[] = {