mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-06-05 21:04:45 +00:00
feat(lwip): Add DNS external resolve hook
This commit is contained in:
committed by
Wang Qixiang
parent
6bc36ec020
commit
0606eed9d8
@@ -110,6 +110,10 @@ static dns_setserver_callback_t s_dns_setserver_callback = NULL;
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
|
||||
/** Random generator function to create random TXIDs and source ports for queries */
|
||||
#ifndef DNS_RAND_TXID
|
||||
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_XID) != 0)
|
||||
@@ -1709,6 +1713,14 @@ dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, dns_found_call
|
||||
return ERR_ARG;
|
||||
}
|
||||
|
||||
#ifdef LWIP_HOOK_DNS_EXTERNAL_RESOLVE
|
||||
{
|
||||
err_t err = ERR_OK;
|
||||
if (LWIP_HOOK_DNS_EXTERNAL_RESOLVE(hostname, addr, found, callback_arg, dns_addrtype, &err)) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_HOOK_DNS_EXTERNAL_RESOLVE */
|
||||
|
||||
#if LWIP_HAVE_LOOPIF
|
||||
if (strcmp(hostname, "localhost") == 0) {
|
||||
|
||||
@@ -3097,6 +3097,34 @@
|
||||
#define LWIP_HOOK_IP6_SELECT_SRC_ADDR(netif, dest)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_HOOK_DNS_EXTERNAL_RESOLVE(name, addr, found, callback_arg, addrtype, err):
|
||||
* Called from dns APIs (usable with callback apps) allowing an
|
||||
* external DNS resolver (which uses sequential API) to handle the query.
|
||||
* The external resolver is called from LwIP thread context. Please carefully use this hook
|
||||
* to avoid thread issues(such as deadlock).
|
||||
* Signature:\code{.c}
|
||||
* int my_hook(const char *name, ip_addr_t *addr, dns_found_callback found, void *callback_arg,
|
||||
* u8_t addrtype, err_t *err)
|
||||
* \endcode
|
||||
* Arguments:
|
||||
* - name: hostname to resolve
|
||||
* - addr: output host address
|
||||
* - found: dns host address found callback
|
||||
* - callback_arg: found callback argument
|
||||
* - addrtype: type of address to query
|
||||
* - err: output error
|
||||
* Return values:
|
||||
* - 0: Hook has not consumed hostname query, query continues into DNS module
|
||||
* - != 0: Hook has consumed the query
|
||||
*
|
||||
* err must also be checked to determine if the hook consumed the query, but
|
||||
* the query failed
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_HOOK_DNS_EXTERNAL_RESOLVE(name, addr, found, callback_arg, addrtype, err)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
|
||||
* Called from ethernet_input() if VLAN support is enabled
|
||||
|
||||
Reference in New Issue
Block a user