Merge pull request #3161 from geky/nsapi-dns-version-heuristic

nsapi - Add better heuristic for the default record of DNS queries
pull/3184/head
Sam Grove 2016-11-01 14:17:08 -05:00 committed by GitHub
commit 7829b2f9bf
1 changed files with 9 additions and 0 deletions

View File

@ -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);
}