OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "net/base/ip_address.h" | 5 #include "net/base/ip_address.h" |
6 | 6 |
7 #include "net/base/ip_address_number.h" | 7 #include "net/base/ip_address_number.h" |
8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
9 #include "url/url_canon_ip.h" | 9 #include "url/url_canon_ip.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 bool IPAddress::IsIPv4MappedIPv6() const { | 50 bool IPAddress::IsIPv4MappedIPv6() const { |
51 return net::IsIPv4Mapped(ip_address_); | 51 return net::IsIPv4Mapped(ip_address_); |
52 } | 52 } |
53 | 53 |
54 std::string IPAddress::ToString() const { | 54 std::string IPAddress::ToString() const { |
55 return IPAddressToString(ip_address_); | 55 return IPAddressToString(ip_address_); |
56 } | 56 } |
57 | 57 |
58 // static | 58 bool IPAddress::AssignFromIPLiteral(const base::StringPiece& ip_literal) { |
59 bool IPAddress::FromIPLiteral(const base::StringPiece& ip_literal, | |
60 IPAddress* ip_address) { | |
61 std::vector<uint8_t> number; | 59 std::vector<uint8_t> number; |
62 if (!ParseIPLiteralToNumber(ip_literal, &number)) | 60 if (!ParseIPLiteralToNumber(ip_literal, &number)) |
63 return false; | 61 return false; |
64 | 62 |
65 std::swap(number, ip_address->ip_address_); | 63 std::swap(number, ip_address_); |
66 return true; | 64 return true; |
67 } | 65 } |
68 | 66 |
69 bool IPAddress::operator==(const IPAddress& that) const { | 67 bool IPAddress::operator==(const IPAddress& that) const { |
70 return ip_address_ == that.ip_address_; | 68 return ip_address_ == that.ip_address_; |
71 } | 69 } |
72 | 70 |
73 bool IPAddress::operator!=(const IPAddress& that) const { | 71 bool IPAddress::operator!=(const IPAddress& that) const { |
74 return ip_address_ != that.ip_address_; | 72 return ip_address_ != that.ip_address_; |
75 } | 73 } |
(...skipping 17 matching lines...) Expand all Loading... |
93 | 91 |
94 IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address) { | 92 IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address) { |
95 return IPAddress(ConvertIPv4NumberToIPv6Number(address.bytes())); | 93 return IPAddress(ConvertIPv4NumberToIPv6Number(address.bytes())); |
96 } | 94 } |
97 | 95 |
98 IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address) { | 96 IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address) { |
99 return IPAddress(ConvertIPv4MappedToIPv4(address.bytes())); | 97 return IPAddress(ConvertIPv4MappedToIPv4(address.bytes())); |
100 } | 98 } |
101 | 99 |
102 } // namespace net | 100 } // namespace net |
OLD | NEW |