mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 09:33:50 +01:00
net/util: make unconditional use of dns_query()
This commit is contained in:
parent
af8faa0257
commit
839b75df77
@ -22,8 +22,8 @@
|
||||
#include "net/utils.h"
|
||||
#if defined(MODULE_DNS)
|
||||
#include "net/af.h"
|
||||
#include "net/dns.h"
|
||||
#endif
|
||||
#include "net/dns.h"
|
||||
|
||||
/* get the next netif, returns true if there are more */
|
||||
static bool _netif_get(netif_t **current_netif)
|
||||
@ -44,7 +44,6 @@ int netutils_get_ipv4(ipv4_addr_t *addr, const char *hostname)
|
||||
for (size_t i = 0; i < strlen(hostname); i++) {
|
||||
bool is_not_ipv4 = (hostname[i] < '0' || hostname[i] > '9') && hostname[i] != '.';
|
||||
|
||||
#if defined(MODULE_SOCK_DNS) || defined(MODULE_SOCK_DNS_MOCK)
|
||||
/* once we see an invalid character for an IPv4 address try to
|
||||
* resolve the hostname by DNS */
|
||||
if (is_not_ipv4) {
|
||||
@ -54,11 +53,6 @@ int netutils_get_ipv4(ipv4_addr_t *addr, const char *hostname)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if (is_not_ipv4) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t len = strlen(hostname);
|
||||
@ -77,7 +71,6 @@ int netutils_get_ipv6(ipv6_addr_t *addr, netif_t **netif, const char *hostname)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#if defined(MODULE_SOCK_DNS) || defined(MODULE_SOCK_DNS_MOCK)
|
||||
/* hostname is not an IPv6 address */
|
||||
if (strchr(hostname, ':') == NULL) {
|
||||
int res = dns_query(hostname, addr, AF_INET6);
|
||||
@ -86,7 +79,6 @@ int netutils_get_ipv6(ipv6_addr_t *addr, netif_t **netif, const char *hostname)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* search for interface ID */
|
||||
size_t len = strlen(hostname);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user