| 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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (S_ISREG(buf.st_mode)) return File::kFile; | 177 if (S_ISREG(buf.st_mode)) return File::kFile; |
| 178 return File::kOther; | 178 return File::kOther; |
| 179 } | 179 } |
| 180 | 180 |
| 181 | 181 |
| 182 intptr_t Socket::GetStdioHandle(int num) { | 182 intptr_t Socket::GetStdioHandle(int num) { |
| 183 return static_cast<intptr_t>(num); | 183 return static_cast<intptr_t>(num); |
| 184 } | 184 } |
| 185 | 185 |
| 186 | 186 |
| 187 SocketAddresses* Socket::LookupAddress(const char* host, | 187 AddressList<SocketAddress>* Socket::LookupAddress(const char* host, |
| 188 int type, | 188 int type, |
| 189 OSError** os_error) { | 189 OSError** os_error) { |
| 190 // Perform a name lookup for a host name. | 190 // Perform a name lookup for a host name. |
| 191 struct addrinfo hints; | 191 struct addrinfo hints; |
| 192 memset(&hints, 0, sizeof(hints)); | 192 memset(&hints, 0, sizeof(hints)); |
| 193 hints.ai_family = SocketAddress::FromType(type); | 193 hints.ai_family = SocketAddress::FromType(type); |
| 194 hints.ai_socktype = SOCK_STREAM; | 194 hints.ai_socktype = SOCK_STREAM; |
| 195 hints.ai_flags = 0; | 195 hints.ai_flags = 0; |
| 196 hints.ai_protocol = IPPROTO_TCP; | 196 hints.ai_protocol = IPPROTO_TCP; |
| 197 struct addrinfo* info = NULL; | 197 struct addrinfo* info = NULL; |
| 198 int status = getaddrinfo(host, 0, &hints, &info); | 198 int status = getaddrinfo(host, 0, &hints, &info); |
| 199 if (status != 0) { | 199 if (status != 0) { |
| 200 ASSERT(*os_error == NULL); | 200 ASSERT(*os_error == NULL); |
| 201 *os_error = new OSError(status, | 201 *os_error = new OSError(status, |
| 202 gai_strerror(status), | 202 gai_strerror(status), |
| 203 OSError::kGetAddressInfo); | 203 OSError::kGetAddressInfo); |
| 204 return NULL; | 204 return NULL; |
| 205 } | 205 } |
| 206 intptr_t count = 0; | 206 intptr_t count = 0; |
| 207 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { | 207 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { |
| 208 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++; | 208 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) count++; |
| 209 } | 209 } |
| 210 SocketAddresses* addresses = new SocketAddresses(count); | |
| 211 intptr_t i = 0; | 210 intptr_t i = 0; |
| 211 AddressList<SocketAddress>* addresses = new AddressList<SocketAddress>(count); |
| 212 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { | 212 for (struct addrinfo* c = info; c != NULL; c = c->ai_next) { |
| 213 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { | 213 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { |
| 214 addresses->SetAt(i, new SocketAddress(c)); | 214 addresses->SetAt(i, new SocketAddress(c->ai_addr)); |
| 215 i++; | 215 i++; |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 freeaddrinfo(info); | 218 freeaddrinfo(info); |
| 219 return addresses; | 219 return addresses; |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 223 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 224 int family = ifa->ifa_addr->sa_family; | 224 int family = ifa->ifa_addr->sa_family; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 IPPROTO_TCP, | 355 IPPROTO_TCP, |
| 356 TCP_NODELAY, | 356 TCP_NODELAY, |
| 357 reinterpret_cast<char *>(&on), | 357 reinterpret_cast<char *>(&on), |
| 358 sizeof(on))) == 0; | 358 sizeof(on))) == 0; |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace bin | 361 } // namespace bin |
| 362 } // namespace dart | 362 } // namespace dart |
| 363 | 363 |
| 364 #endif // defined(TARGET_OS_MACOS) | 364 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |