mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-16 14:11:02 +00:00
Improved DNS_LOCAL_HOSTLIST interface (bug #50325)
(cherry picked from commit deaa6e9406
)
Conflicts:
CHANGELOG
This commit is contained in:
parent
fa8b6a92b4
commit
e318688195
@ -280,6 +280,7 @@ DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static
|
|||||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||||
|
|
||||||
static void dns_init_local(void);
|
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 */
|
#endif /* DNS_LOCAL_HOSTLIST */
|
||||||
|
|
||||||
|
|
||||||
@ -430,6 +431,38 @@ dns_init_local(void)
|
|||||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */
|
#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
|
* @ingroup dns
|
||||||
* Scans the local host-list for a hostname.
|
* 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 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
|
* @param addr the first IP address for the hostname in the local host-list or
|
||||||
* IPADDR_NONE if not found.
|
* 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
|
* @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
|
static err_t
|
||||||
dns_lookup_local(const char *hostname, ip_addr_t *addr LWIP_DNS_ADDRTYPE_ARG(u8_t dns_addrtype))
|
dns_lookup_local(const char *hostname, ip_addr_t *addr LWIP_DNS_ADDRTYPE_ARG(u8_t dns_addrtype))
|
||||||
{
|
{
|
||||||
|
@ -112,10 +112,14 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add
|
|||||||
u8_t dns_addrtype);
|
u8_t dns_addrtype);
|
||||||
|
|
||||||
|
|
||||||
#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
#if DNS_LOCAL_HOSTLIST
|
||||||
|
size_t dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg);
|
||||||
|
err_t dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype);
|
||||||
|
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||||
int dns_local_removehost(const char *hostname, const ip_addr_t *addr);
|
int dns_local_removehost(const char *hostname, const ip_addr_t *addr);
|
||||||
err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr);
|
err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr);
|
||||||
#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||||
|
#endif /* DNS_LOCAL_HOSTLIST */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user