diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index c7a2e87687..7472ec4244 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -13,6 +13,7 @@ global: nm_connection_for_each_setting_value; nm_connection_get_connection_type; nm_connection_get_id; + nm_connection_get_interface_name; nm_connection_get_path; nm_connection_get_setting; nm_connection_get_setting_802_1x; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 934c8610c0..936090c83b 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -1105,6 +1105,33 @@ nm_connection_get_path (NMConnection *connection) return NM_CONNECTION_GET_PRIVATE (connection)->path; } +/** + * nm_connection_get_interface_name: + * @connection: The #NMConnection + * + * Returns the interface name as stored in NMSettingConnection:interface_name. + * If the connection contains no NMSettingConnection, it will return %NULL. + * + * For hardware devices and software devices created outside of NetworkManager, + * this name is used to match the device. for software devices created by + * NetworkManager, this is the name of the created interface. + * + * Returns: Name of the kernel interface or %NULL + * + * Since: 1.0 + */ +const char * +nm_connection_get_interface_name (NMConnection *connection) +{ + NMSettingConnection *s_con; + + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + s_con = nm_connection_get_setting_connection (connection); + + return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL; +} + /** * nm_connection_get_virtual_iface_name: * @connection: The #NMConnection diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 4524c8f62d..4f7680f495 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -181,6 +181,9 @@ const char * nm_connection_get_path (NMConnection *connection); const char * nm_connection_get_virtual_iface_name (NMConnection *connection); +NM_AVAILABLE_IN_1_0 +const char * nm_connection_get_interface_name (NMConnection *connection); + gboolean nm_connection_is_type (NMConnection *connection, const char *type); void nm_connection_for_each_setting_value (NMConnection *connection, diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index b35b0fca10..6a6d3ebe47 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -1138,6 +1138,8 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) * set, then the connection can be attached to any interface of the * appropriate type (subject to restrictions imposed by other settings). * + * For software devices this specifies the name of the created device. + * * For connection types where interface names cannot easily be made * persistent (e.g. mobile broadband or USB Ethernet), this property should * not be used. Setting this property restricts the interfaces a connection @@ -1171,7 +1173,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) /** * NMSettingConnection:permissions: - * + * * An array of strings defining what access a given user has to this * connection. If this is %NULL or empty, all users are allowed to access * this connection. Otherwise a user is allowed to access this connection