mirror of https://github.com/ARMmbed/mbed-os.git
nsapi - Added better heuristic for the default record of DNS queries
Takes advantage of the get_ip_address function to predict the IP address version wanted by the underlying interface. The should avoid the need for most IPv6 interfaces to overload gethostbyname. suggested by @kjbracey-armpull/3161/head
parent
c9f9ffa583
commit
d8d2b0a41d
|
@ -33,6 +33,15 @@ int NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_
|
|||
return 0;
|
||||
}
|
||||
|
||||
// if the version is unspecified, try to guess the version from the
|
||||
// ip address of the underlying stack
|
||||
if (version == NSAPI_UNSPEC) {
|
||||
SocketAddress testaddress;
|
||||
if (testaddress.set_ip_address(this->get_ip_address())) {
|
||||
version = testaddress.get_ip_version();
|
||||
}
|
||||
}
|
||||
|
||||
return nsapi_dns_query(this, name, address, version);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue