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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 ASSERT(*os_error == NULL); | 237 ASSERT(*os_error == NULL); |
238 *os_error = new OSError(status, | 238 *os_error = new OSError(status, |
239 gai_strerror(status), | 239 gai_strerror(status), |
240 OSError::kGetAddressInfo); | 240 OSError::kGetAddressInfo); |
241 return false; | 241 return false; |
242 } | 242 } |
243 return true; | 243 return true; |
244 } | 244 } |
245 | 245 |
246 | 246 |
| 247 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { |
| 248 int result; |
| 249 if (type == SocketAddress::TYPE_IPV4) { |
| 250 result = inet_pton(AF_INET, address, &addr->in.sin_addr); |
| 251 } else { |
| 252 ASSERT(type == SocketAddress::TYPE_IPV6); |
| 253 result = inet_pton(AF_INET6, address, &addr->in6.sin6_addr); |
| 254 } |
| 255 return result == 1; |
| 256 } |
| 257 |
| 258 |
247 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 259 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
248 if (ifa->ifa_addr == NULL) { | 260 if (ifa->ifa_addr == NULL) { |
249 // OpenVPN's virtual device tun0. | 261 // OpenVPN's virtual device tun0. |
250 return false; | 262 return false; |
251 } | 263 } |
252 int family = ifa->ifa_addr->sa_family; | 264 int family = ifa->ifa_addr->sa_family; |
253 if (lookup_family == family) return true; | 265 if (lookup_family == family) return true; |
254 if (lookup_family == AF_UNSPEC && | 266 if (lookup_family == AF_UNSPEC && |
255 (family == AF_INET || family == AF_INET6)) { | 267 (family == AF_INET || family == AF_INET6)) { |
256 return true; | 268 return true; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 IPPROTO_TCP, | 406 IPPROTO_TCP, |
395 TCP_NODELAY, | 407 TCP_NODELAY, |
396 reinterpret_cast<char *>(&on), | 408 reinterpret_cast<char *>(&on), |
397 sizeof(on))) == 0; | 409 sizeof(on))) == 0; |
398 } | 410 } |
399 | 411 |
400 } // namespace bin | 412 } // namespace bin |
401 } // namespace dart | 413 } // namespace dart |
402 | 414 |
403 #endif // defined(TARGET_OS_MACOS) | 415 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |