OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 5 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 break; | 444 break; |
445 } | 445 } |
446 default: | 446 default: |
447 // InitNetAddress sets net_addr->is_valid to false. | 447 // InitNetAddress sets net_addr->is_valid to false. |
448 return false; | 448 return false; |
449 } | 449 } |
450 return true;} | 450 return true;} |
451 | 451 |
452 // static | 452 // static |
453 bool NetAddressPrivateImpl::IPEndPointToNetAddress( | 453 bool NetAddressPrivateImpl::IPEndPointToNetAddress( |
454 const std::vector<uint8_t>& address, | 454 const net::IPAddress::IPAddressBytes& address, |
455 uint16_t port, | 455 uint16_t port, |
456 PP_NetAddress_Private* addr) { | 456 PP_NetAddress_Private* addr) { |
457 if (!addr) | 457 if (!addr) |
458 return false; | 458 return false; |
459 | 459 |
460 NetAddress* net_addr = InitNetAddress(addr); | 460 NetAddress* net_addr = InitNetAddress(addr); |
461 switch (address.size()) { | 461 switch (address.size()) { |
462 case kIPv4AddressSize: { | 462 case kIPv4AddressSize: { |
463 net_addr->is_valid = true; | 463 net_addr->is_valid = true; |
464 net_addr->is_ipv6 = false; | 464 net_addr->is_ipv6 = false; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 ipv6_addr->port = ConvertToNetEndian16(net_addr->port); | 584 ipv6_addr->port = ConvertToNetEndian16(net_addr->port); |
585 | 585 |
586 static_assert(sizeof(ipv6_addr->addr) == kIPv6AddressSize, | 586 static_assert(sizeof(ipv6_addr->addr) == kIPv6AddressSize, |
587 "mismatched IPv6 address size"); | 587 "mismatched IPv6 address size"); |
588 memcpy(ipv6_addr->addr, net_addr->address, kIPv6AddressSize); | 588 memcpy(ipv6_addr->addr, net_addr->address, kIPv6AddressSize); |
589 | 589 |
590 return true; | 590 return true; |
591 } | 591 } |
592 | 592 |
593 } // namespace ppapi | 593 } // namespace ppapi |
OLD | NEW |