1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/dns: select appropriate address family if AF_UNSPEC

This commit is contained in:
Benjamin Valentin 2022-12-07 22:26:31 +01:00
parent eea954cc22
commit 5986d8f371

View File

@ -74,6 +74,15 @@ static inline int dns_query(const char *domain_name, void *addr_out, int family)
{
int res = -ENOTSUP;
if (family == AF_UNSPEC) {
if (!IS_USED(MODULE_IPV4_ADDR)) {
family = AF_INET6;
}
else if (!IS_USED(MODULE_IPV6_ADDR)) {
family = AF_INET;
}
}
if (res <= 0 && IS_USED(MODULE_GCOAP_DNS)) {
res = gcoap_dns_query(domain_name, addr_out, family);
}