diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-04-27 17:45:53 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-06-09 18:11:25 +0200 |
commit | 6f647fe689ddc5102c7a4492740a96f043d4a478 (patch) | |
tree | 51a0007f17c322cfdf71f7742df98d09ecbaf25d | |
parent | f208e7030f9b305bee4063d541163e47e2f51c06 (diff) | |
download | NetworkManager-6f647fe689ddc5102c7a4492740a96f043d4a478.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.
-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 7bc927bc1d..b2274d36b0 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -74,6 +74,7 @@ typedef struct { char *zone; GSList *secondaries; /* secondary connections to activate with the base connection */ guint gateway_ping_timeout; + NMMetered metered; } NMSettingConnectionPrivate; enum { @@ -92,6 +93,7 @@ enum { PROP_SLAVE_TYPE, PROP_SECONDARIES, PROP_GATEWAY_PING_TIMEOUT, + PROP_METERED, LAST_PROP }; @@ -738,6 +740,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.2 + **/ +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) { @@ -899,6 +918,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) { @@ -1129,6 +1160,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; @@ -1199,6 +1233,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; @@ -1567,4 +1604,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.2 + **/ + 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 d1ad0fe1e5..1692fe2c53 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -58,6 +58,7 @@ G_BEGIN_DECLS #define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type" #define NM_SETTING_CONNECTION_SECONDARIES "secondaries" #define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout" +#define NM_SETTING_CONNECTION_METERED "metered" /** * NMSettingConnection: @@ -119,6 +120,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_2 +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 55e905d5e8..1aca515a88 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -1967,6 +1967,7 @@ test_connection_diff_a_only (void) { NM_SETTING_CONNECTION_SLAVE_TYPE, 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 c77069bc3c..34890414c3 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -853,6 +853,7 @@ global: nm_metered_get_type; nm_setting_802_1x_check_cert_scheme; nm_setting_bridge_get_multicast_snooping; + nm_setting_connection_get_metered; nm_setting_ip_config_add_dns_option; nm_setting_ip_config_clear_dns_options; nm_setting_ip_config_get_dns_option; |