Merge tag 'upstream/1.40' into tizen.
[platform/upstream/connman.git] / vpn / plugins / pptp.c
index 5fc861e..4a704bb 100755 (executable)
 enum {
        OPT_STRING = 1,
        OPT_BOOL = 2,
+       OPT_PPTP_ONLY = 3,
 };
 
 struct {
        const char *cm_opt;
        const char *pptp_opt;
-       const char *vpnc_default;
+       const char *pptp_default;
        int type;
 } pptp_options[] = {
        { "PPTP.User", "user", NULL, OPT_STRING },
+       { "PPTP.IdleWait", "--idle-wait", NULL, OPT_PPTP_ONLY},
+       { "PPTP.MaxEchoWait", "--max-echo-wait", NULL, OPT_PPTP_ONLY},
        { "PPPD.EchoFailure", "lcp-echo-failure", "0", OPT_STRING },
        { "PPPD.EchoInterval", "lcp-echo-interval", "0", OPT_STRING },
        { "PPPD.Debug", "debug", NULL, OPT_STRING },
@@ -204,6 +207,7 @@ static int pptp_notify(DBusMessage *msg, struct vpn_provider *provider)
                connman_ipaddress_set_ipv4(ipaddress, addressv4, netmask,
                                        gateway);
 
+       connman_ipaddress_set_p2p(ipaddress, true);
        vpn_provider_set_ipaddress(provider, ipaddress);
        vpn_provider_set_nameservers(provider, nameservers);
 
@@ -436,7 +440,9 @@ static int run_connect(struct vpn_provider *provider,
                        vpn_provider_connect_cb_t cb, void *user_data,
                        const char *username, const char *password)
 {
-       const char *opt_s, *host;
+       GString *pptp_opt_s;
+       const char *opt_s;
+       const char *host;
        char *str;
        int err, i;
 
@@ -450,16 +456,11 @@ static int run_connect(struct vpn_provider *provider,
        DBG("username %s password %p", username, password);
 
        host = vpn_provider_get_string(provider, "Host");
-       str = g_strdup_printf("%s %s --nolaunchpppd --loglevel 2",
-                               PPTP, host);
-       if (!str) {
-               connman_error("can not allocate memory");
-               err = -ENOMEM;
-               goto done;
-       }
 
-       connman_task_add_argument(task, "pty", str);
-       g_free(str);
+       /* Create PPTP options for pppd "pty" */
+       pptp_opt_s = g_string_new(NULL);
+       g_string_append_printf(pptp_opt_s, "%s %s --nolaunchpppd --loglevel 2",
+                               PPTP, host);
 
        connman_task_add_argument(task, "nodetach", NULL);
        connman_task_add_argument(task, "lock", NULL);
@@ -474,7 +475,7 @@ static int run_connect(struct vpn_provider *provider,
                opt_s = vpn_provider_get_string(provider,
                                        pptp_options[i].cm_opt);
                if (!opt_s)
-                       opt_s = pptp_options[i].vpnc_default;
+                       opt_s = pptp_options[i].pptp_default;
 
                if (!opt_s)
                        continue;
@@ -485,8 +486,15 @@ static int run_connect(struct vpn_provider *provider,
                else if (pptp_options[i].type == OPT_BOOL)
                        pptp_write_bool_option(task,
                                        pptp_options[i].pptp_opt, opt_s);
+               else if (pptp_options[i].type == OPT_PPTP_ONLY)
+                       g_string_append_printf(pptp_opt_s, " %s %s",
+                                       pptp_options[i].pptp_opt, opt_s);
        }
 
+       str = g_string_free(pptp_opt_s, FALSE);
+       connman_task_add_argument(task, "pty", str);
+       g_free(str);
+
        connman_task_add_argument(task, "plugin",
                                SCRIPTDIR "/libppp-plugin.so");