Fix use of reachable DNS server logic
Move reachable DNS server computation out of ConnectivityService and split it into LinkProperties#isReachable() and a companion change in WifiStateMachine's makeLinkProperties(). Restore previous ConnectivityService#updateDnses() behaviour, as the pruning is done in WifiStateMachine now. Bug: 19470192 Bug: 20733156 Bug: 22098233 Change-Id: I810ef74d504e5dc1ca2017d435cdadd6b82171e6
This commit is contained in:
parent
fafc8fef0c
commit
a923dbae3a
1 changed files with 118 additions and 45 deletions
|
|
@ -517,7 +517,7 @@ public final class LinkProperties implements Parcelable {
|
|||
* Note that Http Proxies are only a hint - the system recommends their use, but it does
|
||||
* not enforce it and applications may ignore them.
|
||||
*
|
||||
* @param proxy A {@link ProxyInfo} defining the Http Proxy to use on this link.
|
||||
* @param proxy A {@link ProxyInfo} defining the HTTP Proxy to use on this link.
|
||||
* @hide
|
||||
*/
|
||||
public void setHttpProxy(ProxyInfo proxy) {
|
||||
|
|
@ -773,6 +773,43 @@ public final class LinkProperties implements Parcelable {
|
|||
return (isIPv4Provisioned() || isIPv6Provisioned());
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate whether the {@link InetAddress} is considered reachable.
|
||||
*
|
||||
* @return {@code true} if the given {@link InetAddress} is considered reachable,
|
||||
* {@code false} otherwise.
|
||||
* @hide
|
||||
*/
|
||||
public boolean isReachable(InetAddress ip) {
|
||||
final List<RouteInfo> allRoutes = getAllRoutes();
|
||||
// If we don't have a route to this IP address, it's not reachable.
|
||||
final RouteInfo bestRoute = RouteInfo.selectBestRoute(allRoutes, ip);
|
||||
if (bestRoute == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: better source address evaluation for destination addresses.
|
||||
|
||||
if (ip instanceof Inet4Address) {
|
||||
// For IPv4, it suffices for now to simply have any address.
|
||||
return hasIPv4Address();
|
||||
} else if (ip instanceof Inet6Address) {
|
||||
if (ip.isLinkLocalAddress()) {
|
||||
// For now, just make sure link-local destinations have
|
||||
// scopedIds set, since transmits will generally fail otherwise.
|
||||
// TODO: verify it matches the ifindex of one of the interfaces.
|
||||
return (((Inet6Address)ip).getScopeId() != 0);
|
||||
} else {
|
||||
// For non-link-local destinations check that either the best route
|
||||
// is directly connected or that some global preferred address exists.
|
||||
// TODO: reconsider all cases (disconnected ULA networks, ...).
|
||||
return (!bestRoute.hasGateway() || hasGlobalIPv6Address());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this {@code LinkProperties} interface name against the target
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue