[dns-client] add support for NAT64 during address resolution (#6414)

This commit adds support for NAT64 address translation (from IPv4 to
IPv6) during address resolution in `Dns::Client`. This feature is
enabled using `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` config
option. When enabled, the caller can specify in the address query
configuration whether to allow or disallow NAT64 address translation
for a specific query. The default behavior can also be set using the
default DNS client config.

When the NAT64 is allowed, if the response from server does not
provide an IPv6 address for the host name, we first check if the
server has provided IPv4 address information in the response, and if
not, start a new query for the IPv4 address. Once the IPv4 address(es)
of the host name are resolved, they are translated to IPv6 address(es)
and reported to the user in the query callback function.
This commit is contained in:
Abtin Keshavarzian
2021-04-14 00:45:18 -07:00
committed by GitHub
parent 3e833c120f
commit 7d008f6c76
8 changed files with 316 additions and 51 deletions
+2 -2
View File
@@ -399,13 +399,13 @@ void TestIp4Ip6Translation(void)
SuccessOrQuit(expectedAddress.FromString(testCase.mIp6Address), "Ip6::FromString() failed");
address.SetFromTranslatedIp4Address(prefix, ip4Address);
address.SynthesizeFromIp4Address(prefix, ip4Address);
printf("Prefix: %-26s IPv4Addr: %-12s Ipv6Address: %-36s Expected: %s (%s)\n", prefix.ToString().AsCString(),
ip4Address.ToString().AsCString(), address.ToString().AsCString(), testCase.mIp6Address,
expectedAddress.ToString().AsCString());
VerifyOrQuit(address == expectedAddress, "Ip6::SetFromTranslatedIp4Address() failed");
VerifyOrQuit(address == expectedAddress, "Ip6::SynthesizeFromIp4Address() failed");
}
}