Skip to content

Commit 15da163

Browse files
authored
LwipIntfDev.h - apply static DNS config (#8076)
DNS setting was not applied. Additionally default values for dns parameters in config are added.
1 parent 1a5ef71 commit 15da163

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

cores/esp8266/LwipIntfDev.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <lwip/netif.h>
1212
#include <lwip/etharp.h>
1313
#include <lwip/dhcp.h>
14+
#include <lwip/dns.h>
1415
#include <lwip/apps/sntp.h>
1516

1617
#include <user_interface.h> // wifi_get_macaddr()
@@ -40,7 +41,7 @@ class LwipIntfDev: public LwipIntf, public RawDev
4041
memset(&_netif, 0, sizeof(_netif));
4142
}
4243

43-
boolean config(const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2, const IPAddress& arg3, const IPAddress& dns2);
44+
boolean config(const IPAddress& local_ip, const IPAddress& arg1, const IPAddress& arg2, const IPAddress& arg3 = IPADDR_NONE, const IPAddress& dns2 = IPADDR_NONE);
4445

4546
// default mac-address is inferred from esp8266's STA interface
4647
boolean begin(const uint8_t *macAddress = nullptr, const uint16_t mtu = DEFAULT_MTU);
@@ -116,6 +117,17 @@ boolean LwipIntfDev<RawDev>::config(const IPAddress& localIP, const IPAddress& g
116117
ip4_addr_set_u32(ip_2_ip4(&_netif.gw), realGateway.v4());
117118
ip4_addr_set_u32(ip_2_ip4(&_netif.netmask), realNetmask.v4());
118119

120+
if (realDns1.isSet())
121+
{
122+
// Set DNS1-Server
123+
dns_setserver(0, realDns1);
124+
}
125+
126+
if (dns2.isSet())
127+
{
128+
// Set DNS2-Server
129+
dns_setserver(1, dns2);
130+
}
119131
return true;
120132
}
121133

0 commit comments

Comments
 (0)