Merge "Update IpSecManager to use InetAddress and prefixLen" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b172d5b437
@@ -3083,10 +3083,10 @@ package android.net {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class IpSecManager.IpSecTunnelInterface implements java.lang.AutoCloseable {
|
public static final class IpSecManager.IpSecTunnelInterface implements java.lang.AutoCloseable {
|
||||||
method public void addAddress(android.net.LinkAddress) throws java.io.IOException;
|
method public void addAddress(java.net.InetAddress, int) throws java.io.IOException;
|
||||||
method public void close();
|
method public void close();
|
||||||
method public java.lang.String getInterfaceName();
|
method public java.lang.String getInterfaceName();
|
||||||
method public void removeAddress(android.net.LinkAddress) throws java.io.IOException;
|
method public void removeAddress(java.net.InetAddress, int) throws java.io.IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class IpSecTransform implements java.lang.AutoCloseable {
|
public final class IpSecTransform implements java.lang.AutoCloseable {
|
||||||
|
|||||||
@@ -684,14 +684,15 @@ public final class IpSecManager {
|
|||||||
* tunneled traffic.
|
* tunneled traffic.
|
||||||
*
|
*
|
||||||
* @param address the local address for traffic inside the tunnel
|
* @param address the local address for traffic inside the tunnel
|
||||||
|
* @param prefixLen length of the InetAddress prefix
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
|
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
|
||||||
public void addAddress(@NonNull LinkAddress address) throws IOException {
|
public void addAddress(@NonNull InetAddress address, int prefixLen) throws IOException {
|
||||||
try {
|
try {
|
||||||
mService.addAddressToTunnelInterface(
|
mService.addAddressToTunnelInterface(
|
||||||
mResourceId, address, mOpPackageName);
|
mResourceId, new LinkAddress(address, prefixLen), mOpPackageName);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
@@ -703,14 +704,15 @@ public final class IpSecManager {
|
|||||||
* <p>Remove an address which was previously added to the IpSecTunnelInterface
|
* <p>Remove an address which was previously added to the IpSecTunnelInterface
|
||||||
*
|
*
|
||||||
* @param address to be removed
|
* @param address to be removed
|
||||||
|
* @param prefixLen length of the InetAddress prefix
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
|
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
|
||||||
public void removeAddress(@NonNull LinkAddress address) throws IOException {
|
public void removeAddress(@NonNull InetAddress address, int prefixLen) throws IOException {
|
||||||
try {
|
try {
|
||||||
mService.removeAddressFromTunnelInterface(
|
mService.removeAddressFromTunnelInterface(
|
||||||
mResourceId, address, mOpPackageName);
|
mResourceId, new LinkAddress(address, prefixLen), mOpPackageName);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,12 +260,14 @@ public class IpSecManagerTest {
|
|||||||
IpSecManager.IpSecTunnelInterface tunnelIntf =
|
IpSecManager.IpSecTunnelInterface tunnelIntf =
|
||||||
createAndValidateVti(DUMMY_RESOURCE_ID, VTI_INTF_NAME);
|
createAndValidateVti(DUMMY_RESOURCE_ID, VTI_INTF_NAME);
|
||||||
|
|
||||||
tunnelIntf.addAddress(VTI_INNER_ADDRESS);
|
tunnelIntf.addAddress(VTI_INNER_ADDRESS.getAddress(),
|
||||||
|
VTI_INNER_ADDRESS.getPrefixLength());
|
||||||
verify(mMockIpSecService)
|
verify(mMockIpSecService)
|
||||||
.addAddressToTunnelInterface(
|
.addAddressToTunnelInterface(
|
||||||
eq(DUMMY_RESOURCE_ID), eq(VTI_INNER_ADDRESS), anyString());
|
eq(DUMMY_RESOURCE_ID), eq(VTI_INNER_ADDRESS), anyString());
|
||||||
|
|
||||||
tunnelIntf.removeAddress(VTI_INNER_ADDRESS);
|
tunnelIntf.removeAddress(VTI_INNER_ADDRESS.getAddress(),
|
||||||
|
VTI_INNER_ADDRESS.getPrefixLength());
|
||||||
verify(mMockIpSecService)
|
verify(mMockIpSecService)
|
||||||
.addAddressToTunnelInterface(
|
.addAddressToTunnelInterface(
|
||||||
eq(DUMMY_RESOURCE_ID), eq(VTI_INNER_ADDRESS), anyString());
|
eq(DUMMY_RESOURCE_ID), eq(VTI_INNER_ADDRESS), anyString());
|
||||||
|
|||||||
Reference in New Issue
Block a user