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

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

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 years, 6 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 static const size_t kIPv4AddressSize = 4; 24 static const size_t kIPv4AddressSize = 4;
25 static const size_t kIPv6AddressSize = 16; 25 static const size_t kIPv6AddressSize = 16;
26 26
27 // Returns true if an IP address hostname is in a range reserved by the IANA. 27 // Returns true if an IP address hostname is in a range reserved by the IANA.
28 // Works with both IPv4 and IPv6 addresses, and only compares against a given 28 // Works with both IPv4 and IPv6 addresses, and only compares against a given
29 // protocols's reserved ranges. 29 // protocols's reserved ranges.
30 NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address); 30 NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address);
31 31
32 // Returns the string representation of an IP address. 32 // Returns the string representation of an IP address.
33 // For example: "192.168.0.1" or "::1". 33 // For example: "192.168.0.1" or "::1".
34 NET_EXPORT std::string IPAddressToString(const uint8* address, 34 NET_EXPORT std::string IPAddressToString(const uint8_t* address,
35 size_t address_len); 35 size_t address_len);
36 36
37 // Returns the string representation of an IP address along with its port. 37 // Returns the string representation of an IP address along with its port.
38 // For example: "192.168.0.1:99" or "[::1]:80". 38 // For example: "192.168.0.1:99" or "[::1]:80".
39 NET_EXPORT std::string IPAddressToStringWithPort(const uint8* address, 39 NET_EXPORT std::string IPAddressToStringWithPort(const uint8_t* address,
40 size_t address_len, 40 size_t address_len,
41 uint16 port); 41 uint16_t port);
42 42
43 // Same as IPAddressToString() but for an IPAddressNumber. 43 // Same as IPAddressToString() but for an IPAddressNumber.
44 NET_EXPORT std::string IPAddressToString(const IPAddressNumber& addr); 44 NET_EXPORT std::string IPAddressToString(const IPAddressNumber& addr);
45 45
46 // Same as IPAddressToStringWithPort() but for an IPAddressNumber. 46 // Same as IPAddressToStringWithPort() but for an IPAddressNumber.
47 NET_EXPORT std::string IPAddressToStringWithPort( 47 NET_EXPORT std::string IPAddressToStringWithPort(const IPAddressNumber& addr,
48 const IPAddressNumber& addr, uint16 port); 48 uint16_t port);
49 49
50 // Returns the address as a sequence of bytes in network-byte-order. 50 // Returns the address as a sequence of bytes in network-byte-order.
51 NET_EXPORT std::string IPAddressToPackedString(const IPAddressNumber& addr); 51 NET_EXPORT std::string IPAddressToPackedString(const IPAddressNumber& addr);
52 52
53 // Parses a URL-safe IP literal (see RFC 3986, Sec 3.2.2) to its numeric value. 53 // Parses a URL-safe IP literal (see RFC 3986, Sec 3.2.2) to its numeric value.
54 // Returns true on success, and fills |ip_number| with the numeric value 54 // Returns true on success, and fills |ip_number| with the numeric value
55 NET_EXPORT bool ParseURLHostnameToNumber(const std::string& hostname, 55 NET_EXPORT bool ParseURLHostnameToNumber(const std::string& hostname,
56 IPAddressNumber* ip_number); 56 IPAddressNumber* ip_number);
57 57
58 // Parses an IP address literal (either IPv4 or IPv6) to its numeric value. 58 // Parses an IP address literal (either IPv4 or IPv6) to its numeric value.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Returns number of matching initial bits between the addresses |a1| and |a2|. 104 // Returns number of matching initial bits between the addresses |a1| and |a2|.
105 unsigned CommonPrefixLength(const IPAddressNumber& a1, 105 unsigned CommonPrefixLength(const IPAddressNumber& a1,
106 const IPAddressNumber& a2); 106 const IPAddressNumber& a2);
107 107
108 // Computes the number of leading 1-bits in |mask|. 108 // Computes the number of leading 1-bits in |mask|.
109 unsigned MaskPrefixLength(const IPAddressNumber& mask); 109 unsigned MaskPrefixLength(const IPAddressNumber& mask);
110 110
111 } // namespace net 111 } // namespace net
112 112
113 #endif // NET_BASE_IP_ADDRESS_NUMBER_H_ 113 #endif // NET_BASE_IP_ADDRESS_NUMBER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698