fix(lwip/dhcps): Fallback DNS option to DHCP server's IP by default

Adds backward compatibity option CONFIG_LWIP_DHCPS_ADD_DNS, which
prevents breaking changes.
This option should be removed in IDF v6.0

Merges https://github.com/espressif/esp-idf/pull/14132
This commit is contained in:
David Cermak
2024-10-01 17:27:43 +02:00
committed by Abhik Roy
parent 484a2d6d6c
commit 649816d9a1
2 changed files with 23 additions and 0 deletions

View File

@@ -433,6 +433,20 @@ menu "LWIP"
Enabling this option allows DHCP server to support temporary static ARP entries
for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast.
config LWIP_DHCPS_ADD_DNS
bool "Always add DNS option in DHCP responses"
default y
depends on LWIP_DHCPS
help
This allows the DNS option to be optional in the DHCP offers,
depending on the server's runtime configuration.
When enabled, the DHCP server will always add the DNS option to DHCP responses.
If a DNS server is not explicitly configured, the server's IP address will be used
as the fallback for the DNS option.
When disabled, the DHCP server will only include the DNS option in responses
if a DNS server has been explicitly configured.
This option will be removed in IDF v6.x
endmenu # DHCPS
menuconfig LWIP_AUTOIP

View File

@@ -461,6 +461,15 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
*optptr++ = ip4_addr2(&dhcps->dns_server);
*optptr++ = ip4_addr3(&dhcps->dns_server);
*optptr++ = ip4_addr4(&dhcps->dns_server);
#ifdef CONFIG_LWIP_DHCPS_ADD_DNS
}else {
*optptr++ = DHCP_OPTION_DNS_SERVER;
*optptr++ = 4;
*optptr++ = ip4_addr1(&ipadd);
*optptr++ = ip4_addr2(&ipadd);
*optptr++ = ip4_addr3(&ipadd);
*optptr++ = ip4_addr4(&ipadd);
#endif /* CONFIG_LWIP_DHCPS_ADD_DNS */
}
ip4_addr_t broadcast_addr = { .addr = (ipadd.addr & dhcps->dhcps_mask.addr) | ~dhcps->dhcps_mask.addr };