forked from espressif/esp-idf
Merge branch 'contrib/github_pr_14132' into 'master'
feat(dhcp server): only hand out DNS if explicitly specified (GitHub PR) Closes IDFGH-13195 See merge request espressif/esp-idf!33683
This commit is contained in:
@@ -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
|
||||
|
@@ -454,18 +454,22 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
|
||||
}
|
||||
}
|
||||
|
||||
*optptr++ = DHCP_OPTION_DNS_SERVER;
|
||||
*optptr++ = 4;
|
||||
if (dhcps_dns_enabled(dhcps->dhcps_dns)) {
|
||||
*optptr++ = DHCP_OPTION_DNS_SERVER;
|
||||
*optptr++ = 4;
|
||||
*optptr++ = ip4_addr1(&dhcps->dns_server);
|
||||
*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 };
|
||||
|
Reference in New Issue
Block a user