summaryrefslogtreecommitdiff
path: root/libnm-util/nm-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-util/nm-connection.c')
-rw-r--r--libnm-util/nm-connection.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index f7d643193c..52b541120b 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -24,6 +24,7 @@
*/
#include <glib-object.h>
+#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
#include <string.h>
#include "nm-connection.h"
@@ -1242,6 +1243,47 @@ nm_connection_get_id (NMConnection *connection)
return nm_setting_connection_get_id (s_con);
}
+/**
+ * nm_connection_get_virtual_device_description:
+ * @connection: an #NMConnection for a virtual device type
+ *
+ * Returns the name that nm_device_disambiguate_names() would
+ * return for the virtual device that would be created for @connection.
+ * Eg, "VLAN (eth1.1)".
+ *
+ * Returns: (transfer full): the name of @connection's device,
+ * or %NULL if @connection is not a virtual connection type
+ */
+char *
+nm_connection_get_virtual_device_description (NMConnection *connection)
+{
+ const char *iface, *type, *display_type;
+ NMSettingConnection *s_con;
+
+ iface = nm_connection_get_virtual_iface_name (connection);
+ if (!iface)
+ return NULL;
+
+ s_con = nm_connection_get_setting_connection (connection);
+ g_return_val_if_fail (s_con != NULL, NULL);
+ type = nm_setting_connection_get_connection_type (s_con);
+
+ if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME))
+ display_type = _("Bond");
+ else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME))
+ display_type = _("Team");
+ else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME))
+ display_type = _("Bridge");
+ else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME))
+ display_type = _("VLAN");
+ else {
+ g_warning ("Unrecognized virtual device type '%s'", type);
+ display_type = type;
+ }
+
+ return g_strdup_printf ("%s (%s)", display_type, iface);
+}
+
/*************************************************************/
/**