diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-04-27 17:45:53 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-07-22 13:52:45 +0200 |
commit | 4eb05767ee125dd388881a3154a0f6366f40fbf0 (patch) | |
tree | 5f1ba60b3cfb85abc7e43f4d9c8b6ab6926725c7 | |
parent | e16c0682898bfa899d440b6325f13e9546981614 (diff) | |
download | NetworkManager-4eb05767ee125dd388881a3154a0f6366f40fbf0.tar.gz |
libnm-core: add 'metered' property to NMSettingConnection
Add a 'metered' enum property to NMSettingConnection with possible
values: unknown,yes,no. The value indicates the presence of limitations
in the amount of traffic flowing through the connection.
(cherry picked from commit 6f647fe689ddc5102c7a4492740a96f043d4a478)
-rw-r--r-- | libnm-core/nm-setting-connection.c | 52 | ||||
-rw-r--r-- | libnm-core/nm-setting-connection.h | 3 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 1 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
4 files changed, 57 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 07b3401d1e..b73d2289f0 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -76,6 +76,7 @@ typedef struct { char *zone; GSList *secondaries; /* secondary connections to activate with the base connection */ guint gateway_ping_timeout; + NMMetered metered; } NMSettingConnectionPrivate; enum { @@ -95,6 +96,7 @@ enum { PROP_AUTOCONNECT_SLAVES, PROP_SECONDARIES, PROP_GATEWAY_PING_TIMEOUT, + PROP_METERED, LAST_PROP }; @@ -760,6 +762,23 @@ nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting) return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->gateway_ping_timeout; } +/** + * nm_setting_connection_get_metered: + * @setting: the #NMSettingConnection + * + * Returns: the #NMSettingConnection:metered property of the setting. + * + * Since: 1.0.6 + **/ +NMMetered +nm_setting_connection_get_metered (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), + NM_METERED_UNKNOWN); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->metered; +} + static void _set_error_missing_base_setting (GError **error, const char *type) { @@ -921,6 +940,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } + if (priv->metered != NM_METERED_UNKNOWN && + priv->metered != NM_METERED_YES && + priv->metered != NM_METERED_NO) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("metered value %d is not valid"), priv->metered); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_METERED); + return FALSE; + } + /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */ if (!priv->uuid) { @@ -1154,6 +1185,9 @@ set_property (GObject *object, guint prop_id, case PROP_GATEWAY_PING_TIMEOUT: priv->gateway_ping_timeout = g_value_get_uint (value); break; + case PROP_METERED: + priv->metered = g_value_get_enum (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1227,6 +1261,9 @@ get_property (GObject *object, guint prop_id, case PROP_GATEWAY_PING_TIMEOUT: g_value_set_uint (value, priv->gateway_ping_timeout); break; + case PROP_METERED: + g_value_set_enum (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1626,4 +1663,19 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)); + + /** + * NMSettingConnection:metered: + * + * Whether the connection is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_enum (NM_SETTING_CONNECTION_METERED, "", "", + NM_TYPE_METERED, + NM_METERED_UNKNOWN, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index ff89d20081..24b5f6accc 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -59,6 +59,7 @@ G_BEGIN_DECLS #define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves" #define NM_SETTING_CONNECTION_SECONDARIES "secondaries" #define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout" +#define NM_SETTING_CONNECTION_METERED "metered" /* Types for property values */ /** @@ -142,6 +143,8 @@ void nm_setting_connection_remove_secondary (NMSettingConnection *set gboolean nm_setting_connection_remove_secondary_by_value (NMSettingConnection *setting, const char *sec_uuid); guint32 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting); +NM_AVAILABLE_IN_1_0_6 +NMMetered nm_setting_connection_get_metered (NMSettingConnection *setting); G_END_DECLS diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index bd144f384b..a077740dc9 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -1969,6 +1969,7 @@ test_connection_diff_a_only (void) { NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_SECONDARIES, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_CONNECTION_METERED, NM_SETTING_DIFF_RESULT_IN_A }, { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN } } }, { NM_SETTING_WIRED_SETTING_NAME, { diff --git a/libnm/libnm.ver b/libnm/libnm.ver index b33f11812b..ecdfc3416c 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -855,5 +855,6 @@ libnm_1_0_6 { global: nm_device_get_metered; nm_metered_get_type; + nm_setting_connection_get_metered; } libnm_1_0_4; |