diff options
Diffstat (limited to 'clients/common')
| -rw-r--r-- | clients/common/nm-meta-setting-desc.c | 165 | ||||
| -rw-r--r-- | clients/common/nm-meta-setting-desc.h | 11 | ||||
| -rw-r--r-- | clients/common/settings-docs.h | 2 | ||||
| -rw-r--r-- | clients/common/settings-docs.h.in | 2 |
4 files changed, 112 insertions, 68 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index f794c67b..d291732a 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -783,7 +783,8 @@ _get_fcn_gobject_int (ARGS_GET_FCN) { GParamSpec *pspec; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; - gint64 v; + gboolean is_uint64 = FALSE; + NMMetaSignUnsignInt64 v; guint base = 10; const NMMetaUtilsIntValueInfo *value_infos; char *return_str; @@ -799,13 +800,18 @@ _get_fcn_gobject_int (ARGS_GET_FCN) NM_SET_OUT (out_is_default, g_param_value_defaults (pspec, &gval)); switch (pspec->value_type) { case G_TYPE_INT: - v = g_value_get_int (&gval); + v.i64 = g_value_get_int (&gval); break; case G_TYPE_UINT: - v = g_value_get_uint (&gval); + v.u64 = g_value_get_uint (&gval); + is_uint64 = TRUE; break; case G_TYPE_INT64: - v = g_value_get_int64 (&gval); + v.i64 = g_value_get_int64 (&gval); + break; + case G_TYPE_UINT64: + v.u64 = g_value_get_uint64 (&gval); + is_uint64 = TRUE; break; default: g_return_val_if_reached (NULL); @@ -819,10 +825,16 @@ _get_fcn_gobject_int (ARGS_GET_FCN) switch (base) { case 10: - return_str = g_strdup_printf ("%"G_GINT64_FORMAT, v); + if (is_uint64) + return_str = g_strdup_printf ("%"G_GUINT64_FORMAT, v.u64); + else + return_str = g_strdup_printf ("%"G_GINT64_FORMAT, v.i64); break; case 16: - return_str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", v); + if (is_uint64) + return_str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", v.u64); + else + return_str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", (guint64) v.i64); break; default: return_str = NULL; @@ -833,7 +845,8 @@ _get_fcn_gobject_int (ARGS_GET_FCN) && property_info->property_typ_data && (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) { for (; value_infos->nick; value_infos++) { - if (value_infos->value == v) { + if ( ( is_uint64 && value_infos->value.u64 == v.u64) + || (!is_uint64 && value_infos->value.i64 == v.i64)) { char *old_str = return_str; return_str = g_strdup_printf ("%s (%s)", old_str, value_infos->nick); @@ -1060,16 +1073,21 @@ _set_fcn_gobject_int (ARGS_SET_FCN) int errsv; const GParamSpec *pspec; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; - gint64 v = 0; + gboolean is_uint64; + NMMetaSignUnsignInt64 v; gboolean has_minmax = FALSE; - gint64 min = G_MININT64; - gint64 max = G_MAXINT64; + NMMetaSignUnsignInt64 min = { 0 }; + NMMetaSignUnsignInt64 max = { 0 }; guint base = 10; - const NMMetaUtilsIntValueInfo *value_infos = NULL; - gboolean has_value = FALSE; + const NMMetaUtilsIntValueInfo *value_infos; - if (property_info->property_typ_data) { + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), property_info->property_name); + if (!G_IS_PARAM_SPEC (pspec)) + g_return_val_if_reached (FALSE); + is_uint64 = NM_IN_SET (pspec->value_type, G_TYPE_UINT, G_TYPE_UINT64); + + if (property_info->property_typ_data) { if ( value && (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) { gs_free char *vv_stripped = NULL; @@ -1083,85 +1101,106 @@ _set_fcn_gobject_int (ARGS_SET_FCN) for (; value_infos->nick; value_infos++) { if (nm_streq (value_infos->nick, vv)) { v = value_infos->value; - has_value = TRUE; - break; + goto have_value_from_nick; } } } if (property_info->property_typ_data->subtype.gobject_int.base > 0) base = property_info->property_typ_data->subtype.gobject_int.base; - if ( property_info->property_typ_data->subtype.gobject_int.min - || property_info->property_typ_data->subtype.gobject_int.max) { + + if ( ( is_uint64 + && ( property_info->property_typ_data->subtype.gobject_int.min.u64 + || property_info->property_typ_data->subtype.gobject_int.max.u64)) + || ( !is_uint64 + && ( property_info->property_typ_data->subtype.gobject_int.min.i64 + || property_info->property_typ_data->subtype.gobject_int.max.i64))) { min = property_info->property_typ_data->subtype.gobject_int.min; max = property_info->property_typ_data->subtype.gobject_int.max; has_minmax = TRUE; } } - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), property_info->property_name); - if (!G_IS_PARAM_SPEC (pspec)) - g_return_val_if_reached (FALSE); - switch (pspec->value_type) { - case G_TYPE_INT: - if (!has_minmax) { - const GParamSpecInt *p = (GParamSpecInt *) pspec; + if (!has_minmax) { + switch (pspec->value_type) { + case G_TYPE_INT: + { + const GParamSpecInt *p = (GParamSpecInt *) pspec; - min = p->minimum; - max = p->maximum; - } - break; - case G_TYPE_UINT: - if (!has_minmax) { - const GParamSpecUInt *p = (GParamSpecUInt *) pspec; + min.i64 = p->minimum; + max.i64 = p->maximum; + } + break; + case G_TYPE_UINT: + { + const GParamSpecUInt *p = (GParamSpecUInt *) pspec; - min = p->minimum; - max = p->maximum; - } - break; - case G_TYPE_INT64: - if (!has_minmax) { - const GParamSpecInt64 *p = (GParamSpecInt64 *) pspec; + min.u64 = p->minimum; + max.u64 = p->maximum; + } + break; + case G_TYPE_INT64: + { + const GParamSpecInt64 *p = (GParamSpecInt64 *) pspec; + + min.i64 = p->minimum; + max.i64 = p->maximum; + } + break; + case G_TYPE_UINT64: + { + const GParamSpecUInt64 *p = (GParamSpecUInt64 *) pspec; - min = p->minimum; - max = p->maximum; + min.u64 = p->minimum; + max.u64 = p->maximum; + } + break; + default: + g_return_val_if_reached (FALSE); } - break; - default: - g_return_val_if_reached (FALSE); } - if (!has_value) { - v = _nm_utils_ascii_str_to_int64 (value, base, min, max, 0); + if (is_uint64) + v.u64 = _nm_utils_ascii_str_to_uint64 (value, base, min.u64, max.u64, 0); + else + v.i64 = _nm_utils_ascii_str_to_int64 (value, base, min.i64, max.i64, 0); - if ((errsv = errno) != 0) { - if (errsv == ERANGE) { + if ((errsv = errno) != 0) { + if (errsv == ERANGE) { + if (is_uint64) { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, - _("'%s' is out of range [%lli, %lli]"), - value, - (long long) min, - (long long) max); + _("'%s' is out of range [%"G_GUINT64_FORMAT", %"G_GUINT64_FORMAT"]"), + value, min.u64, max.u64); } else { g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, - _("'%s' is not a valid number"), value); + _("'%s' is out of range [%"G_GINT64_FORMAT", %"G_GINT64_FORMAT"]"), + value, min.i64, max.i64); } - return FALSE; + } else { + g_set_error (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, + _("'%s' is not a valid number"), value); } + return FALSE; } +have_value_from_nick: + g_value_init (&gval, pspec->value_type); switch (pspec->value_type) { case G_TYPE_INT: - g_value_set_int (&gval, v); + g_value_set_int (&gval, v.i64); break; case G_TYPE_UINT: - g_value_set_uint (&gval, v); + g_value_set_uint (&gval, v.u64); break; case G_TYPE_INT64: - g_value_set_int64 (&gval, v); + g_value_set_int64 (&gval, v.i64); + break; + case G_TYPE_UINT64: + g_value_set_uint64 (&gval, v.u64); break; default: - nm_assert_not_reached (); + g_return_val_if_reached (FALSE); break; } @@ -1302,12 +1341,13 @@ _set_fcn_gobject_enum (ARGS_SET_FCN) g_value_set_int (&gval, v); else if (gtype_prop == G_TYPE_UINT) g_value_set_uint (&gval, v); - else if (G_IS_ENUM_CLASS (gtype_class)) - g_value_set_enum (&gval, v); - else if (G_IS_FLAGS_CLASS (gtype_class)) + else if (is_flags) { + nm_assert (G_IS_FLAGS_CLASS (gtype_class)); g_value_set_flags (&gval, v); - else - g_return_val_if_reached (FALSE); + } else { + nm_assert (G_IS_ENUM_CLASS (gtype_class)); + g_value_set_enum (&gval, v); + } if (!nm_g_object_set_property (G_OBJECT (setting), property_info->property_name, &gval, NULL)) goto fail; @@ -7120,7 +7160,6 @@ static const NMMetaPropertyInfo *const property_infos_SERIAL[] = { .property_type = &_pt_gobject_enum, .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, - .get_gtype = nm_setting_serial_parity_get_type, .value_infos = ENUM_VALUE_INFOS ( { .value = NM_SETTING_SERIAL_PARITY_EVEN, diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index 31f1dd51..163dcf2e 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -232,9 +232,14 @@ struct _NMMetaPropertyType { struct _NMUtilsEnumValueInfo; +typedef union { + gint64 i64; + guint64 u64; +} NMMetaSignUnsignInt64; + typedef struct { const char *nick; - gint64 value; + NMMetaSignUnsignInt64 value; } NMMetaUtilsIntValueInfo; struct _NMMetaPropertyTypData { @@ -255,8 +260,8 @@ struct _NMMetaPropertyTypData { int value); } gobject_enum; struct { - gint64 min; - gint64 max; + NMMetaSignUnsignInt64 min; + NMMetaSignUnsignInt64 max; guint base; const NMMetaUtilsIntValueInfo *value_infos; } gobject_int; diff --git a/clients/common/settings-docs.h b/clients/common/settings-docs.h index 001f7323..f07769c0 100644 --- a/clients/common/settings-docs.h +++ b/clients/common/settings-docs.h @@ -9,7 +9,7 @@ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CHANNEL N_("Wireless channel to use for the Wi-Fi connection. The device will only join (or create for Ad-Hoc networks) a Wi-Fi network on the specified channel. Because channel numbers overlap between bands, this property also requires the \"band\" property to be set.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS N_("If specified, request that the device use this MAC address instead. This is known as MAC cloning or spoofing. Beside explicitly specifying a MAC address, the special values \"preserve\", \"permanent\", \"random\" and \"stable\" are supported. \"preserve\" means not to touch the MAC address on activation. \"permanent\" means to use the permanent hardware address of the device. \"random\" creates a random MAC address on each connect. \"stable\" creates a hashed MAC address based on connection.stable-id and a machine dependent key. If unspecified, the value can be overwritten via global defaults, see manual of NetworkManager.conf. If still unspecified, it defaults to \"preserve\" (older versions of NetworkManager may use a different default value). On D-Bus, this field is expressed as \"assigned-mac-address\" or the deprecated \"cloned-mac-address\".") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK N_("With \"cloned-mac-address\" setting \"random\" or \"stable\", by default all bits of the MAC address are scrambled and a locally-administered, unicast MAC address is created. This property allows to specify that certain bits are fixed. Note that the least significant bit of the first MAC address will always be unset to create a unicast MAC address. If the property is NULL, it is eligible to be overwritten by a default connection setting. If the value is still NULL or an empty string, the default is to create a locally-administered, unicast MAC address. If the value contains one MAC address, this address is used as mask. The set bits of the mask are to be filled with the current MAC address of the device, while the unset bits are subject to randomization. Setting \"FE:FF:FF:00:00:00\" means to preserve the OUI of the current MAC address and only randomize the lower 3 bytes using the \"random\" or \"stable\" algorithm. If the value contains one additional MAC address after the mask, this address is used instead of the current MAC address to fill the bits that shall not be randomized. For example, a value of \"FE:FF:FF:00:00:00 68:F7:28:00:00:00\" will set the OUI of the MAC address to 68:F7:28, while the lower bits are randomized. A value of \"02:00:00:00:00:00 00:00:00:00:00:00\" will create a fully scrambled globally-administered, burned-in MAC address. If the value contains more than one additional MAC addresses, one of them is chosen randomly. For example, \"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00\" will create a fully scrambled MAC address, randomly locally or globally administered.") -#define DESCRIBE_DOC_NM_SETTING_WIRELESS_HIDDEN N_("If TRUE, indicates this network is a non-broadcasting network that hides its SSID. In this case various workarounds may take place, such as probe-scanning the SSID for more reliable network discovery. However, these workarounds expose inherent insecurities with hidden SSID networks, and thus hidden SSID networks should be used with caution. Note that marking the network as hidden may be a privacy issue for you, as the explicit probe-scans may be distinctly recognizable on the air.") +#define DESCRIBE_DOC_NM_SETTING_WIRELESS_HIDDEN N_("If TRUE, indicates that the network is a non-broadcasting network that hides its SSID. This works both in infrastructure and AP mode. In infrastructure mode, various workarounds are used for a more reliable discovery of hidden networks, such as probe-scanning the SSID. However, these workarounds expose inherent insecurities with hidden SSID networks, and thus hidden SSID networks should be used with caution. In AP mode, the created network does not broadcast its SSID. Note that marking the network as hidden may be a privacy issue for you (in infrastructure mode) or client stations (in AP mode), as the explicit probe-scans are distinctly recognizable on the air.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS N_("If specified, this connection will only apply to the Wi-Fi device whose permanent MAC address matches. This property does not change the MAC address of the device (i.e. MAC spoofing).") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST N_("A list of permanent MAC addresses of Wi-Fi devices to which this connection should never apply. Each MAC address should be given in the standard hex-digits-and-colons notation (eg \"00:11:22:33:44:55\").") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION N_("One of NM_SETTING_MAC_RANDOMIZATION_DEFAULT (0) (never randomize unless the user has set a global default to randomize and the supplicant supports randomization), NM_SETTING_MAC_RANDOMIZATION_NEVER (1) (never randomize the MAC address), or NM_SETTING_MAC_RANDOMIZATION_ALWAYS (2) (always randomize the MAC address). This property is deprecated for 'cloned-mac-address'. Deprecated: 1") diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in index 001f7323..f07769c0 100644 --- a/clients/common/settings-docs.h.in +++ b/clients/common/settings-docs.h.in @@ -9,7 +9,7 @@ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CHANNEL N_("Wireless channel to use for the Wi-Fi connection. The device will only join (or create for Ad-Hoc networks) a Wi-Fi network on the specified channel. Because channel numbers overlap between bands, this property also requires the \"band\" property to be set.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS N_("If specified, request that the device use this MAC address instead. This is known as MAC cloning or spoofing. Beside explicitly specifying a MAC address, the special values \"preserve\", \"permanent\", \"random\" and \"stable\" are supported. \"preserve\" means not to touch the MAC address on activation. \"permanent\" means to use the permanent hardware address of the device. \"random\" creates a random MAC address on each connect. \"stable\" creates a hashed MAC address based on connection.stable-id and a machine dependent key. If unspecified, the value can be overwritten via global defaults, see manual of NetworkManager.conf. If still unspecified, it defaults to \"preserve\" (older versions of NetworkManager may use a different default value). On D-Bus, this field is expressed as \"assigned-mac-address\" or the deprecated \"cloned-mac-address\".") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK N_("With \"cloned-mac-address\" setting \"random\" or \"stable\", by default all bits of the MAC address are scrambled and a locally-administered, unicast MAC address is created. This property allows to specify that certain bits are fixed. Note that the least significant bit of the first MAC address will always be unset to create a unicast MAC address. If the property is NULL, it is eligible to be overwritten by a default connection setting. If the value is still NULL or an empty string, the default is to create a locally-administered, unicast MAC address. If the value contains one MAC address, this address is used as mask. The set bits of the mask are to be filled with the current MAC address of the device, while the unset bits are subject to randomization. Setting \"FE:FF:FF:00:00:00\" means to preserve the OUI of the current MAC address and only randomize the lower 3 bytes using the \"random\" or \"stable\" algorithm. If the value contains one additional MAC address after the mask, this address is used instead of the current MAC address to fill the bits that shall not be randomized. For example, a value of \"FE:FF:FF:00:00:00 68:F7:28:00:00:00\" will set the OUI of the MAC address to 68:F7:28, while the lower bits are randomized. A value of \"02:00:00:00:00:00 00:00:00:00:00:00\" will create a fully scrambled globally-administered, burned-in MAC address. If the value contains more than one additional MAC addresses, one of them is chosen randomly. For example, \"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00\" will create a fully scrambled MAC address, randomly locally or globally administered.") -#define DESCRIBE_DOC_NM_SETTING_WIRELESS_HIDDEN N_("If TRUE, indicates this network is a non-broadcasting network that hides its SSID. In this case various workarounds may take place, such as probe-scanning the SSID for more reliable network discovery. However, these workarounds expose inherent insecurities with hidden SSID networks, and thus hidden SSID networks should be used with caution. Note that marking the network as hidden may be a privacy issue for you, as the explicit probe-scans may be distinctly recognizable on the air.") +#define DESCRIBE_DOC_NM_SETTING_WIRELESS_HIDDEN N_("If TRUE, indicates that the network is a non-broadcasting network that hides its SSID. This works both in infrastructure and AP mode. In infrastructure mode, various workarounds are used for a more reliable discovery of hidden networks, such as probe-scanning the SSID. However, these workarounds expose inherent insecurities with hidden SSID networks, and thus hidden SSID networks should be used with caution. In AP mode, the created network does not broadcast its SSID. Note that marking the network as hidden may be a privacy issue for you (in infrastructure mode) or client stations (in AP mode), as the explicit probe-scans are distinctly recognizable on the air.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS N_("If specified, this connection will only apply to the Wi-Fi device whose permanent MAC address matches. This property does not change the MAC address of the device (i.e. MAC spoofing).") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST N_("A list of permanent MAC addresses of Wi-Fi devices to which this connection should never apply. Each MAC address should be given in the standard hex-digits-and-colons notation (eg \"00:11:22:33:44:55\").") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION N_("One of NM_SETTING_MAC_RANDOMIZATION_DEFAULT (0) (never randomize unless the user has set a global default to randomize and the supplicant supports randomization), NM_SETTING_MAC_RANDOMIZATION_NEVER (1) (never randomize the MAC address), or NM_SETTING_MAC_RANDOMIZATION_ALWAYS (2) (always randomize the MAC address). This property is deprecated for 'cloned-mac-address'. Deprecated: 1") |