LWIP DHCP server: fix disabling DNS offer

Applying tcpip_adapter_dhcps_option(TCPIP_ADAPTER_OP_SET,
TCPIP_ADAPTER_DOMAIN_NAME_SERVER, …) with option value 0 now disables
the DNS offer. It previously would only switch the DNS offer to sending
the interface IP address instead of the DNS set. If enabled now with an
unset DNS IP (0.0.0.0) it will fallback to the interface IP.
This commit is contained in:
Michael Balzer 2019-12-17 21:16:36 +01:00
parent c3465e05c1
commit 4195d7c2ee

View file

@ -341,9 +341,10 @@ static u8_t *add_offer_options(u8_t *optptr)
}
}
if (dhcps_dns_enabled(dhcps_dns)) {
*optptr++ = DHCP_OPTION_DNS_SERVER;
*optptr++ = 4;
if (dhcps_dns_enabled(dhcps_dns)) {
if (dns_server.addr != IPADDR_ANY) {
*optptr++ = ip4_addr1(&dns_server);
*optptr++ = ip4_addr2(&dns_server);
*optptr++ = ip4_addr3(&dns_server);
@ -354,6 +355,7 @@ static u8_t *add_offer_options(u8_t *optptr)
*optptr++ = ip4_addr3(&ipadd);
*optptr++ = ip4_addr4(&ipadd);
}
}
#ifdef CLASS_B_NET
*optptr++ = DHCP_OPTION_BROADCAST_ADDRESS;