From ac3a4c16e9e173d3108f10b358047a0c369e1fb6 Mon Sep 17 00:00:00 2001 From: Jussi Laakkonen Date: Thu, 22 Oct 2020 14:38:27 +0300 Subject: pptp: Support --idle-wait and --max-echo-wait options Implement support for --idle-wait and --max-echo-wait options. By default these are set to 60 if omitted. Added OPT_PPTP_ONLY to be able to separate these from the PPPD options. All PPTP options need to be added with "pty" as one option in order for them to work. --- vpn/plugins/pptp.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'vpn') diff --git a/vpn/plugins/pptp.c b/vpn/plugins/pptp.c index 5fc861e4..0ede6f8b 100644 --- a/vpn/plugins/pptp.c +++ b/vpn/plugins/pptp.c @@ -54,15 +54,18 @@ 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 }, @@ -436,7 +439,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 +455,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 +474,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 +485,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"); -- cgit v1.2.1