| 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 bool Socket::ReverseLookup(RawAddr addr, |
| 226 char* host, |
| 227 intptr_t host_len, |
| 228 OSError** os_error) { |
| 229 ASSERT(host_len >= NI_MAXHOST); |
| 230 int status = TEMP_FAILURE_RETRY(getnameinfo( |
| 231 &addr.addr, |
| 232 SocketAddress::GetAddrLength(&addr), |
| 233 host, |
| 234 host_len, |
| 235 NULL, |
| 236 0, |
| 237 NI_NAMEREQD)); |
| 238 if (status != 0) { |
| 239 ASSERT(*os_error == NULL); |
| 240 *os_error = new OSError(status, |
| 241 gai_strerror(status), |
| 242 OSError::kGetAddressInfo); |
| 243 return false; |
| 244 } |
| 245 return true; |
| 246 } |
| 247 |
| 248 |
| 225 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 249 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 226 int family = ifa->ifa_addr->sa_family; | 250 int family = ifa->ifa_addr->sa_family; |
| 227 if (lookup_family == family) return true; | 251 if (lookup_family == family) return true; |
| 228 if (lookup_family == AF_UNSPEC && | 252 if (lookup_family == AF_UNSPEC && |
| 229 (family == AF_INET || family == AF_INET6)) { | 253 (family == AF_INET || family == AF_INET6)) { |
| 230 return true; | 254 return true; |
| 231 } | 255 } |
| 232 return false; | 256 return false; |
| 233 } | 257 } |
| 234 | 258 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 SOL_TCP, | 391 SOL_TCP, |
| 368 TCP_NODELAY, | 392 TCP_NODELAY, |
| 369 reinterpret_cast<char *>(&on), | 393 reinterpret_cast<char *>(&on), |
| 370 sizeof(on))) == 0; | 394 sizeof(on))) == 0; |
| 371 } | 395 } |
| 372 | 396 |
| 373 } // namespace bin | 397 } // namespace bin |
| 374 } // namespace dart | 398 } // namespace dart |
| 375 | 399 |
| 376 #endif // defined(TARGET_OS_ANDROID) | 400 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |