New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 739853 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task

Blocking:
issue 739856



Sign in to add a comment

Add methods to net::IPAddress to retrieve reserved IP address prefix

Project Member Reported by uthakore@chromium.org, Jul 6 2017

Issue description

net::IPAddress currently doesn't support the ability to determine the reserved IP range to which a reserved address belongs. This functionality is used in a handful of places in the codebase (e.g., net::IsLocalhost(), net::HostResolverImpl::IsGloballyReachable(), LocalNetworkRequestsPageLoadMetricsObserver::OnCommit()), resulting in code duplication. Changes to the list of reserved IP address prefixes by IANA would require changes to some of these checks.

The information required to determine which reserved IP range an address falls into is present in tables within IPAddress::IsReservedIPv4() and IPAddress::IsReservedIPv6(), but is not accessible outside the class or elsewhere in net/. As a result, determining whether two IP addresses belong to the same reserved IP range (as in LocalNetworkRequestsPageLoadMetricsObserver::OnCommit()) requires duplication of the information.

I propose two new methods be added to net::IPAddress to provide the ability to retrieve the reserved IP prefix for a reserved IP address:

bool IPAddress::IsInReservedRangeIPv4(uint8_t* prefix, size_t* prefix_length)
bool IPAddress::IsInReservedRangeIPv6(uint8_t* prefix, size_t* prefix_length) 

The methods should return true iff the IPAddress is of the correct type (IPv4 or IPv6) and belongs to a reserved range (same behavior as IsReservedIPv4 and IsReservedIPv6), and return through output parameters |prefix| and |prefix_length| the reserved IP prefix as an array of uint8_t and corresponding prefix length in bits.

For example, for the address 10.5.0.1, IsInReservedRangeIPv4 should return true and assign prefix=[10,0,0,0] and prefix_length=8.

 
Blocking: 739856

Comment 2 by mef@chromium.org, Jul 18 2017

Owner: uthakore@chromium.org
Status: Assigned (was: Untriaged)

Sign in to add a comment