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 #ifndef NET_BASE_IP_ADDRESS_NET_H_ | 5 #ifndef NET_BASE_IP_ADDRESS_NET_H_ |
6 #define NET_BASE_IP_ADDRESS_NET_H_ | 6 #define NET_BASE_IP_ADDRESS_NET_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // Returns true if the IP is an empty, zero-sized (invalid) address. | 68 // Returns true if the IP is an empty, zero-sized (invalid) address. |
69 bool empty() const { return ip_address_.empty(); } | 69 bool empty() const { return ip_address_.empty(); } |
70 | 70 |
71 // Returns the canonical string representation of an IP address. | 71 // Returns the canonical string representation of an IP address. |
72 // For example: "192.168.0.1" or "::1". The IP address must be | 72 // For example: "192.168.0.1" or "::1". The IP address must be |
73 // valid, calling this on an invalid address will result in a crash. | 73 // valid, calling this on an invalid address will result in a crash. |
74 std::string ToString() const; | 74 std::string ToString() const; |
75 | 75 |
76 // Parses an IP address literal (either IPv4 or IPv6) to its numeric value. | 76 // Parses an IP address literal (either IPv4 or IPv6) to its numeric value. |
77 // Returns true on success and fills |ip_address| with the numeric value. | 77 // Returns true on success and fills |ip_address_| with the numeric value. |
78 static bool FromIPLiteral(const base::StringPiece& ip_literal, | 78 bool AssignFromIPLiteral(const base::StringPiece& ip_literal) |
79 IPAddress* ip_address) WARN_UNUSED_RESULT; | 79 WARN_UNUSED_RESULT; |
80 | 80 |
81 // Returns the underlying byte vector. | 81 // Returns the underlying byte vector. |
82 const std::vector<uint8_t>& bytes() const { return ip_address_; }; | 82 const std::vector<uint8_t>& bytes() const { return ip_address_; }; |
83 | 83 |
84 bool operator==(const IPAddress& that) const; | 84 bool operator==(const IPAddress& that) const; |
85 bool operator!=(const IPAddress& that) const; | 85 bool operator!=(const IPAddress& that) const; |
86 bool operator<(const IPAddress& that) const; | 86 bool operator<(const IPAddress& that) const; |
87 | 87 |
88 private: | 88 private: |
89 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address | 89 // IPv4 addresses will have length kIPv4AddressSize, whereas IPv6 address |
(...skipping 19 matching lines...) Expand all Loading... |
109 // For example 192.168.0.1 would be converted to ::ffff:192.168.0.1. | 109 // For example 192.168.0.1 would be converted to ::ffff:192.168.0.1. |
110 NET_EXPORT IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address); | 110 NET_EXPORT IPAddress ConvertIPv4ToIPv4MappedIPv6(const IPAddress& address); |
111 | 111 |
112 // Converts an IPv4-mapped IPv6 address to IPv4 address. Should only be called | 112 // Converts an IPv4-mapped IPv6 address to IPv4 address. Should only be called |
113 // on IPv4-mapped IPv6 addresses. | 113 // on IPv4-mapped IPv6 addresses. |
114 NET_EXPORT IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address); | 114 NET_EXPORT IPAddress ConvertIPv4MappedIPv6ToIPv4(const IPAddress& address); |
115 | 115 |
116 } // namespace net | 116 } // namespace net |
117 | 117 |
118 #endif // NET_BASE_IP_ADDRESS_NET_H_ | 118 #endif // NET_BASE_IP_ADDRESS_NET_H_ |
OLD | NEW |