| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 static const uint8_t kLocalhostIPv6[] = {0, 0, 0, 0, 0, 0, 0, 0, | 82 static const uint8_t kLocalhostIPv6[] = {0, 0, 0, 0, 0, 0, 0, 0, |
| 83 0, 0, 0, 0, 0, 0, 0, 1}; | 83 0, 0, 0, 0, 0, 0, 0, 1}; |
| 84 return IPAddress(kLocalhostIPv6); | 84 return IPAddress(kLocalhostIPv6); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // static | 87 // static |
| 88 IPAddress IPAddress::AllZeros(size_t num_zero_bytes) { | 88 IPAddress IPAddress::AllZeros(size_t num_zero_bytes) { |
| 89 return IPAddress(std::vector<uint8_t>(num_zero_bytes)); | 89 return IPAddress(std::vector<uint8_t>(num_zero_bytes)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // static |
| 93 IPAddress IPAddress::IPv4AllZeros() { |
| 94 return AllZeros(kIPv4AddressSize); |
| 95 } |
| 96 |
| 97 // static |
| 98 IPAddress IPAddress::IPv6AllZeros() { |
| 99 return AllZeros(kIPv6AddressSize); |
| 100 } |
| 101 |
| 92 bool IPAddress::operator==(const IPAddress& that) const { | 102 bool IPAddress::operator==(const IPAddress& that) const { |
| 93 return ip_address_ == that.ip_address_; | 103 return ip_address_ == that.ip_address_; |
| 94 } | 104 } |
| 95 | 105 |
| 96 bool IPAddress::operator!=(const IPAddress& that) const { | 106 bool IPAddress::operator!=(const IPAddress& that) const { |
| 97 return ip_address_ != that.ip_address_; | 107 return ip_address_ != that.ip_address_; |
| 98 } | 108 } |
| 99 | 109 |
| 100 bool IPAddress::operator<(const IPAddress& that) const { | 110 bool IPAddress::operator<(const IPAddress& that) const { |
| 101 // Sort IPv4 before IPv6. | 111 // Sort IPv4 before IPv6. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 131 | 141 |
| 132 unsigned CommonPrefixLength(const IPAddress& a1, const IPAddress& a2) { | 142 unsigned CommonPrefixLength(const IPAddress& a1, const IPAddress& a2) { |
| 133 return CommonPrefixLength(a1.bytes(), a2.bytes()); | 143 return CommonPrefixLength(a1.bytes(), a2.bytes()); |
| 134 } | 144 } |
| 135 | 145 |
| 136 unsigned MaskPrefixLength(const IPAddress& mask) { | 146 unsigned MaskPrefixLength(const IPAddress& mask) { |
| 137 return MaskPrefixLength(mask.bytes()); | 147 return MaskPrefixLength(mask.bytes()); |
| 138 } | 148 } |
| 139 | 149 |
| 140 } // namespace net | 150 } // namespace net |
| OLD | NEW |