diff options
author | takuo <kitame@gmail.com> | 2010-05-18 17:42:10 +0900 |
---|---|---|
committer | ctso <ctsoyars@gmail.com> | 2010-07-02 17:25:47 +0000 |
commit | 284e3c054a5693ec92933dd273d7a6adf14e5fea (patch) | |
tree | 26d1ab308633b534b50456d42dd929309e4a0582 /vpn | |
parent | 75b2a25dee28ff6fcd1ff63dac24df36627db0f8 (diff) | |
download | frameworks_base-284e3c054a5693ec92933dd273d7a6adf14e5fea.zip frameworks_base-284e3c054a5693ec92933dd273d7a6adf14e5fea.tar.gz frameworks_base-284e3c054a5693ec92933dd273d7a6adf14e5fea.tar.bz2 |
OpenVPN device(tun/tap) can be selectable.
Diffstat (limited to 'vpn')
-rw-r--r-- | vpn/java/android/net/vpn/OpenvpnProfile.java | 135 |
1 files changed, 91 insertions, 44 deletions
diff --git a/vpn/java/android/net/vpn/OpenvpnProfile.java b/vpn/java/android/net/vpn/OpenvpnProfile.java index 97afa0e..34696fe 100644 --- a/vpn/java/android/net/vpn/OpenvpnProfile.java +++ b/vpn/java/android/net/vpn/OpenvpnProfile.java @@ -19,37 +19,55 @@ package android.net.vpn; import android.os.Parcel; /** - * The profile for Openvpn type of VPN. + * The profile for Openvpn type of VPN. * {@hide} */ public class OpenvpnProfile extends VpnProfile { private static final long serialVersionUID = 1L; + private static final String PROTO_UDP = "udp"; + private static final String PROTO_TCP = "tcp"; + private static final String DEVICE_TUN = "tun"; + + private static final String DEVICE_TAP = "tap"; + // Standard Settings private boolean mUserAuth = false; + private String mCA; + private String mCert; + // Advanced Settings private int mPort = 1194; + private String mProto = PROTO_UDP; + private boolean mUseCompLzo = false; + private boolean mSupplyAddr = false; + + private boolean mRedirectGateway = false; + private String mLocalAddr; + private String mRemoteAddr; + private String mDevice = DEVICE_TUN; + @Override public VpnType getType() { return VpnType.OPENVPN; } public void setPort(String port) { - try { - mPort = Integer.parseInt(port); - } catch (NumberFormatException e) { - // no update - } + try { + mPort = Integer.parseInt(port); + } catch (NumberFormatException e) { + // no update + } } public String getPort() { @@ -57,105 +75,134 @@ public class OpenvpnProfile extends VpnProfile { } public String getProto() { - return mProto; + return mProto; } public CharSequence[] getProtoList() { - String[] s = new String[2]; - s[0] = PROTO_UDP; - s[1] = PROTO_TCP; - return s; + String[] s = new String[2]; + s[0] = PROTO_UDP; + s[1] = PROTO_TCP; + return s; } public void setProto(String p) { - if (p.contains(PROTO_TCP)) - mProto = PROTO_TCP; - else if(p.contains(PROTO_UDP)) - mProto = PROTO_UDP; + if (p.contains(PROTO_TCP)) + mProto = PROTO_TCP; + else if (p.contains(PROTO_UDP)) + mProto = PROTO_UDP; + } + + public String getDevice() { + return mDevice; + } + + public CharSequence[] getDeviceList() { + String[] s = new String[2]; + s[0] = DEVICE_TUN; + s[1] = DEVICE_TAP; + return s; + } + + public void setDevice(String p) { + if (p.contains(DEVICE_TAP)) + mDevice = DEVICE_TAP; + else if (p.contains(DEVICE_TUN)) + mDevice = DEVICE_TUN; } - public boolean getUserAuth() { - return mUserAuth; + return mUserAuth; } public void setUserAuth(boolean auth) { - mUserAuth = auth; + mUserAuth = auth; } public String getCAName() { - return mCA; + return mCA; } public void setCAName(String name) { - mCA = name; + mCA = name; } public String getCertName() { - return mCert; + return mCert; } public void setCertName(String name) { - mCert = name; + mCert = name; } public void setUseCompLzo(boolean b) { - mUseCompLzo = b; + mUseCompLzo = b; } public boolean getUseCompLzo() { - return mUseCompLzo; + return mUseCompLzo; } + public void setRedirectGateway(boolean b) { + mRedirectGateway = b; + } + + public boolean getRedirectGateway() { + return mRedirectGateway; + } + public void setSupplyAddr(boolean b) { - mSupplyAddr = b; + mSupplyAddr = b; } public boolean getSupplyAddr() { - return mSupplyAddr; + return mSupplyAddr; } public void setLocalAddr(String addr) { - mLocalAddr = addr; + mLocalAddr = addr; } public String getLocalAddr() { - return mLocalAddr; + return mLocalAddr; } public void setRemoteAddr(String addr) { - mRemoteAddr = addr; + mRemoteAddr = addr; } public String getRemoteAddr() { - return mRemoteAddr; + return mRemoteAddr; } @Override protected void readFromParcel(Parcel in) { super.readFromParcel(in); mPort = in.readInt(); - mProto = in.readString(); - mUserAuth = in.readInt() == 1; - mCA = in.readString(); - mCert = in.readString(); - mUseCompLzo = in.readInt() == 1; - mSupplyAddr = in.readInt() == 1; - mLocalAddr = in.readString(); - mRemoteAddr = in.readString(); + mProto = in.readString(); + mUserAuth = in.readInt() == 1; + mCA = in.readString(); + mCert = in.readString(); + mUseCompLzo = in.readInt() == 1; + mRedirectGateway = in.readInt() == 1; + mSupplyAddr = in.readInt() == 1; + mLocalAddr = in.readString(); + mRemoteAddr = in.readString(); + mDevice = in.readString(); } @Override public void writeToParcel(Parcel parcel, int flags) { super.writeToParcel(parcel, flags); parcel.writeInt(mPort); - parcel.writeString(mProto); - parcel.writeInt(mUserAuth ? 1 : 0); + parcel.writeString(mProto); + parcel.writeInt(mUserAuth ? 1 : 0); parcel.writeString(mCA); parcel.writeString(mCert); - parcel.writeInt(mUseCompLzo ? 1 : 0); - parcel.writeInt(mSupplyAddr ? 1 : 0); - parcel.writeString(mLocalAddr); - parcel.writeString(mRemoteAddr); + parcel.writeInt(mUseCompLzo ? 1 : 0); + parcel.writeInt(mRedirectGateway ? 1 : 0); + parcel.writeInt(mSupplyAddr ? 1 : 0); + parcel.writeString(mLocalAddr); + parcel.writeString(mRemoteAddr); + parcel.writeString(mDevice); } } |