| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
| 9 #include <stdio.h> // NOLINT | 9 #include <stdio.h> // NOLINT |
| 10 #include <stdlib.h> // NOLINT | 10 #include <stdlib.h> // NOLINT |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { | 215 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { |
| 216 addresses->SetAt(i, new SocketAddress(c->ai_addr)); | 216 addresses->SetAt(i, new SocketAddress(c->ai_addr)); |
| 217 i++; | 217 i++; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 freeaddrinfo(info); | 220 freeaddrinfo(info); |
| 221 return addresses; | 221 return addresses; |
| 222 } | 222 } |
| 223 | 223 |
| 224 | 224 |
| 225 const char* Socket::ReverseLookup(RawAddr addr, OSError** os_error) { |
| 226 char* host = new char[NI_MAXHOST]; |
| 227 int status = TEMP_FAILURE_RETRY(getnameinfo( |
| 228 &addr.addr, |
| 229 SocketAddress::GetAddrLength(&addr), |
| 230 host, |
| 231 NI_MAXHOST, |
| 232 NULL, |
| 233 0, |
| 234 NI_NAMEREQD)); |
| 235 if (status != 0) { |
| 236 ASSERT(*os_error == NULL); |
| 237 *os_error = new OSError(status, |
| 238 gai_strerror(status), |
| 239 OSError::kGetAddressInfo); |
| 240 delete host; |
| 241 return NULL; |
| 242 } |
| 243 return host; |
| 244 } |
| 245 |
| 246 |
| 225 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 247 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 226 int family = ifa->ifa_addr->sa_family; | 248 int family = ifa->ifa_addr->sa_family; |
| 227 if (lookup_family == family) return true; | 249 if (lookup_family == family) return true; |
| 228 if (lookup_family == AF_UNSPEC && | 250 if (lookup_family == AF_UNSPEC && |
| 229 (family == AF_INET || family == AF_INET6)) { | 251 (family == AF_INET || family == AF_INET6)) { |
| 230 return true; | 252 return true; |
| 231 } | 253 } |
| 232 return false; | 254 return false; |
| 233 } | 255 } |
| 234 | 256 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 SOL_TCP, | 389 SOL_TCP, |
| 368 TCP_NODELAY, | 390 TCP_NODELAY, |
| 369 reinterpret_cast<char *>(&on), | 391 reinterpret_cast<char *>(&on), |
| 370 sizeof(on))) == 0; | 392 sizeof(on))) == 0; |
| 371 } | 393 } |
| 372 | 394 |
| 373 } // namespace bin | 395 } // namespace bin |
| 374 } // namespace dart | 396 } // namespace dart |
| 375 | 397 |
| 376 #endif // defined(TARGET_OS_ANDROID) | 398 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |