| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (S_ISREG(buf.st_mode)) return File::kFile; | 179 if (S_ISREG(buf.st_mode)) return File::kFile; |
| 180 return File::kOther; | 180 return File::kOther; |
| 181 } | 181 } |
| 182 | 182 |
| 183 | 183 |
| 184 intptr_t Socket::GetStdioHandle(int num) { | 184 intptr_t Socket::GetStdioHandle(int num) { |
| 185 return static_cast<intptr_t>(num); | 185 return static_cast<intptr_t>(num); |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 SocketAddresses* Socket::LookupAddress(const char* host, | 189 AddressList<SocketAddress>* Socket::LookupAddress(const char* host, |
| 190 int type, | 190 int type, |
| 191 OSError** os_error) { | 191 OSError** os_error) { |
| 192 // Perform a name lookup for a host name. | 192 // Perform a name lookup for a host name. |
| 193 struct addrinfo hints; | 193 struct addrinfo hints; |
| 194 memset(&hints, 0, sizeof(hints)); | 194 memset(&hints, 0, sizeof(hints)); |
| 195 hints.ai_family = SocketAddress::FromType(type); | 195 hints.ai_family = SocketAddress::FromType(type); |
| 196 hints.ai_socktype = SOCK_STREAM; | 196 hints.ai_socktype = SOCK_STREAM; |
| 197 hints.ai_flags = 0; | 197 hints.ai_flags = 0; |
| 198 hints.ai_protocol = IPPROTO_TCP; | 198 hints.ai_protocol = IPPROTO_TCP; |
| 199 struct addrinfo* info = NULL; | 199 struct addrinfo* info = NULL; |
| 200 int status = getaddrinfo(host, 0, &hints, &info); | 200 int status = getaddrinfo(host, 0, &hints, &info); |
| 201 if (status != 0) { | 201 if (status != 0) { |
| 202 ASSERT(*os_error == NULL); | 202 ASSERT(*os_error == NULL); |
| 203 *os_error = new OSError(status, | 203 *os_error = new OSError(status, |
| 204 gai_strerror(status), | 204 gai_strerror(status), |
| 205 OSError::kGetAddressInfo); | 205 OSError::kGetAddressInfo); |
| 206 return NULL; | 206 return NULL; |
| 207 } | 207 } |
| 208 intptr_t count = 0; | 208 intptr_t count = 0; |
| 209 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { | 209 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { |
| 210 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++; | 210 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++; |
| 211 } | 211 } |
| 212 SocketAddresses* addresses = new SocketAddresses(count); | |
| 213 intptr_t i = 0; | 212 intptr_t i = 0; |
| 213 AddressList<SocketAddress>* addresses = new AddressList<SocketAddress>(count); |
| 214 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { | 214 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { |
| 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)); | 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 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 225 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 226 int family = ifa->ifa_addr->sa_family; | 226 int family = ifa->ifa_addr->sa_family; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 SOL_TCP, | 367 SOL_TCP, |
| 368 TCP_NODELAY, | 368 TCP_NODELAY, |
| 369 reinterpret_cast<char *>(&on), | 369 reinterpret_cast<char *>(&on), |
| 370 sizeof(on))) == 0; | 370 sizeof(on))) == 0; |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace bin | 373 } // namespace bin |
| 374 } // namespace dart | 374 } // namespace dart |
| 375 | 375 |
| 376 #endif // defined(TARGET_OS_ANDROID) | 376 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |