Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: webrtc/base/nethelpers.cc

Issue 2083013008: Return both IPv6 and IPv4 address from the lookup. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/nethelpers.cc
diff --git a/webrtc/base/nethelpers.cc b/webrtc/base/nethelpers.cc
index fddfdaf58b5832318fe4f73d4f2ad7262f5b03bf..1f6bb8df7b7f71628524df9bd1fa27240ab9fe7b 100644
--- a/webrtc/base/nethelpers.cc
+++ b/webrtc/base/nethelpers.cc
@@ -44,8 +44,24 @@ int ResolveHostname(const std::string& hostname, int family,
addresses->clear();
struct addrinfo* result = NULL;
struct addrinfo hints = {0};
- // TODO(djw): For now this is IPv4 only so existing users remain unaffected.
- hints.ai_family = AF_INET;
+ hints.ai_family = family;
+ // |family| here will almost always be AF_UNSPEC, because |family| comes from
+ // AsyncResolver::addr_.family(), which comes from a SocketAddress constructed
+ // with a hostname. When a SocketAddress is constructed with a hostname, its
+ // family is AF_UNSPEC. However, if someday in the future we construct
+ // a SocketAddress with both a hostname and a family other than AF_UNSPEC,
+ // then it would be possible to get a specific family value here.
+
+ // The behavior of AF_UNSPEC is roughly "get both ipv4 and ipv6", as
+ // documented by the various operating systems:
+ // Linux: http://man7.org/linux/man-pages/man3/getaddrinfo.3.html
+ // Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/
+ // ms738520(v=vs.85).aspx
+ // Mac: https://developer.apple.com/legacy/library/documentation/Darwin/
+ // Reference/ManPages/man3/getaddrinfo.3.html
+ // Android (source code, not documentation):
+ // https://android.googlesource.com/platform/bionic/+/
+ // 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657
hints.ai_flags = AI_ADDRCONFIG;
int ret = getaddrinfo(hostname.c_str(), NULL, &hints, &result);
if (ret != 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698