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_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
11 #include "bin/lockers.h" | 11 #include "bin/lockers.h" |
12 #include "bin/log.h" | 12 #include "bin/log.h" |
13 #include "bin/socket.h" | 13 #include "bin/socket.h" |
14 #include "bin/thread.h" | 14 #include "bin/thread.h" |
15 #include "bin/utils.h" | 15 #include "bin/utils.h" |
| 16 #include "bin/utils_win.h" |
| 17 |
16 | 18 |
17 namespace dart { | 19 namespace dart { |
18 namespace bin { | 20 namespace bin { |
19 | 21 |
20 SocketAddress::SocketAddress(struct sockaddr* sockaddr) { | 22 SocketAddress::SocketAddress(struct sockaddr* sockaddr) { |
21 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN); | 23 ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN); |
22 RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr); | 24 RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr); |
23 | 25 |
24 // Clear the port before calling WSAAddressToString as WSAAddressToString | 26 // Clear the port before calling WSAAddressToString as WSAAddressToString |
25 // includes the port in the formatted string. | 27 // includes the port in the formatted string. |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 SetLastError(error_code); | 352 SetLastError(error_code); |
351 *os_error = new OSError(); | 353 *os_error = new OSError(); |
352 return false; | 354 return false; |
353 } | 355 } |
354 return true; | 356 return true; |
355 } | 357 } |
356 | 358 |
357 | 359 |
358 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { | 360 bool Socket::ParseAddress(int type, const char* address, RawAddr* addr) { |
359 int result; | 361 int result; |
360 const wchar_t* system_address = StringUtils::Utf8ToWide(address); | 362 const wchar_t* system_address = StringUtilsWin::Utf8ToWide(address); |
361 if (type == SocketAddress::TYPE_IPV4) { | 363 if (type == SocketAddress::TYPE_IPV4) { |
362 result = InetPton(AF_INET, system_address, &addr->in.sin_addr); | 364 result = InetPton(AF_INET, system_address, &addr->in.sin_addr); |
363 } else { | 365 } else { |
364 ASSERT(type == SocketAddress::TYPE_IPV6); | 366 ASSERT(type == SocketAddress::TYPE_IPV6); |
365 result = InetPton(AF_INET6, system_address, &addr->in6.sin6_addr); | 367 result = InetPton(AF_INET6, system_address, &addr->in6.sin6_addr); |
366 } | 368 } |
367 free(const_cast<wchar_t*>(system_address)); | 369 free(const_cast<wchar_t*>(system_address)); |
368 return result == 1; | 370 return result == 1; |
369 } | 371 } |
370 | 372 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 449 } |
448 } | 450 } |
449 AddressList<InterfaceSocketAddress>* addresses = | 451 AddressList<InterfaceSocketAddress>* addresses = |
450 new AddressList<InterfaceSocketAddress>(count); | 452 new AddressList<InterfaceSocketAddress>(count); |
451 intptr_t i = 0; | 453 intptr_t i = 0; |
452 for (IP_ADAPTER_ADDRESSES* a = addrs; a != NULL; a = a->Next) { | 454 for (IP_ADAPTER_ADDRESSES* a = addrs; a != NULL; a = a->Next) { |
453 for (IP_ADAPTER_UNICAST_ADDRESS* u = a->FirstUnicastAddress; | 455 for (IP_ADAPTER_UNICAST_ADDRESS* u = a->FirstUnicastAddress; |
454 u != NULL; u = u->Next) { | 456 u != NULL; u = u->Next) { |
455 addresses->SetAt(i, new InterfaceSocketAddress( | 457 addresses->SetAt(i, new InterfaceSocketAddress( |
456 u->Address.lpSockaddr, | 458 u->Address.lpSockaddr, |
457 StringUtils::WideToUtf8(a->FriendlyName), | 459 StringUtilsWin::WideToUtf8(a->FriendlyName), |
458 a->Ipv6IfIndex)); | 460 a->Ipv6IfIndex)); |
459 i++; | 461 i++; |
460 } | 462 } |
461 } | 463 } |
462 free(addrs); | 464 free(addrs); |
463 return addresses; | 465 return addresses; |
464 } | 466 } |
465 | 467 |
466 | 468 |
467 intptr_t ServerSocket::CreateBindListen(const RawAddr& addr, | 469 intptr_t ServerSocket::CreateBindListen(const RawAddr& addr, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 proto, | 708 proto, |
707 MCAST_LEAVE_GROUP, | 709 MCAST_LEAVE_GROUP, |
708 reinterpret_cast<char *>(&mreq), | 710 reinterpret_cast<char *>(&mreq), |
709 sizeof(mreq)) == 0; | 711 sizeof(mreq)) == 0; |
710 } | 712 } |
711 | 713 |
712 } // namespace bin | 714 } // namespace bin |
713 } // namespace dart | 715 } // namespace dart |
714 | 716 |
715 #endif // defined(TARGET_OS_WINDOWS) | 717 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |