[mle] adding LeaderData class (#4679)

This commit adds `LeaderData` (subclass of `otLeaderData`) to store
the info from Leader Data TLV. It also adds `ReadLeaderData()` to
read Leader Data TLV from a message.
This commit is contained in:
Abtin Keshavarzian
2020-03-09 15:11:37 -07:00
committed by Jonathan Hui
parent 54e884569b
commit 052047a15f
11 changed files with 229 additions and 171 deletions
+9 -4
View File
@@ -264,31 +264,36 @@ otDeviceRole otThreadGetDeviceRole(otInstance *aInstance)
otError otThreadGetLeaderData(otInstance *aInstance, otLeaderData *aLeaderData)
{
Instance &instance = *static_cast<Instance *>(aInstance);
otError error = OT_ERROR_NONE;
OT_ASSERT(aLeaderData != NULL);
return instance.Get<Mle::MleRouter>().GetLeaderData(*aLeaderData);
VerifyOrExit(instance.Get<Mle::MleRouter>().IsAttached(), error = OT_ERROR_DETACHED);
*aLeaderData = instance.Get<Mle::MleRouter>().GetLeaderData();
exit:
return error;
}
uint8_t otThreadGetLeaderRouterId(otInstance *aInstance)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.Get<Mle::MleRouter>().GetLeaderDataTlv().GetLeaderRouterId();
return instance.Get<Mle::MleRouter>().GetLeaderId();
}
uint8_t otThreadGetLeaderWeight(otInstance *aInstance)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.Get<Mle::MleRouter>().GetLeaderDataTlv().GetWeighting();
return instance.Get<Mle::MleRouter>().GetLeaderData().GetWeighting();
}
uint32_t otThreadGetPartitionId(otInstance *aInstance)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return instance.Get<Mle::MleRouter>().GetLeaderDataTlv().GetPartitionId();
return instance.Get<Mle::MleRouter>().GetLeaderData().GetPartitionId();
}
uint16_t otThreadGetRloc16(otInstance *aInstance)