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 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 IPPROTO_TCP, | 415 IPPROTO_TCP, |
404 TCP_NODELAY, | 416 TCP_NODELAY, |
405 reinterpret_cast<char *>(&on), | 417 reinterpret_cast<char *>(&on), |
406 sizeof(on))) == 0; | 418 sizeof(on))) == 0; |
407 } | 419 } |
408 | 420 |
409 } // namespace bin | 421 } // namespace bin |
410 } // namespace dart | 422 } // namespace dart |
411 | 423 |
412 #endif // defined(TARGET_OS_LINUX) | 424 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |