mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 14:47:46 +00:00
[posix] DNS resolver to handle link-local server address (#11548)
When `sendto` is used with a Link-Local IPv6 destination, the index of the outgoing network interface must be included.
This commit is contained in:
@@ -231,8 +231,8 @@ otError Resolver::SendQueryToServer(Transaction *aTxn,
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otIp4Address ip4Addr;
|
||||
sockaddr_in serverAddr4;
|
||||
sockaddr_in6 serverAddr6;
|
||||
sockaddr_in serverAddr4 = {};
|
||||
sockaddr_in6 serverAddr6 = {};
|
||||
|
||||
if (otIp4FromIp4MappedIp6Address(&aServerAddress, &ip4Addr) == OT_ERROR_NONE)
|
||||
{
|
||||
@@ -249,6 +249,11 @@ otError Resolver::SendQueryToServer(Transaction *aTxn,
|
||||
memcpy(&serverAddr6.sin6_addr, &aServerAddress, sizeof(otIp6Address));
|
||||
serverAddr6.sin6_family = AF_INET6;
|
||||
serverAddr6.sin6_port = htons(53);
|
||||
if (IsIp6AddressLinkLocal(aServerAddress))
|
||||
{
|
||||
// Network interface index is required for link local destinations
|
||||
serverAddr6.sin6_scope_id = otSysGetInfraNetifIndex();
|
||||
}
|
||||
|
||||
VerifyOrExit(sendto(aTxn->mUdpFd6, aPacket, aLength, MSG_DONTWAIT, reinterpret_cast<sockaddr *>(&serverAddr6),
|
||||
sizeof(serverAddr6)) > 0,
|
||||
|
||||
Reference in New Issue
Block a user