diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index e405a384ba..b2e3827e2a 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -139,6 +139,12 @@ The device MTU (maximum transmission unit). + + + Whether the amount of traffic flowing through the device is + subject to limitations, for example set by service providers. + + @@ -654,6 +660,34 @@ + + + + The device metered status is unknown. + + + + + The device is metered and the value was statically set. + + + + + The device is not metered and the value was statically set. + + + + + The device is metered and the value was guessed. + + + + + The device is not metered and the value was guessed. + + + + diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index ccc3b3a9e9..8c5cd3c4c1 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -403,7 +403,6 @@ typedef enum { NM_DEVICE_STATE_FAILED = 120 } NMDeviceState; - /** * NMDeviceStateReason: * @NM_DEVICE_STATE_REASON_NONE: No reason given @@ -540,6 +539,26 @@ typedef enum { NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62, } NMDeviceStateReason; +/** + * NMMetered: + * @NM_METERED_UNKNOWN: The metered status is unknown + * @NM_METERED_YES: Metered, the value was statically set + * @NM_METERED_NO: Not metered, the value was statically set + * @NM_METERED_GUESS_YES: Metered, the value was guessed + * @NM_METERED_GUESS_NO: Not metered, the value was guessed + * + * (Corresponds to the NM_METERED type in nm-device.xml.) + * + * Since: 1.0.6 + **/ +NM_AVAILABLE_IN_1_0_6 +typedef enum { + NM_METERED_UNKNOWN = 0, + NM_METERED_YES = 1, + NM_METERED_NO = 2, + NM_METERED_GUESS_YES = 3, + NM_METERED_GUESS_NO = 4, +} NMMetered; /** * NMActiveConnectionState: diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 294bab4109..b33f11812b 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -851,3 +851,9 @@ global: nm_setting_connection_get_autoconnect_slaves; } libnm_1_0_0; +libnm_1_0_6 { +global: + nm_device_get_metered; + nm_metered_get_type; +} libnm_1_0_4; + diff --git a/libnm/nm-device.c b/libnm/nm-device.c index cd14c0e902..d3ac705c1c 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -81,6 +81,7 @@ typedef struct { char *driver_version; char *firmware_version; char *type_description; + NMMetered metered; NMDeviceCapabilities capabilities; gboolean managed; gboolean firmware_missing; @@ -130,6 +131,7 @@ enum { PROP_AVAILABLE_CONNECTIONS, PROP_PHYSICAL_PORT_ID, PROP_MTU, + PROP_METERED, LAST_PROP }; @@ -193,6 +195,7 @@ init_dbus (NMObject *object) { NM_DEVICE_AVAILABLE_CONNECTIONS, &priv->available_connections, NULL, NM_TYPE_REMOTE_CONNECTION }, { NM_DEVICE_PHYSICAL_PORT_ID, &priv->physical_port_id }, { NM_DEVICE_MTU, &priv->mtu }, + { NM_DEVICE_METERED, &priv->metered }, /* Properties that exist in D-Bus but that we don't track */ { "ip4-address", NULL }, @@ -449,6 +452,9 @@ get_property (GObject *object, case PROP_MTU: g_value_set_uint (value, nm_device_get_mtu (device)); break; + case PROP_METERED: + g_value_set_uint (value, nm_device_get_metered (device)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -793,6 +799,20 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMDevice:metered: + * + * Whether the device is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_DEVICE_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* signals */ /** @@ -1883,6 +1903,24 @@ nm_device_get_mtu (NMDevice *device) return NM_DEVICE_GET_PRIVATE (device)->mtu; } +/** + * nm_device_get_metered: + * @device: a #NMDevice + * + * Gets the metered setting of a #NMDevice. + * + * Returns: the metered setting. + * + * Since: 1.0.6 + **/ +NMMetered +nm_device_get_metered (NMDevice *device) +{ + g_return_val_if_fail (NM_IS_DEVICE (device), NM_METERED_UNKNOWN); + + return NM_DEVICE_GET_PRIVATE (device)->metered; +} + /** * nm_device_is_software: * @device: a #NMDevice diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5cc3735695..a61dcf3234 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -60,6 +60,7 @@ G_BEGIN_DECLS #define NM_DEVICE_PRODUCT "product" #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" +#define NM_DEVICE_METERED "metered" struct _NMDevice { NMObject parent; @@ -119,6 +120,8 @@ gboolean nm_device_is_software (NMDevice *device); const char * nm_device_get_product (NMDevice *device); const char * nm_device_get_vendor (NMDevice *device); const char * nm_device_get_description (NMDevice *device); +NM_AVAILABLE_IN_1_0_6 +NMMetered nm_device_get_metered (NMDevice *device); char ** nm_device_disambiguate_names (NMDevice **devices, int num_devices); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 75f4a2972d..4c4e04108d 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -128,6 +128,7 @@ enum { PROP_MASTER, PROP_HW_ADDRESS, PROP_HAS_PENDING_ACTION, + PROP_METERED, LAST_PROP }; @@ -338,6 +339,8 @@ typedef struct { gboolean is_master; GSList * slaves; /* list of SlaveInfo */ + NMMetered metered; + NMConnectionProvider *con_provider; } NMDevicePrivate; @@ -687,6 +690,21 @@ nm_device_get_device_type (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->type; } +/** + * nm_device_get_metered: + * @setting: the #NMDevice + * + * Returns: the #NMDevice:metered property of the device. + * + * Since: 1.0.6 + **/ +NMMetered +nm_device_get_metered (NMDevice *self) +{ + g_return_val_if_fail (NM_IS_DEVICE (self), NM_METERED_UNKNOWN); + + return NM_DEVICE_GET_PRIVATE (self)->metered; +} /** * nm_device_get_priority(): @@ -9298,6 +9316,9 @@ get_property (GObject *object, guint prop_id, case PROP_HAS_PENDING_ACTION: g_value_set_boolean (value, nm_device_has_pending_action (self)); break; + case PROP_METERED: + g_value_set_uint (value, priv->metered); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -9561,6 +9582,20 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * NMDevice:metered: + * + * Whether the connection is metered. + * + * Since: 1.0.6 + **/ + g_object_class_install_property + (object_class, PROP_METERED, + g_param_spec_uint (NM_DEVICE_METERED, "", "", + 0, G_MAXUINT32, NM_METERED_UNKNOWN, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + /* Signals */ signals[STATE_CHANGED] = g_signal_new ("state-changed", diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index f1dab9bf21..e9d5b9488d 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -58,6 +58,7 @@ #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" #define NM_DEVICE_HW_ADDRESS "hw-address" +#define NM_DEVICE_METERED "metered" #define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */ #define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */ @@ -74,7 +75,6 @@ #define NM_DEVICE_RECHECK_AUTO_ACTIVATE "recheck-auto-activate" #define NM_DEVICE_RECHECK_ASSUME "recheck-assume" - G_BEGIN_DECLS #define NM_TYPE_DEVICE (nm_device_get_type ()) @@ -281,6 +281,7 @@ const char * nm_device_get_driver_version (NMDevice *dev); const char * nm_device_get_type_desc (NMDevice *dev); const char * nm_device_get_type_description (NMDevice *dev); NMDeviceType nm_device_get_device_type (NMDevice *dev); +NMMetered nm_device_get_metered (NMDevice *dev); int nm_device_get_priority (NMDevice *dev); guint32 nm_device_get_ip4_route_metric (NMDevice *dev);