diff options
author | Dan Winship <danw@gnome.org> | 2012-11-08 13:15:41 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-02-15 13:40:38 -0500 |
commit | 5266e25e2badd61048e403c93a39091d8382f7f1 (patch) | |
tree | 3feb6f1d296c9f95174b5af8ba9a179ee0f9e555 /libnm-util/nm-setting-infiniband.c | |
parent | fe307dbd3e22203b10cf1f1fcaffb14b52a0a347 (diff) | |
download | NetworkManager-5266e25e2badd61048e403c93a39091d8382f7f1.tar.gz |
libnm-utils: add :carrier-detect properties
For settings corresponding to devices that have a :carrier property
(ie bond, bridge, infiniband, vlan, and wired), add a :carrier-detect
property specifying how that affects the connection:
yes: The connection can only be activated when the device
has carrier, and will be deactivated if the device loses
carrier (for more than 4 seconds).
no: The connection ignores carrier on the device; it can be
activated when there is no carrier, and stays activated
when carrier is lost.
on-activate: The connection can only be activated when the
device has carrier, but it will not be deactivated if the
device loses carrier.
https://bugzilla.gnome.org/show_bug.cgi?id=688284
Diffstat (limited to 'libnm-util/nm-setting-infiniband.c')
-rw-r--r-- | libnm-util/nm-setting-infiniband.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c index ee40aa0ec9..c23ab919bb 100644 --- a/libnm-util/nm-setting-infiniband.c +++ b/libnm-util/nm-setting-infiniband.c @@ -66,6 +66,7 @@ typedef struct { GByteArray *mac_address; char *transport_mode; guint32 mtu; + char *carrier_detect; } NMSettingInfinibandPrivate; enum { @@ -73,6 +74,7 @@ enum { PROP_MAC_ADDRESS, PROP_MTU, PROP_TRANSPORT_MODE, + PROP_CARRIER_DETECT, LAST_PROP }; @@ -135,6 +137,21 @@ nm_setting_infiniband_get_transport_mode (NMSettingInfiniband *setting) return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->transport_mode; } +/** + * nm_setting_infiniband_get_carrier_detect: + * @setting: the #NMSettingInfiniband + * + * Returns: the connection's carrier-detection behavior; + * See #NMSettingInfiniband:carrier-detect. + **/ +const char * +nm_setting_infiniband_get_carrier_detect (NMSettingInfiniband *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL); + + return NM_SETTING_INFINIBAND_GET_PRIVATE (setting)->carrier_detect; +} + static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) @@ -163,6 +180,14 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + if (priv->carrier_detect && !_nm_utils_carrier_detect_mode_valid (priv->carrier_detect)) { + g_set_error (error, + NM_SETTING_INFINIBAND_ERROR, + NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY, + NM_SETTING_INFINIBAND_CARRIER_DETECT); + return FALSE; + } + return TRUE; } @@ -203,6 +228,10 @@ set_property (GObject *object, guint prop_id, g_free (priv->transport_mode); priv->transport_mode = g_value_dup_string (value); break; + case PROP_CARRIER_DETECT: + g_free (priv->carrier_detect); + priv->carrier_detect = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -225,6 +254,9 @@ get_property (GObject *object, guint prop_id, case PROP_TRANSPORT_MODE: g_value_set_string (value, nm_setting_infiniband_get_transport_mode (setting)); break; + case PROP_CARRIER_DETECT: + g_value_set_string (value, nm_setting_infiniband_get_carrier_detect (setting)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -293,5 +325,23 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class) "The IPoIB transport mode. Either 'datagram' or 'connected'.", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingInfiniband:carrier-detect: + * + * Controls whether device carrier affects this connection. Possible values + * are 'no', meaning the connection completely ignores carrier; 'yes', + * meaning the connection can only be activated if carrier is present, + * and will be deactivated automatically if carrier is lost; and + * 'on-activate', meaning the connection can only be activated if carrier + * is present, but will not be deactivated if carrier is lost. + **/ + g_object_class_install_property + (object_class, PROP_CARRIER_DETECT, + g_param_spec_string (NM_SETTING_INFINIBAND_CARRIER_DETECT, + "Carrier-detect", + "Controls whether device carrier affects this connection.", + "yes", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); } |