mirror of https://github.com/ARMmbed/mbed-os.git
Move to SocketAddress in gethostbyname
parent
3f08f3957c
commit
bd8cbf0fcb
|
@ -17,7 +17,14 @@
|
|||
#include "DnsQuery.h"
|
||||
#include "mbed.h"
|
||||
|
||||
int NetworkInterface::gethostbyname(const char *name, char *dest)
|
||||
int NetworkInterface::gethostbyname(SocketAddress *address, const char *name)
|
||||
{
|
||||
return dnsQuery(this, name, dest);
|
||||
char buffer[NSAPI_IP_SIZE];
|
||||
int err = dnsQuery(this, name, buffer);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
address->set_ip_address(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -87,11 +87,11 @@ public:
|
|||
}
|
||||
|
||||
/** Looks up the specified host's IP address
|
||||
* @param address Destination for the host SocketAddress
|
||||
* @param name Hostname to lookup
|
||||
* @param dest Destination for IP address, must have space for SocketAddress::IP_SIZE
|
||||
* @return 0 on success, negative on failure
|
||||
*/
|
||||
virtual int gethostbyname(const char *name, char *dest);
|
||||
virtual int gethostbyname(SocketAddress *address, const char *name);
|
||||
|
||||
protected:
|
||||
friend class Socket;
|
||||
|
|
|
@ -98,10 +98,8 @@ SocketAddress::SocketAddress(NetworkInterface *iface, const char *host, uint16_t
|
|||
address_to_ipv4(_ip_bytes, host);
|
||||
} else {
|
||||
// DNS lookup
|
||||
char addr[NSAPI_IP_SIZE];
|
||||
int err = iface->gethostbyname(host, addr);
|
||||
int err = iface->gethostbyname(this, host);
|
||||
if (!err) {
|
||||
set_ip_address(addr);
|
||||
set_port(port);
|
||||
} else {
|
||||
_ip_version = NSAPI_IPv4;
|
||||
|
|
Loading…
Reference in New Issue