android: Use configured NAT-T keepalive interval
authorTobias Brunner <tobias@strongswan.org>
Wed, 28 Jun 2017 16:34:40 +0000 (18:34 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 3 Jul 2017 08:33:29 +0000 (10:33 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/app/src/main/jni/libandroidbridge/charonservice.c

index 965edfb..d8b4b4e 100644 (file)
@@ -250,6 +250,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                                                        SettingsWriter writer = new SettingsWriter();
                                                        writer.setValue("global.language", Locale.getDefault().getLanguage());
                                                        writer.setValue("global.mtu", mCurrentProfile.getMTU());
+                                                       writer.setValue("global.nat_keepalive", mCurrentProfile.getNATKeepAlive());
                                                        writer.setValue("connection.type", mCurrentProfile.getVpnType().getIdentifier());
                                                        writer.setValue("connection.server", mCurrentProfile.getGateway());
                                                        writer.setValue("connection.port", mCurrentProfile.getPort());
index 1e72cf5..f74936e 100644 (file)
@@ -420,6 +420,11 @@ static void initiate(settings_t *settings)
                                                "charon.fragment_size",
                                                settings->get_int(settings, "global.mtu",
                                                                                  ANDROID_DEFAULT_MTU));
+       /* use configured interval, or an increased default to save battery power */
+       lib->settings->set_int(lib->settings,
+                                               "charon.keep_alive",
+                                               settings->get_int(settings, "global.nat_keepalive",
+                                                                                 ANDROID_KEEPALIVE_INTERVAL));
 
        this->creds->clear(this->creds);
        DESTROY_IF(this->service);
@@ -476,9 +481,6 @@ static void set_options(char *logfile)
                                        "charon.retransmit_timeout", ANDROID_RETRANSMIT_TIMEOUT);
        lib->settings->set_double(lib->settings,
                                        "charon.retransmit_base", ANDROID_RETRANSMIT_BASE);
-       /* increase NAT-T keepalive interval a bit to save battery power */
-       lib->settings->set_time(lib->settings,
-                                       "charon.keep_alive", ANDROID_KEEPALIVE_INTERVAL);
        lib->settings->set_bool(lib->settings,
                                        "charon.initiator_only", TRUE);
        lib->settings->set_bool(lib->settings,