| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/host_resolver_proc.h" | 5 #include "net/base/host_resolver_proc.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 10 #include <resolv.h> | |
| 11 #endif | |
| 12 | |
| 13 #include "base/logging.h" | 9 #include "base/logging.h" |
| 14 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| 15 #include "net/base/dns_reload_timer.h" | 11 #include "net/base/dns_reload_timer.h" |
| 16 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 17 #include "net/base/sys_addrinfo.h" | 13 #include "net/base/sys_addrinfo.h" |
| 18 | 14 |
| 15 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 16 #include <resolv.h> |
| 17 #endif |
| 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 bool IsAllLocalhostOfOneFamily(const struct addrinfo* ai) { | 23 bool IsAllLocalhostOfOneFamily(const struct addrinfo* ai) { |
| 24 bool saw_v4_localhost = false; | 24 bool saw_v4_localhost = false; |
| 25 bool saw_v6_localhost = false; | 25 bool saw_v6_localhost = false; |
| 26 for (; ai != NULL; ai = ai->ai_next) { | 26 for (; ai != NULL; ai = ai->ai_next) { |
| 27 switch (ai->ai_family) { | 27 switch (ai->ai_family) { |
| 28 case AF_INET: { | 28 case AF_INET: { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 // Return the OS error to the caller. | 242 // Return the OS error to the caller. |
| 243 if (os_error) | 243 if (os_error) |
| 244 *os_error = err; | 244 *os_error = err; |
| 245 | 245 |
| 246 // If the call to getaddrinfo() failed because of a system error, report | 246 // If the call to getaddrinfo() failed because of a system error, report |
| 247 // it separately from ERR_NAME_NOT_RESOLVED. | 247 // it separately from ERR_NAME_NOT_RESOLVED. |
| 248 #if defined(OS_WIN) | 248 #if defined(OS_WIN) |
| 249 if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA) | 249 if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA) |
| 250 return ERR_NAME_RESOLUTION_FAILED; | 250 return ERR_NAME_RESOLUTION_FAILED; |
| 251 #elif defined(OS_POSIX) | 251 #elif defined(OS_POSIX) && !defined(OS_FREEBSD) |
| 252 if (err != EAI_NONAME && err != EAI_NODATA) | 252 if (err != EAI_NONAME && err != EAI_NODATA) |
| 253 return ERR_NAME_RESOLUTION_FAILED; | 253 return ERR_NAME_RESOLUTION_FAILED; |
| 254 #endif | 254 #endif |
| 255 | 255 |
| 256 return ERR_NAME_NOT_RESOLVED; | 256 return ERR_NAME_NOT_RESOLVED; |
| 257 } | 257 } |
| 258 | 258 |
| 259 *addrlist = AddressList::CreateByAdoptingFromSystem(ai); | 259 *addrlist = AddressList::CreateByAdoptingFromSystem(ai); |
| 260 return OK; | 260 return OK; |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace net | 263 } // namespace net |
| OLD | NEW |