From 4eac78f675686a9a61bb1a110993850e32a16a88 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 21 Aug 2024 17:44:21 +0800 Subject: [PATCH] feat(lwip): Add DNS external hook in TCPIP context(v5.3) --- components/lwip/Kconfig | 15 +++++++++++++++ components/lwip/lwip | 2 +- components/lwip/port/include/lwip_default_hooks.h | 11 ++++++++++- components/lwip/test_apps/README.md | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 5f2bb733e8..bc21534e11 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -1278,6 +1278,21 @@ menu "LWIP" endchoice + choice LWIP_HOOK_DNS_EXTERNAL_RESOLVE + prompt "DNS external resolve Hook" + default LWIP_HOOK_DNS_EXT_RESOLVE_NONE + help + Enables custom DNS resolve hook. + Setting this to "custom" provides hook's declaration + only and expects the application to implement it. + + config LWIP_HOOK_DNS_EXT_RESOLVE_NONE + bool "No hook declared" + config LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM + bool "Custom implementation" + + endchoice + choice LWIP_HOOK_IP6_INPUT prompt "IPv6 packet input" depends on LWIP_IPV6 diff --git a/components/lwip/lwip b/components/lwip/lwip index bced058f73..0606eed9d8 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit bced058f737eaabea1aa193f3c365ee78ff555f3 +Subproject commit 0606eed9d8b98a797514fdf6eabb4daf1c8c8cd9 diff --git a/components/lwip/port/include/lwip_default_hooks.h b/components/lwip/port/include/lwip_default_hooks.h index bdc54064a9..86d33368d4 100644 --- a/components/lwip/port/include/lwip_default_hooks.h +++ b/components/lwip/port/include/lwip_default_hooks.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,7 @@ #include "lwip/ip_addr.h" #include "lwip/arch.h" #include "lwip/err.h" +#include "lwip/dns.h" #include "lwip/pbuf.h" #include "netif/dhcp_state.h" @@ -55,6 +56,14 @@ int lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr, u8_t a #define LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE lwip_hook_netconn_external_resolve #endif /* CONFIG_LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE... */ +#if defined(CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM) +int lwip_hook_dns_external_resolve(const char *name, ip_addr_t *addr, dns_found_callback found, void *callback_arg, + u8_t addrtype, err_t *err); + +#define LWIP_HOOK_DNS_EXTERNAL_RESOLVE lwip_hook_dns_external_resolve +#endif /* CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM */ + + #if defined(CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM) || defined(CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT) int lwip_hook_ip6_input(struct pbuf *p, struct netif *inp); diff --git a/components/lwip/test_apps/README.md b/components/lwip/test_apps/README.md index 3a502b1f86..bf47d80ec6 100644 --- a/components/lwip/test_apps/README.md +++ b/components/lwip/test_apps/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |