Add an API to request route to an IPv6 host.
Add API to create a route to an IPv6 host through a particular interface. Change-Id: I7649051e94832576e02b5f5ad17abe093d21d48e
This commit is contained in:
committed by
Banavathu Srinivas Naik
parent
2198ddbc38
commit
7601f575aa
@@ -27,6 +27,7 @@ import android.net.IConnectivityManager;
|
||||
import android.net.MobileDataStateTracker;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkStateTracker;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.wifi.WifiStateTracker;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
@@ -49,6 +50,8 @@ import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -730,6 +733,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use requestRouteToHostAddress instead
|
||||
*
|
||||
* Ensure that a network route exists to deliver traffic to the specified
|
||||
* host via the specified network interface.
|
||||
* @param networkType the type of the network over which traffic to the
|
||||
@@ -739,6 +744,25 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
* @return {@code true} on success, {@code false} on failure
|
||||
*/
|
||||
public boolean requestRouteToHost(int networkType, int hostAddress) {
|
||||
InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
|
||||
|
||||
if (inetAddress == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return requestRouteToHostAddress(networkType, inetAddress.getAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a network route exists to deliver traffic to the specified
|
||||
* host via the specified network interface.
|
||||
* @param networkType the type of the network over which traffic to the
|
||||
* specified host is to be routed
|
||||
* @param hostAddress the IP address of the host to which the route is
|
||||
* desired
|
||||
* @return {@code true} on success, {@code false} on failure
|
||||
*/
|
||||
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) {
|
||||
enforceChangePermission();
|
||||
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
|
||||
return false;
|
||||
@@ -748,11 +772,18 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
if (tracker == null || !tracker.getNetworkInfo().isConnected() ||
|
||||
tracker.isTeardownRequested()) {
|
||||
if (DBG) {
|
||||
Slog.d(TAG, "requestRouteToHost on down network (" + networkType + ") - dropped");
|
||||
Slog.d(TAG, "requestRouteToHostAddress on down network " +
|
||||
"(" + networkType + ") - dropped");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return tracker.requestRouteToHost(hostAddress);
|
||||
|
||||
try {
|
||||
InetAddress inetAddress = InetAddress.getByAddress(hostAddress);
|
||||
return tracker.requestRouteToHost(inetAddress);
|
||||
} catch (UnknownHostException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user