| Index: net/base/net_util.cc
|
| diff --git a/net/base/net_util.cc b/net/base/net_util.cc
|
| index 941dca9ab53ba1a4cb3214712a4ae7e16cf7ee62..1b65c6b10e4bbf0edf2082ef14970e4747a603f4 100644
|
| --- a/net/base/net_util.cc
|
| +++ b/net/base/net_util.cc
|
| @@ -799,6 +799,28 @@ int ConvertAddressFamily(AddressFamily address_family) {
|
| return AF_UNSPEC;
|
| }
|
|
|
| +bool ParseURLHostnameToNumber(const std::string& hostname,
|
| + IPAddressNumber* ip_number) {
|
| + // |hostname| is an already canoncalized hostname, conforming to RFC 3986.
|
| + // For an IP address, this is defined in Section 3.2.2 of RFC 3986, with
|
| + // the canonical form for IPv6 addresses defined in Section 4 of RFC 5952.
|
| + url::Component host_comp(0, hostname.size());
|
| +
|
| + // If it has a bracket, try parsing it as an IPv6 address.
|
| + if (hostname[0] == '[') {
|
| + ip_number->resize(16); // 128 bits.
|
| + return url::IPv6AddressToNumber(
|
| + hostname.data(), host_comp, &(*ip_number)[0]);
|
| + }
|
| +
|
| + // Otherwise, try IPv4.
|
| + ip_number->resize(4); // 32 bits.
|
| + int num_components;
|
| + url::CanonHostInfo::Family family = url::IPv4AddressToNumber(
|
| + hostname.data(), host_comp, &(*ip_number)[0], &num_components);
|
| + return family == url::CanonHostInfo::IPV4;
|
| +}
|
| +
|
| bool ParseIPLiteralToNumber(const std::string& ip_literal,
|
| IPAddressNumber* ip_number) {
|
| // |ip_literal| could be either a IPv4 or an IPv6 literal. If it contains
|
|
|