Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81c295e1 authored by Sreeram Ramachandran's avatar Sreeram Ramachandran
Browse files

Allow VPNs to dynamically add/remove IP addresses on their tun interface.

New API with stub implementation to be filled out later.

Bug: 15409819
Change-Id: Ic0d2d459953eac86832905115a0d413b9b0b2660
parent 266f677f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16814,12 +16814,14 @@ package android.net {
  public class VpnService extends android.app.Service {
    ctor public VpnService();
    method public boolean addAddress(java.net.InetAddress, int);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onRevoke();
    method public static android.content.Intent prepare(android.content.Context);
    method public boolean protect(int);
    method public boolean protect(java.net.Socket);
    method public boolean protect(java.net.DatagramSocket);
    method public boolean removeAddress(java.net.InetAddress, int);
    field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
  }
+38 −0
Original line number Diff line number Diff line
@@ -201,6 +201,44 @@ public class VpnService extends Service {
        return protect(socket.getFileDescriptor$().getInt$());
    }

    /**
     * Adds a network address to the VPN interface.
     *
     * Both IPv4 and IPv6 addresses are supported. The VPN must already be established. Fails if the
     * address is already in use or cannot be assigned to the interface for any other reason.
     *
     * @throws {@link IllegalArgumentException} if the address is invalid.
     *
     * @param address The IP address (IPv4 or IPv6) to assign to the VPN interface.
     * @param prefixLength The prefix length of the address.
     *
     * @return {@code true} on success.
     * @see Builder#addAddress
     */
    public boolean addAddress(InetAddress address, int prefixLength) {
        // TODO
        return true;
    }

    /**
     * Removes a network address from the VPN interface.
     *
     * Both IPv4 and IPv6 addresses are supported. The VPN must already be established. Fails if the
     * address is not assigned to the VPN interface, or if it is the only address assigned (thus
     * cannot be removed), or if the address cannot be removed for any other reason.
     *
     * @throws {@link IllegalArgumentException} if the address is invalid.
     *
     * @param address The IP address (IPv4 or IPv6) to assign to the VPN interface.
     * @param prefixLength The prefix length of the address.
     *
     * @return {@code true} on success.
     */
    public boolean removeAddress(InetAddress address, int prefixLength) {
        // TODO
        return true;
    }

    /**
     * Return the communication interface to the service. This method returns
     * {@code null} on {@link Intent}s other than {@link #SERVICE_INTERFACE}