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"
25 #include "nm-setting-connection.h"
30 #include "nm-utils-private.h"
31 #include "nm-core-enum-types.h"
32 #include "nm-connection-private.h"
33 #include "nm-setting-bond.h"
34 #include "nm-setting-bridge.h"
35 #include "nm-setting-team.h"
36 #include "nm-setting-vlan.h"
39 * SECTION:nm-setting-connection
40 * @short_description: Describes general connection properties
42 * The #NMSettingConnection object is a #NMSetting subclass that describes
43 * properties that apply to all #NMConnection objects, regardless of what type
44 * of network connection they describe. Each #NMConnection object must contain
45 * a #NMSettingConnection setting.
48 G_DEFINE_TYPE_WITH_CODE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING,
49 _nm_register_setting (CONNECTION, 0))
50 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CONNECTION)
52 #define NM_SETTING_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionPrivate))
70 NMSettingConnectionAutoconnectSlaves autoconnect_slaves;
71 GSList *permissions; /* list of Permission structs */
73 gint autoconnect_priority;
77 GSList *secondaries; /* secondary connections to activate with the base connection */
78 guint gateway_ping_timeout;
80 NMSettingConnectionLldp lldp;
81 } NMSettingConnectionPrivate;
91 PROP_AUTOCONNECT_PRIORITY,
97 PROP_AUTOCONNECT_SLAVES,
99 PROP_GATEWAY_PING_TIMEOUT,
106 /***********************************************************************/
108 #define PERM_USER_PREFIX "user:"
111 permission_new_from_str (const char *str)
114 const char *last_colon;
117 g_return_val_if_fail (strncmp (str, PERM_USER_PREFIX, strlen (PERM_USER_PREFIX)) == 0, NULL);
118 str += strlen (PERM_USER_PREFIX);
120 last_colon = strrchr (str, ':');
122 /* Ensure that somebody didn't pass "user::" */
123 g_return_val_if_fail (last_colon > str, NULL);
125 /* Reject :[detail] for now */
126 g_return_val_if_fail (*(last_colon + 1) == '\0', NULL);
128 /* Make sure we don't include detail in the username */
129 ulen = last_colon - str;
133 /* Sanity check the length of the username */
134 g_return_val_if_fail (ulen < 100, NULL);
136 /* Make sure there's no ':' in the username */
137 for (i = 0; i < ulen; i++)
138 g_return_val_if_fail (str[i] != ':', NULL);
140 /* And the username must be valid UTF-8 */
141 g_return_val_if_fail (g_utf8_validate (str, -1, NULL) == TRUE, NULL);
143 /* Yay, valid... create the new permission */
144 p = g_slice_new0 (Permission);
145 p->ptype = PERM_TYPE_USER;
147 p->item = g_malloc (ulen + 1);
148 memcpy (p->item, str, ulen);
149 p->item[ulen] = '\0';
151 p->item = g_strdup (str);
157 permission_new (const char *uname)
161 g_return_val_if_fail (uname, NULL);
162 g_return_val_if_fail (uname[0] != '\0', NULL);
163 g_return_val_if_fail (strchr (uname, ':') == NULL, NULL);
164 g_return_val_if_fail (g_utf8_validate (uname, -1, NULL) == TRUE, NULL);
166 /* Yay, valid... create the new permission */
167 p = g_slice_new0 (Permission);
168 p->ptype = PERM_TYPE_USER;
169 p->item = g_strdup (uname);
174 permission_to_string (Permission *p)
176 return g_strdup_printf (PERM_USER_PREFIX "%s:", p->item);
180 permission_free (Permission *p)
183 memset (p, 0, sizeof (*p));
184 g_slice_free (Permission, p);
187 /***********************************************************************/
190 * nm_setting_connection_new:
192 * Creates a new #NMSettingConnection object with default values.
194 * Returns: the new empty #NMSettingConnection object
196 NMSetting *nm_setting_connection_new (void)
198 return (NMSetting *) g_object_new (NM_TYPE_SETTING_CONNECTION, NULL);
202 * nm_setting_connection_get_id:
203 * @setting: the #NMSettingConnection
205 * Returns the #NMSettingConnection:id property of the connection.
207 * Returns: the connection ID
210 nm_setting_connection_get_id (NMSettingConnection *setting)
212 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
214 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->id;
218 * nm_setting_connection_get_uuid:
219 * @setting: the #NMSettingConnection
221 * Returns the #NMSettingConnection:uuid property of the connection.
223 * Returns: the connection UUID
226 nm_setting_connection_get_uuid (NMSettingConnection *setting)
228 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
230 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->uuid;
234 * nm_setting_connection_get_interface_name:
235 * @setting: the #NMSettingConnection
237 * Returns the #NMSettingConnection:interface-name property of the connection.
239 * Returns: the connection's interface name
242 nm_setting_connection_get_interface_name (NMSettingConnection *setting)
244 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
246 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->interface_name;
250 * nm_setting_connection_get_connection_type:
251 * @setting: the #NMSettingConnection
253 * Returns the #NMSettingConnection:type property of the connection.
255 * Returns: the connection type
258 nm_setting_connection_get_connection_type (NMSettingConnection *setting)
260 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
262 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->type;
267 * nm_setting_connection_get_num_permissions:
268 * @setting: the #NMSettingConnection
270 * Returns the number of entires in the #NMSettingConnection:permissions
271 * property of this setting.
273 * Returns: the number of permissions entires
276 nm_setting_connection_get_num_permissions (NMSettingConnection *setting)
278 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
280 return g_slist_length (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->permissions);
284 * nm_setting_connection_get_permission:
285 * @setting: the #NMSettingConnection
286 * @idx: the zero-based index of the permissions entry
287 * @out_ptype: on return, the permission type (at this time, always "user")
288 * @out_pitem: on return, the permission item (formatted accoring to @ptype, see
289 * #NMSettingConnection:permissions for more detail
290 * @out_detail: on return, the permission detail (at this time, always %NULL)
292 * Retrieve one of the entries of the #NMSettingConnection:permissions property
295 * Returns: %TRUE if a permission was returned, %FALSE if @idx was invalid
298 nm_setting_connection_get_permission (NMSettingConnection *setting,
300 const char **out_ptype,
301 const char **out_pitem,
302 const char **out_detail)
304 NMSettingConnectionPrivate *priv;
307 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
309 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
311 g_return_val_if_fail (idx < g_slist_length (priv->permissions), FALSE);
313 p = g_slist_nth_data (priv->permissions, idx);
317 *out_pitem = p->item;
325 * nm_setting_connection_permissions_user_allowed:
326 * @setting: the #NMSettingConnection
327 * @uname: the user name to check permissions for
329 * Checks whether the given username is allowed to view/access this connection.
331 * Returns: %TRUE if the requested user is allowed to view this connection,
332 * %FALSE if the given user is not allowed to view this connection
335 nm_setting_connection_permissions_user_allowed (NMSettingConnection *setting,
338 NMSettingConnectionPrivate *priv;
341 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
342 g_return_val_if_fail (uname != NULL, FALSE);
343 g_return_val_if_fail (*uname != '\0', FALSE);
345 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
347 /* If no permissions, visible to all */
348 if (priv->permissions == NULL)
351 /* Find the username in the permissions list */
352 for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
353 Permission *p = iter->data;
355 if (strcmp (uname, p->item) == 0)
363 * nm_setting_connection_add_permission:
364 * @setting: the #NMSettingConnection
365 * @ptype: the permission type; at this time only "user" is supported
366 * @pitem: the permission item formatted as required for @ptype
367 * @detail: (allow-none): unused at this time; must be %NULL
369 * Adds a permission to the connection's permission list. At this time, only
370 * the "user" permission type is supported, and @pitem must be a username. See
371 * #NMSettingConnection:permissions: for more details.
373 * Returns: %TRUE if the permission was unique and was successfully added to the
374 * list, %FALSE if @ptype or @pitem was invalid or it the permission was already
375 * present in the list
378 nm_setting_connection_add_permission (NMSettingConnection *setting,
383 NMSettingConnectionPrivate *priv;
387 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
388 g_return_val_if_fail (ptype, FALSE);
389 g_return_val_if_fail (strlen (ptype) > 0, FALSE);
390 g_return_val_if_fail (detail == NULL, FALSE);
392 /* Only "user" for now... */
393 g_return_val_if_fail (strcmp (ptype, "user") == 0, FALSE);
395 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
398 for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
400 if (strcmp (pitem, p->item) == 0)
404 p = permission_new (pitem);
405 g_return_val_if_fail (p != NULL, FALSE);
406 priv->permissions = g_slist_append (priv->permissions, p);
407 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
413 * nm_setting_connection_remove_permission:
414 * @setting: the #NMSettingConnection
415 * @idx: the zero-based index of the permission to remove
417 * Removes the permission at index @idx from the connection.
420 nm_setting_connection_remove_permission (NMSettingConnection *setting,
423 NMSettingConnectionPrivate *priv;
426 g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
428 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
429 iter = g_slist_nth (priv->permissions, idx);
430 g_return_if_fail (iter != NULL);
432 permission_free ((Permission *) iter->data);
433 priv->permissions = g_slist_delete_link (priv->permissions, iter);
434 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
438 * nm_setting_connection_remove_permission_by_value:
439 * @setting: the #NMSettingConnection
440 * @ptype: the permission type; at this time only "user" is supported
441 * @pitem: the permission item formatted as required for @ptype
442 * @detail: (allow-none): unused at this time; must be %NULL
444 * Removes the permission from the connection.
445 * At this time, only the "user" permission type is supported, and @pitem must
446 * be a username. See #NMSettingConnection:permissions: for more details.
448 * Returns: %TRUE if the permission was found and removed; %FALSE if it was not.
451 nm_setting_connection_remove_permission_by_value (NMSettingConnection *setting,
456 NMSettingConnectionPrivate *priv;
460 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
461 g_return_val_if_fail (ptype, FALSE);
462 g_return_val_if_fail (strlen (ptype) > 0, FALSE);
463 g_return_val_if_fail (detail == NULL, FALSE);
465 /* Only "user" for now... */
466 g_return_val_if_fail (strcmp (ptype, "user") == 0, FALSE);
468 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
469 for (iter = priv->permissions; iter; iter = g_slist_next (iter)) {
471 if (strcmp (pitem, p->item) == 0) {
472 permission_free ((Permission *) iter->data);
473 priv->permissions = g_slist_delete_link (priv->permissions, iter);
474 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_PERMISSIONS);
482 * nm_setting_connection_get_autoconnect:
483 * @setting: the #NMSettingConnection
485 * Returns the #NMSettingConnection:autoconnect property of the connection.
487 * Returns: the connection's autoconnect behavior
490 nm_setting_connection_get_autoconnect (NMSettingConnection *setting)
492 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
494 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect;
498 * nm_setting_connection_get_autoconnect_priority:
499 * @setting: the #NMSettingConnection
501 * Returns the #NMSettingConnection:autoconnect-priority property of the connection.
502 * The higher number, the higher priority.
504 * Returns: the connection's autoconnect priority
507 nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting)
509 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
511 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_priority;
515 * nm_setting_connection_get_timestamp:
516 * @setting: the #NMSettingConnection
518 * Returns the #NMSettingConnection:timestamp property of the connection.
520 * Returns: the connection's timestamp
523 nm_setting_connection_get_timestamp (NMSettingConnection *setting)
525 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
527 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->timestamp;
531 * nm_setting_connection_get_read_only:
532 * @setting: the #NMSettingConnection
534 * Returns the #NMSettingConnection:read-only property of the connection.
536 * Returns: %TRUE if the connection is read-only, %FALSE if it is not
539 nm_setting_connection_get_read_only (NMSettingConnection *setting)
541 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), TRUE);
543 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->read_only;
547 * nm_setting_connection_get_zone:
548 * @setting: the #NMSettingConnection
550 * Returns the #NMSettingConnection:zone property of the connection.
552 * Returns: the trust level of a connection
555 nm_setting_connection_get_zone (NMSettingConnection *setting)
557 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
559 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->zone;
563 * nm_setting_connection_get_master:
564 * @setting: the #NMSettingConnection
566 * Returns the #NMSettingConnection:master property of the connection.
568 * Returns: interface name of the master device or UUID of the master
572 nm_setting_connection_get_master (NMSettingConnection *setting)
574 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
576 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->master;
580 * nm_setting_connection_get_slave_type:
581 * @setting: the #NMSettingConnection
583 * Returns the #NMSettingConnection:slave-type property of the connection.
585 * Returns: the type of slave this connection is, if any
588 nm_setting_connection_get_slave_type (NMSettingConnection *setting)
590 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
592 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type;
596 * nm_setting_connection_is_slave_type:
597 * @setting: the #NMSettingConnection
598 * @type: the setting name (ie #NM_SETTING_BOND_SETTING_NAME) to be matched
599 * against @setting's slave type
601 * Returns: %TRUE if connection is of the given slave @type
604 nm_setting_connection_is_slave_type (NMSettingConnection *setting,
607 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
609 return !g_strcmp0 (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type, type);
613 * nm_setting_connection_get_autoconnect_slaves:
614 * @setting: the #NMSettingConnection
616 * Returns the #NMSettingConnection:autoconnect-slaves property of the connection.
618 * Returns: whether slaves of the connection should be activated together
619 * with the connection.
623 NMSettingConnectionAutoconnectSlaves
624 nm_setting_connection_get_autoconnect_slaves (NMSettingConnection *setting)
626 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT);
628 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_slaves;
630 NM_BACKPORT_SYMBOL (libnm_1_0_4, NMSettingConnectionAutoconnectSlaves, nm_setting_connection_get_autoconnect_slaves, (NMSettingConnection *setting), (setting));
632 NM_BACKPORT_SYMBOL (libnm_1_0_4, GType, nm_setting_connection_autoconnect_slaves_get_type, (void), ());
635 * nm_setting_connection_get_num_secondaries:
636 * @setting: the #NMSettingConnection
638 * Returns: the number of configured secondary connection UUIDs
641 nm_setting_connection_get_num_secondaries (NMSettingConnection *setting)
643 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
645 return g_slist_length (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->secondaries);
649 * nm_setting_connection_get_secondary:
650 * @setting: the #NMSettingConnection
651 * @idx: the zero-based index of the secondary connection UUID entry
653 * Returns: the secondary connection UUID at index @idx
656 nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx)
658 NMSettingConnectionPrivate *priv;
660 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NULL);
662 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
663 g_return_val_if_fail (idx <= g_slist_length (priv->secondaries), NULL);
665 return (const char *) g_slist_nth_data (priv->secondaries, idx);
669 * nm_setting_connection_add_secondary:
670 * @setting: the #NMSettingConnection
671 * @sec_uuid: the secondary connection UUID to add
673 * Adds a new secondary connetion UUID to the setting.
675 * Returns: %TRUE if the secondary connection UUID was added; %FALSE if the UUID
676 * was already present
679 nm_setting_connection_add_secondary (NMSettingConnection *setting,
680 const char *sec_uuid)
682 NMSettingConnectionPrivate *priv;
685 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
686 g_return_val_if_fail (sec_uuid != NULL, FALSE);
687 g_return_val_if_fail (sec_uuid[0] != '\0', FALSE);
689 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
690 for (iter = priv->secondaries; iter; iter = g_slist_next (iter)) {
691 if (!strcmp (sec_uuid, (char *) iter->data))
695 priv->secondaries = g_slist_append (priv->secondaries, g_strdup (sec_uuid));
696 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
701 * nm_setting_connection_remove_secondary:
702 * @setting: the #NMSettingConnection
703 * @idx: index number of the secondary connection UUID
705 * Removes the secondary coonnection UUID at index @idx.
708 nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx)
710 NMSettingConnectionPrivate *priv;
713 g_return_if_fail (NM_IS_SETTING_CONNECTION (setting));
715 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
716 elt = g_slist_nth (priv->secondaries, idx);
717 g_return_if_fail (elt != NULL);
720 priv->secondaries = g_slist_delete_link (priv->secondaries, elt);
721 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
725 * nm_setting_connection_remove_secondary_by_value:
726 * @setting: the #NMSettingConnection
727 * @sec_uuid: the secondary connection UUID to remove
729 * Removes the secondary coonnection UUID @sec_uuid.
731 * Returns: %TRUE if the secondary connection UUID was found and removed; %FALSE if it was not.
734 nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting,
735 const char *sec_uuid)
737 NMSettingConnectionPrivate *priv;
740 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), FALSE);
741 g_return_val_if_fail (sec_uuid != NULL, FALSE);
742 g_return_val_if_fail (sec_uuid[0] != '\0', FALSE);
744 priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
745 for (iter = priv->secondaries; iter; iter = g_slist_next (iter)) {
746 if (!strcmp (sec_uuid, (char *) iter->data)) {
747 priv->secondaries = g_slist_delete_link (priv->secondaries, iter);
748 g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES);
756 * nm_setting_connection_get_gateway_ping_timeout:
757 * @setting: the #NMSettingConnection
759 * Returns: the value contained in the #NMSettingConnection:gateway-ping-timeout
763 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting)
765 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0);
767 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->gateway_ping_timeout;
771 * nm_setting_connection_get_metered:
772 * @setting: the #NMSettingConnection
774 * Returns: the #NMSettingConnection:metered property of the setting.
779 nm_setting_connection_get_metered (NMSettingConnection *setting)
781 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting),
784 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->metered;
787 NM_BACKPORT_SYMBOL (libnm_1_0_6, NMMetered, nm_setting_connection_get_metered, (NMSettingConnection *setting), (setting));
789 NM_BACKPORT_SYMBOL (libnm_1_0_6, GType, nm_metered_get_type, (void), ());
792 * nm_setting_connection_get_lldp:
793 * @setting: the #NMSettingConnection
795 * Returns the #NMSettingConnection:lldp property of the connection.
797 * Returns: a %NMSettingConnectionLldp which indicates whether LLDP must be
798 * enabled for the connection.
802 NMSettingConnectionLldp
803 nm_setting_connection_get_lldp (NMSettingConnection *setting)
805 g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NM_SETTING_CONNECTION_LLDP_DEFAULT);
807 return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->lldp;
811 _set_error_missing_base_setting (GError **error, const char *type)
815 NM_CONNECTION_ERROR_MISSING_SETTING,
816 _("setting required for connection of type '%s'"),
818 g_prefix_error (error, "%s: ", type);
822 verify (NMSetting *setting, NMConnection *connection, GError **error)
824 NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
826 const char *slave_setting_type = NULL;
827 NMSetting *normerr_base_type = NULL;
828 const char *normerr_slave_setting_type = NULL;
829 const char *normerr_missing_slave_type = NULL;
830 const char *normerr_missing_slave_type_port = NULL;
831 gboolean normerr_base_setting = FALSE;
834 g_set_error_literal (error,
836 NM_CONNECTION_ERROR_MISSING_PROPERTY,
837 _("property is missing"));
838 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID);
840 } else if (!priv->id[0]) {
841 g_set_error_literal (error,
843 NM_CONNECTION_ERROR_INVALID_PROPERTY,
844 _("property is empty"));
845 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_ID);
849 if (priv->uuid && !nm_utils_is_uuid (priv->uuid)) {
852 NM_CONNECTION_ERROR_INVALID_PROPERTY,
853 _("'%s' is not a valid UUID"),
855 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID);
859 if (priv->interface_name) {
860 if (!nm_utils_iface_valid_name (priv->interface_name)) {
863 NM_CONNECTION_ERROR_INVALID_PROPERTY,
864 _("'%s' is not a valid interface name"),
865 priv->interface_name);
866 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
872 if (!connection || !(normerr_base_type = _nm_connection_find_base_type_setting (connection))) {
873 g_set_error_literal (error,
875 NM_CONNECTION_ERROR_MISSING_PROPERTY,
876 _("property is missing"));
877 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
883 if (!priv->type[0]) {
884 g_set_error_literal (error,
886 NM_CONNECTION_ERROR_INVALID_PROPERTY,
887 _("property is empty"));
888 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
892 base_type = nm_setting_lookup_type (priv->type);
893 if (base_type == G_TYPE_INVALID || !_nm_setting_type_is_base_type (base_type)) {
896 NM_CONNECTION_ERROR_INVALID_PROPERTY,
897 _("connection type '%s' is not valid"),
899 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
903 /* Make sure the corresponding 'type' item is present */
905 && !nm_connection_get_setting_by_name (connection, priv->type)) {
907 NMConnection *connection2;
909 s_base = g_object_new (base_type, NULL);
910 connection2 = nm_simple_connection_new_clone (connection);
911 nm_connection_add_setting (connection2, s_base);
913 normerr_base_setting = nm_setting_verify (s_base, connection2, NULL);
915 g_object_unref (connection2);
917 if (!normerr_base_setting) {
918 _set_error_missing_base_setting (error, priv->type);
925 if (priv->slave_type)
926 is_slave = _nm_setting_slave_type_is_valid (priv->slave_type, &slave_setting_type);
928 if (priv->slave_type && !is_slave) {
931 NM_CONNECTION_ERROR_INVALID_PROPERTY,
932 _("Unknown slave type '%s'"), priv->slave_type);
933 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
941 NM_CONNECTION_ERROR_MISSING_PROPERTY,
942 _("Slave connections need a valid '%s' property"), NM_SETTING_CONNECTION_MASTER);
943 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER);
946 if ( slave_setting_type
948 && !nm_connection_get_setting_by_name (connection, slave_setting_type))
949 normerr_slave_setting_type = slave_setting_type;
952 const char *slave_type;
956 && (slave_type = _nm_connection_detect_slave_type (connection, &s_port))) {
957 normerr_missing_slave_type = slave_type;
958 normerr_missing_slave_type_port = nm_setting_get_name (s_port);
962 NM_CONNECTION_ERROR_MISSING_PROPERTY,
963 _("Cannot set '%s' without '%s'"),
964 NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_SLAVE_TYPE);
965 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
971 if (priv->metered != NM_METERED_UNKNOWN &&
972 priv->metered != NM_METERED_YES &&
973 priv->metered != NM_METERED_NO) {
976 NM_CONNECTION_ERROR_INVALID_PROPERTY,
977 _("metered value %d is not valid"), priv->metered);
978 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME,
979 NM_SETTING_CONNECTION_METERED);
983 /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
986 g_set_error_literal (error,
988 NM_CONNECTION_ERROR_MISSING_PROPERTY,
989 _("property is missing"));
990 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_UUID);
991 return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
994 if (normerr_base_type) {
997 NM_CONNECTION_ERROR_MISSING_PROPERTY,
998 _("property type should be set to '%s'"),
999 nm_setting_get_name (normerr_base_type));
1000 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE);
1001 return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
1004 if (normerr_base_setting) {
1005 _set_error_missing_base_setting (error, priv->type);
1006 return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
1009 if (normerr_slave_setting_type) {
1011 NM_CONNECTION_ERROR,
1012 NM_CONNECTION_ERROR_MISSING_SETTING,
1013 _("slave-type '%s' requires a '%s' setting in the connection"),
1014 priv->slave_type, normerr_slave_setting_type);
1015 g_prefix_error (error, "%s: ", normerr_slave_setting_type);
1016 return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
1019 if (normerr_missing_slave_type) {
1021 NM_CONNECTION_ERROR,
1022 NM_CONNECTION_ERROR_MISSING_PROPERTY,
1023 _("Detect a slave connection with '%s' set and a port type '%s'. '%s' should be set to '%s'"),
1024 NM_SETTING_CONNECTION_MASTER, normerr_missing_slave_type_port,
1025 NM_SETTING_CONNECTION_SLAVE_TYPE, normerr_missing_slave_type);
1026 g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
1027 return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
1034 find_virtual_interface_name (GVariant *connection_dict)
1036 GVariant *setting_dict;
1037 const char *interface_name;
1039 setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_BOND_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
1041 setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_BRIDGE_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
1043 setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_TEAM_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
1045 setting_dict = g_variant_lookup_value (connection_dict, NM_SETTING_VLAN_SETTING_NAME, NM_VARIANT_TYPE_SETTING);
1050 /* All of the deprecated virtual interface name properties were named "interface-name". */
1051 if (!g_variant_lookup (setting_dict, "interface-name", "&s", &interface_name))
1052 interface_name = NULL;
1054 g_variant_unref (setting_dict);
1055 return interface_name;
1059 nm_setting_connection_set_interface_name (NMSetting *setting,
1060 GVariant *connection_dict,
1061 const char *property,
1064 const char *interface_name;
1066 /* For compatibility reasons, if there is an invalid virtual interface name,
1067 * we need to make verification fail, even if that virtual name would be
1068 * overridden by a valid connection.interface-name.
1070 interface_name = find_virtual_interface_name (connection_dict);
1071 if (!interface_name || nm_utils_iface_valid_name (interface_name))
1072 interface_name = g_variant_get_string (value, NULL);
1074 g_object_set (G_OBJECT (setting),
1075 NM_SETTING_CONNECTION_INTERFACE_NAME, interface_name,
1080 nm_setting_connection_no_interface_name (NMSetting *setting,
1081 GVariant *connection_dict,
1082 const char *property)
1084 const char *virtual_interface_name;
1086 virtual_interface_name = find_virtual_interface_name (connection_dict);
1087 g_object_set (G_OBJECT (setting),
1088 NM_SETTING_CONNECTION_INTERFACE_NAME, virtual_interface_name,
1093 compare_property (NMSetting *setting,
1095 const GParamSpec *prop_spec,
1096 NMSettingCompareFlags flags)
1098 /* Handle ignore ID */
1099 if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_ID)
1100 && g_strcmp0 (prop_spec->name, NM_SETTING_CONNECTION_ID) == 0)
1103 /* Handle ignore timestamp */
1104 if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP)
1105 && g_strcmp0 (prop_spec->name, NM_SETTING_CONNECTION_TIMESTAMP) == 0)
1108 /* Otherwise chain up to parent to handle generic compare */
1109 return NM_SETTING_CLASS (nm_setting_connection_parent_class)->compare_property (setting, other, prop_spec, flags);
1113 nm_setting_connection_init (NMSettingConnection *setting)
1118 finalize (GObject *object)
1120 NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
1123 g_free (priv->uuid);
1124 g_free (priv->interface_name);
1125 g_free (priv->type);
1126 g_free (priv->zone);
1127 g_free (priv->master);
1128 g_free (priv->slave_type);
1129 g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
1130 g_slist_free_full (priv->secondaries, g_free);
1132 G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object);
1136 perm_strv_to_permlist (char **strv)
1138 GSList *list = NULL;
1144 for (i = 0; strv[i]; i++) {
1147 p = permission_new_from_str (strv[i]);
1149 list = g_slist_append (list, p);
1156 set_property (GObject *object, guint prop_id,
1157 const GValue *value, GParamSpec *pspec)
1159 NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (object);
1164 priv->id = g_value_dup_string (value);
1167 g_free (priv->uuid);
1168 priv->uuid = g_value_dup_string (value);
1170 case PROP_INTERFACE_NAME:
1171 g_free (priv->interface_name);
1172 priv->interface_name = g_value_dup_string (value);
1175 g_free (priv->type);
1176 priv->type = g_value_dup_string (value);
1178 case PROP_PERMISSIONS:
1179 g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
1180 priv->permissions = perm_strv_to_permlist (g_value_get_boxed (value));
1182 case PROP_AUTOCONNECT:
1183 priv->autoconnect = g_value_get_boolean (value);
1185 case PROP_AUTOCONNECT_PRIORITY:
1186 priv->autoconnect_priority = g_value_get_int (value);
1188 case PROP_TIMESTAMP:
1189 priv->timestamp = g_value_get_uint64 (value);
1191 case PROP_READ_ONLY:
1192 priv->read_only = g_value_get_boolean (value);
1195 g_free (priv->zone);
1196 priv->zone = g_value_dup_string (value);
1199 g_free (priv->master);
1200 priv->master = g_value_dup_string (value);
1202 case PROP_SLAVE_TYPE:
1203 g_free (priv->slave_type);
1204 priv->slave_type = g_value_dup_string (value);
1206 case PROP_AUTOCONNECT_SLAVES:
1207 priv->autoconnect_slaves = g_value_get_enum (value);
1209 case PROP_SECONDARIES:
1210 g_slist_free_full (priv->secondaries, g_free);
1211 priv->secondaries = _nm_utils_strv_to_slist (g_value_get_boxed (value), TRUE);
1213 case PROP_GATEWAY_PING_TIMEOUT:
1214 priv->gateway_ping_timeout = g_value_get_uint (value);
1217 priv->metered = g_value_get_enum (value);
1220 priv->lldp = g_value_get_int (value);
1223 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1229 perm_permlist_to_strv (GSList *permlist)
1234 strings = g_ptr_array_new ();
1235 for (iter = permlist; iter; iter = g_slist_next (iter))
1236 g_ptr_array_add (strings, permission_to_string ((Permission *) iter->data));
1237 g_ptr_array_add (strings, NULL);
1239 return (char **) g_ptr_array_free (strings, FALSE);
1243 get_property (GObject *object, guint prop_id,
1244 GValue *value, GParamSpec *pspec)
1246 NMSettingConnection *setting = NM_SETTING_CONNECTION (object);
1247 NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
1251 g_value_set_string (value, nm_setting_connection_get_id (setting));
1254 g_value_set_string (value, nm_setting_connection_get_uuid (setting));
1256 case PROP_INTERFACE_NAME:
1257 g_value_set_string (value, nm_setting_connection_get_interface_name (setting));
1260 g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
1262 case PROP_PERMISSIONS:
1263 g_value_take_boxed (value, perm_permlist_to_strv (priv->permissions));
1265 case PROP_AUTOCONNECT:
1266 g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
1268 case PROP_AUTOCONNECT_PRIORITY:
1269 g_value_set_int (value, nm_setting_connection_get_autoconnect_priority (setting));
1271 case PROP_TIMESTAMP:
1272 g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting));
1274 case PROP_READ_ONLY:
1275 g_value_set_boolean (value, nm_setting_connection_get_read_only (setting));
1278 g_value_set_string (value, nm_setting_connection_get_zone (setting));
1281 g_value_set_string (value, nm_setting_connection_get_master (setting));
1283 case PROP_SLAVE_TYPE:
1284 g_value_set_string (value, nm_setting_connection_get_slave_type (setting));
1286 case PROP_AUTOCONNECT_SLAVES:
1287 g_value_set_enum (value, nm_setting_connection_get_autoconnect_slaves (setting));
1289 case PROP_SECONDARIES:
1290 g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->secondaries, TRUE));
1292 case PROP_GATEWAY_PING_TIMEOUT:
1293 g_value_set_uint (value, priv->gateway_ping_timeout);
1296 g_value_set_enum (value, priv->metered);
1299 g_value_set_int (value, priv->lldp);
1302 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1308 nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
1310 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
1311 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
1313 g_type_class_add_private (setting_class, sizeof (NMSettingConnectionPrivate));
1315 /* virtual methods */
1316 object_class->set_property = set_property;
1317 object_class->get_property = get_property;
1318 object_class->finalize = finalize;
1319 parent_class->verify = verify;
1320 parent_class->compare_property = compare_property;
1325 * NMSettingConnection:id:
1327 * A human readable unique identifier for the connection, like "Work Wi-Fi"
1333 * description: User friendly name for the connection profile.
1336 g_object_class_install_property
1337 (object_class, PROP_ID,
1338 g_param_spec_string (NM_SETTING_CONNECTION_ID, "", "",
1341 NM_SETTING_PARAM_FUZZY_IGNORE |
1342 G_PARAM_STATIC_STRINGS));
1345 * NMSettingConnection:uuid:
1347 * A universally unique identifier for the connection, for example generated
1348 * with libuuid. It should be assigned when the connection is created, and
1349 * never changed as long as the connection still applies to the same
1350 * network. For example, it should not be changed when the
1351 * #NMSettingConnection:id property or #NMSettingIP4Config changes, but
1352 * might need to be re-created when the Wi-Fi SSID, mobile broadband network
1353 * provider, or #NMSettingConnection:type property changes.
1355 * The UUID must be in the format "2815492f-7e56-435e-b2e9-246bd7cdc664"
1356 * (ie, contains only hexadecimal characters and "-"). A suitable UUID may
1357 * be generated by nm_utils_uuid_generate() or
1358 * nm_utils_uuid_generate_from_string().
1363 * description: UUID for the connection profile. When missing, NetworkManager
1364 * creates the UUID itself (by hashing the file).
1367 g_object_class_install_property
1368 (object_class, PROP_UUID,
1369 g_param_spec_string (NM_SETTING_CONNECTION_UUID, "", "",
1372 NM_SETTING_PARAM_FUZZY_IGNORE |
1373 G_PARAM_STATIC_STRINGS));
1376 * NMSettingConnection:interface-name:
1378 * The name of the network interface this connection is bound to. If not
1379 * set, then the connection can be attached to any interface of the
1380 * appropriate type (subject to restrictions imposed by other settings).
1382 * For software devices this specifies the name of the created device.
1384 * For connection types where interface names cannot easily be made
1385 * persistent (e.g. mobile broadband or USB Ethernet), this property should
1386 * not be used. Setting this property restricts the interfaces a connection
1387 * can be used with, and if interface names change or are reordered the
1388 * connection may be applied to the wrong interface.
1391 * property: interface-name
1393 * description: Interface name of the device this profile is bound to. The variable
1394 * can be left out when the profile should apply for more devices. Note that DEVICE
1395 * can be required for some connection types.
1398 g_object_class_install_property
1399 (object_class, PROP_INTERFACE_NAME,
1400 g_param_spec_string (NM_SETTING_CONNECTION_INTERFACE_NAME, "", "",
1403 NM_SETTING_PARAM_INFERRABLE |
1404 G_PARAM_STATIC_STRINGS));
1405 _nm_setting_class_override_property (parent_class, NM_SETTING_CONNECTION_INTERFACE_NAME,
1406 G_VARIANT_TYPE_STRING,
1408 nm_setting_connection_set_interface_name,
1409 nm_setting_connection_no_interface_name);
1412 * NMSettingConnection:type:
1414 * Base type of the connection. For hardware-dependent connections, should
1415 * contain the setting name of the hardware-type specific setting (ie,
1416 * "802-3-ethernet" or "802-11-wireless" or "bluetooth", etc), and for
1417 * non-hardware dependent connections like VPN or otherwise, should contain
1418 * the setting name of that setting type (ie, "vpn" or "bridge", etc).
1422 * variable: TYPE (DEVICETYPE, DEVICE)
1423 * values: Ethernet, Wireless, InfiniBand, Bridge, Bond, Vlan, Team, TeamPort
1424 * description: Base type of the connection. DEVICETYPE is used for teaming
1426 * example: TYPE=Ethernet; TYPE=Bond; TYPE=Bridge; DEVICETYPE=TeamPort
1429 g_object_class_install_property
1430 (object_class, PROP_TYPE,
1431 g_param_spec_string (NM_SETTING_CONNECTION_TYPE, "", "",
1434 NM_SETTING_PARAM_INFERRABLE |
1435 G_PARAM_STATIC_STRINGS));
1438 * NMSettingConnection:permissions:
1440 * An array of strings defining what access a given user has to this
1441 * connection. If this is %NULL or empty, all users are allowed to access
1442 * this connection. Otherwise a user is allowed to access this connection
1443 * if and only if they are in this list. Each entry is of the form
1444 * "[type]:[id]:[reserved]"; for example, "user:dcbw:blah".
1446 * At this time only the "user" [type] is allowed. Any other values are
1447 * ignored and reserved for future use. [id] is the username that this
1448 * permission refers to, which may not contain the ":" character. Any
1449 * [reserved] information present must be ignored and is reserved for future
1450 * use. All of [type], [id], and [reserved] must be valid UTF-8.
1453 * property: permissions
1454 * variable: USERS(+)
1455 * description: USERS restrict the access for this conenction to certain
1457 * example: USERS="joe bob"
1460 g_object_class_install_property
1461 (object_class, PROP_PERMISSIONS,
1462 g_param_spec_boxed (NM_SETTING_CONNECTION_PERMISSIONS, "", "",
1465 G_PARAM_STATIC_STRINGS));
1468 * NMSettingConnection:autoconnect:
1470 * Whether or not the connection should be automatically connected by
1471 * NetworkManager when the resources for the connection are available.
1472 * %TRUE to automatically activate the connection, %FALSE to require manual
1473 * intervention to activate the connection.
1476 * property: autoconnect
1479 * description: Whether the connection should be autoconnected (not only while booting).
1482 g_object_class_install_property
1483 (object_class, PROP_AUTOCONNECT,
1484 g_param_spec_boolean (NM_SETTING_CONNECTION_AUTOCONNECT, "", "",
1488 NM_SETTING_PARAM_FUZZY_IGNORE |
1489 G_PARAM_STATIC_STRINGS));
1492 * NMSettingConnection:autoconnect-priority:
1494 * The autoconnect priority. If the connection is set to autoconnect,
1495 * connections with higher priority will be preferred. Defaults to 0.
1496 * The higher number means higher priority.
1499 * property: autoconnect-priority
1500 * variable: AUTOCONNECT_PRIORITY(+)
1501 * values: -999 to 999
1503 * description: Connection priority for automatic activation. Connections with
1504 * higher numbers are preferred when selecting profiles for automatic activation.
1505 * example: AUTOCONNECT_PRIORITY=20
1508 g_object_class_install_property
1509 (object_class, PROP_AUTOCONNECT_PRIORITY,
1510 g_param_spec_int (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, "", "",
1511 NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN,
1512 NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX,
1513 NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT,
1516 NM_SETTING_PARAM_FUZZY_IGNORE |
1517 G_PARAM_STATIC_STRINGS));
1520 * NMSettingConnection:timestamp:
1522 * The time, in seconds since the Unix Epoch, that the connection was last
1523 * _successfully_ fully activated.
1525 * NetworkManager updates the connection timestamp periodically when the
1526 * connection is active to ensure that an active connection has the latest
1527 * timestamp. The property is only meant for reading (changes to this
1528 * property will not be preserved).
1530 g_object_class_install_property
1531 (object_class, PROP_TIMESTAMP,
1532 g_param_spec_uint64 (NM_SETTING_CONNECTION_TIMESTAMP, "", "",
1536 NM_SETTING_PARAM_FUZZY_IGNORE |
1537 G_PARAM_STATIC_STRINGS));
1540 * NMSettingConnection:read-only:
1542 * %FALSE if the connection can be modified using the provided settings
1543 * service's D-Bus interface with the right privileges, or %TRUE if the
1544 * connection is read-only and cannot be modified.
1546 g_object_class_install_property
1547 (object_class, PROP_READ_ONLY,
1548 g_param_spec_boolean (NM_SETTING_CONNECTION_READ_ONLY, "", "",
1552 NM_SETTING_PARAM_FUZZY_IGNORE |
1553 G_PARAM_STATIC_STRINGS));
1556 * NMSettingConnection:zone:
1558 * The trust level of a the connection. Free form case-insensitive string
1559 * (for example "Home", "Work", "Public"). %NULL or unspecified zone means
1560 * the connection will be placed in the default zone as defined by the
1563 * When updating this property on a currently activated connection,
1564 * the change takes effect immediately.
1569 * description: Trust level of this connection. The string is usually used
1571 * example: ZONE=Work
1574 g_object_class_install_property
1575 (object_class, PROP_ZONE,
1576 g_param_spec_string (NM_SETTING_CONNECTION_ZONE, "", "",
1580 NM_SETTING_PARAM_FUZZY_IGNORE |
1581 NM_SETTING_PARAM_REAPPLY_IMMEDIATELY |
1582 G_PARAM_STATIC_STRINGS));
1585 * NMSettingConnection:master:
1587 * Interface name of the master device or UUID of the master connection.
1591 * variable: MASTER, TEAM_MASTER, BRIDGE
1592 * description: Reference to master connection. The variable used depends on
1593 * the connection type.
1596 g_object_class_install_property
1597 (object_class, PROP_MASTER,
1598 g_param_spec_string (NM_SETTING_CONNECTION_MASTER, "", "",
1601 NM_SETTING_PARAM_FUZZY_IGNORE |
1602 NM_SETTING_PARAM_INFERRABLE |
1603 G_PARAM_STATIC_STRINGS));
1606 * NMSettingConnection:slave-type:
1608 * Setting name of the device type of this slave's master connection (eg,
1609 * %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is not a
1613 * property: slave-type
1614 * variable: MASTER, TEAM_MASTER, DEVICETYPE, BRIDGE
1615 * description: Slave type doesn't map directly to a variable, but it is
1616 * recognized using different variables. MASTER for bonding,
1617 * TEAM_MASTER and DEVICETYPE for teaming, BRIDGE for bridging.
1620 g_object_class_install_property
1621 (object_class, PROP_SLAVE_TYPE,
1622 g_param_spec_string (NM_SETTING_CONNECTION_SLAVE_TYPE, "", "",
1625 NM_SETTING_PARAM_FUZZY_IGNORE |
1626 NM_SETTING_PARAM_INFERRABLE |
1627 G_PARAM_STATIC_STRINGS));
1630 * NMSettingConnection:autoconnect-slaves:
1632 * Whether or not slaves of this connection should be automatically brought up
1633 * when NetworkManager activates this connection. This only has a real effect
1634 * for master connections.
1635 * The permitted values are: 0: leave slave connections untouched,
1636 * 1: activate all the slave connections with this connection, -1: default.
1637 * If -1 (default) is set, global connection.autoconnect-slaves is read to
1638 * determine the real value. If it is default as well, this fallbacks to 0.
1643 * property: autoconnect-slaves
1644 * variable: AUTOCONNECT-SLAVES(+)
1645 * default: missing variable means global default
1646 * description: Whether slaves of this connection should be auto-connected
1647 * when this connection is activated.
1650 g_object_class_install_property
1651 (object_class, PROP_AUTOCONNECT_SLAVES,
1652 g_param_spec_enum (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, "", "",
1653 NM_TYPE_SETTING_CONNECTION_AUTOCONNECT_SLAVES,
1654 NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT,
1657 NM_SETTING_PARAM_FUZZY_IGNORE |
1658 G_PARAM_STATIC_STRINGS));
1661 * NMSettingConnection:secondaries:
1663 * List of connection UUIDs that should be activated when the base
1664 * connection itself is activated. Currently only VPN connections are
1668 * property: secondaries
1669 * variable: SECONDARY_UUIDS(+)
1670 * description: UUID of VPN connections that should be activated
1671 * together with this connection.
1674 g_object_class_install_property
1675 (object_class, PROP_SECONDARIES,
1676 g_param_spec_boxed (NM_SETTING_CONNECTION_SECONDARIES, "", "",
1679 NM_SETTING_PARAM_FUZZY_IGNORE |
1680 G_PARAM_STATIC_STRINGS));
1683 * NMSettingConnection:gateway-ping-timeout:
1685 * If greater than zero, delay success of IP addressing until either the
1686 * timeout is reached, or an IP gateway replies to a ping.
1689 * property: gateway-ping-timeout
1690 * variable: GATEWAY_PING_TIMEOUT(+)
1692 * description: If greater than zero, the IP connectivity will be checked by
1693 * pinging the gateway and waiting for the specified timeout (in seconds).
1694 * example: GATEWAY_PING_TIMEOUT=5
1697 g_object_class_install_property
1698 (object_class, PROP_GATEWAY_PING_TIMEOUT,
1699 g_param_spec_uint (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, "", "",
1703 G_PARAM_STATIC_STRINGS));
1706 * NMSettingConnection:metered:
1708 * Whether the connection is metered.
1710 * When updating this property on a currently activated connection,
1711 * the change takes effect immediately.
1717 * variable: CONNECTION_METERED
1718 * values: yes,no,unknown
1719 * description: Whether the device is metered
1720 * example: CONNECTION_METERED=yes
1723 g_object_class_install_property
1724 (object_class, PROP_METERED,
1725 g_param_spec_enum (NM_SETTING_CONNECTION_METERED, "", "",
1729 NM_SETTING_PARAM_REAPPLY_IMMEDIATELY |
1730 G_PARAM_STATIC_STRINGS));
1733 * NMSettingConnection:lldp:
1735 * Whether LLDP is enabled for the connection.
1742 * values: boolean value or 'rx'
1743 * default: missing variable means global default
1744 * description: whether LLDP is enabled for the connection
1748 g_object_class_install_property
1749 (object_class, PROP_LLDP,
1750 g_param_spec_int (NM_SETTING_CONNECTION_LLDP, "", "",
1751 G_MININT32, G_MAXINT32, NM_SETTING_CONNECTION_LLDP_DEFAULT,
1752 NM_SETTING_PARAM_FUZZY_IGNORE |
1755 G_PARAM_STATIC_STRINGS));