Chromium Code Reviews| Index: net/base/net_util.h |
| diff --git a/net/base/net_util.h b/net/base/net_util.h |
| index 839735e5cd5eeb87f91fc21a3a3a4f5927ed192b..e5a04b7827a8c9df2cc4825093650c2b40df43d7 100644 |
| --- a/net/base/net_util.h |
| +++ b/net/base/net_util.h |
| @@ -112,12 +112,15 @@ NET_EXPORT std::string GetHostAndPort(const GURL& url); |
| NET_EXPORT_PRIVATE std::string GetHostAndOptionalPort(const GURL& url); |
| // Returns true if |hostname| contains a non-registerable or non-assignable |
| -// domain name (eg: a gTLD that has not been assigned by IANA) |
| -// |
| -// TODO(rsleevi): http://crbug.com/119212 - Also match internal IP |
| -// address ranges. |
| +// domain name (eg: a gTLD that has not been assigned by IANA) or an IP address |
| +// that falls in an IANA-reserved range. |
| NET_EXPORT bool IsHostnameNonUnique(const std::string& hostname); |
| +// Returns true if an IP address hostname is in a range reserved by the IANA. |
| +// Works with both IPv4 and IPv6 addresses, and only compares against a given |
| +// protocols's reserved ranges. |
| +NET_EXPORT bool IsIPAddressReserved(const IPAddressNumber& address); |
| + |
| // Convenience struct for when you need a |struct sockaddr|. |
| struct SockaddrStorage { |
| SockaddrStorage() : addr_len(sizeof(addr_storage)), |
| @@ -481,6 +484,16 @@ NET_EXPORT_PRIVATE bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, |
| const IPAddressNumber& ip_prefix, |
| size_t prefix_length_in_bits); |
| +// This is a helper method for IPNumberMatchesPrefix and IsIPAddressReserved. |
| +// The |ip_prefix| should be a vector or an array. The |prefix_length_in_bits| |
| +// should be a size_t, unsigned char, int, etc. |
| +// We assume that the |ip_number| and |ip_prefix| are both IPv4 or both IPv6. |
| +template<typename Arr, typename Length> |
|
Ryan Sleevi
2013/08/09 22:50:12
style nit: "template<" -> "template <"
felt
2013/08/10 03:04:33
Done.
|
| +NET_EXPORT_PRIVATE bool IPNumberPrefixCheck( |
| + const IPAddressNumber& ip_number, |
| + const Arr ip_prefix, |
| + const Length prefix_length_in_bits); |
|
Ryan Sleevi
2013/08/09 22:50:12
You can't (safely) forward declare the template li
felt
2013/08/10 03:04:33
Done.
|
| + |
| // Retuns the port field of the |sockaddr|. |
| const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, |
| socklen_t address_len); |