diff --git a/Makefile.am b/Makefile.am
index 80729373c..e23ea47d3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3122,6 +3122,8 @@ clients_tui_nmtui_SOURCES = \
clients/tui/nmt-page-ethernet.h \
clients/tui/nmt-page-infiniband.c \
clients/tui/nmt-page-infiniband.h \
+ clients/tui/nmt-page-ip-tunnel.c \
+ clients/tui/nmt-page-ip-tunnel.h \
clients/tui/nmt-page-ip4.c \
clients/tui/nmt-page-ip4.h \
clients/tui/nmt-page-ip6.c \
diff --git a/clients/tui/nm-editor-utils.c b/clients/tui/nm-editor-utils.c
index 0ec55f3d2..90a0c83b8 100644
--- a/clients/tui/nm-editor-utils.c
+++ b/clients/tui/nm-editor-utils.c
@@ -221,6 +221,14 @@ nm_editor_utils_get_connection_type_list (void)
item->id_format = _("VLAN connection %d");
g_ptr_array_add (array, item);
+ item = g_new0 (NMEditorConnectionTypeDataReal, 1);
+ item->data.name = _("IP tunnel");
+ item->data.setting_type = NM_TYPE_SETTING_IP_TUNNEL;
+ item->data.device_type = NM_TYPE_DEVICE_IP_TUNNEL;
+ item->data.virtual = TRUE;
+ item->id_format = _("IP tunnel connection %d");
+ g_ptr_array_add (array, item);
+
#if 0
/* Add "VPN" only if there are plugins */
vpn_plugins_hash = nm_vpn_get_plugin_infos ();
diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c
index 0aecd3870..edfaa09b3 100644
--- a/clients/tui/nmt-connect-connection-list.c
+++ b/clients/tui/nmt-connect-connection-list.c
@@ -107,6 +107,7 @@ static const char *device_sort_order[] = {
NM_SETTING_BOND_SETTING_NAME,
NM_SETTING_TEAM_SETTING_NAME,
NM_SETTING_BRIDGE_SETTING_NAME,
+ NM_SETTING_IP_TUNNEL_SETTING_NAME,
"NMDeviceModem",
"NMDeviceBt"
};
diff --git a/clients/tui/nmt-editor.c b/clients/tui/nmt-editor.c
index 12f35b560..395e661ae 100644
--- a/clients/tui/nmt-editor.c
+++ b/clients/tui/nmt-editor.c
@@ -44,6 +44,7 @@
#include "nmt-page-dsl.h"
#include "nmt-page-ethernet.h"
#include "nmt-page-infiniband.h"
+#include "nmt-page-ip-tunnel.h"
#include "nmt-page-ip4.h"
#include "nmt-page-ip6.h"
#include "nmt-page-ppp.h"
@@ -359,6 +360,8 @@ nmt_editor_constructed (GObject *object)
page = nmt_page_ethernet_new (priv->edit_connection, deventry);
else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_WIRELESS_SETTING_NAME))
page = nmt_page_wifi_new (priv->edit_connection, deventry);
+ else if (nm_connection_is_type (priv->edit_connection, NM_SETTING_IP_TUNNEL_SETTING_NAME))
+ page = nmt_page_ip_tunnel_new (priv->edit_connection, deventry);
else
g_assert_not_reached ();
diff --git a/clients/tui/nmt-page-ip-tunnel.c b/clients/tui/nmt-page-ip-tunnel.c
new file mode 100644
index 000000000..0b0b30eac
--- /dev/null
+++ b/clients/tui/nmt-page-ip-tunnel.c
@@ -0,0 +1,206 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2016 Red Hat, Inc.
+ */
+/**
+ * SECTION:nmt-page-ip_tunnel
+ * @short_description: The editor page for IP tunnel connections
+ */
+
+#include "nm-default.h"
+
+#include "nmt-page-ip-tunnel.h"
+
+#include "nmt-device-entry.h"
+#include "nmt-mtu-entry.h"
+
+G_DEFINE_TYPE (NmtPageIPTunnel, nmt_page_ip_tunnel, NMT_TYPE_EDITOR_PAGE_DEVICE)
+
+#define NMT_PAGE_IP_TUNNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_IP_TUNNEL, NmtPageIPTunnelPrivate))
+
+typedef struct {
+ NmtNewtEntry *input_key;
+ NmtNewtEntry *output_key;
+} NmtPageIPTunnelPrivate;
+
+NmtEditorPage *
+nmt_page_ip_tunnel_new (NMConnection *conn,
+ NmtDeviceEntry *deventry)
+{
+ return g_object_new (NMT_TYPE_PAGE_IP_TUNNEL,
+ "connection", conn,
+ "device-entry", deventry,
+ NULL);
+}
+
+static void
+nmt_page_ip_tunnel_init (NmtPageIPTunnel *ip_tunnel)
+{
+}
+
+static void
+mode_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (object);
+ NmtPageIPTunnel *ip_tunnel = NMT_PAGE_IP_TUNNEL (user_data);
+ NmtPageIPTunnelPrivate *priv = NMT_PAGE_IP_TUNNEL_GET_PRIVATE (ip_tunnel);
+ NMIPTunnelMode mode;
+ gboolean enable_keys;
+
+ mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
+ enable_keys = NM_IN_SET (mode, NM_IP_TUNNEL_MODE_GRE, NM_IP_TUNNEL_MODE_IP6GRE);
+ nmt_newt_widget_set_visible (NMT_NEWT_WIDGET (priv->input_key), enable_keys);
+ nmt_newt_widget_set_visible (NMT_NEWT_WIDGET (priv->output_key), enable_keys);
+
+ if (!enable_keys) {
+ nmt_newt_entry_set_text (priv->input_key, "");
+ nmt_newt_entry_set_text (priv->output_key, "");
+ }
+}
+
+static NmtNewtPopupEntry tunnel_mode[] = {
+ /* The order must match the NM_IP_TUNNEL_MODE_* enum */
+ { N_("IPIP"), "IPIP" },
+ { N_("GRE"), "GRE" },
+ { N_("SIT"), "SIT" },
+ { N_("ISATAP"), "ISATAP" },
+ { N_("VTI"), "VTI" },
+ { N_("IP6IP6"), "IP6IP6" },
+ { N_("IPIP6"), "IPIP6" },
+ { N_("IP6GRE"), "IP6GRE" },
+ { N_("VTI6"), "VTI6" },
+ { NULL, NULL }
+};
+
+static gboolean
+add_offset (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ guint v;
+ gint offset = GPOINTER_TO_INT (user_data);
+
+ g_return_val_if_fail (G_VALUE_HOLDS (from_value, G_TYPE_UINT), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS (to_value, G_TYPE_UINT), FALSE);
+
+ v = g_value_get_uint (from_value);
+ v += offset;
+
+ g_value_set_uint (to_value, v);
+
+ return TRUE;
+}
+
+static void
+nmt_page_ip_tunnel_constructed (GObject *object)
+{
+ NmtPageIPTunnel *ip_tunnel = NMT_PAGE_IP_TUNNEL (object);
+ NmtPageIPTunnelPrivate *priv = NMT_PAGE_IP_TUNNEL_GET_PRIVATE (ip_tunnel);
+ NmtEditorSection *section;
+ NmtEditorGrid *grid;
+ NMSettingIPTunnel *s_ip_tunnel;
+ NmtNewtWidget *widget, *parent;
+ NMConnection *conn;
+ GClosure *s2w, *w2s;
+
+ conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ip_tunnel));
+ s_ip_tunnel = nm_connection_get_setting_ip_tunnel (conn);
+ if (!s_ip_tunnel) {
+ nm_connection_add_setting (conn, nm_setting_ip_tunnel_new ());
+ s_ip_tunnel = nm_connection_get_setting_ip_tunnel (conn);
+ }
+
+ /* Initialize the mode for new connections */
+ if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) == NM_IP_TUNNEL_MODE_UNKNOWN) {
+ g_object_set (s_ip_tunnel,
+ NM_SETTING_IP_TUNNEL_MODE, (guint) NM_IP_TUNNEL_MODE_IPIP,
+ NULL);
+ }
+
+ section = nmt_editor_section_new (_("IP tunnel"), NULL, TRUE);
+ grid = nmt_editor_section_get_body (section);
+
+ /* To convert between widget index (0-based) and setting index (1-based) */
+ s2w = g_cclosure_new (G_CALLBACK (add_offset), GINT_TO_POINTER (-1), NULL);
+ w2s = g_cclosure_new (G_CALLBACK (add_offset), GINT_TO_POINTER (1), NULL);
+
+ widget = nmt_newt_popup_new (tunnel_mode);
+ g_object_bind_property_with_closures (s_ip_tunnel, NM_SETTING_IP_TUNNEL_MODE,
+ widget, "active",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE,
+ s2w, w2s);
+ nmt_editor_grid_append (grid, _("Mode"), widget, NULL);
+
+ widget = parent = nmt_device_entry_new (_("Parent"), 40, G_TYPE_NONE);
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_PARENT,
+ widget, "interface-name",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ nmt_editor_grid_append (grid, NULL, widget, NULL);
+
+ widget = nmt_newt_entry_new (40, 0);
+ nmt_editor_grid_append (grid, _("Local IP"), widget, NULL);
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_LOCAL,
+ widget, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ widget = nmt_newt_entry_new (40, 0);
+ nmt_editor_grid_append (grid, _("Remote IP"), widget, NULL);
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_REMOTE,
+ widget, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+ widget = nmt_newt_entry_new (40, 0);
+ nmt_editor_grid_append (grid, _("Input key"), widget, NULL);
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_INPUT_KEY,
+ widget, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ priv->input_key = NMT_NEWT_ENTRY (widget);
+
+ widget = nmt_newt_entry_new (40, 0);
+ nmt_editor_grid_append (grid, _("Output key"), widget, NULL);
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_OUTPUT_KEY,
+ widget, "text",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ priv->output_key = NMT_NEWT_ENTRY (widget);
+
+ widget = nmt_mtu_entry_new ();
+ g_object_bind_property (s_ip_tunnel, NM_SETTING_IP_TUNNEL_MTU,
+ widget, "mtu",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ nmt_editor_grid_append (grid, _("MTU"), widget, NULL);
+
+ g_signal_connect (s_ip_tunnel, "notify::" NM_SETTING_IP_TUNNEL_MODE,
+ G_CALLBACK (mode_changed), ip_tunnel);
+ mode_changed (G_OBJECT (s_ip_tunnel), NULL, ip_tunnel);
+
+ nmt_editor_page_add_section (NMT_EDITOR_PAGE (ip_tunnel), section);
+
+ G_OBJECT_CLASS (nmt_page_ip_tunnel_parent_class)->constructed (object);
+}
+
+static void
+nmt_page_ip_tunnel_class_init (NmtPageIPTunnelClass *ip_tunnel_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (ip_tunnel_class);
+
+ g_type_class_add_private (ip_tunnel_class, sizeof (NmtPageIPTunnelPrivate));
+
+ /* virtual methods */
+ object_class->constructed = nmt_page_ip_tunnel_constructed;
+}
diff --git a/clients/tui/nmt-page-ip-tunnel.h b/clients/tui/nmt-page-ip-tunnel.h
new file mode 100644
index 000000000..5cbb87a7a
--- /dev/null
+++ b/clients/tui/nmt-page-ip-tunnel.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Copyright 2016 Red Hat, Inc.
+ */
+
+#ifndef NMT_PAGE_IP_TUNNEL_H
+#define NMT_PAGE_IP_TUNNEL_H
+
+#include "nmt-editor-page-device.h"
+
+#define NMT_TYPE_PAGE_IP_TUNNEL (nmt_page_ip_tunnel_get_type ())
+#define NMT_PAGE_IP_TUNNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMT_TYPE_PAGE_IP_TUNNEL, NmtPageIPTunnel))
+#define NMT_PAGE_IP_TUNNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMT_TYPE_PAGE_IP_TUNNEL, NmtPageIPTunnelClass))
+#define NMT_IS_PAGE_IP_TUNNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMT_TYPE_PAGE_IP_TUNNEL))
+#define NMT_IS_PAGE_IP_TUNNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMT_TYPE_PAGE_IP_TUNNEL))
+#define NMT_PAGE_IP_TUNNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMT_TYPE_PAGE_IP_TUNNEL, NmtPageIPTunnelClass))
+
+typedef struct {
+ NmtEditorPageDevice parent;
+} NmtPageIPTunnel;
+
+typedef struct {
+ NmtEditorPageDeviceClass parent;
+} NmtPageIPTunnelClass;
+
+GType nmt_page_ip_tunnel_get_type (void);
+
+NmtEditorPage *nmt_page_ip_tunnel_new (NMConnection *conn,
+ NmtDeviceEntry *deventry);
+
+#endif /* NMT_PAGE_IP_TUNNEL_H */
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index ff56cfbf3..b7bca4f90 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -1871,7 +1871,8 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
else if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
display_type = _("InfiniBand");
iface = nm_setting_infiniband_get_virtual_interface_name (nm_connection_get_setting_infiniband (connection));
- }
+ } else if (!strcmp (type, NM_SETTING_IP_TUNNEL_SETTING_NAME))
+ display_type = _("IP Tunnel");
if (!iface || !display_type)
return NULL;
diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c
index 4b78bde05..50630a457 100644
--- a/libnm-core/nm-setting-ip-tunnel.c
+++ b/libnm-core/nm-setting-ip-tunnel.c
@@ -291,7 +291,7 @@ static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE (setting);
- int family;
+ int family = AF_UNSPEC;
switch (priv->mode) {
case NM_IP_TUNNEL_MODE_IPIP:
@@ -307,8 +307,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
case NM_IP_TUNNEL_MODE_VTI6:
family = AF_INET6;
break;
- default:
- family = AF_UNSPEC;
+ case NM_IP_TUNNEL_MODE_UNKNOWN:
+ break;
}
if (family == AF_UNSPEC) {
@@ -345,7 +345,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
- if (priv->remote && !nm_utils_ipaddr_valid (family, priv->remote)) {
+ if (!priv->remote) {
+ g_set_error_literal (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("property is missing"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_IP_TUNNEL_SETTING_NAME, NM_SETTING_IP_TUNNEL_REMOTE);
+ return FALSE;
+ }
+
+ if (!nm_utils_ipaddr_valid (family, priv->remote)) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h
index cca05cffd..6af091fae 100644
--- a/libnm/NetworkManager.h
+++ b/libnm/NetworkManager.h
@@ -36,10 +36,14 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
+#include
#include
+#include
#include
#include
#include
@@ -52,34 +56,34 @@
#include
#include
#include
-#include
#include
+#include
#include
#include
#include
#include
#include
#include
-#include
-#include
-#include
#include
#include
+#include
+#include
#include
#include
#include
#include
+#include
#include
-#include
#include
+#include
#include
#include
#include
#include
#include
#include
-#include
#include
+#include
#include
#include
#include
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 07053ae3a..fcd6502a3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -30,6 +30,7 @@ clients/tui/nmt-page-ethernet.c
clients/tui/nmt-page-infiniband.c
clients/tui/nmt-page-ip4.c
clients/tui/nmt-page-ip6.c
+clients/tui/nmt-page-ip-tunnel.c
clients/tui/nmt-page-ppp.c
clients/tui/nmt-page-team-port.c
clients/tui/nmt-page-team.c
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index 0aef9d2ef..ee3725434 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -557,12 +557,13 @@ platform_link_to_tunnel_mode (const NMPlatformLink *link)
return NM_IP_TUNNEL_MODE_GRE;
case NM_LINK_TYPE_IP6TNL:
lnk = nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, link->ifindex, NULL);
- if (lnk->proto == IPPROTO_IPIP)
- return NM_IP_TUNNEL_MODE_IPIP6;
- else if (lnk->proto == IPPROTO_IPV6)
- return NM_IP_TUNNEL_MODE_IP6IP6;
- else
- return NM_IP_TUNNEL_MODE_UNKNOWN;
+ if (lnk) {
+ if (lnk->proto == IPPROTO_IPIP)
+ return NM_IP_TUNNEL_MODE_IPIP6;
+ if (lnk->proto == IPPROTO_IPV6)
+ return NM_IP_TUNNEL_MODE_IP6IP6;
+ }
+ return NM_IP_TUNNEL_MODE_UNKNOWN;
case NM_LINK_TYPE_IPIP:
return NM_IP_TUNNEL_MODE_IPIP;
case NM_LINK_TYPE_SIT:
@@ -585,9 +586,15 @@ tunnel_mode_to_link_type (NMIPTunnelMode tunnel_mode)
return NM_LINK_TYPE_IPIP;
case NM_IP_TUNNEL_MODE_SIT:
return NM_LINK_TYPE_SIT;
- default:
- g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN);
+ case NM_IP_TUNNEL_MODE_VTI:
+ case NM_IP_TUNNEL_MODE_IP6GRE:
+ case NM_IP_TUNNEL_MODE_VTI6:
+ case NM_IP_TUNNEL_MODE_ISATAP:
+ return NM_LINK_TYPE_UNKNOWN;
+ case NM_IP_TUNNEL_MODE_UNKNOWN:
+ break;
}
+ g_return_val_if_reached (NM_LINK_TYPE_UNKNOWN);
}
/*****************************************************************************/
@@ -1004,7 +1011,7 @@ create_device (NMDeviceFactory *factory,
mode = platform_link_to_tunnel_mode (plink);
}
- if (mode == NM_IP_TUNNEL_MODE_UNKNOWN)
+ if (mode == NM_IP_TUNNEL_MODE_UNKNOWN || link_type == NM_LINK_TYPE_UNKNOWN)
return NULL;
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_IP_TUNNEL,