diff -ur network-manager-openvpn-0.8~rc1/properties/auth-helpers.c network-manager-openvpn-10.04/properties/auth-helpers.c --- network-manager-openvpn-0.8~rc1/properties/auth-helpers.c 2010-01-26 22:17:37.000000000 +0100 +++ network-manager-openvpn-10.04/properties/auth-helpers.c 2010-01-27 15:51:13.781401828 +0100 @@ -762,6 +762,7 @@ NM_OPENVPN_KEY_TA_DIR, NM_OPENVPN_KEY_TA, NM_OPENVPN_KEY_RENEG_SECONDS, + NM_OPENVPN_KEY_FRAGMENT, NULL }; @@ -804,6 +805,16 @@ } static void +fragment_toggled_cb (GtkWidget *check, gpointer user_data) +{ + GladeXML *xml = (GladeXML *) user_data; + GtkWidget *widget; + + widget = glade_xml_get_widget (xml, "fragment_spinbutton"); + gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check))); +} + +static void reneg_toggled_cb (GtkWidget *check, gpointer user_data) { GladeXML *xml = (GladeXML *) user_data; @@ -1071,6 +1082,31 @@ gtk_widget_set_sensitive (widget, FALSE); } + widget = glade_xml_get_widget (xml, "fragment_checkbutton"); + g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (fragment_toggled_cb), xml); + + value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_FRAGMENT); + if (value && strlen (value)) { + long int tmp; + + errno = 0; + tmp = strtol (value, NULL, 10); + if (errno == 0 && tmp > 0 && tmp < 65536) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); + + widget = glade_xml_get_widget (xml, "fragment_spinbutton"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), + (gdouble) tmp); + } + gtk_widget_set_sensitive (widget, TRUE); + } else { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); + + widget = glade_xml_get_widget (xml, "fragment_spinbutton"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 1300.0); + gtk_widget_set_sensitive (widget, FALSE); + } + value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_COMP_LZO); if (value && !strcmp (value, "yes")) { widget = glade_xml_get_widget (xml, "lzo_checkbutton"); @@ -1189,6 +1225,15 @@ g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_PORT), g_strdup_printf ("%d", port)); } + widget = glade_xml_get_widget (xml, "fragment_checkbutton"); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + int fragment; + + widget = glade_xml_get_widget (xml, "fragment_spinbutton"); + fragment = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); + g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_FRAGMENT), g_strdup_printf ("%d", fragment)); + } + widget = glade_xml_get_widget (xml, "lzo_checkbutton"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_COMP_LZO), g_strdup ("yes")); diff -ur network-manager-openvpn-0.8~rc1/properties/import-export.c network-manager-openvpn-10.04/properties/import-export.c --- network-manager-openvpn-0.8~rc1/properties/import-export.c 2010-01-26 22:17:37.000000000 +0100 +++ network-manager-openvpn-10.04/properties/import-export.c 2010-01-27 16:17:36.301434230 +0100 @@ -59,6 +59,7 @@ #define TLS_AUTH_TAG "tls-auth" #define AUTH_TAG "auth " #define RENEG_SEC_TAG "reneg-sec" +#define FRAGMENT_TAG "fragment" static gboolean handle_path_item (const char *line, @@ -238,6 +239,27 @@ continue; } + if (!strncmp (*line, FRAGMENT_TAG, strlen (FRAGMENT_TAG))) { + items = get_args (*line + strlen (FRAGMENT_TAG)); + if (!items) + continue; + + if (g_strv_length (items) >= 1) { + glong fragment_mtu; + + errno = 0; + fragment_mtu = strtol (items[0], NULL, 10); + if ((errno == 0) && (fragment_mtu >= 0) && (fragment_mtu < 65535)) { + char *tmp = g_strdup_printf ("%d", (guint32) fragment_mtu); + nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_FRAGMENT, tmp); + g_free (tmp); + } else + g_warning ("%s: invalid fragment MTU size in option '%s'", __func__, *line); + } + g_strfreev (items); + continue; + } + if (!strncmp (*line, RENEG_SEC_TAG, strlen (RENEG_SEC_TAG))) { items = get_args (*line + strlen (RENEG_SEC_TAG)); if (!items) @@ -430,6 +452,7 @@ const char *static_key = NULL; const char *static_key_direction = NULL; const char *port = NULL; + const char *fragment = NULL; const char *local_ip = NULL; const char *remote_ip = NULL; gboolean success = FALSE; @@ -527,6 +550,10 @@ if (value && strlen (value)) remote_ip = value; + value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FRAGMENT); + if (value && strlen (value)) + fragment = value; + /* Advanced values end */ fprintf (f, "client\n"); @@ -568,6 +595,9 @@ if (local_ip && remote_ip) fprintf (f, "ifconfig %s %s\n", local_ip, remote_ip); + if (fragment) + fprintf (f, "fragment %s\n", fragment); + /* Add hard-coded stuff */ fprintf (f, "nobind\n" diff -ur network-manager-openvpn-0.8~rc1/properties/nm-openvpn-dialog.glade network-manager-openvpn-10.04/properties/nm-openvpn-dialog.glade --- network-manager-openvpn-0.8~rc1/properties/nm-openvpn-dialog.glade 2010-01-26 22:17:37.000000000 +0100 +++ network-manager-openvpn-10.04/properties/nm-openvpn-dialog.glade 2010-01-27 15:51:13.781401828 +0100 @@ -1011,6 +1011,43 @@ 4 + + + True + 6 + + + UDP _fragmentation: + True + True + False + True + True + + + 0 + + + + + True + True + 1300 1 65535 1 10 10 + 1 + True + + + False + False + 1 + + + + + False + 5 + + diff -ur network-manager-openvpn-0.8~rc1/src/nm-openvpn-service.c network-manager-openvpn-10.04/src/nm-openvpn-service.c --- network-manager-openvpn-0.8~rc1/src/nm-openvpn-service.c 2010-01-26 22:17:37.000000000 +0100 +++ network-manager-openvpn-10.04/src/nm-openvpn-service.c 2010-01-27 15:51:13.791417978 +0100 @@ -102,6 +102,7 @@ { NM_OPENVPN_KEY_TA_DIR, G_TYPE_INT, 0, 1, FALSE }, { NM_OPENVPN_KEY_USERNAME, G_TYPE_STRING, 0, 0, FALSE }, { NM_OPENVPN_KEY_RENEG_SECONDS, G_TYPE_INT, 0, G_MAXINT, FALSE }, + { NM_OPENVPN_KEY_FRAGMENT, G_TYPE_INT, 1, 65535, FALSE }, { NULL, G_TYPE_NONE, FALSE } }; @@ -721,6 +722,21 @@ add_openvpn_arg (args, "1194"); } + /* Fragment */ + tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FRAGMENT); + if (tmp && strlen (tmp)) { + add_openvpn_arg (args, "--fragment"); + if (!add_openvpn_arg_int (args, tmp)) { + g_set_error (error, + NM_VPN_PLUGIN_ERROR, + NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, + "Invalid fragment MTU size '%s'.", + tmp); + free_openvpn_args (args); + return FALSE; + } + } + /* Cipher */ tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_CIPHER); if (tmp && strlen (tmp)) { diff -ur network-manager-openvpn-0.8~rc1/src/nm-openvpn-service.h network-manager-openvpn-10.04/src/nm-openvpn-service.h --- network-manager-openvpn-0.8~rc1/src/nm-openvpn-service.h 2010-01-26 22:17:37.000000000 +0100 +++ network-manager-openvpn-10.04/src/nm-openvpn-service.h 2010-01-27 15:51:13.801531896 +0100 @@ -56,6 +56,7 @@ #define NM_OPENVPN_KEY_TA "ta" #define NM_OPENVPN_KEY_TA_DIR "ta-dir" #define NM_OPENVPN_KEY_USERNAME "username" +#define NM_OPENVPN_KEY_FRAGMENT "fragment" #define NM_OPENVPN_KEY_PASSWORD "password" #define NM_OPENVPN_KEY_CERTPASS "cert-pass"