diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index 5e0c1a678..7997eb419 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -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;