android: Pass the type of VPN to the native parts
authorTobias Brunner <tobias@strongswan.org>
Tue, 28 Aug 2012 13:32:14 +0000 (15:32 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 31 Aug 2012 16:24:46 +0000 (18:24 +0200)
src/frontends/android/jni/libandroidbridge/charonservice.c
src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java

index fab99ac..57d118f 100644 (file)
@@ -260,7 +260,8 @@ METHOD(charonservice_t, get_vpnservice_builder, vpnservice_builder_t*,
  * @param username                     username (gets owned)
  * @param password                     password (gets owned)
  */
-static void initiate(char *local, char *gateway, char *username, char *password)
+static void initiate(char *type, char *local, char *gateway,
+                                        char *username, char *password)
 {
        private_charonservice_t *this = (private_charonservice_t*)charonservice;
 
@@ -271,6 +272,7 @@ static void initiate(char *local, char *gateway, char *username, char *password)
 
        DESTROY_IF(this->service);
        this->service = android_service_create(local, gateway, username);
+       free(type);
 }
 
 /**
@@ -477,15 +479,16 @@ JNI_METHOD(CharonVpnService, deinitializeCharon, void)
  * Initiate SA
  */
 JNI_METHOD(CharonVpnService, initiate, void,
-       jstring jlocal_address, jstring jgateway, jstring jusername,
+       jstring jtype, jstring jlocal_address, jstring jgateway, jstring jusername,
        jstring jpassword)
 {
-       char *local_address, *gateway, *username, *password;
+       char *type, *local_address, *gateway, *username, *password;
 
+       type = androidjni_convert_jstring(env, jtype);
        local_address = androidjni_convert_jstring(env, jlocal_address);
        gateway = androidjni_convert_jstring(env, jgateway);
        username = androidjni_convert_jstring(env, jusername);
        password = androidjni_convert_jstring(env, jpassword);
 
-       initiate(local_address, gateway, username, password);
+       initiate(type, local_address, gateway, username, password);
 }
index c9c1ad0..71fc046 100644 (file)
@@ -214,7 +214,8 @@ public class CharonVpnService extends VpnService implements Runnable
                                                Log.i(TAG, "charon started");
 
                                                String local_address = getLocalIPv4Address();
-                                               initiate(local_address != null ? local_address : "0.0.0.0",
+                                               initiate(mCurrentProfile.getVpnType().getIdentifier(),
+                                                                local_address != null ? local_address : "0.0.0.0",
                                                                 mCurrentProfile.getGateway(), mCurrentProfile.getUsername(),
                                                                 mCurrentProfile.getPassword());
                                        }
@@ -436,7 +437,7 @@ public class CharonVpnService extends VpnService implements Runnable
        /**
         * Initiate VPN, provided by libandroidbridge.so
         */
-       public native void initiate(String local_address, String gateway,
+       public native void initiate(String type, String local_address, String gateway,
                                                                String username, String password);
 
        /**