| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { | 214 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { |
| 215 addresses->SetAt(i, new SocketAddress(c->ai_addr)); | 215 addresses->SetAt(i, new SocketAddress(c->ai_addr)); |
| 216 i++; | 216 i++; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 freeaddrinfo(info); | 219 freeaddrinfo(info); |
| 220 return addresses; | 220 return addresses; |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 bool Socket::ReverseLookup(RawAddr addr, |
| 225 char* host, |
| 226 intptr_t host_len, |
| 227 OSError** os_error) { |
| 228 ASSERT(host_len >= NI_MAXHOST); |
| 229 int status = TEMP_FAILURE_RETRY(getnameinfo( |
| 230 &addr.addr, |
| 231 SocketAddress::GetAddrLength(&addr), |
| 232 host, |
| 233 host_len, |
| 234 NULL, |
| 235 0, |
| 236 NI_NAMEREQD)); |
| 237 if (status != 0) { |
| 238 ASSERT(*os_error == NULL); |
| 239 *os_error = new OSError(status, |
| 240 gai_strerror(status), |
| 241 OSError::kGetAddressInfo); |
| 242 return false; |
| 243 } |
| 244 return true; |
| 245 } |
| 246 |
| 247 |
| 224 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 248 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 225 int family = ifa->ifa_addr->sa_family; | 249 int family = ifa->ifa_addr->sa_family; |
| 226 if (lookup_family == family) return true; | 250 if (lookup_family == family) return true; |
| 227 if (lookup_family == AF_UNSPEC && | 251 if (lookup_family == AF_UNSPEC && |
| 228 (family == AF_INET || family == AF_INET6)) { | 252 (family == AF_INET || family == AF_INET6)) { |
| 229 return true; | 253 return true; |
| 230 } | 254 } |
| 231 return false; | 255 return false; |
| 232 } | 256 } |
| 233 | 257 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 SOL_TCP, | 390 SOL_TCP, |
| 367 TCP_NODELAY, | 391 TCP_NODELAY, |
| 368 reinterpret_cast<char *>(&on), | 392 reinterpret_cast<char *>(&on), |
| 369 sizeof(on))) == 0; | 393 sizeof(on))) == 0; |
| 370 } | 394 } |
| 371 | 395 |
| 372 } // namespace bin | 396 } // namespace bin |
| 373 } // namespace dart | 397 } // namespace dart |
| 374 | 398 |
| 375 #endif // defined(TARGET_OS_LINUX) | 399 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |