Load libipsec in Android app.
authorTobias Brunner <tobias@strongswan.org>
Wed, 22 Feb 2012 14:36:33 +0000 (15:36 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Aug 2012 13:12:24 +0000 (15:12 +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/CharonVpnService.java

index e5659a4..ad5ddd6 100644 (file)
@@ -57,6 +57,7 @@ include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
                vstr \
                openssl \
                libandroidbridge \
+               strongswan/src/libipsec \
                strongswan/src/libcharon \
                strongswan/src/libhydra \
                strongswan/src/libstrongswan \
index 7f25a54..3b8b98b 100644 (file)
@@ -9,6 +9,7 @@ charonservice.c
 
 LOCAL_C_INCLUDES += \
        $(libvstr_PATH) \
+       $(strongswan_PATH)/src/libipsec \
        $(strongswan_PATH)/src/libhydra \
        $(strongswan_PATH)/src/libcharon \
        $(strongswan_PATH)/src/libstrongswan
@@ -26,7 +27,7 @@ LOCAL_PRELINK_MODULE := false
 
 LOCAL_LDLIBS := -llog
 
-LOCAL_SHARED_LIBRARIES := libstrongswan libhydra libcharon
+LOCAL_SHARED_LIBRARIES := libstrongswan libhydra libipsec libcharon
 
 include $(BUILD_SHARED_LIBRARY)
 
index ecc2434..424d50d 100644 (file)
@@ -18,6 +18,7 @@
 #include <jni.h>
 
 #include <hydra.h>
+#include <ipsec.h>
 #include <daemon.h>
 #include <library.h>
 
@@ -88,10 +89,19 @@ JNI_METHOD(CharonVpnService, initializeCharon, void)
                return;
        }
 
+       if (!libipsec_init())
+       {
+               libipsec_deinit();
+               libhydra_deinit();
+               library_deinit();
+               return;
+       }
+
        if (!libcharon_init("charon") ||
                !charon->initialize(charon, PLUGINS))
        {
                libcharon_deinit();
+               libipsec_deinit();
                libhydra_deinit();
                library_deinit();
                return;
@@ -107,6 +117,7 @@ JNI_METHOD(CharonVpnService, initializeCharon, void)
 JNI_METHOD(CharonVpnService, deinitializeCharon, void)
 {
        libcharon_deinit();
+       libipsec_deinit();
        libhydra_deinit();
        library_deinit();
 }
index 596372f..52d427c 100644 (file)
@@ -45,6 +45,7 @@ public class CharonVpnService extends VpnService {
                System.loadLibrary("strongswan");
                System.loadLibrary("hydra");
                System.loadLibrary("charon");
+               System.loadLibrary("ipsec");
                System.loadLibrary("androidbridge");
        }
 }