Skip to content

Commit e776a9b

Browse files
author
Kimmo Vaisanen
committed
Netsocket: Add get_dns_server API for NetworkInterface
With get_dns_server DNS servers can be queried from NetworkInterface object
1 parent 09fe166 commit e776a9b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

UNITTESTS/stubs/NetworkInterface_stub.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ nsapi_error_t NetworkInterface::add_dns_server(const SocketAddress &address, con
7272
return NSAPI_ERROR_UNSUPPORTED;
7373
}
7474

75+
nsapi_error_t NetworkInterface::get_dns_server(int index, SocketAddress *address, const char *interface_name)
76+
{
77+
return NSAPI_ERROR_UNSUPPORTED;
78+
}
79+
7580
void NetworkInterface::attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
7681
{
7782

features/netsocket/NetworkInterface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ nsapi_error_t NetworkInterface::add_dns_server(const SocketAddress &address, con
101101
return get_stack()->add_dns_server(address, interface_name);
102102
}
103103

104+
nsapi_error_t NetworkInterface::get_dns_server(int index, SocketAddress *address, const char *interface_name)
105+
{
106+
return get_stack()->get_dns_server(index, address, interface_name);
107+
}
108+
104109
void NetworkInterface::attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
105110
{
106111
// Dummy, that needs to be overwritten when inherited, but cannot be removed

features/netsocket/NetworkInterface.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,18 @@ class NetworkInterface: public DNS {
324324
*/
325325
virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name);
326326

327+
/** Get a domain name server from a list of servers to query
328+
*
329+
* Returns a DNS server address for a index. If returns error no more
330+
* DNS servers to read.
331+
*
332+
* @param index Index of the DNS server, starts from zero
333+
* @param address Destination for the host address
334+
* @param interface_name Network interface name
335+
* @return NSAPI_ERROR_OK on success, negative error code on failure
336+
*/
337+
virtual nsapi_error_t get_dns_server(int index, SocketAddress *address, const char *interface_name = NULL);
338+
327339
/** Register callback for status reporting.
328340
*
329341
* The specified status callback function will be called on status changes

0 commit comments

Comments
 (0)