mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 12:47:47 +00:00
[tmf] add Tmf::MessageInfo (#7589)
This commit adds `Tmf::MessageInfo` which is a sub-class of the `Ip6::MessageInfo` class intended for use when sending TMF messages. The peer port number is by default set to the TMF port from the constructor. This class also provides helper methods for commonly used patterns, e.g., source or `SockAddr` set to device's RLOC address and/or the destination or `PeerAddr` set to leader ALOC or RLOC, or a given address.
This commit is contained in:
@@ -424,7 +424,7 @@ void DuaManager::PerformNextRegistration(void)
|
||||
Error error = kErrorNone;
|
||||
Mle::MleRouter & mle = Get<Mle::MleRouter>();
|
||||
Coap::Message * message = nullptr;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
Ip6::Address dua;
|
||||
|
||||
VerifyOrExit(mle.IsAttached(), error = kErrorInvalidState);
|
||||
@@ -517,8 +517,7 @@ void DuaManager::PerformNextRegistration(void)
|
||||
Get<BackboneRouter::Leader>().GetServer16());
|
||||
}
|
||||
|
||||
messageInfo.SetPeerPort(Tmf::kUdpPort);
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
messageInfo.SetSockAddrToRloc();
|
||||
|
||||
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo, &DuaManager::HandleDuaResponse, this));
|
||||
|
||||
@@ -726,7 +725,7 @@ void DuaManager::SendAddressNotification(Ip6::Address & aAddress,
|
||||
const Child & aChild)
|
||||
{
|
||||
Coap::Message * message = nullptr;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
Error error;
|
||||
|
||||
VerifyOrExit((message = Get<Tmf::Agent>().NewPriorityMessage()) != nullptr, error = kErrorNoBufs);
|
||||
@@ -737,9 +736,7 @@ void DuaManager::SendAddressNotification(Ip6::Address & aAddress,
|
||||
SuccessOrExit(error = Tlv::Append<ThreadStatusTlv>(*message, aStatus));
|
||||
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, aAddress));
|
||||
|
||||
messageInfo.GetPeerAddr().SetToRoutingLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), aChild.GetRloc16());
|
||||
messageInfo.SetPeerPort(Tmf::kUdpPort);
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
messageInfo.SetSockAddrToRlocPeerAddrTo(aChild.GetRloc16());
|
||||
|
||||
SuccessOrExit(error = Get<Tmf::Agent>().SendMessage(*message, messageInfo));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user