Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Side by Side Diff: net/base/ip_address_number.h

Issue 1769783002: Migrate net::IPAddressList to net::IPAddress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments eroman Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef NET_BASE_IP_ADDRESS_NUMBER_H_ 5 #ifndef NET_BASE_IP_ADDRESS_NUMBER_H_
6 #define NET_BASE_IP_ADDRESS_NUMBER_H_ 6 #define NET_BASE_IP_ADDRESS_NUMBER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 // IPAddressNumber is used to represent an IP address's numeric value as an 19 // IPAddressNumber is used to represent an IP address's numeric value as an
20 // array of bytes, from most significant to least significant. This is the 20 // array of bytes, from most significant to least significant. This is the
21 // network byte ordering. 21 // network byte ordering.
22 // 22 //
23 // IPv4 addresses will have length 4, whereas IPv6 address will have length 16. 23 // IPv4 addresses will have length 4, whereas IPv6 address will have length 16.
24 // 24 //
25 // TODO(Martijnc): Remove the IPAddressNumber typedef. New code should use 25 // TODO(Martijnc): Remove the IPAddressNumber typedef. New code should use
26 // IPAddress instead and existing code should be switched over. 26 // IPAddress instead and existing code should be switched over.
27 // https://crbug.com/496258 27 // https://crbug.com/496258
28 typedef std::vector<unsigned char> IPAddressNumber; 28 typedef std::vector<unsigned char> IPAddressNumber;
29 typedef std::vector<IPAddressNumber> IPAddressList;
30 29
31 static const size_t kIPv4AddressSize = 4; 30 static const size_t kIPv4AddressSize = 4;
32 static const size_t kIPv6AddressSize = 16; 31 static const size_t kIPv6AddressSize = 16;
33 32
34 // Returns true if an IP address hostname is in a range reserved by the IANA. 33 // Returns true if an IP address hostname is in a range reserved by the IANA.
35 // Works with both IPv4 and IPv6 addresses, and only compares against a given 34 // Works with both IPv4 and IPv6 addresses, and only compares against a given
36 // protocols's reserved ranges. 35 // protocols's reserved ranges.
37 NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address); 36 NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address);
38 37
39 // Returns the string representation of an IP address. 38 // Returns the string representation of an IP address.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Returns number of matching initial bits between the addresses |a1| and |a2|. 112 // Returns number of matching initial bits between the addresses |a1| and |a2|.
114 unsigned CommonPrefixLength(const IPAddressNumber& a1, 113 unsigned CommonPrefixLength(const IPAddressNumber& a1,
115 const IPAddressNumber& a2); 114 const IPAddressNumber& a2);
116 115
117 // Computes the number of leading 1-bits in |mask|. 116 // Computes the number of leading 1-bits in |mask|.
118 unsigned MaskPrefixLength(const IPAddressNumber& mask); 117 unsigned MaskPrefixLength(const IPAddressNumber& mask);
119 118
120 } // namespace net 119 } // namespace net
121 120
122 #endif // NET_BASE_IP_ADDRESS_NUMBER_H_ 121 #endif // NET_BASE_IP_ADDRESS_NUMBER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698