OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
8 #if defined(TARGET_OS_FUCHSIA) | 8 #if defined(TARGET_OS_FUCHSIA) |
9 | 9 |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 socklen_t size = sizeof(raw); | 235 socklen_t size = sizeof(raw); |
236 LOG_INFO("Socket::GetPort: calling getsockname(%ld)\n", fd); | 236 LOG_INFO("Socket::GetPort: calling getsockname(%ld)\n", fd); |
237 if (NO_RETRY_EXPECTED(getsockname(fd, &raw.addr, &size))) { | 237 if (NO_RETRY_EXPECTED(getsockname(fd, &raw.addr, &size))) { |
238 return 0; | 238 return 0; |
239 } | 239 } |
240 return SocketAddress::GetAddrPort(raw); | 240 return SocketAddress::GetAddrPort(raw); |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { | 244 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { |
245 LOG_ERR("Socket::GetRemotePeer is unimplemented\n"); | 245 ASSERT(fd >= 0); |
246 UNIMPLEMENTED(); | 246 RawAddr raw; |
247 return NULL; | 247 socklen_t size = sizeof(raw); |
| 248 if (NO_RETRY_EXPECTED(getpeername(fd, &raw.addr, &size))) { |
| 249 return NULL; |
| 250 } |
| 251 *port = SocketAddress::GetAddrPort(raw); |
| 252 return new SocketAddress(&raw.addr); |
248 } | 253 } |
249 | 254 |
250 | 255 |
251 void Socket::GetError(intptr_t fd, OSError* os_error) { | 256 void Socket::GetError(intptr_t fd, OSError* os_error) { |
252 LOG_ERR("Socket::GetError is unimplemented\n"); | 257 LOG_ERR("Socket::GetError is unimplemented\n"); |
253 UNIMPLEMENTED(); | 258 UNIMPLEMENTED(); |
254 } | 259 } |
255 | 260 |
256 | 261 |
257 int Socket::GetType(intptr_t fd) { | 262 int Socket::GetType(intptr_t fd) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 char* host, | 322 char* host, |
318 intptr_t host_len, | 323 intptr_t host_len, |
319 OSError** os_error) { | 324 OSError** os_error) { |
320 LOG_ERR("Socket::ReverseLookup is unimplemented\n"); | 325 LOG_ERR("Socket::ReverseLookup is unimplemented\n"); |
321 UNIMPLEMENTED(); | 326 UNIMPLEMENTED(); |
322 return false; | 327 return false; |
323 } | 328 } |
324 | 329 |
325 | 330 |
326 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { | 331 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { |
327 LOG_ERR("Socket::ParseAddress is unimplemented\n"); | 332 int result; |
328 UNIMPLEMENTED(); | 333 if (type == SocketAddress::TYPE_IPV4) { |
329 return false; | 334 result = NO_RETRY_EXPECTED(inet_pton(AF_INET, address, &addr->in.sin_addr)); |
| 335 } else { |
| 336 ASSERT(type == SocketAddress::TYPE_IPV6); |
| 337 result = |
| 338 NO_RETRY_EXPECTED(inet_pton(AF_INET6, address, &addr->in6.sin6_addr)); |
| 339 } |
| 340 return (result == 1); |
330 } | 341 } |
331 | 342 |
332 | 343 |
333 intptr_t Socket::CreateBindDatagram(const RawAddr& addr, bool reuseAddress) { | 344 intptr_t Socket::CreateBindDatagram(const RawAddr& addr, bool reuseAddress) { |
334 LOG_ERR("Socket::CreateBindDatagram is unimplemented\n"); | 345 LOG_ERR("Socket::CreateBindDatagram is unimplemented\n"); |
335 UNIMPLEMENTED(); | 346 UNIMPLEMENTED(); |
336 return -1; | 347 return -1; |
337 } | 348 } |
338 | 349 |
339 | 350 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 482 |
472 | 483 |
473 bool Socket::GetNoDelay(intptr_t fd, bool* enabled) { | 484 bool Socket::GetNoDelay(intptr_t fd, bool* enabled) { |
474 LOG_ERR("Socket::GetNoDelay is unimplemented\n"); | 485 LOG_ERR("Socket::GetNoDelay is unimplemented\n"); |
475 UNIMPLEMENTED(); | 486 UNIMPLEMENTED(); |
476 return false; | 487 return false; |
477 } | 488 } |
478 | 489 |
479 | 490 |
480 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { | 491 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { |
| 492 // TODO(US-94): Enable. |
| 493 #if 0 |
481 int on = enabled ? 1 : 0; | 494 int on = enabled ? 1 : 0; |
482 return NO_RETRY_EXPECTED(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, | 495 return NO_RETRY_EXPECTED(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, |
483 reinterpret_cast<char*>(&on), | 496 reinterpret_cast<char*>(&on), |
484 sizeof(on))) == 0; | 497 sizeof(on))) == 0; |
| 498 #else |
| 499 return true; |
| 500 #endif |
485 } | 501 } |
486 | 502 |
487 | 503 |
488 bool Socket::GetMulticastLoop(intptr_t fd, intptr_t protocol, bool* enabled) { | 504 bool Socket::GetMulticastLoop(intptr_t fd, intptr_t protocol, bool* enabled) { |
489 LOG_ERR("Socket::GetMulticastLoop is unimplemented\n"); | 505 LOG_ERR("Socket::GetMulticastLoop is unimplemented\n"); |
490 UNIMPLEMENTED(); | 506 UNIMPLEMENTED(); |
491 return false; | 507 return false; |
492 } | 508 } |
493 | 509 |
494 | 510 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 UNIMPLEMENTED(); | 561 UNIMPLEMENTED(); |
546 return false; | 562 return false; |
547 } | 563 } |
548 | 564 |
549 } // namespace bin | 565 } // namespace bin |
550 } // namespace dart | 566 } // namespace dart |
551 | 567 |
552 #endif // defined(TARGET_OS_FUCHSIA) | 568 #endif // defined(TARGET_OS_FUCHSIA) |
553 | 569 |
554 #endif // !defined(DART_IO_DISABLED) | 570 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |