DA: Skip initializing failed_bssids list when eapol failure case
[platform/upstream/connman.git] / vpn / plugins / openvpn.c
old mode 100644 (file)
new mode 100755 (executable)
index bc0303c..8c8d316
@@ -51,7 +51,6 @@
 #include "../vpn-agent.h"
 
 #include "vpn.h"
-#include "../vpn.h"
 
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
@@ -84,6 +83,9 @@ struct {
        { "OpenVPN.ConfigFile", "--config", 1 },
        { "OpenVPN.DeviceType", NULL, 1 },
        { "OpenVPN.Verb", "--verb", 1 },
+       { "OpenVPN.Ping", "--ping", 1},
+       { "OpenVPN.PingExit", "--ping-exit", 1},
+       { "OpenVPN.RemapUsr1", "--remap-usr1", 1},
 };
 
 struct ov_private_data {
@@ -152,8 +154,15 @@ static struct nameserver_entry *ov_append_dns_entries(const char *key,
                                options[2]) {
 
                entry = g_try_new(struct nameserver_entry, 1);
+#if defined TIZEN_EXT
+               if (!entry) {
+                       g_strfreev(options);
+                       return NULL;
+               }
+#else
                if (!entry)
                        return NULL;
+#endif
 
                entry->nameserver = g_strdup(options[2]);
                entry->id = atoi(key + 15); /* foreign_option_XXX */
@@ -290,6 +299,7 @@ static int ov_notify(DBusMessage *msg, struct vpn_provider *provider)
 
        connman_ipaddress_set_ipv4(ipaddress, address, netmask, gateway);
        connman_ipaddress_set_peer(ipaddress, peer);
+       connman_ipaddress_set_p2p(ipaddress, true);
        vpn_provider_set_ipaddress(provider, ipaddress);
 
        if (nameserver_list) {
@@ -493,20 +503,19 @@ static int run_connect(struct ov_private_data *data,
 
        connman_task_add_argument(task, "--persist-tun", NULL);
 
+#if !defined TIZEN_EXT
        connman_task_add_argument(task, "--route-noexec", NULL);
        connman_task_add_argument(task, "--ifconfig-noexec", NULL);
+#endif
 
        /*
-        * Disable client restarts because we can't handle this at the
-        * moment. The problem is that when OpenVPN decides to switch
+        * Disable client restarts with TCP because we can't handle this at
+        * the moment. The problem is that when OpenVPN decides to switch
         * from CONNECTED state to RECONNECTING and then to RESOLVE,
         * it is not possible to do a DNS lookup. The DNS server is
         * not accessible through the tunnel anymore and so we end up
         * trying to resolve the OpenVPN servers address.
-        */
-       connman_task_add_argument(task, "--ping-restart", "0");
-
-       /*
+        *
         * Disable connetion retrying when OpenVPN is connected over TCP.
         * With TCP OpenVPN attempts to handle reconnection silently without
         * reporting the error back when establishing a connection or
@@ -516,8 +525,24 @@ static int run_connect(struct ov_private_data *data,
         * including DNS.
        */
        option = vpn_provider_get_string(provider, "OpenVPN.Proto");
-       if (option && g_str_has_prefix(option, "tcp"))
+       if (option && g_str_has_prefix(option, "tcp")) {
+               option = vpn_provider_get_string(provider, "OpenVPN.PingExit");
+               if (!option)
+                       connman_task_add_argument(task, "--ping-restart", "0");
+
                connman_task_add_argument(task, "--connect-retry-max", "1");
+       /* Apply defaults for --ping and --ping-exit only with UDP protocol. */
+       } else {
+               /* Apply default of 10 second interval for ping if omitted. */
+               option = vpn_provider_get_string(provider, "OpenVPN.Ping");
+               if (!option)
+                       connman_task_add_argument(task, "--ping", "10");
+
+               /* Apply default of 60 seconds for ping exit if omitted. */
+               option = vpn_provider_get_string(provider, "OpenVPN.PingExit");
+               if (!option)
+                       connman_task_add_argument(task, "--ping-exit", "60");
+       }
 
        err = connman_task_run(task, ov_died, data, NULL, NULL, NULL);
        if (err < 0) {