Skip to content

Commit 7829b2f

Browse files
authored
Merge pull request #3161 from geky/nsapi-dns-version-heuristic
nsapi - Add better heuristic for the default record of DNS queries
2 parents 2a3f4ed + d8d2b0a commit 7829b2f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

features/netsocket/NetworkStack.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ int NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_
3333
return 0;
3434
}
3535

36+
// if the version is unspecified, try to guess the version from the
37+
// ip address of the underlying stack
38+
if (version == NSAPI_UNSPEC) {
39+
SocketAddress testaddress;
40+
if (testaddress.set_ip_address(this->get_ip_address())) {
41+
version = testaddress.get_ip_version();
42+
}
43+
}
44+
3645
return nsapi_dns_query(this, name, address, version);
3746
}
3847

0 commit comments

Comments
 (0)