fix(esp_netif): Restore DNS servers per netif when setting it default(5.2)

Introducing config option `CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF`
to overcome LWIP limitation of using global DNS server info.
This config option enables LWIP callbacks to collect per netif DNS
server info and then restores global DNS servers of whichever network
interface is selected as default.

LWIP submodule update v5.2: git log --oneline f1746813..3a3d1fb3
  - dns: Allow storing dnsserver per netif (espressif/esp-lwip@3a3d1fb3)
  - api_msg: Fix unused local variable if LWIP_NETCONN_SEM_PER_THREAD=1
    (espressif/esp-lwip@aa4f6e78)
  - lwip: fix gcc -fanalyzer warnings (espressif/esp-lwip@4297782b)
This commit is contained in:
David Cermak
2024-05-21 16:57:06 +02:00
parent bde21acfb6
commit 7931ac6f19
8 changed files with 131 additions and 30 deletions

View File

@@ -715,6 +715,11 @@ esp_err_t esp_netif_dhcps_get_clients_by_mac(esp_netif_t *esp_netif, int num, es
* and is designed to be set via this API.
* If DHCP client is disabled, all DNS server types can be set via this API only.
*
* Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused
* in the default LWIP configuration.
* If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API sets internal DNS server information per
* netif. It's also possible set the global DNS server info by supplying esp_netif=NULL
*
* If DHCP server is enabled, the Main DNS Server setting is used by the DHCP server to provide a DNS Server option
* to DHCP clients (Wi-Fi stations).
* - The default Main DNS server is typically the IP of the DHCP server itself.
@@ -740,6 +745,11 @@ esp_err_t esp_netif_set_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t ty
* This may be result of a previous call to esp_netif_set_dns_info(). If the interface's DHCP client is enabled,
* the Main or Backup DNS Server may be set by the current DHCP lease.
*
* Note that LWIP stores DNS server information globally, not per interface, so the first parameter is unused
* in the default LWIP configuration.
* If CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF=1 this API returns internally saved DNS server information per
* netif. It's also possible to ask for the global DNS server info by supplying esp_netif=NULL
*
* @param[in] esp_netif Handle to esp-netif instance
* @param[in] type Type of DNS Server to get: ESP_NETIF_DNS_MAIN, ESP_NETIF_DNS_BACKUP, ESP_NETIF_DNS_FALLBACK
* @param[out] dns DNS Server result is written here on success