android: Use a different set of plugins if BYOD features are enabled
authorTobias Brunner <tobias@strongswan.org>
Wed, 19 Jun 2013 10:00:04 +0000 (12:00 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 8 Jul 2013 16:49:29 +0000 (18:49 +0200)
src/frontends/android/jni/Android.mk
src/frontends/android/jni/libandroidbridge/Android.mk
src/frontends/android/jni/libandroidbridge/charonservice.c
src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java

index 0163e30..de3403f 100644 (file)
@@ -10,10 +10,11 @@ strongswan_CHARON_PLUGINS := android-log openssl fips-prf random nonce pubkey \
        eap-identity eap-mschapv2 eap-md5 eap-gtc
 
 ifneq ($(strongswan_USE_BYOD),)
-strongswan_CHARON_PLUGINS += eap-ttls eap-tnc tnc-imc tnc-tnccs tnccs-20
+strongswan_BYOD_PLUGINS := eap-ttls eap-tnc tnc-imc tnc-tnccs tnccs-20
 endif
 
-strongswan_PLUGINS := $(strongswan_CHARON_PLUGINS)
+strongswan_PLUGINS := $(strongswan_CHARON_PLUGINS) \
+       $(strongswan_BYOD_PLUGINS)
 
 include $(LOCAL_PATH)/strongswan/Android.common.mk
 
index 29f95e5..7dd8ad6 100644 (file)
@@ -41,6 +41,10 @@ endif
 LOCAL_CFLAGS := $(strongswan_CFLAGS) \
        -DPLUGINS='"$(strongswan_CHARON_PLUGINS)"'
 
+ifneq ($(strongswan_USE_BYOD),)
+LOCAL_CFLAGS += -DPLUGINS_BYOD='"$(strongswan_BYOD_PLUGINS)"'
+endif
+
 LOCAL_MODULE := libandroidbridge
 
 LOCAL_MODULE_TAGS := optional
@@ -58,5 +62,3 @@ LOCAL_SHARED_LIBRARIES += libimcv libtncif libtnccs libpts
 endif
 
 include $(BUILD_SHARED_LIBRARY)
-
-
index 03599b7..41fc4d6 100644 (file)
@@ -507,7 +507,8 @@ static void set_options(char *logfile)
 /**
  * Initialize the charonservice object
  */
-static void charonservice_init(JNIEnv *env, jobject service, jobject builder)
+static void charonservice_init(JNIEnv *env, jobject service, jobject builder,
+                                                          jboolean byod)
 {
        private_charonservice_t *this;
        static plugin_feature_t features[] = {
@@ -543,6 +544,7 @@ static void charonservice_init(JNIEnv *env, jobject service, jobject builder)
                                                                          countof(features), TRUE);
 
 #ifdef USE_BYOD
+       if (byod)
        {
                plugin_feature_t byod_features[] = {
                        PLUGIN_CALLBACK(imc_android_register, this->vpn_service),
@@ -588,11 +590,11 @@ static void segv_handler(int signal)
  * Initialize charon and the libraries via JNI
  */
 JNI_METHOD(CharonVpnService, initializeCharon, void,
-       jobject builder, jstring jlogfile)
+       jobject builder, jstring jlogfile, jboolean byod)
 {
        struct sigaction action;
        struct utsname utsname;
-       char *logfile;
+       char *logfile, *plugins;
 
        /* logging for library during initialization, as we have no bus yet */
        dbg = dbg_android;
@@ -635,7 +637,7 @@ JNI_METHOD(CharonVpnService, initializeCharon, void,
 
        charon->load_loggers(charon, NULL, FALSE);
 
-       charonservice_init(env, this, builder);
+       charonservice_init(env, this, builder, byod);
 
        if (uname(&utsname) != 0)
        {
@@ -644,7 +646,18 @@ JNI_METHOD(CharonVpnService, initializeCharon, void,
        DBG1(DBG_DMN, "Starting IKE charon daemon (strongSwan "VERSION", %s %s, %s)",
                  utsname.sysname, utsname.release, utsname.machine);
 
-       if (!charon->initialize(charon, PLUGINS))
+#ifdef PLUGINS_BYOD
+       if (byod)
+       {
+               plugins = PLUGINS " " PLUGINS_BYOD;
+       }
+       else
+#endif
+       {
+               plugins = PLUGINS;
+       }
+
+       if (!charon->initialize(charon, plugins))
        {
                libcharon_deinit();
                charonservice_deinit(env);
index bc90386..9274717 100644 (file)
@@ -214,7 +214,7 @@ public class CharonVpnService extends VpnService implements Runnable
                                                mIsDisconnecting = false;
 
                                                BuilderAdapter builder = new BuilderAdapter(mCurrentProfile.getName());
-                                               initializeCharon(builder, mLogFile);
+                                               initializeCharon(builder, mLogFile, true);
                                                Log.i(TAG, "charon started");
 
                                                initiate(mCurrentProfile.getVpnType().getIdentifier(),
@@ -516,8 +516,9 @@ public class CharonVpnService extends VpnService implements Runnable
         *
         * @param builder BuilderAdapter for this connection
         * @param logfile absolute path to the logfile
+        * @param boyd enable BYOD features
         */
-       public native void initializeCharon(BuilderAdapter builder, String logfile);
+       public native void initializeCharon(BuilderAdapter builder, String logfile, boolean byod);
 
        /**
         * Deinitialize charon, provided by libandroidbridge.so