[network-manager-openvpn/th/ping-bgo651657: 2/7] properties: Import the ping/ping-exit/ping-restart options from openvpn
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/th/ping-bgo651657: 2/7] properties: Import the ping/ping-exit/ping-restart options from openvpn
- Date: Mon, 10 Aug 2015 11:18:45 +0000 (UTC)
commit ca686c4113fef5c95b3d85bc4ae8f9fdef3500ce
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 17 18:09:04 2015 -0500
properties: Import the ping/ping-exit/ping-restart options from openvpn
This is part of https://bugzilla.gnome.org/show_bug.cgi?id=651657
properties/import-export.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 9d1225a..5d5c0f8 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -59,6 +59,9 @@
#define IFCONFIG_TAG "ifconfig "
#define KEY_TAG "key "
#define MSSFIX_TAG "mssfix"
+#define PING_TAG "ping "
+#define PING_EXIT_TAG "ping-exit "
+#define PING_RESTART_TAG "ping-restart "
#define PKCS12_TAG "pkcs12 "
#define PORT_TAG "port "
#define PROTO_TAG "proto "
@@ -283,6 +286,38 @@ parse_http_proxy_auth (const char *path,
return *out_user && *out_pass;
}
+static gboolean
+handle_num_seconds_item (const char *line,
+ const char *tag,
+ const char *key,
+ NMSettingVPN *s_vpn)
+{
+ char **items = NULL;
+ int nitems;
+
+ if (!strncmp (line, tag, strlen (tag))) {
+ int seconds;
+
+ items = get_args (line + strlen (tag), &nitems);
+ if (nitems == 1) {
+ seconds = parse_seconds (items[0], line);
+ if (seconds >= 0) {
+ char *tmp;
+
+ tmp = g_strdup_printf ("%d", seconds);
+ nm_setting_vpn_add_data_item (s_vpn, key, tmp);
+ g_free (tmp);
+ }
+ } else
+ g_warning ("%s: invalid number of arguments in option '%s', must be one integer",
__func__, line);
+
+ g_strfreev (items);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
NMConnection *
do_import (const char *path, char **lines, GError **error)
{
@@ -600,6 +635,15 @@ do_import (const char *path, char **lines, GError **error)
continue;
}
+ if (handle_num_seconds_item (*line, PING_TAG, NM_OPENVPN_KEY_PING, s_vpn))
+ continue;
+
+ if (handle_num_seconds_item (*line, PING_EXIT_TAG, NM_OPENVPN_KEY_PING_EXIT, s_vpn))
+ continue;
+
+ if (handle_num_seconds_item (*line, PING_RESTART_TAG, NM_OPENVPN_KEY_PING_RESTART, s_vpn))
+ continue;
+
if ( handle_path_item (*line, PKCS12_TAG, NM_OPENVPN_KEY_CA, s_vpn, default_path, NULL) &&
handle_path_item (*line, PKCS12_TAG, NM_OPENVPN_KEY_CERT, s_vpn, default_path, NULL) &&
handle_path_item (*line, PKCS12_TAG, NM_OPENVPN_KEY_KEY, s_vpn, default_path, NULL))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]