8000 Add ::dnsServerIP · OS-Q/Arduino_Core_mbed@8c7962f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c7962f

Browse files
committed
Add ::dnsServerIP
1 parent d9fa625 commit 8c7962f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

libraries/SocketWrapper/src/SocketHelpers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ arduino::IPAddress arduino::MbedSocketClass::gatewayIP() {
4343
return ipAddressFromSocketAddress(ip);
4444
}
4545

46+
arduino::IPAddress arduino::MbedSocketClass::dnsServerIP() {
47+
SocketAddress ip;
48+
NetworkInterface* interface = getNetwork();
49+
interface->get_dns_server(0, &ip, nullptr);
50+
return ipAddressFromSocketAddress(ip);
51+
}
52+
4653
void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) {
4754
nsapi_addr_t convertedIP = { NSAPI_IPv4, { local_ip[0], local_ip[1], local_ip[2], local_ip[3] } };
4855
_ip = SocketAddress(convertedIP);

libraries/SocketWrapper/src/SocketHelpers.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ class MbedSocketClass {
9292
*/
9393
IPAddress gatewayIP();
9494

95+
/*
96+
* Get the DNS Server ip address.
97+
*
98+
* return: DNS Server ip address value
99+
*/
100+
IPAddress dnsServerIP();
101+
95102
virtual NetworkInterface* getNetwork() = 0;
96103

97104
int download(char* url, const char* target, bool const is_https = false);
@@ -128,4 +135,4 @@ using SocketHelpers = MbedSocketClass;
128135

129136
}
130137

131-
#endif
138+
#endif

0 commit comments

Comments
 (0)
0