Skip to content

SocketHelpers - added dnsIP(n) getter as in WiFi libraries #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libraries/SocketWrapper/src/SocketHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ arduino::IPAddress arduino::MbedSocketClass::dnsServerIP() {
return ipAddressFromSocketAddress(ip);
}

arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) {
SocketAddress ip;
NetworkInterface* interface = getNetwork();
interface->get_dns_server(n, &ip, nullptr);
return ipAddressFromSocketAddress(ip);
}

void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) {
nsapi_addr_t convertedIP = { NSAPI_IPv4, { local_ip[0], local_ip[1], local_ip[2], local_ip[3] } };
_ip = SocketAddress(convertedIP);
Expand Down
7 changes: 7 additions & 0 deletions libraries/SocketWrapper/src/SocketHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class MbedSocketClass {
*/
IPAddress dnsServerIP();

/*
* Get the DNS Server ip address.
*
* return: DNS Server ip address value
*/
IPAddress dnsIP(int n = 0);

virtual NetworkInterface* getNetwork() = 0;

int download(char* url, const char* target, bool const is_https = false);
Expand Down