Merge branch 'feature/add_reserved_dns_server' into 'master'

ladd reserved DNS server to avoid DHCP changing all DNS server address

See merge request sdk/ESP8266_RTOS_SDK!958
This commit is contained in:
Dong Heng
2019-05-29 16:07:22 +08:00
3 changed files with 23 additions and 2 deletions

View File

@ -275,10 +275,18 @@ config LWIP_IGMP
bool "Enable IGMP module"
default y
config ESP_DNS
bool "Enable espressif advansed DNS"
default y
help
Enable this option, espressif advansed DNS functions will be enable. User can set the
reserved DNS server(its index is DNS_FALLBACK_SERVER_INDEX) which will not be changed by DHCP.
config DNS_MAX_SERVERS
int "The maximum of DNS servers"
range 1 5
default 2
range 2 5
default 3 if ESP_DNS
default 2 if !ESP_DNS
menuconfig LWIP_NETIF_LOOPBACK
bool "Enable per-interface loopback"

View File

@ -657,6 +657,12 @@ dhcp_handle_ack(struct netif *netif)
#if LWIP_DHCP_PROVIDE_DNS_SERVERS
/* DNS servers */
for (n = 0; (n < LWIP_DHCP_PROVIDE_DNS_SERVERS) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n); n++) {
#if ESP_DNS
if (n == DNS_FALLBACK_SERVER_INDEX) {
continue;
}
#endif
ip_addr_t dns_addr;
ip_addr_set_ip4_u32(&dns_addr, lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_DNS_SERVER + n)));
dns_setserver(n, &dns_addr);

View File

@ -54,6 +54,12 @@
#define ESP_LWIP 1
#ifdef CONFIG_ESP_DNS
#define ESP_DNS 1
#else
#define ESP_DNS 0
#endif
#ifdef CONFIG_LWIP_IPV6_MLD_SOCK
#define ESP_LWIP_IPV6_MLD 1
#else
@ -831,6 +837,7 @@ size_t memp_malloc_get_size(size_t type);
* DNS_SERVER_ADDRESS(ipaddr), where 'ipaddr' is an 'ip_addr_t*'
*/
#define DNS_MAX_SERVERS CONFIG_DNS_MAX_SERVERS
#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1)
/** DNS do a name checking between the query and the response. */
#define DNS_DOES_NAME_CHECK 1