1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA.
19 * Copyright 2007 - 2013 Red Hat, Inc.
20 * Copyright 2007 - 2008 Novell, Inc.
23 #include "nm-default.h"
27 #include "nm-connection.h"
28 #include "nm-connection-private.h"
30 #include "nm-setting-private.h"
31 #include "nm-core-internal.h"
34 * SECTION:nm-connection
35 * @short_description: Describes a connection to specific network or provider
37 * An #NMConnection describes all the settings and configuration values that
38 * are necessary to configure network devices for operation on a specific
39 * network. Connections are the fundamental operating object for
40 * NetworkManager; no device is connected without a #NMConnection, or
41 * disconnected without having been connected with a #NMConnection.
43 * Each #NMConnection contains a list of #NMSetting objects usually referenced
44 * by name (using nm_connection_get_setting_by_name()) or by type (with
45 * nm_connection_get_setting()). The settings describe the actual parameters
46 * with which the network devices are configured, including device-specific
47 * parameters (MTU, SSID, APN, channel, rate, etc) and IP-level parameters
48 * (addresses, routes, addressing methods, etc).
57 /* D-Bus path of the connection, if any */
59 } NMConnectionPrivate;
61 static NMConnectionPrivate *nm_connection_get_private (NMConnection *connection);
62 #define NM_CONNECTION_GET_PRIVATE(o) (nm_connection_get_private ((NMConnection *)o))
64 G_DEFINE_INTERFACE (NMConnection, nm_connection, G_TYPE_OBJECT)
73 static guint signals[LAST_SIGNAL] = { 0 };
76 static NMSettingVerifyResult _nm_connection_verify (NMConnection *connection, GError **error);
79 /*************************************************************/
82 setting_changed_cb (NMSetting *setting,
86 g_signal_emit (self, signals[CHANGED], 0);
90 _setting_release (gpointer key, gpointer value, gpointer user_data)
92 g_signal_handlers_disconnect_by_func (user_data, setting_changed_cb, value);
97 _nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
99 NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
100 const char *name = G_OBJECT_TYPE_NAME (setting);
103 if ((s_old = g_hash_table_lookup (priv->settings, (gpointer) name)))
104 g_signal_handlers_disconnect_by_func (s_old, setting_changed_cb, connection);
105 g_hash_table_insert (priv->settings, (gpointer) name, setting);
106 /* Listen for property changes so we can emit the 'changed' signal */
107 g_signal_connect (setting, "notify", (GCallback) setting_changed_cb, connection);
111 * nm_connection_add_setting:
112 * @connection: a #NMConnection
113 * @setting: (transfer full): the #NMSetting to add to the connection object
115 * Adds a #NMSetting to the connection, replacing any previous #NMSetting of the
116 * same name which has previously been added to the #NMConnection. The
117 * connection takes ownership of the #NMSetting object and does not increase
118 * the setting object's reference count.
121 nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
123 g_return_if_fail (NM_IS_CONNECTION (connection));
124 g_return_if_fail (NM_IS_SETTING (setting));
126 _nm_connection_add_setting (connection, setting);
127 g_signal_emit (connection, signals[CHANGED], 0);
131 * nm_connection_remove_setting:
132 * @connection: a #NMConnection
133 * @setting_type: the #GType of the setting object to remove
135 * Removes the #NMSetting with the given #GType from the #NMConnection. This
136 * operation dereferences the #NMSetting object.
139 nm_connection_remove_setting (NMConnection *connection, GType setting_type)
141 NMConnectionPrivate *priv;
143 const char *setting_name;
145 g_return_if_fail (NM_IS_CONNECTION (connection));
146 g_return_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING));
148 priv = NM_CONNECTION_GET_PRIVATE (connection);
149 setting_name = g_type_name (setting_type);
150 setting = g_hash_table_lookup (priv->settings, setting_name);
152 g_signal_handlers_disconnect_by_func (setting, setting_changed_cb, connection);
153 g_hash_table_remove (priv->settings, setting_name);
154 g_signal_emit (connection, signals[CHANGED], 0);
159 * nm_connection_get_setting:
160 * @connection: a #NMConnection
161 * @setting_type: the #GType of the setting object to return
163 * Gets the #NMSetting with the given #GType, if one has been previously added
164 * to the #NMConnection.
166 * Returns: (transfer none): the #NMSetting, or %NULL if no setting of that type was previously
167 * added to the #NMConnection
170 nm_connection_get_setting (NMConnection *connection, GType setting_type)
172 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
173 g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), NULL);
175 return (NMSetting *) g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
176 g_type_name (setting_type));
180 * nm_connection_get_setting_by_name:
181 * @connection: a #NMConnection
182 * @name: a setting name
184 * Gets the #NMSetting with the given name, if one has been previously added
187 * Returns: (transfer none): the #NMSetting, or %NULL if no setting with that name was previously
188 * added to the #NMConnection
191 nm_connection_get_setting_by_name (NMConnection *connection, const char *name)
195 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
196 g_return_val_if_fail (name != NULL, NULL);
198 type = nm_setting_lookup_type (name);
200 return type ? nm_connection_get_setting (connection, type) : NULL;
204 validate_permissions_type (GVariant *variant, GError **error)
207 GVariant *permissions;
208 gboolean valid = TRUE;
210 /* Ensure the connection::permissions item (if present) is the correct
211 * type, otherwise the g_object_set() will throw a warning and ignore the
212 * error, leaving us with no permissions.
214 s_con = g_variant_lookup_value (variant, NM_SETTING_CONNECTION_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
218 permissions = g_variant_lookup_value (s_con, NM_SETTING_CONNECTION_PERMISSIONS, NULL);
220 if (!g_variant_is_of_type (permissions, G_VARIANT_TYPE_STRING_ARRAY)) {
221 g_set_error_literal (error,
223 NM_CONNECTION_ERROR_INVALID_PROPERTY,
224 _("wrong type; should be a list of strings."));
225 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_PERMISSIONS);
228 g_variant_unref (permissions);
231 g_variant_unref (s_con);
236 * _nm_connection_replace_settings:
237 * @connection: a #NMConnection
238 * @new_settings: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION, with the new settings
239 * @parse_flags: flags.
240 * @error: location to store error, or %NULL
242 * Replaces @connection's settings with @new_settings (which must be
243 * syntactically valid, and describe a known type of connection, but does not
244 * need to result in a connection that passes nm_connection_verify()).
246 * Returns: %TRUE if connection was updated, %FALSE if @new_settings could not
247 * be deserialized (in which case @connection will be unchanged).
248 * Only exception is the NM_SETTING_PARSE_FLAGS_NORMALIZE flag: if normalization
249 * fails, the input @connection is already modified and the original settings
253 _nm_connection_replace_settings (NMConnection *connection,
254 GVariant *new_settings,
255 NMSettingParseFlags parse_flags,
258 NMConnectionPrivate *priv;
260 const char *setting_name;
261 GVariant *setting_dict;
262 GSList *settings = NULL, *s;
263 gboolean changed, success;
265 g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
266 g_return_val_if_fail (g_variant_is_of_type (new_settings, NM_VARIANT_TYPE_CONNECTION), FALSE);
267 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
269 nm_assert (!NM_FLAGS_ANY (parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL));
270 nm_assert (!NM_FLAGS_ALL (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT | NM_SETTING_PARSE_FLAGS_BEST_EFFORT));
272 priv = NM_CONNECTION_GET_PRIVATE (connection);
274 if ( !NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)
275 && !validate_permissions_type (new_settings, error))
278 g_variant_iter_init (&iter, new_settings);
279 while (g_variant_iter_next (&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) {
280 gs_unref_variant GVariant *setting_dict_free = NULL;
281 GError *local = NULL;
285 setting_dict_free = setting_dict;
287 type = nm_setting_lookup_type (setting_name);
288 if (type == G_TYPE_INVALID) {
289 if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
291 g_set_error_literal (error,
293 NM_CONNECTION_ERROR_INVALID_SETTING,
294 _("unknown setting name"));
295 g_prefix_error (error, "%s: ", setting_name);
296 g_slist_free_full (settings, g_object_unref);
300 for (s = settings; s; s = s->next) {
301 if (G_OBJECT_TYPE (s->data) == type) {
302 if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) {
303 g_set_error_literal (error,
305 NM_CONNECTION_ERROR_INVALID_SETTING,
306 _("duplicate setting name"));
307 g_prefix_error (error, "%s: ", setting_name);
308 g_slist_free_full (settings, g_object_unref);
312 g_object_unref (s->data);
313 settings = g_slist_delete_link (settings, s);
318 setting = _nm_setting_new_from_dbus (type, setting_dict, new_settings, parse_flags, &local);
321 if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT))
323 g_propagate_error (error, local);
324 g_slist_free_full (settings, g_object_unref);
328 settings = g_slist_prepend (settings, setting);
331 if (g_hash_table_size (priv->settings) > 0) {
332 g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
335 changed = (settings != NULL);
337 /* Note: @settings might be empty in which case the connection
338 * has no NMSetting instances... which is fine, just something
340 for (s = settings; s; s = s->next)
341 _nm_connection_add_setting (connection, s->data);
343 g_slist_free (settings);
345 /* If verification/normalization fails, the original connection
346 * is already lost. From an API point of view, it would be nicer
347 * not to touch the input argument if we fail at the end.
348 * However, that would require creating a temporary connection
349 * to validate it first. As none of the caller cares about the
350 * state of the @connection when normalization fails, just do it
352 if (NM_FLAGS_HAS (parse_flags, NM_SETTING_PARSE_FLAGS_NORMALIZE))
353 success = nm_connection_normalize (connection, NULL, NULL, error);
358 g_signal_emit (connection, signals[CHANGED], 0);
363 * nm_connection_replace_settings:
364 * @connection: a #NMConnection
365 * @new_settings: a #GVariant of type %NM_VARIANT_TYPE_CONNECTION, with the new settings
366 * @error: location to store error, or %NULL
368 * Replaces @connection's settings with @new_settings (which must be
369 * syntactically valid, and describe a known type of connection, but does not
370 * need to result in a connection that passes nm_connection_verify()).
372 * Returns: %TRUE if connection was updated, %FALSE if @new_settings could not
373 * be deserialized (in which case @connection will be unchanged).
376 nm_connection_replace_settings (NMConnection *connection,
377 GVariant *new_settings,
380 return _nm_connection_replace_settings (connection, new_settings, NM_SETTING_PARSE_FLAGS_NONE, error);
384 * nm_connection_replace_settings_from_connection:
385 * @connection: a #NMConnection
386 * @new_connection: a #NMConnection to replace the settings of @connection with
388 * Deep-copies the settings of @new_connection and replaces the settings of @connection
389 * with the copied settings.
392 nm_connection_replace_settings_from_connection (NMConnection *connection,
393 NMConnection *new_connection)
395 NMConnectionPrivate *priv, *new_priv;
400 g_return_if_fail (NM_IS_CONNECTION (connection));
401 g_return_if_fail (NM_IS_CONNECTION (new_connection));
403 /* When 'connection' and 'new_connection' are the same object simply return
404 * in order not to destroy 'connection'.
406 if (connection == new_connection)
409 /* No need to validate permissions like nm_connection_replace_settings()
410 * since we're dealing with an NMConnection which has already done that.
413 priv = NM_CONNECTION_GET_PRIVATE (connection);
414 new_priv = NM_CONNECTION_GET_PRIVATE (new_connection);
416 if ((changed = g_hash_table_size (priv->settings) > 0))
417 g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
419 if (g_hash_table_size (new_priv->settings)) {
420 g_hash_table_iter_init (&iter, new_priv->settings);
421 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting))
422 _nm_connection_add_setting (connection, nm_setting_duplicate (setting));
427 g_signal_emit (connection, signals[CHANGED], 0);
431 * nm_connection_clear_settings:
432 * @connection: a #NMConnection
434 * Deletes all of @connection's settings.
437 nm_connection_clear_settings (NMConnection *connection)
439 NMConnectionPrivate *priv;
441 g_return_if_fail (NM_IS_CONNECTION (connection));
443 priv = NM_CONNECTION_GET_PRIVATE (connection);
445 if (g_hash_table_size (priv->settings) > 0) {
446 g_hash_table_foreach_remove (priv->settings, _setting_release, connection);
447 g_signal_emit (connection, signals[CHANGED], 0);
452 * nm_connection_compare:
453 * @a: a #NMConnection
454 * @b: a second #NMConnection to compare with the first
455 * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
457 * Compares two #NMConnection objects for similarity, with comparison behavior
458 * modified by a set of flags. See nm_setting_compare() for a description of
459 * each flag's behavior.
461 * Returns: %TRUE if the comparison succeeds, %FALSE if it does not
464 nm_connection_compare (NMConnection *a,
466 NMSettingCompareFlags flags)
476 /* B / A: ensure settings in B that are not in A make the comparison fail */
477 if (g_hash_table_size (NM_CONNECTION_GET_PRIVATE (a)->settings) !=
478 g_hash_table_size (NM_CONNECTION_GET_PRIVATE (b)->settings))
481 /* A / B: ensure all settings in A match corresponding ones in B */
482 g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (a)->settings);
483 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &src)) {
484 NMSetting *cmp = nm_connection_get_setting (b, G_OBJECT_TYPE (src));
486 if (!cmp || !nm_setting_compare (src, cmp, flags))
495 diff_one_connection (NMConnection *a,
497 NMSettingCompareFlags flags,
498 gboolean invert_results,
501 NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (a);
503 NMSetting *a_setting = NULL;
505 g_hash_table_iter_init (&iter, priv->settings);
506 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &a_setting)) {
507 NMSetting *b_setting = NULL;
508 const char *setting_name = nm_setting_get_name (a_setting);
510 gboolean new_results = TRUE;
513 b_setting = nm_connection_get_setting (b, G_OBJECT_TYPE (a_setting));
515 results = g_hash_table_lookup (diffs, setting_name);
519 if (!nm_setting_diff (a_setting, b_setting, flags, invert_results, &results)) {
521 g_hash_table_insert (diffs, g_strdup (setting_name), results);
527 * nm_connection_diff:
528 * @a: a #NMConnection
529 * @b: a second #NMConnection to compare with the first
530 * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
531 * @out_settings: (element-type utf8 GLib.HashTable): if the
532 * connections differ, on return a hash table mapping setting names to
533 * second-level GHashTable (utf8 to guint32), which contains the key names that
534 * differ mapped to one or more of %NMSettingDiffResult as a bitfield
536 * Compares two #NMConnection objects for similarity, with comparison behavior
537 * modified by a set of flags. See nm_setting_compare() for a description of
538 * each flag's behavior. If the connections differ, settings and keys within
539 * each setting that differ are added to the returned @out_settings hash table.
540 * No values are returned, only key names.
542 * Returns: %TRUE if the connections contain the same values, %FALSE if they do
546 nm_connection_diff (NMConnection *a,
548 NMSettingCompareFlags flags,
549 GHashTable **out_settings)
553 g_return_val_if_fail (NM_IS_CONNECTION (a), FALSE);
554 g_return_val_if_fail (out_settings != NULL, FALSE);
555 g_return_val_if_fail (*out_settings == NULL, FALSE);
557 g_return_val_if_fail (NM_IS_CONNECTION (b), FALSE);
562 diffs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
564 /* Diff A to B, then B to A to capture keys in B that aren't in A */
565 diff_one_connection (a, b, flags, FALSE, diffs);
567 diff_one_connection (b, a, flags, TRUE, diffs);
569 if (g_hash_table_size (diffs) == 0)
570 g_hash_table_destroy (diffs);
572 *out_settings = diffs;
574 return *out_settings ? FALSE : TRUE;
578 _nm_connection_find_base_type_setting (NMConnection *connection)
580 NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
582 NMSetting *setting = NULL, *s_iter;
584 g_hash_table_iter_init (&iter, priv->settings);
585 while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
586 if (!_nm_setting_is_base_type (s_iter))
590 /* FIXME: currently, if there is more than one matching base type,
591 * we cannot detect the base setting.
592 * See: https://bugzilla.gnome.org/show_bug.cgi?id=696936#c8 */
601 _normalize_connection_uuid (NMConnection *self)
603 NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
608 if (nm_setting_connection_get_uuid (s_con))
611 uuid = nm_utils_uuid_generate ();
612 g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
619 _normalize_connection_type (NMConnection *self)
621 NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
622 NMSetting *s_base = NULL;
625 type = nm_setting_connection_get_connection_type (s_con);
628 s_base = nm_connection_get_setting_by_name (self, type);
631 GType base_type = nm_setting_lookup_type (type);
633 g_return_val_if_fail (base_type, FALSE);
634 nm_connection_add_setting (self, g_object_new (base_type, NULL));
638 s_base = _nm_connection_find_base_type_setting (self);
639 g_return_val_if_fail (s_base, FALSE);
641 type = nm_setting_get_name (s_base);
642 g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NULL);
650 _nm_connection_detect_slave_type (NMConnection *connection, NMSetting **out_s_port)
652 NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
654 const char *slave_type = NULL;
655 NMSetting *s_port = NULL, *s_iter;
657 g_hash_table_iter_init (&iter, priv->settings);
658 while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
659 const char *name = nm_setting_get_name (s_iter);
660 const char *i_slave_type = NULL;
662 if (!strcmp (name, NM_SETTING_BRIDGE_PORT_SETTING_NAME))
663 i_slave_type = NM_SETTING_BRIDGE_SETTING_NAME;
664 else if (!strcmp (name, NM_SETTING_TEAM_PORT_SETTING_NAME))
665 i_slave_type = NM_SETTING_TEAM_SETTING_NAME;
670 /* there are more then one matching port types, cannot detect the slave type. */
675 slave_type = i_slave_type;
680 *out_s_port = s_port;
685 _normalize_connection_slave_type (NMConnection *self)
687 NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
688 const char *slave_type, *port_type;
692 if (!nm_setting_connection_get_master (s_con))
695 slave_type = nm_setting_connection_get_slave_type (s_con);
697 if ( _nm_setting_slave_type_is_valid (slave_type, &port_type)
701 s_port = nm_connection_get_setting_by_name (self, port_type);
703 GType p_type = nm_setting_lookup_type (port_type);
705 g_return_val_if_fail (p_type, FALSE);
706 nm_connection_add_setting (self, g_object_new (p_type, NULL));
711 if ((slave_type = _nm_connection_detect_slave_type (self, NULL))) {
712 g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL);
720 _normalize_ip_config (NMConnection *self, GHashTable *parameters)
722 NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
723 const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
724 const char *default_ip6_method = NULL;
725 NMSettingIPConfig *s_ip4, *s_ip6;
729 default_ip6_method = g_hash_table_lookup (parameters, NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD);
730 if (!default_ip6_method)
731 default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
733 s_ip4 = nm_connection_get_setting_ip4_config (self);
734 s_ip6 = nm_connection_get_setting_ip6_config (self);
736 if (nm_setting_connection_get_master (s_con)) {
737 /* Slave connections don't have IP configuration. */
740 nm_connection_remove_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
743 nm_connection_remove_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
745 return s_ip4 || s_ip6;
747 /* Ensure all non-slave connections have IP4 and IP6 settings objects. If no
748 * IP6 setting was specified, then assume that means IP6 config is allowed
749 * to fail. But if no IP4 setting was specified, assume the caller was just
753 setting = nm_setting_ip4_config_new ();
755 g_object_set (setting,
756 NM_SETTING_IP_CONFIG_METHOD, default_ip4_method,
758 nm_connection_add_setting (self, setting);
761 setting = nm_setting_ip6_config_new ();
763 g_object_set (setting,
764 NM_SETTING_IP_CONFIG_METHOD, default_ip6_method,
765 NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
767 nm_connection_add_setting (self, setting);
769 return !s_ip4 || !s_ip6;
774 _normalize_infiniband_mtu (NMConnection *self, GHashTable *parameters)
776 NMSettingInfiniband *s_infini = nm_connection_get_setting_infiniband (self);
779 const char *transport_mode = nm_setting_infiniband_get_transport_mode (s_infini);
782 if (transport_mode) {
783 if (!strcmp (transport_mode, "datagram"))
785 else if (!strcmp (transport_mode, "connected"))
788 if (max_mtu && nm_setting_infiniband_get_mtu (s_infini) > max_mtu) {
789 g_object_set (s_infini, NM_SETTING_INFINIBAND_MTU, max_mtu, NULL);
798 _normalize_bond_mode (NMConnection *self, GHashTable *parameters)
800 NMSettingBond *s_bond = nm_connection_get_setting_bond (self);
802 /* Convert mode from numeric to string notation */
804 const char *mode = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE);
805 int mode_int = nm_utils_bond_mode_string_to_int (mode);
807 if (mode_int != -1) {
808 const char *mode_new = nm_utils_bond_mode_int_to_string (mode_int);
809 if (g_strcmp0 (mode_new, mode) != 0) {
810 nm_setting_bond_add_option (s_bond, NM_SETTING_BOND_OPTION_MODE, mode_new);
819 * nm_connection_verify:
820 * @connection: the #NMConnection to verify
821 * @error: location to store error, or %NULL
823 * Validates the connection and all its settings. Each setting's properties
824 * have allowed values, and some values are dependent on other values. For
825 * example, if a Wi-Fi connection is security enabled, the #NMSettingWireless
826 * setting object's 'security' property must contain the setting name of the
827 * #NMSettingWirelessSecurity object, which must also be present in the
828 * connection for the connection to be valid. As another example, the
829 * #NMSettingWired object's 'mac-address' property must be a validly formatted
830 * MAC address. The returned #GError contains information about which
831 * setting and which property failed validation, and how it failed validation.
833 * Returns: %TRUE if the connection is valid, %FALSE if it is not
836 nm_connection_verify (NMConnection *connection, GError **error)
838 NMSettingVerifyResult result;
840 result = _nm_connection_verify (connection, error);
842 /* we treat normalizable connections as valid. */
843 if (result == NM_SETTING_VERIFY_NORMALIZABLE)
844 g_clear_error (error);
846 return result == NM_SETTING_VERIFY_SUCCESS || result == NM_SETTING_VERIFY_NORMALIZABLE;
849 static NMSettingVerifyResult
850 _nm_connection_verify (NMConnection *connection, GError **error)
852 NMConnectionPrivate *priv;
853 NMSettingConnection *s_con;
854 NMSettingIPConfig *s_ip4, *s_ip6;
857 GSList *all_settings = NULL, *setting_i;
858 NMSettingVerifyResult success = NM_SETTING_VERIFY_ERROR;
859 GError *normalizable_error = NULL;
860 NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS;
862 g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR);
863 g_return_val_if_fail (!error || !*error, NM_SETTING_VERIFY_ERROR);
865 priv = NM_CONNECTION_GET_PRIVATE (connection);
867 /* First, make sure there's at least 'connection' setting */
868 s_con = nm_connection_get_setting_connection (connection);
870 g_set_error_literal (error,
872 NM_CONNECTION_ERROR_MISSING_SETTING,
873 _("setting not found"));
874 g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
878 /* Build up the list of settings */
879 g_hash_table_iter_init (&iter, priv->settings);
880 while (g_hash_table_iter_next (&iter, NULL, &value)) {
881 /* Order NMSettingConnection so that it will be verified first.
882 * The reason is, that errors in this setting might be more fundamental
883 * and should be checked and reported with higher priority.
886 all_settings = g_slist_append (all_settings, value);
888 all_settings = g_slist_prepend (all_settings, value);
890 all_settings = g_slist_reverse (all_settings);
892 /* Now, run the verify function of each setting */
893 for (setting_i = all_settings; setting_i; setting_i = setting_i->next) {
894 GError *verify_error = NULL;
895 NMSettingVerifyResult verify_result;
897 /* verify all settings. We stop if we find the first non-normalizable
898 * @NM_SETTING_VERIFY_ERROR. If we find normalizable errors we continue
899 * but remember the error to return it to the user.
900 * @NM_SETTING_VERIFY_NORMALIZABLE_ERROR has a higher priority then
901 * @NM_SETTING_VERIFY_NORMALIZABLE, so, if we encounter such an error type,
902 * we remember it instead (to return it as output).
904 verify_result = _nm_setting_verify (NM_SETTING (setting_i->data), connection, &verify_error);
905 if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE ||
906 verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR) {
907 if ( verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR
908 && normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE) {
909 /* NORMALIZABLE_ERROR has higher priority. */
910 g_clear_error (&normalizable_error);
912 if (!normalizable_error) {
913 g_propagate_error (&normalizable_error, verify_error);
915 normalizable_error_type = verify_result;
917 } else if (verify_result != NM_SETTING_VERIFY_SUCCESS) {
918 g_propagate_error (error, verify_error);
919 g_slist_free (all_settings);
920 g_return_val_if_fail (verify_result == NM_SETTING_VERIFY_ERROR, success);
923 g_clear_error (&verify_error);
925 g_slist_free (all_settings);
927 s_ip4 = nm_connection_get_setting_ip4_config (connection);
928 s_ip6 = nm_connection_get_setting_ip6_config (connection);
930 if (nm_setting_connection_get_master (s_con)) {
931 if ((normalizable_error_type == NM_SETTING_VERIFY_SUCCESS ||
932 (normalizable_error_type == NM_SETTING_VERIFY_NORMALIZABLE)) && (s_ip4 || s_ip6)) {
933 g_clear_error (&normalizable_error);
934 g_set_error_literal (&normalizable_error,
936 NM_CONNECTION_ERROR_INVALID_SETTING,
937 _("setting not allowed in slave connection"));
938 g_prefix_error (&normalizable_error, "%s: ",
939 s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME);
940 /* having a slave with IP config *was* and is a verify() error. */
941 normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
944 if (normalizable_error_type == NM_SETTING_VERIFY_SUCCESS && (!s_ip4 || !s_ip6)) {
945 g_set_error_literal (&normalizable_error,
947 NM_CONNECTION_ERROR_MISSING_SETTING,
948 _("setting is required for non-slave connections"));
949 g_prefix_error (&normalizable_error, "%s: ",
950 !s_ip4 ? NM_SETTING_IP4_CONFIG_SETTING_NAME : NM_SETTING_IP6_CONFIG_SETTING_NAME);
951 /* having a master without IP config was not a verify() error, accept
952 * it for backward compatibility. */
953 normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
957 if (normalizable_error_type != NM_SETTING_VERIFY_SUCCESS) {
958 g_propagate_error (error, normalizable_error);
959 normalizable_error = NULL;
960 success = normalizable_error_type;
962 success = NM_SETTING_VERIFY_SUCCESS;
965 g_clear_error (&normalizable_error);
970 * nm_connection_verify_secrets:
971 * @connection: the #NMConnection to verify in
972 * @error: location to store error, or %NULL
974 * Verifies the secrets in the connection.
976 * Returns: %TRUE if the secrets are valid, %FALSE if they are not
981 nm_connection_verify_secrets (NMConnection *connection, GError **error)
986 g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
987 g_return_val_if_fail (!error || !*error, FALSE);
989 g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
990 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
991 if (!nm_setting_verify_secrets (setting, connection, error))
998 * nm_connection_normalize:
999 * @connection: the #NMConnection to normalize
1000 * @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
1001 * normalization parameters to allow customization of the normalization by providing
1002 * specific arguments. Unknown arguments will be ignored and the default will be
1003 * used. The keys must be strings, hashed by g_str_hash() and g_str_equal() functions.
1004 * The values are opaque and depend on the parameter name.
1005 * @modified: (out) (allow-none): outputs whether any settings were modified.
1006 * @error: location to store error, or %NULL. Contains the reason,
1007 * why the connection is invalid, if the function returns an error.
1009 * Does some basic normalization and fixup of well known inconsistencies
1010 * and deprecated fields. If the connection was modified in any way,
1011 * the output parameter @modified is set %TRUE.
1013 * Finally the connection will be verified and %TRUE returns if the connection
1014 * is valid. As this function only performs some specific normalization steps
1015 * it cannot repair all connections. If the connection has errors that
1016 * cannot be normalized, the connection will not be modified.
1018 * Returns: %TRUE if the connection is valid, %FALSE if it is not
1021 nm_connection_normalize (NMConnection *connection,
1022 GHashTable *parameters,
1026 NMSettingVerifyResult success;
1027 gboolean was_modified = FALSE;
1028 GError *normalizable_error = NULL;
1030 success = _nm_connection_verify (connection, &normalizable_error);
1032 if (success == NM_SETTING_VERIFY_ERROR ||
1033 success == NM_SETTING_VERIFY_SUCCESS) {
1034 if (normalizable_error)
1035 g_propagate_error (error, normalizable_error);
1038 if (success == NM_SETTING_VERIFY_ERROR && error && !*error) {
1039 g_set_error_literal (error,
1040 NM_CONNECTION_ERROR,
1041 NM_CONNECTION_ERROR_FAILED,
1042 _("Unexpected failure to verify the connection"));
1043 g_return_val_if_reached (FALSE);
1045 return success == NM_SETTING_VERIFY_SUCCESS;
1047 g_assert (success == NM_SETTING_VERIFY_NORMALIZABLE || success == NM_SETTING_VERIFY_NORMALIZABLE_ERROR);
1048 g_clear_error (&normalizable_error);
1050 /* Try to perform all kind of normalizations on the settings to fix it.
1051 * We only do this, after verifying that the connection contains no un-normalizable
1052 * errors, because in that case we rather fail without touching the settings. */
1054 was_modified |= _normalize_connection_uuid (connection);
1055 was_modified |= _normalize_connection_type (connection);
1056 was_modified |= _normalize_connection_slave_type (connection);
1057 was_modified |= _normalize_ip_config (connection, parameters);
1058 was_modified |= _normalize_infiniband_mtu (connection, parameters);
1059 was_modified |= _normalize_bond_mode (connection, parameters);
1062 success = _nm_connection_verify (connection, error);
1065 *modified = was_modified;
1067 if (success != NM_SETTING_VERIFY_SUCCESS) {
1068 /* we would expect, that after normalization, the connection can be verified.
1069 * Also treat NM_SETTING_VERIFY_NORMALIZABLE as failure, because there is something
1071 if (error && !*error) {
1072 g_set_error_literal (error,
1073 NM_CONNECTION_ERROR,
1074 NM_CONNECTION_ERROR_FAILED,
1075 _("Unexpected failure to normalize the connection"));
1077 g_return_val_if_reached (FALSE);
1080 /* we would expect, that the connection was modified during normalization. */
1081 g_return_val_if_fail (was_modified, TRUE);
1087 * nm_connection_update_secrets:
1088 * @connection: the #NMConnection
1089 * @setting_name: the setting object name to which the secrets apply
1090 * @secrets: a #GVariant of secrets, of type %NM_VARIANT_TYPE_CONNECTION
1091 * or %NM_VARIANT_TYPE_SETTING
1092 * @error: location to store error, or %NULL
1094 * Update the specified setting's secrets, given a dictionary of secrets
1095 * intended for that setting (deserialized from D-Bus for example). Will also
1096 * extract the given setting's secrets hash if given a connection dictionary.
1097 * If @setting_name is %NULL, expects a fully serialized #NMConnection as
1098 * returned by nm_connection_to_dbus() and will update all secrets from all
1099 * settings contained in @secrets.
1101 * Returns: %TRUE if the secrets were successfully updated, %FALSE if the update
1102 * failed (tried to update secrets for a setting that doesn't exist, etc)
1105 nm_connection_update_secrets (NMConnection *connection,
1106 const char *setting_name,
1111 gboolean success = TRUE, updated = FALSE;
1112 GVariant *setting_dict = NULL;
1115 gboolean full_connection;
1118 g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
1119 g_return_val_if_fail ( g_variant_is_of_type (secrets, NM_VARIANT_TYPE_SETTING)
1120 || g_variant_is_of_type (secrets, NM_VARIANT_TYPE_CONNECTION), FALSE);
1122 g_return_val_if_fail (*error == NULL, FALSE);
1124 full_connection = g_variant_is_of_type (secrets, NM_VARIANT_TYPE_CONNECTION);
1125 g_return_val_if_fail (setting_name != NULL || full_connection, FALSE);
1127 /* Empty @secrets means success */
1128 if (g_variant_n_children (secrets) == 0)
1132 /* Update just one setting's secrets */
1133 setting = nm_connection_get_setting_by_name (connection, setting_name);
1135 g_set_error_literal (error,
1136 NM_CONNECTION_ERROR,
1137 NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
1142 if (full_connection) {
1143 setting_dict = g_variant_lookup_value (secrets, setting_name, NM_VARIANT_TYPE_SETTING);
1144 if (!setting_dict) {
1145 /* The connection dictionary didn't contain any secrets for
1146 * @setting_name; just return success.
1152 g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
1153 success_detail = _nm_setting_update_secrets (setting,
1154 setting_dict ? setting_dict : secrets,
1156 g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
1158 g_clear_pointer (&setting_dict, g_variant_unref);
1160 if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR)
1162 if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
1165 /* check first, whether all the settings exist... */
1166 g_variant_iter_init (&iter, secrets);
1167 while (g_variant_iter_next (&iter, "{&s@a{sv}}", &key, NULL)) {
1168 setting = nm_connection_get_setting_by_name (connection, key);
1170 g_set_error_literal (error,
1171 NM_CONNECTION_ERROR,
1172 NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
1178 /* Update each setting with any secrets from the connection dictionary */
1179 g_variant_iter_init (&iter, secrets);
1180 while (g_variant_iter_next (&iter, "{&s@a{sv}}", &key, &setting_dict)) {
1181 /* Update the secrets for this setting */
1182 setting = nm_connection_get_setting_by_name (connection, key);
1184 g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
1185 success_detail = _nm_setting_update_secrets (setting, setting_dict, error);
1186 g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
1188 g_variant_unref (setting_dict);
1190 if (success_detail == NM_SETTING_UPDATE_SECRET_ERROR) {
1194 if (success_detail == NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED)
1200 g_signal_emit (connection, signals[SECRETS_UPDATED], 0, setting_name);
1201 g_signal_emit (connection, signals[CHANGED], 0);
1208 * nm_connection_need_secrets:
1209 * @connection: the #NMConnection
1210 * @hints: (out) (element-type utf8) (allow-none) (transfer container):
1211 * the address of a pointer to a #GPtrArray, initialized to %NULL, which on
1212 * return points to an allocated #GPtrArray containing the property names of
1213 * secrets of the #NMSetting which may be required; the caller owns the array
1214 * and must free the array itself with g_ptr_array_free(), but not free its
1217 * Returns the name of the first setting object in the connection which would
1218 * need secrets to make a successful connection. The returned hints are only
1219 * intended as a guide to what secrets may be required, because in some
1220 * circumstances, there is no way to conclusively determine exactly which
1221 * secrets are needed.
1223 * Returns: the setting name of the #NMSetting object which has invalid or
1227 nm_connection_need_secrets (NMConnection *connection,
1230 NMConnectionPrivate *priv;
1231 GHashTableIter hiter;
1232 GSList *settings = NULL;
1234 const char *name = NULL;
1237 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1239 g_return_val_if_fail (*hints == NULL, NULL);
1241 priv = NM_CONNECTION_GET_PRIVATE (connection);
1243 /* Get list of settings in priority order */
1244 g_hash_table_iter_init (&hiter, priv->settings);
1245 while (g_hash_table_iter_next (&hiter, NULL, (gpointer) &setting))
1246 settings = g_slist_insert_sorted (settings, setting, _nm_setting_compare_priority);
1248 for (iter = settings; iter; iter = g_slist_next (iter)) {
1251 setting = NM_SETTING (iter->data);
1252 secrets = _nm_setting_need_secrets (setting);
1257 g_ptr_array_free (secrets, TRUE);
1259 name = nm_setting_get_name (setting);
1264 g_slist_free (settings);
1269 * nm_connection_clear_secrets:
1270 * @connection: the #NMConnection
1272 * Clears and frees any secrets that may be stored in the connection, to avoid
1273 * keeping secret data in memory when not needed.
1276 nm_connection_clear_secrets (NMConnection *connection)
1278 GHashTableIter iter;
1280 gboolean changed = FALSE;
1282 g_return_if_fail (NM_IS_CONNECTION (connection));
1284 g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
1285 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
1286 g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
1287 changed |= _nm_setting_clear_secrets (setting);
1288 g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
1291 g_signal_emit (connection, signals[SECRETS_CLEARED], 0);
1293 g_signal_emit (connection, signals[CHANGED], 0);
1297 * nm_connection_clear_secrets_with_flags:
1298 * @connection: the #NMConnection
1299 * @func: (scope call): function to be called to determine whether a
1300 * specific secret should be cleared or not
1301 * @user_data: caller-supplied data passed to @func
1303 * Clears and frees secrets determined by @func.
1306 nm_connection_clear_secrets_with_flags (NMConnection *connection,
1307 NMSettingClearSecretsWithFlagsFn func,
1310 GHashTableIter iter;
1312 gboolean changed = FALSE;
1314 g_return_if_fail (NM_IS_CONNECTION (connection));
1316 g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
1317 while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting)) {
1318 g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
1319 changed |= _nm_setting_clear_secrets_with_flags (setting, func, user_data);
1320 g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);
1323 g_signal_emit (connection, signals[SECRETS_CLEARED], 0);
1325 g_signal_emit (connection, signals[CHANGED], 0);
1329 * nm_connection_to_dbus:
1330 * @connection: the #NMConnection
1331 * @flags: serialization flags, e.g. %NM_CONNECTION_SERIALIZE_ALL
1333 * Converts the #NMConnection into a #GVariant of type
1334 * %NM_VARIANT_TYPE_CONNECTION describing the connection, suitable for
1335 * marshalling over D-Bus or otherwise serializing.
1337 * Returns: (transfer none): a new floating #GVariant describing the connection,
1338 * its settings, and each setting's properties.
1341 nm_connection_to_dbus (NMConnection *connection,
1342 NMConnectionSerializationFlags flags)
1344 NMConnectionPrivate *priv;
1345 GVariantBuilder builder;
1346 GHashTableIter iter;
1348 GVariant *setting_dict, *ret;
1350 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1351 priv = NM_CONNECTION_GET_PRIVATE (connection);
1353 g_variant_builder_init (&builder, NM_VARIANT_TYPE_CONNECTION);
1355 /* Add each setting's hash to the main hash */
1356 g_hash_table_iter_init (&iter, priv->settings);
1357 while (g_hash_table_iter_next (&iter, &key, &data)) {
1358 NMSetting *setting = NM_SETTING (data);
1360 setting_dict = _nm_setting_to_dbus (setting, connection, flags);
1362 g_variant_builder_add (&builder, "{s@a{sv}}", nm_setting_get_name (setting), setting_dict);
1365 ret = g_variant_builder_end (&builder);
1367 /* Don't send empty hashes */
1368 if (g_variant_n_children (ret) == 0) {
1369 g_variant_unref (ret);
1377 * nm_connection_is_type:
1378 * @connection: the #NMConnection
1379 * @type: a setting name to check the connection's type against (like
1380 * %NM_SETTING_WIRELESS_SETTING_NAME or %NM_SETTING_WIRED_SETTING_NAME)
1382 * A convenience function to check if the given @connection is a particular
1383 * type (ie wired, Wi-Fi, ppp, etc). Checks the #NMSettingConnection:type
1384 * property of the connection and matches that against @type.
1386 * Returns: %TRUE if the connection is of the given @type, %FALSE if not
1389 nm_connection_is_type (NMConnection *connection, const char *type)
1391 NMSettingConnection *s_con;
1394 g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
1395 g_return_val_if_fail (type != NULL, FALSE);
1397 s_con = nm_connection_get_setting_connection (connection);
1401 type2 = nm_setting_connection_get_connection_type (s_con);
1403 return (g_strcmp0 (type2, type) == 0);
1407 _for_each_sort (NMSetting **p_a, NMSetting **p_b, void *unused)
1409 NMSetting *a = *p_a;
1410 NMSetting *b = *p_b;
1413 c = _nm_setting_compare_priority (a, b);
1416 return strcmp (nm_setting_get_name (a), nm_setting_get_name (b));
1420 * nm_connection_for_each_setting_value:
1421 * @connection: the #NMConnection
1422 * @func: (scope call): user-supplied function called for each setting's property
1423 * @user_data: user data passed to @func at each invocation
1425 * Iterates over the properties of each #NMSetting object in the #NMConnection,
1426 * calling the supplied user function for each property.
1429 nm_connection_for_each_setting_value (NMConnection *connection,
1430 NMSettingValueIterFn func,
1433 NMConnectionPrivate *priv;
1434 gs_free NMSetting **arr_free = NULL;
1435 NMSetting *arr_temp[20], **arr;
1436 GHashTableIter iter;
1440 g_return_if_fail (NM_IS_CONNECTION (connection));
1441 g_return_if_fail (func != NULL);
1443 priv = NM_CONNECTION_GET_PRIVATE (connection);
1445 size = g_hash_table_size (priv->settings);
1449 if (size > G_N_ELEMENTS (arr_temp))
1450 arr = arr_free = g_new (NMSetting *, size);
1454 g_hash_table_iter_init (&iter, priv->settings);
1455 for (i = 0; g_hash_table_iter_next (&iter, NULL, &value); i++)
1456 arr[i] = NM_SETTING (value);
1457 g_assert (i == size);
1459 /* sort the settings. This has an effect on the order in which keyfile
1462 g_qsort_with_data (arr, size, sizeof (NMSetting *), (GCompareDataFunc) _for_each_sort, NULL);
1464 for (i = 0; i < size; i++)
1465 nm_setting_enumerate_values (arr[i], func, user_data);
1469 * nm_connection_dump:
1470 * @connection: the #NMConnection
1472 * Print the connection to stdout. For debugging purposes ONLY, should NOT
1473 * be used for serialization of the connection or machine-parsed in any way. The
1474 * output format is not guaranteed to be stable and may change at any time.
1477 nm_connection_dump (NMConnection *connection)
1479 GHashTableIter iter;
1481 const char *setting_name;
1487 g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
1488 while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting)) {
1489 str = nm_setting_to_string (setting);
1490 g_print ("%s\n", str);
1496 * nm_connection_set_path:
1497 * @connection: the #NMConnection
1498 * @path: the D-Bus path of the connection as given by the settings service
1499 * which provides the connection
1501 * Sets the D-Bus path of the connection. This property is not serialized, and
1502 * is only for the reference of the caller. Sets the #NMConnection:path
1506 nm_connection_set_path (NMConnection *connection, const char *path)
1508 NMConnectionPrivate *priv;
1510 g_return_if_fail (NM_IS_CONNECTION (connection));
1512 priv = NM_CONNECTION_GET_PRIVATE (connection);
1514 g_free (priv->path);
1518 priv->path = g_strdup (path);
1522 * nm_connection_get_path:
1523 * @connection: the #NMConnection
1525 * Returns the connection's D-Bus path.
1527 * Returns: the D-Bus path of the connection, previously set by a call to
1528 * nm_connection_set_path().
1531 nm_connection_get_path (NMConnection *connection)
1533 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1535 return NM_CONNECTION_GET_PRIVATE (connection)->path;
1539 * nm_connection_get_interface_name:
1540 * @connection: The #NMConnection
1542 * Returns the interface name as stored in NMSettingConnection:interface_name.
1543 * If the connection contains no NMSettingConnection, it will return %NULL.
1545 * For hardware devices and software devices created outside of NetworkManager,
1546 * this name is used to match the device. for software devices created by
1547 * NetworkManager, this is the name of the created interface.
1549 * Returns: Name of the kernel interface or %NULL
1552 nm_connection_get_interface_name (NMConnection *connection)
1554 NMSettingConnection *s_con;
1556 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1558 s_con = nm_connection_get_setting_connection (connection);
1560 return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
1564 _nm_connection_verify_required_interface_name (NMConnection *connection,
1567 const char *interface_name;
1569 interface_name = nm_connection_get_interface_name (connection);
1573 g_set_error_literal (error,
1574 NM_CONNECTION_ERROR,
1575 NM_CONNECTION_ERROR_MISSING_PROPERTY,
1576 _("property is missing"));
1577 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
1582 * nm_connection_get_uuid:
1583 * @connection: the #NMConnection
1585 * A shortcut to return the UUID from the connection's #NMSettingConnection.
1587 * Returns: the UUID from the connection's 'connection' setting
1590 nm_connection_get_uuid (NMConnection *connection)
1592 NMSettingConnection *s_con;
1594 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1596 s_con = nm_connection_get_setting_connection (connection);
1600 return nm_setting_connection_get_uuid (s_con);
1604 * nm_connection_get_id:
1605 * @connection: the #NMConnection
1607 * A shortcut to return the ID from the connection's #NMSettingConnection.
1609 * Returns: the ID from the connection's 'connection' setting
1612 nm_connection_get_id (NMConnection *connection)
1614 NMSettingConnection *s_con;
1616 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1618 s_con = nm_connection_get_setting_connection (connection);
1622 return nm_setting_connection_get_id (s_con);
1626 * nm_connection_get_connection_type:
1627 * @connection: the #NMConnection
1629 * A shortcut to return the type from the connection's #NMSettingConnection.
1631 * Returns: the type from the connection's 'connection' setting
1634 nm_connection_get_connection_type (NMConnection *connection)
1636 NMSettingConnection *s_con;
1638 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1640 s_con = nm_connection_get_setting_connection (connection);
1644 return nm_setting_connection_get_connection_type (s_con);
1648 * nm_connection_is_virtual:
1649 * @connection: an #NMConnection
1651 * Checks if @connection refers to a virtual device (and thus can potentially be
1652 * activated even if the device it refers to doesn't exist).
1654 * Returns: whether @connection refers to a virtual device
1657 nm_connection_is_virtual (NMConnection *connection)
1661 type = nm_connection_get_connection_type (connection);
1662 g_return_val_if_fail (type != NULL, FALSE);
1664 if ( !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
1665 || !strcmp (type, NM_SETTING_TEAM_SETTING_NAME)
1666 || !strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)
1667 || !strcmp (type, NM_SETTING_VLAN_SETTING_NAME)
1668 || !strcmp (type, NM_SETTING_TUN_SETTING_NAME)
1669 || !strcmp (type, NM_SETTING_IP_TUNNEL_SETTING_NAME)
1670 || !strcmp (type, NM_SETTING_MACVLAN_SETTING_NAME)
1671 || !strcmp (type, NM_SETTING_VXLAN_SETTING_NAME))
1674 if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
1675 NMSettingInfiniband *s_ib;
1677 s_ib = nm_connection_get_setting_infiniband (connection);
1678 g_return_val_if_fail (s_ib != NULL, FALSE);
1679 return nm_setting_infiniband_get_virtual_interface_name (s_ib) != NULL;
1686 * nm_connection_get_virtual_device_description:
1687 * @connection: an #NMConnection for a virtual device type
1689 * Returns the name that nm_device_disambiguate_names() would
1690 * return for the virtual device that would be created for @connection.
1691 * Eg, "VLAN (eth1.1)".
1693 * Returns: (transfer full): the name of @connection's device,
1694 * or %NULL if @connection is not a virtual connection type
1697 nm_connection_get_virtual_device_description (NMConnection *connection)
1700 const char *iface = NULL, *display_type = NULL;
1702 iface = nm_connection_get_interface_name (connection);
1704 type = nm_connection_get_connection_type (connection);
1705 g_return_val_if_fail (type != NULL, FALSE);
1707 if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME))
1708 display_type = _("Bond");
1709 else if (!strcmp (type, NM_SETTING_TEAM_SETTING_NAME))
1710 display_type = _("Team");
1711 else if (!strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME))
1712 display_type = _("Bridge");
1713 else if (!strcmp (type, NM_SETTING_VLAN_SETTING_NAME))
1714 display_type = _("VLAN");
1715 else if (!strcmp (type, NM_SETTING_INFINIBAND_SETTING_NAME)) {
1716 display_type = _("InfiniBand");
1717 iface = nm_setting_infiniband_get_virtual_interface_name (nm_connection_get_setting_infiniband (connection));
1720 if (!iface || !display_type)
1723 return g_strdup_printf ("%s (%s)", display_type, iface);
1726 /*************************************************************/
1729 * nm_connection_get_setting_802_1x:
1730 * @connection: the #NMConnection
1732 * A shortcut to return any #NMSetting8021x the connection might contain.
1734 * Returns: (transfer none): an #NMSetting8021x if the connection contains one, otherwise %NULL
1737 nm_connection_get_setting_802_1x (NMConnection *connection)
1739 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1741 return (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
1745 * nm_connection_get_setting_bluetooth:
1746 * @connection: the #NMConnection
1748 * A shortcut to return any #NMSettingBluetooth the connection might contain.
1750 * Returns: (transfer none): an #NMSettingBluetooth if the connection contains one, otherwise %NULL
1752 NMSettingBluetooth *
1753 nm_connection_get_setting_bluetooth (NMConnection *connection)
1755 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1757 return (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
1761 * nm_connection_get_setting_bond:
1762 * @connection: the #NMConnection
1764 * A shortcut to return any #NMSettingBond the connection might contain.
1766 * Returns: (transfer none): an #NMSettingBond if the connection contains one, otherwise %NULL
1769 nm_connection_get_setting_bond (NMConnection *connection)
1771 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1773 return (NMSettingBond *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BOND);
1777 * nm_connection_get_setting_team:
1778 * @connection: the #NMConnection
1780 * A shortcut to return any #NMSettingTeam the connection might contain.
1782 * Returns: (transfer none): an #NMSettingTeam if the connection contains one, otherwise %NULL
1785 nm_connection_get_setting_team (NMConnection *connection)
1787 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1789 return (NMSettingTeam *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM);
1793 * nm_connection_get_setting_team_port:
1794 * @connection: the #NMConnection
1796 * A shortcut to return any #NMSettingTeamPort the connection might contain.
1798 * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL
1801 nm_connection_get_setting_team_port (NMConnection *connection)
1803 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1805 return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT);
1809 * nm_connection_get_setting_bridge:
1810 * @connection: the #NMConnection
1812 * A shortcut to return any #NMSettingBridge the connection might contain.
1814 * Returns: (transfer none): an #NMSettingBridge if the connection contains one, otherwise %NULL
1817 nm_connection_get_setting_bridge (NMConnection *connection)
1819 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1821 return (NMSettingBridge *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE);
1825 * nm_connection_get_setting_cdma:
1826 * @connection: the #NMConnection
1828 * A shortcut to return any #NMSettingCdma the connection might contain.
1830 * Returns: (transfer none): an #NMSettingCdma if the connection contains one, otherwise %NULL
1833 nm_connection_get_setting_cdma (NMConnection *connection)
1835 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1837 return (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
1841 * nm_connection_get_setting_connection:
1842 * @connection: the #NMConnection
1844 * A shortcut to return any #NMSettingConnection the connection might contain.
1846 * Returns: (transfer none): an #NMSettingConnection if the connection contains one, otherwise %NULL
1848 NMSettingConnection *
1849 nm_connection_get_setting_connection (NMConnection *connection)
1851 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1853 return (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
1857 * nm_connection_get_setting_dcb:
1858 * @connection: the #NMConnection
1860 * A shortcut to return any #NMSettingDcb the connection might contain.
1862 * Returns: (transfer none): an #NMSettingDcb if the connection contains one, otherwise NULL
1865 nm_connection_get_setting_dcb (NMConnection *connection)
1867 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1869 return (NMSettingDcb *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DCB);
1873 * nm_connection_get_setting_generic:
1874 * @connection: the #NMConnection
1876 * A shortcut to return any #NMSettingGeneric the connection might contain.
1878 * Returns: (transfer none): an #NMSettingGeneric if the connection contains one, otherwise NULL
1881 nm_connection_get_setting_generic (NMConnection *connection)
1883 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1885 return (NMSettingGeneric *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GENERIC);
1889 * nm_connection_get_setting_gsm:
1890 * @connection: the #NMConnection
1892 * A shortcut to return any #NMSettingGsm the connection might contain.
1894 * Returns: (transfer none): an #NMSettingGsm if the connection contains one, otherwise %NULL
1897 nm_connection_get_setting_gsm (NMConnection *connection)
1899 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1901 return (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
1905 * nm_connection_get_setting_infiniband:
1906 * @connection: the #NMConnection
1908 * A shortcut to return any #NMSettingInfiniband the connection might contain.
1910 * Returns: (transfer none): an #NMSettingInfiniband if the connection contains one, otherwise %NULL
1912 NMSettingInfiniband *
1913 nm_connection_get_setting_infiniband (NMConnection *connection)
1915 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1917 return (NMSettingInfiniband *) nm_connection_get_setting (connection, NM_TYPE_SETTING_INFINIBAND);
1921 * nm_connection_get_setting_ip4_config:
1922 * @connection: the #NMConnection
1924 * A shortcut to return any #NMSettingIP4Config the connection might contain.
1926 * Note that it returns the value as type #NMSettingIPConfig, since the vast
1927 * majority of IPv4-setting-related methods are on that type, not
1928 * #NMSettingIP4Config.
1930 * Returns: (type NMSettingIP4Config) (transfer none): an #NMSettingIP4Config if the
1931 * connection contains one, otherwise %NULL
1934 nm_connection_get_setting_ip4_config (NMConnection *connection)
1936 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1938 return (NMSettingIPConfig *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
1942 * nm_connection_get_setting_ip_tunnel:
1943 * @connection: the #NMConnection
1945 * A shortcut to return any #NMSettingIPTunnel the connection might contain.
1947 * Returns: (transfer none): an #NMSettingIPTunnel if the connection contains one, otherwise %NULL
1952 nm_connection_get_setting_ip_tunnel (NMConnection *connection)
1954 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1956 return (NMSettingIPTunnel *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP_TUNNEL);
1960 * nm_connection_get_setting_ip6_config:
1961 * @connection: the #NMConnection
1963 * A shortcut to return any #NMSettingIP6Config the connection might contain.
1965 * Note that it returns the value as type #NMSettingIPConfig, since the vast
1966 * majority of IPv6-setting-related methods are on that type, not
1967 * #NMSettingIP6Config.
1969 * Returns: (type NMSettingIP6Config) (transfer none): an #NMSettingIP6Config if the
1970 * connection contains one, otherwise %NULL
1973 nm_connection_get_setting_ip6_config (NMConnection *connection)
1975 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1977 return (NMSettingIPConfig *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
1981 * nm_connection_get_setting_macvlan:
1982 * @connection: the #NMConnection
1984 * A shortcut to return any #NMSettingMacvlan the connection might contain.
1986 * Returns: (transfer none): an #NMSettingMacvlan if the connection contains one, otherwise %NULL
1991 nm_connection_get_setting_macvlan (NMConnection *connection)
1993 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
1995 return (NMSettingMacvlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_MACVLAN);
1999 * nm_connection_get_setting_olpc_mesh:
2000 * @connection: the #NMConnection
2002 * A shortcut to return any #NMSettingOlpcMesh the connection might contain.
2004 * Returns: (transfer none): an #NMSettingOlpcMesh if the connection contains one, otherwise %NULL
2007 nm_connection_get_setting_olpc_mesh (NMConnection *connection)
2009 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2011 return (NMSettingOlpcMesh *) nm_connection_get_setting (connection, NM_TYPE_SETTING_OLPC_MESH);
2015 * nm_connection_get_setting_ppp:
2016 * @connection: the #NMConnection
2018 * A shortcut to return any #NMSettingPpp the connection might contain.
2020 * Returns: (transfer none): an #NMSettingPpp if the connection contains one, otherwise %NULL
2023 nm_connection_get_setting_ppp (NMConnection *connection)
2025 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2027 return (NMSettingPpp *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
2031 * nm_connection_get_setting_pppoe:
2032 * @connection: the #NMConnection
2034 * A shortcut to return any #NMSettingPppoe the connection might contain.
2036 * Returns: (transfer none): an #NMSettingPppoe if the connection contains one, otherwise %NULL
2039 nm_connection_get_setting_pppoe (NMConnection *connection)
2041 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2043 return (NMSettingPppoe *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
2047 * nm_connection_get_setting_serial:
2048 * @connection: the #NMConnection
2050 * A shortcut to return any #NMSettingSerial the connection might contain.
2052 * Returns: (transfer none): an #NMSettingSerial if the connection contains one, otherwise %NULL
2055 nm_connection_get_setting_serial (NMConnection *connection)
2057 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2059 return (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
2063 * nm_connection_get_setting_tun:
2064 * @connection: the #NMConnection
2066 * A shortcut to return any #NMSettingTun the connection might contain.
2068 * Returns: (transfer none): an #NMSettingTun if the connection contains one, otherwise %NULL
2073 nm_connection_get_setting_tun (NMConnection *connection)
2075 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2077 return (NMSettingTun *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TUN);
2081 * nm_connection_get_setting_vpn:
2082 * @connection: the #NMConnection
2084 * A shortcut to return any #NMSettingVpn the connection might contain.
2086 * Returns: (transfer none): an #NMSettingVpn if the connection contains one, otherwise %NULL
2089 nm_connection_get_setting_vpn (NMConnection *connection)
2091 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2093 return (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
2097 * nm_connection_get_setting_vxlan:
2098 * @connection: the #NMConnection
2100 * A shortcut to return any #NMSettingVxlan the connection might contain.
2102 * Returns: (transfer none): an #NMSettingVxlan if the connection contains one, otherwise %NULL
2107 nm_connection_get_setting_vxlan (NMConnection *connection)
2109 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2111 return (NMSettingVxlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VXLAN);
2115 * nm_connection_get_setting_wimax:
2116 * @connection: the #NMConnection
2118 * A shortcut to return any #NMSettingWimax the connection might contain.
2120 * Returns: (transfer none): an #NMSettingWimax if the connection contains one, otherwise %NULL
2123 nm_connection_get_setting_wimax (NMConnection *connection)
2125 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2127 return (NMSettingWimax *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
2131 * nm_connection_get_setting_wired:
2132 * @connection: the #NMConnection
2134 * A shortcut to return any #NMSettingWired the connection might contain.
2136 * Returns: (transfer none): an #NMSettingWired if the connection contains one, otherwise %NULL
2139 nm_connection_get_setting_wired (NMConnection *connection)
2141 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2143 return (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
2147 * nm_connection_get_setting_adsl:
2148 * @connection: the #NMConnection
2150 * A shortcut to return any #NMSettingAdsl the connection might contain.
2152 * Returns: (transfer none): an #NMSettingAdsl if the connection contains one, otherwise %NULL
2155 nm_connection_get_setting_adsl (NMConnection *connection)
2157 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2159 return (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL);
2163 * nm_connection_get_setting_wireless:
2164 * @connection: the #NMConnection
2166 * A shortcut to return any #NMSettingWireless the connection might contain.
2168 * Returns: (transfer none): an #NMSettingWireless if the connection contains one, otherwise %NULL
2171 nm_connection_get_setting_wireless (NMConnection *connection)
2173 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2175 return (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
2179 * nm_connection_get_setting_wireless_security:
2180 * @connection: the #NMConnection
2182 * A shortcut to return any #NMSettingWirelessSecurity the connection might contain.
2184 * Returns: (transfer none): an #NMSettingWirelessSecurity if the connection contains one, otherwise %NULL
2186 NMSettingWirelessSecurity *
2187 nm_connection_get_setting_wireless_security (NMConnection *connection)
2189 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2191 return (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
2195 * nm_connection_get_setting_bridge_port:
2196 * @connection: the #NMConnection
2198 * A shortcut to return any #NMSettingBridgePort the connection might contain.
2200 * Returns: (transfer none): an #NMSettingBridgePort if the connection contains one, otherwise %NULL
2202 NMSettingBridgePort *
2203 nm_connection_get_setting_bridge_port (NMConnection *connection)
2205 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2207 return (NMSettingBridgePort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE_PORT);
2211 * nm_connection_get_setting_vlan:
2212 * @connection: the #NMConnection
2214 * A shortcut to return any #NMSettingVlan the connection might contain.
2216 * Returns: (transfer none): an #NMSettingVlan if the connection contains one, otherwise %NULL
2219 nm_connection_get_setting_vlan (NMConnection *connection)
2221 g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
2223 return (NMSettingVlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VLAN);
2226 /*************************************************************/
2229 nm_connection_private_free (NMConnectionPrivate *priv)
2231 NMConnection *self = priv->self;
2233 g_hash_table_foreach_remove (priv->settings, _setting_release, self);
2234 g_hash_table_destroy (priv->settings);
2235 g_free (priv->path);
2237 g_slice_free (NMConnectionPrivate, priv);
2240 static NMConnectionPrivate *
2241 nm_connection_get_private (NMConnection *connection)
2243 NMConnectionPrivate *priv;
2245 priv = g_object_get_data (G_OBJECT (connection), "NMConnectionPrivate");
2247 priv = g_slice_new0 (NMConnectionPrivate);
2248 g_object_set_data_full (G_OBJECT (connection), "NMConnectionPrivate",
2249 priv, (GDestroyNotify) nm_connection_private_free);
2251 priv->self = connection;
2252 priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
2259 nm_connection_default_init (NMConnectionInterface *iface)
2264 * NMConnection::secrets-updated:
2265 * @connection: the object on which the signal is emitted
2266 * @setting_name: the setting name of the #NMSetting for which secrets were
2269 * The ::secrets-updated signal is emitted when the secrets of a setting
2270 * have been changed.
2272 signals[SECRETS_UPDATED] =
2273 g_signal_new (NM_CONNECTION_SECRETS_UPDATED,
2276 G_STRUCT_OFFSET (NMConnectionInterface, secrets_updated),
2278 g_cclosure_marshal_VOID__STRING,
2283 * NMConnection::secrets-cleared:
2284 * @connection: the object on which the signal is emitted
2286 * The ::secrets-cleared signal is emitted when the secrets of a connection
2289 signals[SECRETS_CLEARED] =
2290 g_signal_new (NM_CONNECTION_SECRETS_CLEARED,
2293 G_STRUCT_OFFSET (NMConnectionInterface, secrets_cleared),
2295 g_cclosure_marshal_VOID__VOID,
2299 * NMConnection::changed:
2300 * @connection: the object on which the signal is emitted
2302 * The ::changed signal is emitted when any property of any property
2303 * (including secrets) of any setting of the connection is modified,
2304 * or when settings are added or removed.
2307 g_signal_new (NM_CONNECTION_CHANGED,
2310 G_STRUCT_OFFSET (NMConnectionInterface, changed),
2312 g_cclosure_marshal_VOID__VOID,