OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 26 matching lines...) Loading... | |
37 ASSERT(false); | 37 ASSERT(false); |
38 LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl"; | 38 LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl"; |
39 return -1; | 39 return -1; |
40 #else // __native_client__ | 40 #else // __native_client__ |
41 if (!addresses) { | 41 if (!addresses) { |
42 return -1; | 42 return -1; |
43 } | 43 } |
44 addresses->clear(); | 44 addresses->clear(); |
45 struct addrinfo* result = NULL; | 45 struct addrinfo* result = NULL; |
46 struct addrinfo hints = {0}; | 46 struct addrinfo hints = {0}; |
47 // TODO(djw): For now this is IPv4 only so existing users remain unaffected. | 47 hints.ai_family = family; |
honghaiz3
2016/06/24 01:19:08
This will be essentially using AF_UNSPEC because t
pthatcher1
2016/06/24 18:36:05
I think we should have a really big comment right
honghaiz3
2016/06/24 21:26:39
Done. Thanks!
| |
48 hints.ai_family = AF_INET; | |
49 hints.ai_flags = AI_ADDRCONFIG; | 48 hints.ai_flags = AI_ADDRCONFIG; |
50 int ret = getaddrinfo(hostname.c_str(), NULL, &hints, &result); | 49 int ret = getaddrinfo(hostname.c_str(), NULL, &hints, &result); |
51 if (ret != 0) { | 50 if (ret != 0) { |
52 return ret; | 51 return ret; |
53 } | 52 } |
54 struct addrinfo* cursor = result; | 53 struct addrinfo* cursor = result; |
55 for (; cursor; cursor = cursor->ai_next) { | 54 for (; cursor; cursor = cursor->ai_next) { |
56 if (family == AF_UNSPEC || cursor->ai_family == family) { | 55 if (family == AF_UNSPEC || cursor->ai_family == family) { |
57 IPAddress ip; | 56 IPAddress ip; |
58 if (IPFromAddrInfo(cursor, &ip)) { | 57 if (IPFromAddrInfo(cursor, &ip)) { |
(...skipping 114 matching lines...) Loading... | |
173 break; | 172 break; |
174 } | 173 } |
175 } | 174 } |
176 freeifaddrs(ifa); | 175 freeifaddrs(ifa); |
177 return has_ipv6; | 176 return has_ipv6; |
178 #else | 177 #else |
179 return true; | 178 return true; |
180 #endif | 179 #endif |
181 } | 180 } |
182 } // namespace rtc | 181 } // namespace rtc |
OLD | NEW |