mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 06:37:46 +00:00
[network-diagnostic] specify link-local source for link-local destination (#3935)
In #3284, the source for network diagnostic is explicitly specified as RLOC. However when link-local address is the destination, link-local source is preferred.
This commit is contained in:
@@ -115,7 +115,15 @@ otError NetworkDiagnostic::SendDiagnosticGet(const Ip6::Address &aDestination,
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aCount));
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
if (aDestination.IsLinkLocal() || aDestination.IsLinkLocalMulticast())
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetLinkLocalAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
}
|
||||
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
@@ -499,7 +507,15 @@ void NetworkDiagnostic::HandleDiagnosticGetQuery(Coap::Message &aMessage, const
|
||||
SuccessOrExit(error = message->SetPayloadMarker());
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
if (aMessageInfo.GetSockAddr().IsLinkLocal() || aMessageInfo.GetSockAddr().IsLinkLocalMulticast())
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetLinkLocalAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
}
|
||||
|
||||
messageInfo.SetPeerAddr(aMessageInfo.GetPeerAddr());
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
@@ -601,7 +617,15 @@ otError NetworkDiagnostic::SendDiagnosticReset(const Ip6::Address &aDestination,
|
||||
SuccessOrExit(error = message->Append(aTlvTypes, aCount));
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
if (aDestination.IsLinkLocal() || aDestination.IsLinkLocalMulticast())
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetLinkLocalAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
}
|
||||
|
||||
messageInfo.SetPeerAddr(aDestination);
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user