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:
parent
c3465e05c1
commit
4195d7c2ee
1 changed files with 16 additions and 14 deletions
|
@ -341,18 +341,20 @@ static u8_t *add_offer_options(u8_t *optptr)
|
|||
}
|
||||
}
|
||||
|
||||
*optptr++ = DHCP_OPTION_DNS_SERVER;
|
||||
*optptr++ = 4;
|
||||
if (dhcps_dns_enabled(dhcps_dns)) {
|
||||
*optptr++ = ip4_addr1(&dns_server);
|
||||
*optptr++ = ip4_addr2(&dns_server);
|
||||
*optptr++ = ip4_addr3(&dns_server);
|
||||
*optptr++ = ip4_addr4(&dns_server);
|
||||
}else {
|
||||
*optptr++ = ip4_addr1(&ipadd);
|
||||
*optptr++ = ip4_addr2(&ipadd);
|
||||
*optptr++ = ip4_addr3(&ipadd);
|
||||
*optptr++ = ip4_addr4(&ipadd);
|
||||
*optptr++ = DHCP_OPTION_DNS_SERVER;
|
||||
*optptr++ = 4;
|
||||
if (dns_server.addr != IPADDR_ANY) {
|
||||
*optptr++ = ip4_addr1(&dns_server);
|
||||
*optptr++ = ip4_addr2(&dns_server);
|
||||
*optptr++ = ip4_addr3(&dns_server);
|
||||
*optptr++ = ip4_addr4(&dns_server);
|
||||
} else {
|
||||
*optptr++ = ip4_addr1(&ipadd);
|
||||
*optptr++ = ip4_addr2(&ipadd);
|
||||
*optptr++ = ip4_addr3(&ipadd);
|
||||
*optptr++ = ip4_addr4(&ipadd);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CLASS_B_NET
|
||||
|
@ -1110,7 +1112,7 @@ static void dhcps_poll_set(u32_t ip)
|
|||
|
||||
/******************************************************************************
|
||||
* FunctionName : dhcps_set_new_lease_cb
|
||||
* Description : set callback for dhcp server when it assign an IP
|
||||
* Description : set callback for dhcp server when it assign an IP
|
||||
* to the connected dhcp client
|
||||
* Parameters : cb -- callback for dhcp server
|
||||
* Returns : none
|
||||
|
@ -1306,7 +1308,7 @@ dhcps_dns_setserver(const ip_addr_t *dnsserver)
|
|||
dns_server = *(ip_2_ip4(dnsserver));
|
||||
} else {
|
||||
dns_server = *(ip_2_ip4(IP_ADDR_ANY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -1315,7 +1317,7 @@ dhcps_dns_setserver(const ip_addr_t *dnsserver)
|
|||
* Parameters : none
|
||||
* Returns : ip4_addr_t
|
||||
*******************************************************************************/
|
||||
ip4_addr_t
|
||||
ip4_addr_t
|
||||
dhcps_dns_getserver()
|
||||
{
|
||||
return dns_server;
|
||||
|
|
Loading…
Reference in a new issue