[network-manager-openvpn/th/ping-bgo651657: 5/6] properties: import the keepalive option



commit 6afd16bcacd87a019e12f4df0d63a9e0e8c94e9e
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jun 15 20:11:33 2015 -0500

    properties: import the keepalive option
    
    [thaller redhat com: fix leaking temporary variable]

 properties/import-export.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 2157988..efdcb9c 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -58,6 +58,7 @@
 #define FRAGMENT_TAG "fragment "
 #define IFCONFIG_TAG "ifconfig "
 #define KEY_TAG "key "
+#define KEEPALIVE_TAG "keepalive "
 #define MSSFIX_TAG "mssfix"
 #define PING_TAG "ping "
 #define PING_EXIT_TAG "ping-exit "
@@ -705,6 +706,33 @@ do_import (const char *path, char **lines, GError **error)
                        continue;
                }
 
+               if (!strncmp (*line, KEEPALIVE_TAG, strlen (KEEPALIVE_TAG))) {
+                       int ping_secs;
+                       int ping_restart_secs;
+
+                       items = get_args (*line + strlen (KEEPALIVE_TAG), &nitems);
+                       if (nitems == 2) {
+                               ping_secs = parse_seconds (items[0], *line);
+                               ping_restart_secs = parse_seconds (items[1], *line);
+
+                               if (ping_secs >= 0 && ping_restart_secs >= 0) {
+                                       tmp = g_strdup_printf ("%d", ping_secs);
+                                       tmp2 = g_strdup_printf ("%d", ping_restart_secs);
+
+                                       nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_PING, tmp);
+                                       nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_PING_RESTART, 
tmp2);
+
+                                       g_free (tmp);
+                                       g_free (tmp2);
+                               } else
+                                       g_warning ("%s: invalid arguments in option '%s', must be two 
integers", __func__, *line);
+                       } else
+                               g_warning ("%s: invalid number of arguments in option '%s', must be two 
integers", __func__, *line);
+
+                       g_strfreev (items);
+                       continue;
+               }
+
                if (!strncmp (*line, KEYSIZE_TAG, strlen (KEYSIZE_TAG))) {
                        items = get_args (*line + strlen (KEYSIZE_TAG), &nitems);
                        if (nitems == 1) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]