|
|
|
|
@ -280,6 +280,7 @@ DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static
|
|
|
|
|
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ |
|
|
|
|
|
|
|
|
|
static void dns_init_local(void); |
|
|
|
|
static err_t dns_lookup_local(const char *hostname, ip_addr_t *addr LWIP_DNS_ADDRTYPE_ARG(u8_t dns_addrtype)); |
|
|
|
|
#endif /* DNS_LOCAL_HOSTLIST */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -430,6 +431,38 @@ dns_init_local(void)
|
|
|
|
|
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup dns |
|
|
|
|
* Iterate the local host-list for a hostname. |
|
|
|
|
* |
|
|
|
|
* @param iterator_fn a function that is called for every entry in the local host-list |
|
|
|
|
* @param iterator_arg 3rd argument passed to iterator_fn |
|
|
|
|
* @return the number of entries in the local host-list |
|
|
|
|
*/ |
|
|
|
|
size_t |
|
|
|
|
dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg) |
|
|
|
|
{ |
|
|
|
|
size_t i; |
|
|
|
|
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC |
|
|
|
|
struct local_hostlist_entry *entry = local_hostlist_dynamic; |
|
|
|
|
i = 0; |
|
|
|
|
while (entry != NULL) { |
|
|
|
|
if (iterator_fn != NULL) { |
|
|
|
|
iterator_fn(entry->name, &entry->addr, iterator_arg); |
|
|
|
|
} |
|
|
|
|
i++; |
|
|
|
|
entry = entry->next; |
|
|
|
|
} |
|
|
|
|
#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ |
|
|
|
|
for (i = 0; i < LWIP_ARRAYSIZE(local_hostlist_static); i++) { |
|
|
|
|
if (iterator_fn != NULL) { |
|
|
|
|
iterator_fn(local_hostlist_static[i].name, &local_hostlist_static[i].addr, iterator_arg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup dns |
|
|
|
|
* Scans the local host-list for a hostname. |
|
|
|
|
@ -437,8 +470,20 @@ dns_init_local(void)
|
|
|
|
|
* @param hostname Hostname to look for in the local host-list |
|
|
|
|
* @param addr the first IP address for the hostname in the local host-list or |
|
|
|
|
* IPADDR_NONE if not found. |
|
|
|
|
* @param dns_addrtype - LWIP_DNS_ADDRTYPE_IPV4_IPV6: try to resolve IPv4 (ATTENTION: no fallback here!) |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6_IPV4: try to resolve IPv6 (ATTENTION: no fallback here!) |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV4: try to resolve IPv4 only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6: try to resolve IPv6 only |
|
|
|
|
* @return ERR_OK if found, ERR_ARG if not found |
|
|
|
|
*/ |
|
|
|
|
err_t |
|
|
|
|
dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype) |
|
|
|
|
{ |
|
|
|
|
LWIP_UNUSED_ARG(dns_addrtype); |
|
|
|
|
return dns_lookup_local(hostname, addr LWIP_DNS_ADDRTYPE_ARG(dns_addrtype)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Internal implementation for dns_local_lookup and dns_lookup */ |
|
|
|
|
static err_t |
|
|
|
|
dns_lookup_local(const char *hostname, ip_addr_t *addr LWIP_DNS_ADDRTYPE_ARG(u8_t dns_addrtype)) |
|
|
|
|
{ |
|
|
|
|
@ -1434,9 +1479,9 @@ dns_gethostbyname(const char *hostname, ip_addr_t *addr, dns_found_callback foun
|
|
|
|
|
* ERR_INPROGRESS is returned!) |
|
|
|
|
* @param callback_arg argument to pass to the callback function |
|
|
|
|
* @param dns_addrtype - LWIP_DNS_ADDRTYPE_IPV4_IPV6: try to resolve IPv4 first, try IPv6 if IPv4 fails only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6_IPV4: try to resolve IPv6 first, try IPv4 if IPv6 fails only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV4: try to resolve IPv4 only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6: try to resolve IPv6 only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6_IPV4: try to resolve IPv6 first, try IPv4 if IPv6 fails only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV4: try to resolve IPv4 only |
|
|
|
|
* - LWIP_DNS_ADDRTYPE_IPV6: try to resolve IPv6 only |
|
|
|
|
*/ |
|
|
|
|
err_t |
|
|
|
|
dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, dns_found_callback found, |
|
|
|
|
|