From 255bc928d71f0e91a65609a25e6655dea6e6dd7e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Mar 2017 19:04:26 +0200 Subject: [PATCH 01/53] libnm: fix error message for invalid ipv6.addr-gen-mode --- libnm-core/nm-setting-ip6-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index 429f27c95c..fbeffe7e0b 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -224,7 +224,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP_CONFIG_METHOD); + g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE); return FALSE; } From 112f09cf4b703ec0ecbd192a057f859f651f83d0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Mar 2017 16:36:55 +0200 Subject: [PATCH 02/53] libnm: return zero flags value from nm_utils_enum_to_str() It is not uncommon that a flags type has also the value 0 mapped, for example to "unknown" or "none". In that case, we should not return an empty string, but instead that zero value. Also, flags actually have an unsigned type. That isn't a real problem to cast it to a signed int. But be more careful about it and use unsigned while handling unsigned values and only cast to int once. --- libnm-core/nm-utils.c | 24 +++++++++++++++--------- libnm-core/tests/test-general.c | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 1feee7ac2a..7fe543d14c 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4303,21 +4303,23 @@ _nm_utils_enum_to_str_full (GType type, } else if (G_IS_FLAGS_CLASS (class)) { GFlagsValue *flags_value; GString *str = g_string_new (""); + unsigned uvalue = (unsigned) value; flags_separator = flags_separator ?: " "; - while (value) { - flags_value = g_flags_get_first_value (G_FLAGS_CLASS (class), value); + do { + flags_value = g_flags_get_first_value (G_FLAGS_CLASS (class), uvalue); if (str->len) g_string_append (str, flags_separator); if ( !flags_value || !_enum_is_valid_flags_nick (flags_value->value_nick)) { - g_string_append_printf (str, "0x%x", (unsigned) value); + if (uvalue) + g_string_append_printf (str, "0x%x", uvalue); break; } g_string_append (str, flags_value->value_nick); - value &= ~flags_value->value; - } + uvalue &= ~flags_value->value; + } while (uvalue); ret = g_string_free (str, FALSE); } else g_return_val_if_reached (NULL); @@ -4333,8 +4335,9 @@ _nm_utils_enum_to_str_full (GType type, * * Converts an enum value to its string representation. If the enum is a * %G_TYPE_FLAGS the function returns a comma-separated list of matching values. - * If the enum is a %G_TYPE_ENUM and the given value is not valid the - * function returns %NULL. + * If the value has no corresponding string representation, it is converted + * to a number. For enums it is converted to a decimal number, for flags + * to an (unsigned) hex number. * * Returns: a newly allocated string or %NULL * @@ -4403,6 +4406,7 @@ nm_utils_enum_from_str (GType type, const char *str, } } else if (G_IS_FLAGS_CLASS (class)) { GFlagsValue *flags_value; + unsigned uvalue = 0; ret = TRUE; while (s[0]) { @@ -4423,19 +4427,21 @@ nm_utils_enum_from_str (GType type, const char *str, ret = FALSE; break; } - value |= (int) v64; + uvalue |= (unsigned) v64; } else { flags_value = g_flags_get_value_by_nick (G_FLAGS_CLASS (class), s); if (!flags_value) { ret = FALSE; break; } - value |= flags_value->value; + uvalue |= flags_value->value; } } s = s_end; } + + value = (int) uvalue; } else g_return_val_if_reached (FALSE); diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 87ef938913..0f65e8f6ae 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -5200,7 +5200,7 @@ static void test_nm_utils_enum (void) test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_67, "67"); test_nm_utils_enum_to_str_do (bool_enum, NM_TEST_GENERAL_BOOL_ENUM_46, "64"); - test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, ""); + test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_NONE, "none"); test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_BAZ, "baz"); test_nm_utils_enum_to_str_do (meta_flags, NM_TEST_GENERAL_META_FLAGS_FOO | NM_TEST_GENERAL_META_FLAGS_BAR | From e26a81cf350d8d43da6a68fde2afcdb48f20f146 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Mar 2017 18:05:00 +0200 Subject: [PATCH 03/53] libnm: handler numeric values more gracefully in nm_utils_enum_from_str() nm_utils_enum_to_str() may also output numeric values if there is no corresponding "nick" for the enum/flag value. For enums the value is in decimal and for flags the value is hexadecimal (with a "0x" prefix). The same was already supported by nm_utils_enum_from_str() when reading the value. However, previously, reading a flag would only support hex numbers and reading a enum would only support decimal numbers. Extend that, to allow passing numbers in any base. For nm_utils_enum_to_str() also make sure to never output nicks that may be misinterpreted as numbers. --- libnm-core/nm-utils.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 7fe543d14c..56f9497f2a 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4260,12 +4260,20 @@ _is_hex_string (const char *str) && NM_STRCHAR_ALL (&str[2], ch, g_ascii_isxdigit (ch)); } +static gboolean +_is_dec_string (const char *str) +{ + return str[0] + && NM_STRCHAR_ALL (&str[0], ch, g_ascii_isdigit (ch)); +} + static gboolean _enum_is_valid_enum_nick (const char *str) { return str[0] && !NM_STRCHAR_ANY (str, ch, g_ascii_isspace (ch)) - && !NM_STRCHAR_ALL (str, ch, g_ascii_isdigit (ch)); + && !_is_dec_string (str) + && !_is_hex_string (str); } static gboolean @@ -4273,6 +4281,7 @@ _enum_is_valid_flags_nick (const char *str) { return str[0] && !NM_STRCHAR_ANY (str, ch, IS_FLAGS_SEPARATOR (ch)) + && !_is_dec_string (str) && !_is_hex_string (str); } @@ -4390,8 +4399,14 @@ nm_utils_enum_from_str (GType type, const char *str, GEnumValue *enum_value; if (s[0]) { - if (NM_STRCHAR_ALL (s, ch, g_ascii_isdigit (ch))) { - v64 = _nm_utils_ascii_str_to_int64 (s, 10, 0, G_MAXINT, -1); + if (_is_hex_string (s)) { + v64 = _nm_utils_ascii_str_to_int64 (s, 16, 0, G_MAXUINT, -1); + if (v64 != -1) { + value = (int) v64; + ret = TRUE; + } + } else if (_is_dec_string (s)) { + v64 = _nm_utils_ascii_str_to_int64 (s, 10, 0, G_MAXUINT, -1); if (v64 != -1) { value = (int) v64; ret = TRUE; @@ -4428,6 +4443,13 @@ nm_utils_enum_from_str (GType type, const char *str, break; } uvalue |= (unsigned) v64; + } else if (_is_dec_string (s)) { + v64 = _nm_utils_ascii_str_to_int64 (s, 10, 0, G_MAXUINT, -1); + if (v64 == -1) { + ret = FALSE; + break; + } + uvalue |= (unsigned) v64; } else { flags_value = g_flags_get_value_by_nick (G_FLAGS_CLASS (class), s); if (!flags_value) { From 2b0c00a3e377312895d12f2b220ab1c8579d600e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Mar 2017 11:11:11 +0200 Subject: [PATCH 04/53] Revert "nmcli: output property values in "parsable" mode when the "--terse" option is specified" This will be solved differently by th/setting-user-data-bgo776276 branch. Revert the change for now, the same functionality will be restored later. This reverts commit 623d888801f611be4e4d14570d6c2f84dcd92937. --- clients/cli/settings.c | 802 +++++++++++++++++------------------------ 1 file changed, 336 insertions(+), 466 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 87b1f50f71..cf2a4b518c 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -8650,14 +8650,11 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) /*----------------------------------------------------------------------------*/ -#define GET_SECRET(show, setting, func, type) \ - (show ? func (setting, type) : g_strdup (_(""))) +#define GET_SECRET(show, setting, func) \ + (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) static gboolean -setting_connection_details (NMSetting *setting, NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); NmcOutputField *tmpl, *arr; @@ -8674,25 +8671,25 @@ setting_connection_details (NMSetting *setting, NmCli *nmc, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_connection_get_id (setting, type)); - set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, type)); - set_val_str (arr, 3, nmc_property_connection_get_stable_id (setting, type)); - set_val_str (arr, 4, nmc_property_connection_get_interface_name (setting, type)); - set_val_str (arr, 5, nmc_property_connection_get_type (setting, type)); - set_val_str (arr, 6, nmc_property_connection_get_autoconnect (setting, type)); - set_val_str (arr, 7, nmc_property_connection_get_autoconnect_priority (setting, type)); - set_val_str (arr, 8, nmc_property_connection_get_autoconnect_retries (setting, type)); - set_val_str (arr, 9, nmc_property_connection_get_timestamp (setting, type)); - set_val_str (arr, 10, nmc_property_connection_get_read_only (setting, type)); - set_val_str (arr, 11, nmc_property_connection_get_permissions (setting, type)); - set_val_str (arr, 12, nmc_property_connection_get_zone (setting, type)); - set_val_str (arr, 13, nmc_property_connection_get_master (setting, type)); - set_val_str (arr, 14, nmc_property_connection_get_slave_type (setting, type)); - set_val_str (arr, 15, nmc_property_connection_get_autoconnect_slaves (setting, type)); - set_val_str (arr, 16, nmc_property_connection_get_secondaries (setting, type)); - set_val_str (arr, 17, nmc_property_connection_get_gateway_ping_timeout (setting, type)); - set_val_str (arr, 18, nmc_property_connection_get_metered (setting, type)); - set_val_str (arr, 19, nmc_property_connection_get_lldp (setting, type)); + set_val_str (arr, 1, nmc_property_connection_get_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_connection_get_stable_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_connection_get_interface_name (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_connection_get_type (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_connection_get_autoconnect (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_connection_get_autoconnect_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_connection_get_autoconnect_retries (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_connection_get_timestamp (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_connection_get_read_only (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_connection_get_permissions (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_connection_get_zone (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_connection_get_master (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_connection_get_slave_type (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 17, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 18, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 19, nmc_property_connection_get_lldp (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8701,11 +8698,7 @@ setting_connection_details (NMSetting *setting, NmCli *nmc, } static gboolean -setting_wired_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWired *s_wired = NM_SETTING_WIRED (setting); NmcOutputField *tmpl, *arr; @@ -8722,20 +8715,20 @@ setting_wired_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wired_get_port (setting, type)); - set_val_str (arr, 2, nmc_property_wired_get_speed (setting, type)); - set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, type)); - set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, type)); - set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, type)); - set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, type)); - set_val_str (arr, 7, nmc_property_wired_get_generate_mac_address_mask (setting, type)); - set_val_str (arr, 8, nmc_property_wired_get_mac_address_blacklist (setting, type)); - set_val_str (arr, 9, nmc_property_wired_get_mtu (setting, type)); - set_val_str (arr, 10, nmc_property_wired_get_s390_subchannels (setting, type)); - set_val_str (arr, 11, nmc_property_wired_get_s390_nettype (setting, type)); - set_val_str (arr, 12, nmc_property_wired_get_s390_options (setting, type)); - set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan (setting, type)); - set_val_str (arr, 14, nmc_property_wired_get_wake_on_lan_password (setting, type)); + set_val_str (arr, 1, nmc_property_wired_get_port (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_wired_get_speed (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_wired_get_generate_mac_address_mask (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_wired_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_wired_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8744,11 +8737,7 @@ setting_wired_details (NMSetting *setting, } static gboolean -setting_802_1X_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_802_1X_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting); NmcOutputField *tmpl, *arr; @@ -8765,50 +8754,50 @@ setting_802_1X_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, type)); - set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, type)); - set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, type)); - set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, type)); - set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, type)); - set_val_str (arr, 6, GET_SECRET (secrets, setting, nmc_property_802_1X_get_ca_cert_password, type)); - set_val_str (arr, 7, nmc_property_802_1X_get_ca_cert_password_flags (setting, type)); - set_val_str (arr, 8, nmc_property_802_1X_get_ca_path (setting, type)); - set_val_str (arr, 9, nmc_property_802_1X_get_subject_match (setting, type)); - set_val_str (arr, 10, nmc_property_802_1X_get_altsubject_matches (setting, type)); - set_val_str (arr, 11, nmc_property_802_1X_get_domain_suffix_match (setting, type)); - set_val_str (arr, 12, nmc_property_802_1X_get_client_cert (setting, type, secrets)); - set_val_str (arr, 13, GET_SECRET (secrets, setting, nmc_property_802_1X_get_client_cert_password, type)); - set_val_str (arr, 14, nmc_property_802_1X_get_client_cert_password_flags (setting, type)); - set_val_str (arr, 15, nmc_property_802_1X_get_phase1_peapver (setting, type)); - set_val_str (arr, 16, nmc_property_802_1X_get_phase1_peaplabel (setting, type)); - set_val_str (arr, 17, nmc_property_802_1X_get_phase1_fast_provisioning (setting, type)); - set_val_str (arr, 18, nmc_property_802_1X_get_phase1_auth_flags (setting, type)); - set_val_str (arr, 19, nmc_property_802_1X_get_phase2_auth (setting, type)); - set_val_str (arr, 20, nmc_property_802_1X_get_phase2_autheap (setting, type)); - set_val_str (arr, 21, nmc_property_802_1X_get_phase2_ca_cert (setting, type)); - set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_ca_cert_password, type)); - set_val_str (arr, 23, nmc_property_802_1X_get_phase2_ca_cert_password_flags (setting, type)); - set_val_str (arr, 24, nmc_property_802_1X_get_phase2_ca_path (setting, type)); - set_val_str (arr, 25, nmc_property_802_1X_get_phase2_subject_match (setting, type)); - set_val_str (arr, 26, nmc_property_802_1X_get_phase2_altsubject_matches (setting, type)); - set_val_str (arr, 27, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, type)); - set_val_str (arr, 28, nmc_property_802_1X_get_phase2_client_cert (setting, type, secrets)); - set_val_str (arr, 29, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_client_cert_password, type)); - set_val_str (arr, 30, nmc_property_802_1X_get_phase2_client_cert_password_flags (setting, type)); - set_val_str (arr, 31, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password, type)); - set_val_str (arr, 32, nmc_property_802_1X_get_password_flags (setting, type)); - set_val_str (arr, 33, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw, type)); - set_val_str (arr, 34, nmc_property_802_1X_get_password_raw_flags (setting, type)); - set_val_str (arr, 35, nmc_property_802_1X_get_private_key (setting, type, secrets)); - set_val_str (arr, 36, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password, type)); - set_val_str (arr, 37, nmc_property_802_1X_get_private_key_password_flags (setting, type)); - set_val_str (arr, 38, nmc_property_802_1X_get_phase2_private_key (setting, type, secrets)); - set_val_str (arr, 39, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password, type)); - set_val_str (arr, 40, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, type)); - set_val_str (arr, 41, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin, type)); - set_val_str (arr, 42, nmc_property_802_1X_get_pin_flags (setting, type)); - set_val_str (arr, 43, nmc_property_802_1X_get_system_ca_certs (setting, type)); - set_val_str (arr, 44, nmc_property_802_1X_get_auth_timeout (setting, type)); + set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, GET_SECRET (secrets, setting, nmc_property_802_1X_get_ca_cert_password)); + set_val_str (arr, 7, nmc_property_802_1X_get_ca_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_802_1X_get_ca_path (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_802_1X_get_subject_match (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_802_1X_get_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_802_1X_get_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_802_1X_get_client_cert (setting, NMC_PROPERTY_GET_PRETTY, secrets)); + set_val_str (arr, 13, GET_SECRET (secrets, setting, nmc_property_802_1X_get_client_cert_password)); + set_val_str (arr, 14, nmc_property_802_1X_get_client_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_802_1X_get_phase1_peapver (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_802_1X_get_phase1_peaplabel (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 17, nmc_property_802_1X_get_phase1_fast_provisioning (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 18, nmc_property_802_1X_get_phase1_auth_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 19, nmc_property_802_1X_get_phase2_auth (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 20, nmc_property_802_1X_get_phase2_autheap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 21, nmc_property_802_1X_get_phase2_ca_cert (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_ca_cert_password)); + set_val_str (arr, 23, nmc_property_802_1X_get_phase2_ca_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 24, nmc_property_802_1X_get_phase2_ca_path (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 25, nmc_property_802_1X_get_phase2_subject_match (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 26, nmc_property_802_1X_get_phase2_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 27, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 28, nmc_property_802_1X_get_phase2_client_cert (setting, NMC_PROPERTY_GET_PRETTY, secrets)); + set_val_str (arr, 29, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_client_cert_password)); + set_val_str (arr, 30, nmc_property_802_1X_get_phase2_client_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 31, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password)); + set_val_str (arr, 32, nmc_property_802_1X_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 33, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw)); + set_val_str (arr, 34, nmc_property_802_1X_get_password_raw_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 35, nmc_property_802_1X_get_private_key (setting, NMC_PROPERTY_GET_PRETTY, secrets)); + set_val_str (arr, 36, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password)); + set_val_str (arr, 37, nmc_property_802_1X_get_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 38, nmc_property_802_1X_get_phase2_private_key (setting, NMC_PROPERTY_GET_PRETTY, secrets)); + set_val_str (arr, 39, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password)); + set_val_str (arr, 40, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 41, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin)); + set_val_str (arr, 42, nmc_property_802_1X_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 43, nmc_property_802_1X_get_system_ca_certs (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 44, nmc_property_802_1X_get_auth_timeout (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8817,11 +8806,7 @@ setting_802_1X_details (NMSetting *setting, } static gboolean -setting_wireless_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); NmcOutputField *tmpl, *arr; @@ -8838,22 +8823,22 @@ setting_wireless_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, type)); - set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, type)); - set_val_str (arr, 3, nmc_property_wireless_get_band (setting, type)); - set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, type)); - set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, type)); - set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, type)); - set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, type)); - set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, type)); - set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, type)); - set_val_str (arr, 10, nmc_property_wireless_get_generate_mac_address_mask (setting, type)); - set_val_str (arr, 11, nmc_property_wireless_get_mac_address_blacklist (setting, type)); - set_val_str (arr, 12, nmc_property_wireless_get_mac_address_randomization (setting, type)); - set_val_str (arr, 13, nmc_property_wireless_get_mtu (setting, type)); - set_val_str (arr, 14, nmc_property_wireless_get_seen_bssids (setting, type)); - set_val_str (arr, 15, nmc_property_wireless_get_hidden (setting, type)); - set_val_str (arr, 16, nmc_property_wireless_get_powersave (setting, type)); + set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_wireless_get_band (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_wireless_get_generate_mac_address_mask (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_wireless_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_wireless_get_mac_address_randomization (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_wireless_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8862,11 +8847,7 @@ setting_wireless_details (NMSetting *setting, } static gboolean -setting_wireless_security_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); NmcOutputField *tmpl, *arr; @@ -8883,23 +8864,23 @@ setting_wireless_security_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, type)); - set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, type)); - set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, type)); - set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, type)); - set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, type)); - set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, type)); - set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, type)); - set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0, type)); - set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1, type)); - set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2, type)); - set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3, type)); - set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, type)); - set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, type)); - set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk, type)); - set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, type)); - set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password, type)); - set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, type)); + set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0)); + set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1)); + set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2)); + set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3)); + set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk)); + set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password)); + set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8908,11 +8889,7 @@ setting_wireless_security_details (NMSetting *setting, } static gboolean -setting_ip4_config_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting); NmcOutputField *tmpl, *arr; @@ -8929,25 +8906,25 @@ setting_ip4_config_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, type)); - set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, type)); - set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, type)); - set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, type)); - set_val_str (arr, 5, nmc_property_ipv4_get_dns_priority (setting, type)); - set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, type)); - set_val_str (arr, 7, nmc_property_ipv4_get_gateway (setting, type)); - set_val_str (arr, 8, nmc_property_ipv4_get_routes (setting, type)); - set_val_str (arr, 9, nmc_property_ipv4_get_route_metric (setting, type)); - set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_routes (setting, type)); - set_val_str (arr, 11, nmc_property_ipv4_get_ignore_auto_dns (setting, type)); - set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_client_id (setting, type)); - set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_timeout (setting, type)); - set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_send_hostname (setting, type)); - set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_hostname (setting, type)); - set_val_str (arr, 16, nmc_property_ipv4_get_dhcp_fqdn (setting, type)); - set_val_str (arr, 17, nmc_property_ipv4_get_never_default (setting, type)); - set_val_str (arr, 18, nmc_property_ipv4_get_may_fail (setting, type)); - set_val_str (arr, 19, nmc_property_ipv4_get_dad_timeout (setting, type)); + set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_ipv4_get_dns_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_ipv4_get_gateway (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_ipv4_get_routes (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_ipv4_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_ipv4_get_dhcp_fqdn (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 17, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 18, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 19, nmc_property_ipv4_get_dad_timeout (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -8956,11 +8933,7 @@ setting_ip4_config_details (NMSetting *setting, } static gboolean -setting_ip6_config_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_ip6_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting); NmcOutputField *tmpl, *arr; @@ -8977,24 +8950,24 @@ setting_ip6_config_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, type)); - set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, type)); - set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, type)); - set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, type)); - set_val_str (arr, 5, nmc_property_ipv6_get_dns_priority (setting, type)); - set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, type)); - set_val_str (arr, 7, nmc_property_ipv6_get_gateway (setting, type)); - set_val_str (arr, 8, nmc_property_ipv6_get_routes (setting, type)); - set_val_str (arr, 9, nmc_property_ipv6_get_route_metric (setting, type)); - set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_routes (setting, type)); - set_val_str (arr, 11, nmc_property_ipv6_get_ignore_auto_dns (setting, type)); - set_val_str (arr, 12, nmc_property_ipv6_get_never_default (setting, type)); - set_val_str (arr, 13, nmc_property_ipv6_get_may_fail (setting, type)); - set_val_str (arr, 14, nmc_property_ipv6_get_ip6_privacy (setting, type)); - set_val_str (arr, 15, nmc_property_ipv6_get_addr_gen_mode (setting, type)); - set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_send_hostname (setting, type)); - set_val_str (arr, 17, nmc_property_ipv6_get_dhcp_hostname (setting, type)); - set_val_str (arr, 18, nmc_property_ipv6_get_token (setting, type)); + set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_ipv6_get_dns_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_ipv6_get_gateway (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_ipv6_get_routes (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_ipv6_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_ipv6_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_ipv6_get_never_default (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_ipv6_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_ipv6_get_ip6_privacy (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_ipv6_get_addr_gen_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 17, nmc_property_ipv6_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 18, nmc_property_ipv6_get_token (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9003,11 +8976,7 @@ setting_ip6_config_details (NMSetting *setting, } static gboolean -setting_serial_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting); NmcOutputField *tmpl, *arr; @@ -9024,11 +8993,11 @@ setting_serial_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_serial_get_baud (setting, type)); - set_val_str (arr, 2, nmc_property_serial_get_bits (setting, type)); - set_val_str (arr, 3, nmc_property_serial_get_parity (setting, type)); - set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, type)); - set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, type)); + set_val_str (arr, 1, nmc_property_serial_get_baud (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_serial_get_bits (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_serial_get_parity (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9037,10 +9006,7 @@ setting_serial_details (NMSetting *setting, } static gboolean -setting_ppp_details (NMSetting *setting, NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingPpp *s_ppp = NM_SETTING_PPP (setting); NmcOutputField *tmpl, *arr; @@ -9057,24 +9023,24 @@ setting_ppp_details (NMSetting *setting, NmCli *nmc, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, type)); - set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, type)); - set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, type)); - set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, type)); - set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, type)); - set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, type)); - set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, type)); - set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, type)); - set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, type)); - set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, type)); - set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, type)); - set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, type)); - set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, type)); - set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, type)); - set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, type)); - set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, type)); - set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, type)); - set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, type)); + set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9083,11 +9049,7 @@ setting_ppp_details (NMSetting *setting, NmCli *nmc, } static gboolean -setting_pppoe_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting); NmcOutputField *tmpl, *arr; @@ -9104,10 +9066,10 @@ setting_pppoe_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_pppoe_get_service (setting, type)); - set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, type)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password, type)); - set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, type)); + set_val_str (arr, 1, nmc_property_pppoe_get_service (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password)); + set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9116,11 +9078,7 @@ setting_pppoe_details (NMSetting *setting, } static gboolean -setting_gsm_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingGsm *s_gsm = NM_SETTING_GSM (setting); NmcOutputField *tmpl, *arr; @@ -9137,19 +9095,19 @@ setting_gsm_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_gsm_get_number (setting, type)); - set_val_str (arr, 2, nmc_property_gsm_get_username (setting, type)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password, type)); - set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, type)); - set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, type)); - set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, type)); - set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin, type)); - set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, type)); - set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, type)); - set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, type)); - set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, type)); - set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, type)); - set_val_str (arr, 13, nmc_property_gsm_get_mtu (setting, type)); + set_val_str (arr, 1, nmc_property_gsm_get_number (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_gsm_get_username (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password)); + set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin)); + set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_gsm_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9158,11 +9116,7 @@ setting_gsm_details (NMSetting *setting, } static gboolean -setting_cdma_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_cdma_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting); NmcOutputField *tmpl, *arr; @@ -9179,11 +9133,11 @@ setting_cdma_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_cdma_get_number (setting, type)); - set_val_str (arr, 2, nmc_property_cdma_get_username (setting, type)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password, type)); - set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, type)); - set_val_str (arr, 5, nmc_property_cdma_get_mtu (setting, type)); + set_val_str (arr, 1, nmc_property_cdma_get_number (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_cdma_get_username (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password)); + set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_cdma_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9192,11 +9146,7 @@ setting_cdma_details (NMSetting *setting, } static gboolean -setting_bluetooth_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_bluetooth_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting); NmcOutputField *tmpl, *arr; @@ -9213,8 +9163,8 @@ setting_bluetooth_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bluetooth_get_bdaddr (setting, type)); - set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, type)); + set_val_str (arr, 1, nmc_property_bluetooth_get_bdaddr (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9223,11 +9173,7 @@ setting_bluetooth_details (NMSetting *setting, } static gboolean -setting_olpc_mesh_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting); NmcOutputField *tmpl, *arr; @@ -9244,9 +9190,9 @@ setting_olpc_mesh_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, type)); - set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, type)); - set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, type)); + set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9255,11 +9201,7 @@ setting_olpc_mesh_details (NMSetting *setting, } static gboolean -setting_vpn_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVpn *s_vpn = NM_SETTING_VPN (setting); NmcOutputField *tmpl, *arr; @@ -9276,12 +9218,12 @@ setting_vpn_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, type)); - set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, type)); - set_val_str (arr, 3, nmc_property_vpn_get_data (setting, type)); - set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets, type)); - set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, type)); - set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, type)); + set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_vpn_get_data (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets)); + set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9290,11 +9232,7 @@ setting_vpn_details (NMSetting *setting, } static gboolean -setting_wimax_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_wimax_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting); NmcOutputField *tmpl, *arr; @@ -9311,8 +9249,8 @@ setting_wimax_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, type)); - set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, type)); + set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9321,11 +9259,7 @@ setting_wimax_details (NMSetting *setting, } static gboolean -setting_infiniband_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_infiniband_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting); NmcOutputField *tmpl, *arr; @@ -9342,11 +9276,11 @@ setting_infiniband_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, type)); - set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, type)); - set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, type)); - set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, type)); - set_val_str (arr, 5, nmc_property_ib_get_parent (setting, type)); + set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_ib_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9355,11 +9289,7 @@ setting_infiniband_details (NMSetting *setting, } static gboolean -setting_bond_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBond *s_bond = NM_SETTING_BOND (setting); NmcOutputField *tmpl, *arr; @@ -9376,7 +9306,7 @@ setting_bond_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bond_get_options (setting, type)); + set_val_str (arr, 1, nmc_property_bond_get_options (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9385,11 +9315,7 @@ setting_bond_details (NMSetting *setting, } static gboolean -setting_vlan_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); NmcOutputField *tmpl, *arr; @@ -9406,11 +9332,11 @@ setting_vlan_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, type)); - set_val_str (arr, 2, nmc_property_vlan_get_id (setting, type)); - set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, type)); - set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, type)); - set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, type)); + set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_vlan_get_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9419,11 +9345,7 @@ setting_vlan_details (NMSetting *setting, } static gboolean -setting_adsl_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_adsl_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting); NmcOutputField *tmpl, *arr; @@ -9440,13 +9362,13 @@ setting_adsl_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_adsl_get_username (setting, type)); - set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password, type)); - set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, type)); - set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, type)); - set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, type)); - set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, type)); - set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, type)); + set_val_str (arr, 1, nmc_property_adsl_get_username (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password)); + set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9455,11 +9377,7 @@ setting_adsl_details (NMSetting *setting, } static gboolean -setting_bridge_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting); NmcOutputField *tmpl, *arr; @@ -9476,14 +9394,14 @@ setting_bridge_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, type)); - set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, type)); - set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, type)); - set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, type)); - set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, type)); - set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, type)); - set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, type)); - set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, type)); + set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9492,11 +9410,7 @@ setting_bridge_details (NMSetting *setting, } static gboolean -setting_bridge_port_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_bridge_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting); NmcOutputField *tmpl, *arr; @@ -9513,9 +9427,9 @@ setting_bridge_port_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, type)); - set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, type)); - set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, type)); + set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9524,11 +9438,7 @@ setting_bridge_port_details (NMSetting *setting, } static gboolean -setting_team_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTeam *s_team = NM_SETTING_TEAM (setting); NmcOutputField *tmpl, *arr; @@ -9545,7 +9455,7 @@ setting_team_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_team_get_config (setting, type)); + set_val_str (arr, 1, nmc_property_team_get_config (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9554,11 +9464,7 @@ setting_team_details (NMSetting *setting, } static gboolean -setting_team_port_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_team_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting); NmcOutputField *tmpl, *arr; @@ -9575,7 +9481,7 @@ setting_team_port_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_team_port_get_config (setting, type)); + set_val_str (arr, 1, nmc_property_team_port_get_config (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9584,11 +9490,7 @@ setting_team_port_details (NMSetting *setting, } static gboolean -setting_dcb_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_dcb_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); NmcOutputField *tmpl, *arr; @@ -9605,21 +9507,21 @@ setting_dcb_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, type)); - set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, type)); - set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, type)); - set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, type)); - set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, type)); - set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, type)); - set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, type)); - set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, type)); - set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, type)); - set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, type)); - set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, type)); - set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, type)); - set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, type)); - set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, type)); - set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, type)); + set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9628,11 +9530,7 @@ setting_dcb_details (NMSetting *setting, } static gboolean -setting_tun_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_tun_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTun *s_tun = NM_SETTING_TUN (setting); NmcOutputField *tmpl, *arr; @@ -9649,12 +9547,12 @@ setting_tun_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_tun_get_mode (setting, type)); - set_val_str (arr, 2, nmc_property_tun_get_owner (setting, type)); - set_val_str (arr, 3, nmc_property_tun_get_group (setting, type)); - set_val_str (arr, 4, nmc_property_tun_get_pi (setting, type)); - set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, type)); - set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, type)); + set_val_str (arr, 1, nmc_property_tun_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_tun_get_owner (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_tun_get_group (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_tun_get_pi (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9663,11 +9561,7 @@ setting_tun_details (NMSetting *setting, } static gboolean -setting_ip_tunnel_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting); NmcOutputField *tmpl, *arr; @@ -9684,18 +9578,18 @@ setting_ip_tunnel_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, type)); - set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, type)); - set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, type)); - set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, type)); - set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, type)); - set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, type)); - set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, type)); - set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, type)); - set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, type)); - set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, type)); - set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, type)); - set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, type)); + set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9704,11 +9598,7 @@ setting_ip_tunnel_details (NMSetting *setting, } static gboolean -setting_macsec_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_macsec_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingMacsec *s_macsec = NM_SETTING_MACSEC (setting); NmcOutputField *tmpl, *arr; @@ -9725,14 +9615,14 @@ setting_macsec_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_macsec_get_parent (setting, type)); - set_val_str (arr, 2, nmc_property_macsec_get_mode (setting, type)); - set_val_str (arr, 3, nmc_property_macsec_get_encrypt (setting, type)); - set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_macsec_get_mka_cak, type)); - set_val_str (arr, 5, nmc_property_macsec_get_mka_cak_flags (setting, type)); - set_val_str (arr, 6, nmc_property_macsec_get_mka_ckn (setting, type)); - set_val_str (arr, 7, nmc_property_macsec_get_port (setting, type)); - set_val_str (arr, 8, nmc_property_macsec_get_validation (setting, type)); + set_val_str (arr, 1, nmc_property_macsec_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_macsec_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_macsec_get_encrypt (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_macsec_get_mka_cak)); + set_val_str (arr, 5, nmc_property_macsec_get_mka_cak_flags (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_macsec_get_mka_ckn (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_macsec_get_port (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_macsec_get_validation (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9741,11 +9631,7 @@ setting_macsec_details (NMSetting *setting, } static gboolean -setting_macvlan_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_macvlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting); NmcOutputField *tmpl, *arr; @@ -9762,10 +9648,10 @@ setting_macvlan_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_macvlan_get_parent (setting, type)); - set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, type)); - set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, type)); - set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, type)); + set_val_str (arr, 1, nmc_property_macvlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9774,11 +9660,7 @@ setting_macvlan_details (NMSetting *setting, } static gboolean -setting_vxlan_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_vxlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting); NmcOutputField *tmpl, *arr; @@ -9795,22 +9677,22 @@ setting_vxlan_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vxlan_get_parent (setting, type)); - set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, type)); - set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, type)); - set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, type)); - set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, type)); - set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, type)); - set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, type)); - set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, type)); - set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, type)); - set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, type)); - set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, type)); - set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, type)); - set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, type)); - set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, type)); - set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, type)); - set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, type)); + set_val_str (arr, 1, nmc_property_vxlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9819,11 +9701,7 @@ setting_vxlan_details (NMSetting *setting, } static gboolean -setting_proxy_details (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type) +setting_proxy_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting); NmcOutputField *tmpl, *arr; @@ -9840,10 +9718,10 @@ setting_proxy_details (NMSetting *setting, arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_proxy_get_method (setting, type)); - set_val_str (arr, 2, nmc_property_proxy_get_browser_only (setting, type)); - set_val_str (arr, 3, nmc_property_proxy_get_pac_url (setting, type)); - set_val_str (arr, 4, nmc_property_proxy_get_pac_script (setting, type)); + set_val_str (arr, 1, nmc_property_proxy_get_method (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 2, nmc_property_proxy_get_browser_only (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 3, nmc_property_proxy_get_pac_url (setting, NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, 4, nmc_property_proxy_get_pac_script (setting, NMC_PROPERTY_GET_PRETTY)); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9853,11 +9731,7 @@ setting_proxy_details (NMSetting *setting, typedef struct { const char *sname; - gboolean (*func) (NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets, - NmcPropertyGetType type); + gboolean (*func) (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); } SettingDetails; static const SettingDetails detail_printers[] = { @@ -9899,16 +9773,12 @@ gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { const SettingDetails *iter = &detail_printers[0]; - NmcPropertyGetType type = NMC_PROPERTY_GET_PRETTY; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); - if (nmc->print_output == NMC_PRINT_TERSE) - type = NMC_PROPERTY_GET_PARSABLE; - while (iter->sname) { if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting)) - return iter->func (setting, nmc, one_prop, secrets, type); + return iter->func (setting, nmc, one_prop, secrets); iter++; } From 3690311b02864803d3738bdc2ee3c18f88ce9343 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Mar 2017 15:55:19 +0100 Subject: [PATCH 05/53] meta: add table @nm_meta_setting_infos of all settings types --- shared/nm-setting-metadata.c | 232 +++++++++++++++++++++++++++++++++++ shared/nm-setting-metadata.h | 74 +++++++++-- 2 files changed, 296 insertions(+), 10 deletions(-) diff --git a/shared/nm-setting-metadata.c b/shared/nm-setting-metadata.c index a88fb69f17..7e4a4ea9b5 100644 --- a/shared/nm-setting-metadata.c +++ b/shared/nm-setting-metadata.c @@ -23,6 +23,42 @@ #include "nm-setting-metadata.h" +#include "nm-setting-8021x.h" +#include "nm-setting-adsl.h" +#include "nm-setting-bluetooth.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-cdma.h" +#include "nm-setting-connection.h" +#include "nm-setting-dcb.h" +#include "nm-setting-dummy.h" +#include "nm-setting-generic.h" +#include "nm-setting-gsm.h" +#include "nm-setting-infiniband.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-ip-config.h" +#include "nm-setting-ip-tunnel.h" +#include "nm-setting-macsec.h" +#include "nm-setting-macvlan.h" +#include "nm-setting-olpc-mesh.h" +#include "nm-setting-ppp.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-proxy.h" +#include "nm-setting-serial.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-setting-tun.h" +#include "nm-setting-user.h" +#include "nm-setting-vlan.h" +#include "nm-setting-vpn.h" +#include "nm-setting-vxlan.h" +#include "nm-setting-wimax.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wireless-security.h" + /*****************************************************************************/ const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[] = { @@ -102,3 +138,199 @@ const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[] = { }; /*****************************************************************************/ + +const NMMetaSettingInfo nm_meta_setting_infos[] = { + [NM_META_SETTING_TYPE_802_1X] = { + .meta_type = NM_META_SETTING_TYPE_802_1X, + .setting_name = N_ (NM_SETTING_802_1X_SETTING_NAME), + .get_setting_gtype = nm_setting_802_1x_get_type, + }, + [NM_META_SETTING_TYPE_ADSL] = { + .meta_type = NM_META_SETTING_TYPE_ADSL, + .setting_name = N_ (NM_SETTING_ADSL_SETTING_NAME), + .get_setting_gtype = nm_setting_adsl_get_type, + }, + [NM_META_SETTING_TYPE_BLUETOOTH] = { + .meta_type = NM_META_SETTING_TYPE_BLUETOOTH, + .setting_name = N_ (NM_SETTING_BLUETOOTH_SETTING_NAME), + .get_setting_gtype = nm_setting_bluetooth_get_type, + }, + [NM_META_SETTING_TYPE_BOND] = { + .meta_type = NM_META_SETTING_TYPE_BOND, + .setting_name = N_ (NM_SETTING_BOND_SETTING_NAME), + .get_setting_gtype = nm_setting_bond_get_type, + }, + [NM_META_SETTING_TYPE_BRIDGE] = { + .meta_type = NM_META_SETTING_TYPE_BRIDGE, + .setting_name = N_ (NM_SETTING_BRIDGE_SETTING_NAME), + .get_setting_gtype = nm_setting_bridge_get_type, + }, + [NM_META_SETTING_TYPE_BRIDGE_PORT] = { + .meta_type = NM_META_SETTING_TYPE_BRIDGE_PORT, + .setting_name = N_ (NM_SETTING_BRIDGE_PORT_SETTING_NAME), + .get_setting_gtype = nm_setting_bridge_port_get_type, + }, + [NM_META_SETTING_TYPE_CDMA] = { + .meta_type = NM_META_SETTING_TYPE_CDMA, + .setting_name = N_ (NM_SETTING_CDMA_SETTING_NAME), + .get_setting_gtype = nm_setting_cdma_get_type, + }, + [NM_META_SETTING_TYPE_CONNECTION] = { + .meta_type = NM_META_SETTING_TYPE_CONNECTION, + .setting_name = N_ (NM_SETTING_CONNECTION_SETTING_NAME), + .get_setting_gtype = nm_setting_connection_get_type, + }, + [NM_META_SETTING_TYPE_DCB] = { + .meta_type = NM_META_SETTING_TYPE_DCB, + .setting_name = N_ (NM_SETTING_DCB_SETTING_NAME), + .get_setting_gtype = nm_setting_dcb_get_type, + }, + [NM_META_SETTING_TYPE_GSM] = { + .meta_type = NM_META_SETTING_TYPE_GSM, + .setting_name = N_ (NM_SETTING_GSM_SETTING_NAME), + .get_setting_gtype = nm_setting_gsm_get_type, + }, + [NM_META_SETTING_TYPE_INFINIBAND] = { + .meta_type = NM_META_SETTING_TYPE_INFINIBAND, + .setting_name = N_ (NM_SETTING_INFINIBAND_SETTING_NAME), + .get_setting_gtype = nm_setting_infiniband_get_type, + }, + [NM_META_SETTING_TYPE_IP4_CONFIG] = { + .meta_type = NM_META_SETTING_TYPE_IP4_CONFIG, + .setting_name = N_ (NM_SETTING_IP4_CONFIG_SETTING_NAME), + .get_setting_gtype = nm_setting_ip4_config_get_type, + }, + [NM_META_SETTING_TYPE_IP6_CONFIG] = { + .meta_type = NM_META_SETTING_TYPE_IP6_CONFIG, + .setting_name = N_ (NM_SETTING_IP6_CONFIG_SETTING_NAME), + .get_setting_gtype = nm_setting_ip6_config_get_type, + }, + [NM_META_SETTING_TYPE_IP_TUNNEL] = { + .meta_type = NM_META_SETTING_TYPE_IP_TUNNEL, + .setting_name = N_ (NM_SETTING_IP_TUNNEL_SETTING_NAME), + .get_setting_gtype = nm_setting_ip_tunnel_get_type, + }, + [NM_META_SETTING_TYPE_MACSEC] = { + .meta_type = NM_META_SETTING_TYPE_MACSEC, + .setting_name = N_ (NM_SETTING_MACSEC_SETTING_NAME), + .get_setting_gtype = nm_setting_macsec_get_type, + }, + [NM_META_SETTING_TYPE_MACVLAN] = { + .meta_type = NM_META_SETTING_TYPE_MACVLAN, + .setting_name = N_ (NM_SETTING_MACVLAN_SETTING_NAME), + .get_setting_gtype = nm_setting_macvlan_get_type, + }, + [NM_META_SETTING_TYPE_OLPC_MESH] = { + .meta_type = NM_META_SETTING_TYPE_OLPC_MESH, + .setting_name = N_ (NM_SETTING_OLPC_MESH_SETTING_NAME), + .get_setting_gtype = nm_setting_olpc_mesh_get_type, + }, + [NM_META_SETTING_TYPE_PPPOE] = { + .meta_type = NM_META_SETTING_TYPE_PPPOE, + .setting_name = N_ (NM_SETTING_PPPOE_SETTING_NAME), + .get_setting_gtype = nm_setting_pppoe_get_type, + }, + [NM_META_SETTING_TYPE_PPP] = { + .meta_type = NM_META_SETTING_TYPE_PPP, + .setting_name = N_ (NM_SETTING_PPP_SETTING_NAME), + .get_setting_gtype = nm_setting_ppp_get_type, + }, + [NM_META_SETTING_TYPE_PROXY] = { + .meta_type = NM_META_SETTING_TYPE_PROXY, + .setting_name = N_ (NM_SETTING_PROXY_SETTING_NAME), + .get_setting_gtype = nm_setting_proxy_get_type, + }, + [NM_META_SETTING_TYPE_SERIAL] = { + .meta_type = NM_META_SETTING_TYPE_SERIAL, + .setting_name = N_ (NM_SETTING_SERIAL_SETTING_NAME), + .get_setting_gtype = nm_setting_serial_get_type, + }, + [NM_META_SETTING_TYPE_TEAM] = { + .meta_type = NM_META_SETTING_TYPE_TEAM, + .setting_name = N_ (NM_SETTING_TEAM_SETTING_NAME), + .get_setting_gtype = nm_setting_team_get_type, + }, + [NM_META_SETTING_TYPE_TEAM_PORT] = { + .meta_type = NM_META_SETTING_TYPE_TEAM_PORT, + .setting_name = N_ (NM_SETTING_TEAM_PORT_SETTING_NAME), + .get_setting_gtype = nm_setting_team_port_get_type, + }, + [NM_META_SETTING_TYPE_TUN] = { + .meta_type = NM_META_SETTING_TYPE_TUN, + .setting_name = N_ (NM_SETTING_TUN_SETTING_NAME), + .get_setting_gtype = nm_setting_tun_get_type, + }, + [NM_META_SETTING_TYPE_USER] = { + .meta_type = NM_META_SETTING_TYPE_USER, + .setting_name = N_ (NM_SETTING_USER_SETTING_NAME), + .get_setting_gtype = nm_setting_user_get_type, + }, + [NM_META_SETTING_TYPE_VLAN] = { + .meta_type = NM_META_SETTING_TYPE_VLAN, + .setting_name = N_ (NM_SETTING_VLAN_SETTING_NAME), + .get_setting_gtype = nm_setting_vlan_get_type, + }, + [NM_META_SETTING_TYPE_VPN] = { + .meta_type = NM_META_SETTING_TYPE_VPN, + .setting_name = N_ (NM_SETTING_VPN_SETTING_NAME), + .get_setting_gtype = nm_setting_vpn_get_type, + }, + [NM_META_SETTING_TYPE_VXLAN] = { + .meta_type = NM_META_SETTING_TYPE_VXLAN, + .setting_name = N_ (NM_SETTING_VXLAN_SETTING_NAME), + .get_setting_gtype = nm_setting_vxlan_get_type, + }, + [NM_META_SETTING_TYPE_WIMAX] = { + .meta_type = NM_META_SETTING_TYPE_WIMAX, + .setting_name = N_ (NM_SETTING_WIMAX_SETTING_NAME), + .get_setting_gtype = nm_setting_wimax_get_type, + }, + [NM_META_SETTING_TYPE_WIRED] = { + .meta_type = NM_META_SETTING_TYPE_WIRED, + .setting_name = N_ (NM_SETTING_WIRED_SETTING_NAME), + .get_setting_gtype = nm_setting_wired_get_type, + }, + [NM_META_SETTING_TYPE_WIRELESS] = { + .meta_type = NM_META_SETTING_TYPE_WIRELESS, + .setting_name = N_ (NM_SETTING_WIRELESS_SETTING_NAME), + .get_setting_gtype = nm_setting_wireless_get_type, + }, + [NM_META_SETTING_TYPE_WIRELESS_SECURITY] = { + .meta_type = NM_META_SETTING_TYPE_WIRELESS_SECURITY, + .setting_name = N_ (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME), + .get_setting_gtype = nm_setting_wireless_security_get_type, + }, + + [NM_META_SETTING_TYPE_UNKNOWN] = { + .meta_type = NM_META_SETTING_TYPE_UNKNOWN, + .setting_name = NULL, + }, +}; + +const NMMetaSettingInfo * +nm_meta_setting_infos_by_name (const char *name) +{ + int i; + + if (name) { + for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { + if (nm_streq (nm_meta_setting_infos[i].setting_name, name)) + return &nm_meta_setting_infos[i]; + } + } + return NULL; +} + +const NMMetaSettingInfo * +nm_meta_setting_infos_by_gtype (GType gtype) +{ + int i; + + for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { + if (nm_meta_setting_infos[i].get_setting_gtype () == gtype) + return &nm_meta_setting_infos[i]; + } + return NULL; +} + +/*****************************************************************************/ diff --git a/shared/nm-setting-metadata.h b/shared/nm-setting-metadata.h index 47e6e655eb..f215730eff 100644 --- a/shared/nm-setting-metadata.h +++ b/shared/nm-setting-metadata.h @@ -26,6 +26,19 @@ /*****************************************************************************/ +typedef enum { + NM_SETTING_802_1X_SCHEME_TYPE_CA_CERT, + NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_CA_CERT, + NM_SETTING_802_1X_SCHEME_TYPE_CLIENT_CERT, + NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_CLIENT_CERT, + NM_SETTING_802_1X_SCHEME_TYPE_PRIVATE_KEY, + NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_PRIVATE_KEY, + + NM_SETTING_802_1X_SCHEME_TYPE_UNKNOWN, + + _NM_SETTING_802_1X_SCHEME_TYPE_NUM = NM_SETTING_802_1X_SCHEME_TYPE_UNKNOWN, +} NMSetting8021xSchemeType; + typedef struct { const char *setting_key; NMSetting8021xCKScheme (*scheme_func) (NMSetting8021x *setting); @@ -38,18 +51,59 @@ typedef struct { const char *file_suffix; } NMSetting8021xSchemeVtable; -enum { - NM_SETTING_802_1X_SCHEME_TYPE_CA_CERT, - NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_CA_CERT, - NM_SETTING_802_1X_SCHEME_TYPE_CLIENT_CERT, - NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_CLIENT_CERT, - NM_SETTING_802_1X_SCHEME_TYPE_PRIVATE_KEY, - NM_SETTING_802_1X_SCHEME_TYPE_PHASE2_PRIVATE_KEY, +extern const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[_NM_SETTING_802_1X_SCHEME_TYPE_NUM + 1]; - NM_SETTING_802_1X_SCHEME_TYPE_UNKNOWN, -}; +/*****************************************************************************/ -extern const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[NM_SETTING_802_1X_SCHEME_TYPE_UNKNOWN + 1]; +typedef enum { + NM_META_SETTING_TYPE_802_1X, + NM_META_SETTING_TYPE_ADSL, + NM_META_SETTING_TYPE_BLUETOOTH, + NM_META_SETTING_TYPE_BOND, + NM_META_SETTING_TYPE_BRIDGE, + NM_META_SETTING_TYPE_BRIDGE_PORT, + NM_META_SETTING_TYPE_CDMA, + NM_META_SETTING_TYPE_CONNECTION, + NM_META_SETTING_TYPE_DCB, + NM_META_SETTING_TYPE_GSM, + NM_META_SETTING_TYPE_INFINIBAND, + NM_META_SETTING_TYPE_IP4_CONFIG, + NM_META_SETTING_TYPE_IP6_CONFIG, + NM_META_SETTING_TYPE_IP_TUNNEL, + NM_META_SETTING_TYPE_MACSEC, + NM_META_SETTING_TYPE_MACVLAN, + NM_META_SETTING_TYPE_OLPC_MESH, + NM_META_SETTING_TYPE_PPP, + NM_META_SETTING_TYPE_PPPOE, + NM_META_SETTING_TYPE_PROXY, + NM_META_SETTING_TYPE_SERIAL, + NM_META_SETTING_TYPE_TEAM, + NM_META_SETTING_TYPE_TEAM_PORT, + NM_META_SETTING_TYPE_TUN, + NM_META_SETTING_TYPE_USER, + NM_META_SETTING_TYPE_VLAN, + NM_META_SETTING_TYPE_VPN, + NM_META_SETTING_TYPE_VXLAN, + NM_META_SETTING_TYPE_WIMAX, + NM_META_SETTING_TYPE_WIRED, + NM_META_SETTING_TYPE_WIRELESS, + NM_META_SETTING_TYPE_WIRELESS_SECURITY, + + NM_META_SETTING_TYPE_UNKNOWN, + + _NM_META_SETTING_TYPE_NUM = NM_META_SETTING_TYPE_UNKNOWN, +} NMMetaSettingType; + +typedef struct { + NMMetaSettingType meta_type; + const char *setting_name; + GType (*get_setting_gtype) (void); +} NMMetaSettingInfo; + +extern const NMMetaSettingInfo nm_meta_setting_infos[_NM_META_SETTING_TYPE_NUM + 1]; + +const NMMetaSettingInfo *nm_meta_setting_infos_by_name (const char *name); +const NMMetaSettingInfo *nm_meta_setting_infos_by_gtype (GType gtype); /*****************************************************************************/ From d3ad7920dea0c396c44f2067b5658211d76df32b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Mar 2017 16:27:29 +0100 Subject: [PATCH 06/53] cli: add setting-info structure to settings.c Will get more use soon. --- Makefile.am | 3 + clients/cli/settings.c | 243 ++++++++++++++++++++++++++++------------- clients/cli/settings.h | 19 +++- 3 files changed, 186 insertions(+), 79 deletions(-) diff --git a/Makefile.am b/Makefile.am index bacc616de4..fb18977464 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3117,6 +3117,9 @@ if BUILD_NMCLI bin_PROGRAMS += clients/cli/nmcli clients_cli_nmcli_SOURCES = \ + \ + shared/nm-setting-metadata.c \ + shared/nm-setting-metadata.h \ \ clients/cli/agent.c \ clients/cli/agent.h \ diff --git a/clients/cli/settings.c b/clients/cli/settings.c index cf2a4b518c..0d579605cf 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -8654,7 +8654,7 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) static gboolean -setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_connection_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); NmcOutputField *tmpl, *arr; @@ -8698,7 +8698,7 @@ setting_connection_details (NMSetting *setting, NmCli *nmc, const char *one_pro } static gboolean -setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_wired_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWired *s_wired = NM_SETTING_WIRED (setting); NmcOutputField *tmpl, *arr; @@ -8737,7 +8737,7 @@ setting_wired_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb } static gboolean -setting_802_1X_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_802_1X_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting); NmcOutputField *tmpl, *arr; @@ -8806,7 +8806,7 @@ setting_802_1X_details (NMSetting *setting, NmCli *nmc, const char *one_prop, g } static gboolean -setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_wireless_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); NmcOutputField *tmpl, *arr; @@ -8847,7 +8847,7 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, } static gboolean -setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_wireless_security_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); NmcOutputField *tmpl, *arr; @@ -8889,7 +8889,7 @@ setting_wireless_security_details (NMSetting *setting, NmCli *nmc, const char *o } static gboolean -setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_ip4_config_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting); NmcOutputField *tmpl, *arr; @@ -8933,7 +8933,7 @@ setting_ip4_config_details (NMSetting *setting, NmCli *nmc, const char *one_pro } static gboolean -setting_ip6_config_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_ip6_config_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting); NmcOutputField *tmpl, *arr; @@ -8976,7 +8976,7 @@ setting_ip6_config_details (NMSetting *setting, NmCli *nmc, const char *one_pro } static gboolean -setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting); NmcOutputField *tmpl, *arr; @@ -9006,7 +9006,7 @@ setting_serial_details (NMSetting *setting, NmCli *nmc, const char *one_prop, g } static gboolean -setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_ppp_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingPpp *s_ppp = NM_SETTING_PPP (setting); NmcOutputField *tmpl, *arr; @@ -9049,7 +9049,7 @@ setting_ppp_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboo } static gboolean -setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_pppoe_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting); NmcOutputField *tmpl, *arr; @@ -9078,7 +9078,7 @@ setting_pppoe_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb } static gboolean -setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_gsm_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingGsm *s_gsm = NM_SETTING_GSM (setting); NmcOutputField *tmpl, *arr; @@ -9116,7 +9116,7 @@ setting_gsm_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboo } static gboolean -setting_cdma_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_cdma_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting); NmcOutputField *tmpl, *arr; @@ -9146,7 +9146,7 @@ setting_cdma_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gbo } static gboolean -setting_bluetooth_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_bluetooth_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting); NmcOutputField *tmpl, *arr; @@ -9173,7 +9173,7 @@ setting_bluetooth_details (NMSetting *setting, NmCli *nmc, const char *one_prop } static gboolean -setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_olpc_mesh_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting); NmcOutputField *tmpl, *arr; @@ -9201,7 +9201,7 @@ setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc, const char *one_prop } static gboolean -setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_vpn_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVpn *s_vpn = NM_SETTING_VPN (setting); NmcOutputField *tmpl, *arr; @@ -9232,7 +9232,7 @@ setting_vpn_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboo } static gboolean -setting_wimax_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_wimax_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting); NmcOutputField *tmpl, *arr; @@ -9259,7 +9259,7 @@ setting_wimax_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb } static gboolean -setting_infiniband_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_infiniband_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting); NmcOutputField *tmpl, *arr; @@ -9289,7 +9289,7 @@ setting_infiniband_details (NMSetting *setting, NmCli *nmc, const char *one_pro } static gboolean -setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_bond_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBond *s_bond = NM_SETTING_BOND (setting); NmcOutputField *tmpl, *arr; @@ -9315,7 +9315,7 @@ setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gbo } static gboolean -setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_vlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); NmcOutputField *tmpl, *arr; @@ -9345,7 +9345,7 @@ setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gbo } static gboolean -setting_adsl_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_adsl_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting); NmcOutputField *tmpl, *arr; @@ -9377,7 +9377,7 @@ setting_adsl_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gbo } static gboolean -setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_bridge_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting); NmcOutputField *tmpl, *arr; @@ -9410,7 +9410,7 @@ setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop, g } static gboolean -setting_bridge_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_bridge_port_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting); NmcOutputField *tmpl, *arr; @@ -9438,7 +9438,7 @@ setting_bridge_port_details (NMSetting *setting, NmCli *nmc, const char *one_pr } static gboolean -setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_team_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTeam *s_team = NM_SETTING_TEAM (setting); NmcOutputField *tmpl, *arr; @@ -9464,7 +9464,7 @@ setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gbo } static gboolean -setting_team_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_team_port_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting); NmcOutputField *tmpl, *arr; @@ -9490,7 +9490,7 @@ setting_team_port_details (NMSetting *setting, NmCli *nmc, const char *one_prop } static gboolean -setting_dcb_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_dcb_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); NmcOutputField *tmpl, *arr; @@ -9530,7 +9530,7 @@ setting_dcb_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboo } static gboolean -setting_tun_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_tun_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingTun *s_tun = NM_SETTING_TUN (setting); NmcOutputField *tmpl, *arr; @@ -9561,7 +9561,7 @@ setting_tun_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboo } static gboolean -setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_ip_tunnel_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting); NmcOutputField *tmpl, *arr; @@ -9598,7 +9598,7 @@ setting_ip_tunnel_details (NMSetting *setting, NmCli *nmc, const char *one_prop } static gboolean -setting_macsec_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_macsec_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingMacsec *s_macsec = NM_SETTING_MACSEC (setting); NmcOutputField *tmpl, *arr; @@ -9631,7 +9631,7 @@ setting_macsec_details (NMSetting *setting, NmCli *nmc, const char *one_prop, g } static gboolean -setting_macvlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_macvlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting); NmcOutputField *tmpl, *arr; @@ -9660,7 +9660,7 @@ setting_macvlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, } static gboolean -setting_vxlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_vxlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting); NmcOutputField *tmpl, *arr; @@ -9701,7 +9701,7 @@ setting_vxlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb } static gboolean -setting_proxy_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting); NmcOutputField *tmpl, *arr; @@ -9729,60 +9729,147 @@ setting_proxy_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gb return TRUE; } -typedef struct { - const char *sname; - gboolean (*func) (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); -} SettingDetails; - -static const SettingDetails detail_printers[] = { - { NM_SETTING_CONNECTION_SETTING_NAME, setting_connection_details }, - { NM_SETTING_WIRED_SETTING_NAME, setting_wired_details }, - { NM_SETTING_802_1X_SETTING_NAME, setting_802_1X_details }, - { NM_SETTING_WIRELESS_SETTING_NAME, setting_wireless_details }, - { NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, setting_wireless_security_details }, - { NM_SETTING_IP4_CONFIG_SETTING_NAME, setting_ip4_config_details }, - { NM_SETTING_IP6_CONFIG_SETTING_NAME, setting_ip6_config_details }, - { NM_SETTING_SERIAL_SETTING_NAME, setting_serial_details }, - { NM_SETTING_PPP_SETTING_NAME, setting_ppp_details }, - { NM_SETTING_PPPOE_SETTING_NAME, setting_pppoe_details }, - { NM_SETTING_GSM_SETTING_NAME, setting_gsm_details }, - { NM_SETTING_CDMA_SETTING_NAME, setting_cdma_details }, - { NM_SETTING_BLUETOOTH_SETTING_NAME, setting_bluetooth_details }, - { NM_SETTING_OLPC_MESH_SETTING_NAME, setting_olpc_mesh_details }, - { NM_SETTING_VPN_SETTING_NAME, setting_vpn_details }, - { NM_SETTING_WIMAX_SETTING_NAME, setting_wimax_details }, - { NM_SETTING_INFINIBAND_SETTING_NAME, setting_infiniband_details }, - { NM_SETTING_BOND_SETTING_NAME, setting_bond_details }, - { NM_SETTING_VLAN_SETTING_NAME, setting_vlan_details }, - { NM_SETTING_ADSL_SETTING_NAME, setting_adsl_details }, - { NM_SETTING_BRIDGE_SETTING_NAME, setting_bridge_details }, - { NM_SETTING_BRIDGE_PORT_SETTING_NAME, setting_bridge_port_details }, - { NM_SETTING_TEAM_SETTING_NAME, setting_team_details }, - { NM_SETTING_TEAM_PORT_SETTING_NAME, setting_team_port_details }, - { NM_SETTING_DCB_SETTING_NAME, setting_dcb_details }, - { NM_SETTING_TUN_SETTING_NAME, setting_tun_details }, - { NM_SETTING_IP_TUNNEL_SETTING_NAME, setting_ip_tunnel_details }, - { NM_SETTING_MACSEC_SETTING_NAME, setting_macsec_details }, - { NM_SETTING_MACVLAN_SETTING_NAME, setting_macvlan_details }, - { NM_SETTING_VXLAN_SETTING_NAME, setting_vxlan_details }, - { NM_SETTING_PROXY_SETTING_NAME, setting_proxy_details }, - { NULL }, +const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { + [NM_META_SETTING_TYPE_802_1X] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], + .get_setting_details = setting_802_1X_details, + }, + [NM_META_SETTING_TYPE_ADSL] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_ADSL], + .get_setting_details = setting_adsl_details, + }, + [NM_META_SETTING_TYPE_BLUETOOTH] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BLUETOOTH], + .get_setting_details = setting_bluetooth_details, + }, + [NM_META_SETTING_TYPE_BOND] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BOND], + .get_setting_details = setting_bond_details, + }, + [NM_META_SETTING_TYPE_BRIDGE] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE], + .get_setting_details = setting_bridge_details, + }, + [NM_META_SETTING_TYPE_BRIDGE_PORT] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE_PORT], + .get_setting_details = setting_bridge_port_details, + }, + [NM_META_SETTING_TYPE_CDMA] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CDMA], + .get_setting_details = setting_cdma_details, + }, + [NM_META_SETTING_TYPE_CONNECTION] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CONNECTION], + .get_setting_details = setting_connection_details, + }, + [NM_META_SETTING_TYPE_DCB] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DCB], + .get_setting_details = setting_dcb_details, + }, + [NM_META_SETTING_TYPE_GSM] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_GSM], + .get_setting_details = setting_gsm_details, + }, + [NM_META_SETTING_TYPE_INFINIBAND] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_INFINIBAND], + .get_setting_details = setting_infiniband_details, + }, + [NM_META_SETTING_TYPE_IP4_CONFIG] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP4_CONFIG], + .get_setting_details = setting_ip4_config_details, + }, + [NM_META_SETTING_TYPE_IP6_CONFIG] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP6_CONFIG], + .get_setting_details = setting_ip6_config_details, + }, + [NM_META_SETTING_TYPE_IP_TUNNEL] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP_TUNNEL], + .get_setting_details = setting_ip_tunnel_details, + }, + [NM_META_SETTING_TYPE_MACSEC] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACSEC], + .get_setting_details = setting_macsec_details, + }, + [NM_META_SETTING_TYPE_MACVLAN] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACVLAN], + .get_setting_details = setting_macvlan_details, + }, + [NM_META_SETTING_TYPE_OLPC_MESH] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_OLPC_MESH], + .get_setting_details = setting_olpc_mesh_details, + }, + [NM_META_SETTING_TYPE_PPPOE] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPPOE], + .get_setting_details = setting_pppoe_details, + }, + [NM_META_SETTING_TYPE_PPP] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPP], + .get_setting_details = setting_ppp_details, + }, + [NM_META_SETTING_TYPE_PROXY] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PROXY], + .get_setting_details = setting_proxy_details, + }, + [NM_META_SETTING_TYPE_SERIAL] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_SERIAL], + .get_setting_details = setting_serial_details, + }, + [NM_META_SETTING_TYPE_TEAM] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM], + .get_setting_details = setting_team_details, + }, + [NM_META_SETTING_TYPE_TEAM_PORT] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM_PORT], + .get_setting_details = setting_team_port_details, + }, + [NM_META_SETTING_TYPE_TUN] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TUN], + .get_setting_details = setting_tun_details, + }, + [NM_META_SETTING_TYPE_VLAN] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VLAN], + .get_setting_details = setting_vlan_details, + }, + [NM_META_SETTING_TYPE_VPN] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VPN], + .get_setting_details = setting_vpn_details, + }, + [NM_META_SETTING_TYPE_VXLAN] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VXLAN], + .get_setting_details = setting_vxlan_details, + }, + [NM_META_SETTING_TYPE_WIMAX] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIMAX], + .get_setting_details = setting_wimax_details, + }, + [NM_META_SETTING_TYPE_WIRED] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRED], + .get_setting_details = setting_wired_details, + }, + [NM_META_SETTING_TYPE_WIRELESS] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS], + .get_setting_details = setting_wireless_details, + }, + [NM_META_SETTING_TYPE_WIRELESS_SECURITY] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS_SECURITY], + .get_setting_details = setting_wireless_security_details, + }, }; gboolean -setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { - const SettingDetails *iter = &detail_printers[0]; + const NMMetaSettingInfo *meta_setting_info; + const NmcSettingInfo *setting_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); - while (iter->sname) { - if (nm_setting_lookup_type (iter->sname) == G_OBJECT_TYPE (setting)) - return iter->func (setting, nmc, one_prop, secrets); - iter++; - } + meta_setting_info = nm_meta_setting_infos_by_gtype (G_OBJECT_TYPE (setting)); + g_return_val_if_fail (meta_setting_info, FALSE); - g_assert_not_reached (); - return FALSE; + setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + g_return_val_if_fail (setting_info && setting_info->get_setting_details, FALSE); + + return setting_info->get_setting_details (setting_info, setting, nmc, one_prop, secrets); } diff --git a/clients/cli/settings.h b/clients/cli/settings.h index f663aa46d4..86b7691e09 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -20,10 +20,27 @@ #ifndef NMC_SETTINGS_H #define NMC_SETTINGS_H +#include "nm-setting-metadata.h" + #include "nmcli.h" #include "utils.h" -/* --- Functions --- */ +/*****************************************************************************/ + +typedef struct _NmcSettingInfo NmcSettingInfo; + +struct _NmcSettingInfo { + const NMMetaSettingInfo *general; + gboolean (*get_setting_details) (const NmcSettingInfo *setting_info, + NMSetting *setting, + NmCli *nmc, + const char *one_prop, + gboolean secrets); +}; + +extern const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM]; + +/*****************************************************************************/ void nmc_properties_init (void); void nmc_properties_cleanup (void); From 4e91492b7614cd0d7a3b2deb3289327a1be654cb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Mar 2017 17:32:04 +0100 Subject: [PATCH 07/53] cli: rework property handling via NmcPropertyInfo for NMSettingConnection Add an improved way of tracking meta data about settings. E.g. it is wrong to generate for each property a nmc_property_*_get_*() function. Instead, there should be a meta data about the property itself, and a mechanism to retrieve the property. For now, only do this for NMSettingConnection and keep all the existing infrastructure in place. Later on all settings shall be moved. Especially to accomodate NmcOutputField mangles the concept of setting-meta data, formatting options, and collecting output results. It's a total hack, that will be need fixing later. --- clients/cli/connections.c | 41 ++++-- clients/cli/nmcli.c | 20 ++- clients/cli/nmcli.h | 12 +- clients/cli/settings.c | 282 +++++++++++++++++++++++++++----------- clients/cli/settings.h | 29 +++- clients/cli/utils.c | 39 ++++-- 6 files changed, 321 insertions(+), 102 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 07c1cd23c1..95c8d8435d 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -148,11 +148,22 @@ NmcOutputField nmc_fields_con_show[] = { #define NMC_FIELDS_CON_SHOW_COMMON "NAME,UUID,TYPE,DEVICE" /* Helper macro to define fields */ -#define SETTING_FIELD(setting, props) { setting, N_(setting), 0, props, NULL, FALSE, FALSE, 0 } +#define SETTING_FIELD(setting, props) \ + { \ + .name = setting, \ + .name_l10n = N_(setting), \ + .group_list = props, \ + } +#define SETTING_FIELD_TYPE(setting, setting_type) \ + { \ + .name = setting, \ + .name_l10n = N_ (setting), \ + .setting_info = &nmc_setting_infos[setting_type], \ + } /* Available settings for 'connection show ' - profile part */ NmcOutputField nmc_fields_settings_names[] = { - SETTING_FIELD (NM_SETTING_CONNECTION_SETTING_NAME, nmc_fields_setting_connection + 1), /* 0 */ + SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), SETTING_FIELD (NM_SETTING_WIRED_SETTING_NAME, nmc_fields_setting_wired + 1), /* 1 */ SETTING_FIELD (NM_SETTING_802_1X_SETTING_NAME, nmc_fields_setting_8021X + 1), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ @@ -3179,6 +3190,7 @@ get_valid_properties_string (const NameItem *array, { const NameItem *iter = array; const NmcOutputField *field_iter; + const NmcSettingInfo *setting_info; const char *prop_name = NULL; GString *str; int i, j; @@ -3219,20 +3231,31 @@ get_valid_properties_string (const NameItem *array, g_assert (nmc_fields_settings_names[j].name); j++; } - field_iter = nmc_fields_settings_names[j].group; + field_iter = nmc_fields_settings_names[j].group_list; + setting_info = nmc_fields_settings_names[j].setting_info; j = 0; - while (field_iter[j].name) { + while (TRUE) { gchar *new; - const char *arg_name = field_iter[j].name; + const char *arg_name; + + if (field_iter) { + arg_name = field_iter[j].name; + if (!arg_name) + break; + } else { + if (j + 1 >= setting_info->properties_num) + break; + arg_name = setting_info->properties[j + 1].property_name; + } /* If required, expand the alias too */ if (!postfix && iter->alias) { if (modifier) g_string_append_c (str, modifier); new = g_strdup_printf ("%s.%s\n", - iter->alias, - arg_name); + iter->alias, + arg_name); g_string_append (str, new); g_free (new); } @@ -3245,8 +3268,8 @@ get_valid_properties_string (const NameItem *array, if (modifier) g_string_append_c (str, modifier); new = g_strdup_printf ("%s.%s\n", - prop_name, - arg_name); + prop_name, + arg_name); g_string_append (str, new); g_free (new); j++; diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index ee3f747b46..630fe871e6 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -66,7 +66,23 @@ struct termios termios_orig; NM_CACHED_QUARK_FCN ("nmcli-error-quark", nmcli_error_quark) static void -complete_field (GHashTable *h, const char *setting, NmcOutputField field[]) +complete_field_new (GHashTable *h, const char *setting, NMMetaSettingType setting_type) +{ + const NmcSettingInfo *setting_info = &nmc_setting_infos[setting_type]; + int i; + + for (i = 0; i < setting_info->properties_num; i++) { + const char *n = setting_info->properties[i].property_name; + + if (setting) + g_hash_table_add (h, g_strdup_printf ("%s.%s", setting, n)); + else + g_hash_table_add (h, g_strdup (n)); + } +} + +static void +complete_field (GHashTable *h, const char *setting, const NmcOutputField *field) { int i; @@ -130,7 +146,7 @@ complete_fields (const char *prefix) complete_field (h, NULL, nmc_fields_dev_show_sections); complete_field (h, NULL, nmc_fields_dev_lldp_list); - complete_field (h, "connection", nmc_fields_setting_connection); + complete_field_new (h, "connection", NM_META_SETTING_TYPE_CONNECTION); complete_field (h, "802-3-ethernet", nmc_fields_setting_wired); complete_field (h, "802-1x", nmc_fields_setting_8021X); complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 7e33e3a70a..8efb09289b 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -104,17 +104,27 @@ typedef enum { #define NMC_OF_FLAG_MAIN_HEADER_ADD 0x00000004 /* Print main header in addition to values/field names */ #define NMC_OF_FLAG_MAIN_HEADER_ONLY 0x00000008 /* Print main header only */ +struct _NmcSettingInfo; + typedef struct _NmcOutputField { const char *name; /* Field's name */ const char *name_l10n; /* Field's name for translation */ int width; /* Width in screen columns */ - struct _NmcOutputField *group; /* Points to an array with available section field names if this is a section (group) field */ + const struct _NmcOutputField *group_list; /* Points to an array with available section field names if this is a section (group) field */ void *value; /* Value of current field - char* or char** (NULL-terminated array) */ gboolean value_is_array; /* Whether value is char** instead of char* */ gboolean free_value; /* Whether to free the value */ guint32 flags; /* Flags - whether and how to print values/field names/headers */ NmcTermColor color; /* Use this color to print value */ NmcTermFormat color_fmt; /* Use this terminal format to print value */ + + /* in a very particular case NmcOutputField is used in combination with + * the @group_list above. That list will go away (and the entire NmcOutputField + * should separate formatting-options, setting-metadata and output. + * + * For now, hack around that by alternatively providing a @setting_info instead + * of @group_list. */ + const struct _NmcSettingInfo *setting_info; } NmcOutputField; typedef struct { diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 0d579605cf..7f3869f05f 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -29,61 +29,76 @@ #include "common.h" #include "nm-vpn-helpers.h" -/* Forward declarations */ -static char *wep_key_type_to_string (NMWepKeyType type); +/*****************************************************************************/ -typedef enum { - NMC_PROPERTY_GET_PRETTY, - NMC_PROPERTY_GET_PARSABLE, -} NmcPropertyGetType; - -/* Helper macro to define fields */ #define SETTING_FIELD(setting) { setting, N_(setting), 0, NULL, FALSE, FALSE, 0 } -/* Available fields for NM_SETTING_CONNECTION_SETTING_NAME */ -NmcOutputField nmc_fields_setting_connection[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_CONNECTION_ID), /* 1 */ - SETTING_FIELD (NM_SETTING_CONNECTION_UUID), /* 2 */ - SETTING_FIELD (NM_SETTING_CONNECTION_STABLE_ID), /* 3 */ - SETTING_FIELD (NM_SETTING_CONNECTION_INTERFACE_NAME), /* 4 */ - SETTING_FIELD (NM_SETTING_CONNECTION_TYPE), /* 5 */ - SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT), /* 6 */ - SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), /* 7 */ - SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), /* 8 */ - SETTING_FIELD (NM_SETTING_CONNECTION_TIMESTAMP), /* 9 */ - SETTING_FIELD (NM_SETTING_CONNECTION_READ_ONLY), /* 10 */ - SETTING_FIELD (NM_SETTING_CONNECTION_PERMISSIONS), /* 11 */ - SETTING_FIELD (NM_SETTING_CONNECTION_ZONE), /* 12 */ - SETTING_FIELD (NM_SETTING_CONNECTION_MASTER), /* 13 */ - SETTING_FIELD (NM_SETTING_CONNECTION_SLAVE_TYPE), /* 14 */ - SETTING_FIELD (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), /* 15 */ - SETTING_FIELD (NM_SETTING_CONNECTION_SECONDARIES), /* 16 */ - SETTING_FIELD (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), /* 17 */ - SETTING_FIELD (NM_SETTING_CONNECTION_METERED), /* 18 */ - SETTING_FIELD (NM_SETTING_CONNECTION_LLDP), /* 19 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_CONNECTION_ALL "name"","\ - NM_SETTING_CONNECTION_ID","\ - NM_SETTING_CONNECTION_UUID","\ - NM_SETTING_CONNECTION_STABLE_ID","\ - NM_SETTING_CONNECTION_INTERFACE_NAME","\ - NM_SETTING_CONNECTION_TYPE","\ - NM_SETTING_CONNECTION_AUTOCONNECT","\ - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY","\ - NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES","\ - NM_SETTING_CONNECTION_TIMESTAMP","\ - NM_SETTING_CONNECTION_READ_ONLY","\ - NM_SETTING_CONNECTION_PERMISSIONS","\ - NM_SETTING_CONNECTION_ZONE","\ - NM_SETTING_CONNECTION_MASTER","\ - NM_SETTING_CONNECTION_SLAVE_TYPE","\ - NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES","\ - NM_SETTING_CONNECTION_SECONDARIES","\ - NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT","\ - NM_SETTING_CONNECTION_METERED","\ - NM_SETTING_CONNECTION_LLDP +static char *wep_key_type_to_string (NMWepKeyType type); + +/*****************************************************************************/ + +static char * +_get_fcn_direct (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + return g_strdup (property_info->get_data.get_direct (setting)); +} + +static char * +_get_fcn_nmc (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + return property_info->get_data.get_nmc (setting, get_type); +} + +static char * +_get_fcn_gobject (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + char *s; + GValue val = G_VALUE_INIT; + + g_value_init (&val, G_TYPE_STRING); + g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); + s = g_value_dup_string (&val); + g_value_unset (&val); + return s; +} + +/*****************************************************************************/ + +static const NmcOutputField * +_get_nmc_output_fields (const NmcSettingInfo *setting_info) +{ + static NmcOutputField *fields[_NM_META_SETTING_TYPE_NUM + 1] = { }; + NmcOutputField **field; + guint i; + + g_return_val_if_fail (setting_info, NULL); + g_return_val_if_fail (setting_info->general->meta_type < _NM_META_SETTING_TYPE_NUM, NULL); + + field = &fields[setting_info->general->meta_type]; + + if (G_UNLIKELY (!*field)) { + *field = g_new0 (NmcOutputField, setting_info->properties_num + 1); + for (i = 0; i < setting_info->properties_num; i++) { + NmcOutputField *f = &(*field)[i]; + + f->name = setting_info->properties[i].property_name; + f->name_l10n = setting_info->properties[i].property_name; + } + } + + return *field; +} + +/*****************************************************************************/ /* Available fields for NM_SETTING_WIRED_SETTING_NAME */ NmcOutputField nmc_fields_setting_wired[] = { @@ -8654,42 +8669,33 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) static gboolean -setting_connection_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +_get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { - NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); - NmcOutputField *tmpl, *arr; + gs_free NmcOutputField *tmpl = NULL; + NmcOutputField *arr; + guint i; size_t tmpl_len; - g_return_val_if_fail (NM_IS_SETTING_CONNECTION (s_con), FALSE); + g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE); - tmpl = nmc_fields_setting_connection; - tmpl_len = sizeof (nmc_fields_setting_connection); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CONNECTION_ALL, + tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1); + tmpl = g_memdup (_get_nmc_output_fields (setting_info), tmpl_len); + + nmc->print_fields.indices = parse_output_fields (one_prop ?: setting_info->all_properties, tmpl, FALSE, NULL, NULL); arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); g_ptr_array_add (nmc->output_data, arr); arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_connection_get_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_connection_get_uuid (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_connection_get_stable_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_connection_get_interface_name (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_connection_get_type (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_connection_get_autoconnect (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_connection_get_autoconnect_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_connection_get_autoconnect_retries (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_connection_get_timestamp (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_connection_get_read_only (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_connection_get_permissions (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_connection_get_zone (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_connection_get_master (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_connection_get_slave_type (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_connection_get_autoconnect_slaves (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_connection_get_secondaries (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 17, nmc_property_connection_get_gateway_ping_timeout (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 18, nmc_property_connection_get_metered (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 19, nmc_property_connection_get_lldp (setting, NMC_PROPERTY_GET_PRETTY)); + for (i = 0; i < setting_info->properties_num; i++) { + const NmcPropertyInfo *property_info = &setting_info->properties[i]; + + set_val_str (arr, i, property_info->get_fcn (setting_info, + property_info, + setting, + NMC_PROPERTY_GET_PRETTY)); + } + g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -9729,6 +9735,119 @@ setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, N return TRUE; } +/*****************************************************************************/ + +static const NmcPropertyInfo properties_setting_connection[] = { + { + .property_name = N_ ("name"), + .is_name = TRUE, + .get_fcn = _get_fcn_direct, + .get_data = { .get_direct = nm_setting_get_name, }, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_ID), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_UUID), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_STABLE_ID), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_INTERFACE_NAME), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_TYPE), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), + .get_fcn = _get_fcn_nmc, + .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_retries, }, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_TIMESTAMP), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_READ_ONLY), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_PERMISSIONS), + .get_fcn = _get_fcn_nmc, + .get_data = { .get_nmc = nmc_property_connection_get_permissions, }, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_ZONE), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_MASTER), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_SLAVE_TYPE), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), + .get_fcn = _get_fcn_nmc, + .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_slaves, }, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_SECONDARIES), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), + .get_fcn = _get_fcn_gobject, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_METERED), + .get_fcn = _get_fcn_nmc, + .get_data = { .get_nmc = nmc_property_connection_get_metered, }, + }, + { + .property_name = N_ (NM_SETTING_CONNECTION_LLDP), + .get_fcn = _get_fcn_nmc, + .get_data = { .get_nmc = nmc_property_connection_get_lldp, }, + }, +}; + +#define NMC_FIELDS_SETTING_CONNECTION_ALL "name"","\ + NM_SETTING_CONNECTION_ID","\ + NM_SETTING_CONNECTION_UUID","\ + NM_SETTING_CONNECTION_STABLE_ID","\ + NM_SETTING_CONNECTION_INTERFACE_NAME","\ + NM_SETTING_CONNECTION_TYPE","\ + NM_SETTING_CONNECTION_AUTOCONNECT","\ + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY","\ + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES","\ + NM_SETTING_CONNECTION_TIMESTAMP","\ + NM_SETTING_CONNECTION_READ_ONLY","\ + NM_SETTING_CONNECTION_PERMISSIONS","\ + NM_SETTING_CONNECTION_ZONE","\ + NM_SETTING_CONNECTION_MASTER","\ + NM_SETTING_CONNECTION_SLAVE_TYPE","\ + NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES","\ + NM_SETTING_CONNECTION_SECONDARIES","\ + NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT","\ + NM_SETTING_CONNECTION_METERED","\ + NM_SETTING_CONNECTION_LLDP + const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], @@ -9760,7 +9879,10 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_CONNECTION] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CONNECTION], - .get_setting_details = setting_connection_details, + .get_setting_details = _get_setting_details, + .properties = properties_setting_connection, + .properties_num = G_N_ELEMENTS (properties_setting_connection), + .all_properties = NMC_FIELDS_SETTING_CONNECTION_ALL, }, [NM_META_SETTING_TYPE_DCB] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DCB], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 86b7691e09..3735a1f087 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -27,7 +27,32 @@ /*****************************************************************************/ +typedef enum { + NMC_PROPERTY_GET_PRETTY, + NMC_PROPERTY_GET_PARSABLE, +} NmcPropertyGetType; + typedef struct _NmcSettingInfo NmcSettingInfo; +typedef struct _NmcPropertyInfo NmcPropertyInfo; + +struct _NmcPropertyInfo { + const char *property_name; + + /* the property list for now must contain as first field the + * "name", which isn't a regular property. This is required by + * NmcOutputField and this first field is ignored for the + * group_list/setting_info. */ + bool is_name:1; + + char *(*get_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type); + union { + const char *(*get_direct) (NMSetting *setting); + char *(*get_nmc) (NMSetting *setting, NmcPropertyGetType get_type); + } get_data; +}; struct _NmcSettingInfo { const NMMetaSettingInfo *general; @@ -36,6 +61,9 @@ struct _NmcSettingInfo { NmCli *nmc, const char *one_prop, gboolean secrets); + const NmcPropertyInfo *properties; + guint properties_num; + const char *all_properties; }; extern const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM]; @@ -81,7 +109,6 @@ gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue * gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); -extern NmcOutputField nmc_fields_setting_connection[]; extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_8021X[]; extern NmcOutputField nmc_fields_setting_wireless[]; diff --git a/clients/cli/utils.c b/clients/cli/utils.c index fbd643ffc4..0bdeac87ee 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -29,6 +29,7 @@ #include "utils.h" #include "common.h" +#include "settings.h" gboolean matches (const char *cmd, const char *pattern) @@ -869,16 +870,27 @@ parse_output_fields (const char *fields_str, for (i = 0; fields_array[i].name; i++) { if (strcasecmp (left, fields_array[i].name) == 0) { - NmcOutputField *valid_names = fields_array[i].group; + const NmcOutputField *valid_names = fields_array[i].group_list; + const NmcSettingInfo *setting_info = fields_array[i].setting_info; + idx = i; - if (!right && !valid_names) { + if (!right && !valid_names && !setting_info) { found = TRUE; break; } - for (j = 0; valid_names && valid_names[j].name; j++) { - if (!right || strcasecmp (right, valid_names[j].name) == 0) { - found = TRUE; - break; + if (valid_names) { + for (j = 0; valid_names[j].name; j++) { + if (!right || strcasecmp (right, valid_names[j].name) == 0) { + found = TRUE; + break; + } + } + } else if (setting_info) { + for (j = 1; j < setting_info->properties_num; j++) { + if (!right || strcasecmp (right, setting_info->properties[j].property_name) == 0) { + found = TRUE; + break; + } } } if (found) @@ -946,11 +958,20 @@ nmc_get_allowed_fields (const NmcOutputField fields_array[], int group_idx) GString *allowed_fields = g_string_sized_new (256); int i; - if (group_idx != -1 && fields_array[group_idx].group) { - NmcOutputField *second_level = fields_array[group_idx].group; - for (i = 0; second_level[i].name; i++) + if (group_idx != -1 && fields_array[group_idx].group_list) { + const NmcOutputField *second_level = fields_array[group_idx].group_list; + + for (i = 0; second_level[i].name; i++) { g_string_append_printf (allowed_fields, "%s.%s,", fields_array[group_idx].name, second_level[i].name); + } + } else if (group_idx != -1 && fields_array[group_idx].setting_info) { + const NmcSettingInfo *second_level = fields_array[group_idx].setting_info; + + for (i = 1; i < second_level->properties_num; i++) { + g_string_append_printf (allowed_fields, "%s.%s,", + fields_array[group_idx].name, second_level->properties[i].property_name); + } } else { for (i = 0; fields_array[i].name; i++) g_string_append_printf (allowed_fields, "%s,", fields_array[i].name); From 8b96cee1249d3c4d240cc9f7e3cd5b38e47462a0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 12:56:10 +0100 Subject: [PATCH 08/53] cli: implement property getter for "connection" setting via nmc_setting_info --- clients/cli/settings.c | 190 ++++++++++++++++++++++++++++++++--------- 1 file changed, 149 insertions(+), 41 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 7f3869f05f..c0fdbe36df 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -73,6 +73,116 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, /*****************************************************************************/ +static const NmcSettingInfo * +_meta_find_setting_info_by_name (const char *setting_name) +{ + const NMMetaSettingInfo *meta_setting_info; + const NmcSettingInfo *setting_info; + + g_return_val_if_fail (setting_name, NULL); + + meta_setting_info = nm_meta_setting_infos_by_name (setting_name); + + if (!meta_setting_info) + return NULL; + + g_return_val_if_fail (nm_streq0 (meta_setting_info->setting_name, setting_name), NULL); + + if (meta_setting_info->meta_type >= G_N_ELEMENTS (nmc_setting_infos)) + return NULL; + + setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + + g_return_val_if_fail (setting_info->general == meta_setting_info, NULL); + + return setting_info; +} + +static const NmcSettingInfo * +_meta_find_setting_info_by_gtype (GType gtype) +{ + const NMMetaSettingInfo *meta_setting_info; + const NmcSettingInfo *setting_info; + + meta_setting_info = nm_meta_setting_infos_by_gtype (gtype); + + if (!meta_setting_info) + return NULL; + + g_return_val_if_fail (meta_setting_info->get_setting_gtype, NULL); + g_return_val_if_fail (meta_setting_info->get_setting_gtype () == gtype, NULL); + + if (meta_setting_info->meta_type >= G_N_ELEMENTS (nmc_setting_infos)) + return NULL; + + setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + + g_return_val_if_fail (setting_info->general == meta_setting_info, NULL); + + return setting_info; +} + +static const NmcSettingInfo * +_meta_find_setting_info_by_setting (NMSetting *setting) +{ + const NmcSettingInfo *setting_info; + + g_return_val_if_fail (NM_IS_SETTING (setting), NULL); + + setting_info = _meta_find_setting_info_by_gtype (G_OBJECT_TYPE (setting)); + + if (!setting_info) + return NULL; + + g_return_val_if_fail (setting_info == _meta_find_setting_info_by_name (nm_setting_get_name (setting)), NULL); + + return setting_info; +} + +static const NmcPropertyInfo * +_meta_setting_info_find_property_info (const NmcSettingInfo *setting_info, const char *property_name) +{ + guint i; + + g_return_val_if_fail (setting_info, NULL); + g_return_val_if_fail (property_name, NULL); + + for (i = 0; i < setting_info->properties_num; i++) { + if (nm_streq (setting_info->properties[i].property_name, property_name)) + return &setting_info->properties[i]; + } + + return NULL; +} + +static const NmcPropertyInfo * +_meta_find_property_info_by_name (const char *setting_name, const char *property_name, const NmcSettingInfo **out_setting_info) +{ + const NmcSettingInfo *setting_info; + + setting_info = _meta_find_setting_info_by_name (setting_name); + + NM_SET_OUT (out_setting_info, setting_info); + if (!setting_info) + return NULL; + return _meta_setting_info_find_property_info (setting_info, property_name); +} + +static const NmcPropertyInfo * +_meta_find_property_info_by_setting (NMSetting *setting, const char *property_name, const NmcSettingInfo **out_setting_info) +{ + const NmcSettingInfo *setting_info; + + setting_info = _meta_find_setting_info_by_setting (setting); + + NM_SET_OUT (out_setting_info, setting_info); + if (!setting_info) + return NULL; + return _meta_setting_info_find_property_info (setting_info, property_name); +} + +/*****************************************************************************/ + static const NmcOutputField * _get_nmc_output_fields (const NmcSettingInfo *setting_info) { @@ -2472,18 +2582,6 @@ DEFINE_GETTER (nmc_property_cdma_get_mtu, NM_SETTING_CDMA_MTU) DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS) - -/* --- NM_SETTING_CONNECTION_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_connection_get_id, NM_SETTING_CONNECTION_ID) -DEFINE_GETTER (nmc_property_connection_get_uuid, NM_SETTING_CONNECTION_UUID) -DEFINE_GETTER (nmc_property_connection_get_stable_id, NM_SETTING_CONNECTION_STABLE_ID) -DEFINE_GETTER (nmc_property_connection_get_interface_name, NM_SETTING_CONNECTION_INTERFACE_NAME) -DEFINE_GETTER (nmc_property_connection_get_type, NM_SETTING_CONNECTION_TYPE) -DEFINE_GETTER (nmc_property_connection_get_autoconnect, NM_SETTING_CONNECTION_AUTOCONNECT) -DEFINE_GETTER (nmc_property_connection_get_autoconnect_priority, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY) -DEFINE_GETTER (nmc_property_connection_get_timestamp, NM_SETTING_CONNECTION_TIMESTAMP) -DEFINE_GETTER (nmc_property_connection_get_read_only, NM_SETTING_CONNECTION_READ_ONLY) - static char * nmc_property_connection_get_autoconnect_retries (NMSetting *setting, NmcPropertyGetType get_type) { @@ -2527,10 +2625,6 @@ nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType return g_string_free (perm, TRUE); } -DEFINE_GETTER (nmc_property_connection_get_zone, NM_SETTING_CONNECTION_ZONE) -DEFINE_GETTER (nmc_property_connection_get_master, NM_SETTING_CONNECTION_MASTER) -DEFINE_GETTER (nmc_property_connection_get_slave_type, NM_SETTING_CONNECTION_SLAVE_TYPE) - static char * nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type) { @@ -2538,9 +2632,6 @@ nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyG return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type); } -DEFINE_GETTER (nmc_property_connection_get_secondaries, NM_SETTING_CONNECTION_SECONDARIES) -DEFINE_GETTER (nmc_property_connection_get_gateway_ping_timeout, NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT) - static gboolean nmc_property_connection_set_type (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -2863,7 +2954,6 @@ nmc_property_connection_describe_metered (NMSetting *setting, const char *prop) static const char *metered_valid_values[] = { "yes", "no", "unknown", NULL }; DEFINE_ALLOWED_VAL_FUNC (nmc_property_connection_allowed_metered, metered_valid_values) -/* 'lldp' */ static char * nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type) { @@ -6710,133 +6800,133 @@ nmc_properties_init (void) /* Add editable properties for NM_SETTING_CONNECTION_SETTING_NAME */ nmc_add_prop_funcs (GLUE (CONNECTION, ID), - nmc_property_connection_get_id, + NULL, nmc_property_set_string, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, UUID), - nmc_property_connection_get_uuid, + NULL, NULL, /* forbid setting/removing UUID */ NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, STABLE_ID), - nmc_property_connection_get_stable_id, + NULL, nmc_property_set_string, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME), - nmc_property_connection_get_interface_name, + NULL, nmc_property_set_ifname, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, TYPE), - nmc_property_connection_get_type, + NULL, nmc_property_connection_set_type, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT), - nmc_property_connection_get_autoconnect, + NULL, nmc_property_set_bool, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY), - nmc_property_connection_get_autoconnect_priority, + NULL, nmc_property_set_int, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_RETRIES), - nmc_property_connection_get_autoconnect_retries, + NULL, nmc_property_set_int, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP), - nmc_property_connection_get_timestamp, + NULL, NULL, /* read-only */ NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY), - nmc_property_connection_get_read_only, + NULL, NULL, /* 'read-only' is read-only :-) */ NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS), - nmc_property_connection_get_permissions, + NULL, nmc_property_connection_set_permissions, nmc_property_connection_remove_permissions, nmc_property_connection_describe_permissions, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, ZONE), - nmc_property_connection_get_zone, + NULL, nmc_property_set_string, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, MASTER), - nmc_property_connection_get_master, + NULL, nmc_property_con_set_master, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE), - nmc_property_connection_get_slave_type, + NULL, nmc_property_con_set_slave_type, NULL, NULL, nmc_property_con_allowed_slave_type, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES), - nmc_property_connection_get_autoconnect_slaves, + NULL, nmc_property_set_trilean, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES), - nmc_property_connection_get_secondaries, + NULL, nmc_property_connection_set_secondaries, nmc_property_connection_remove_secondaries, nmc_property_connection_describe_secondaries, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT), - nmc_property_connection_get_gateway_ping_timeout, + NULL, nmc_property_set_uint, NULL, NULL, NULL, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, METERED), - nmc_property_connection_get_metered, + NULL, nmc_property_connection_set_metered, NULL, nmc_property_connection_describe_metered, nmc_property_connection_allowed_metered, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, LLDP), - nmc_property_connection_get_lldp, + NULL, nmc_property_connection_set_lldp, NULL, NULL, @@ -8406,13 +8496,31 @@ static char * get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error) { const NmcPropertyFuncs *item; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->get_func) - return item->get_func (setting, get_type); + if (item) { + if (item->get_func) + return item->get_func (setting, get_type); + } + + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->get_fcn) { + return property_info->get_fcn (setting_info, + property_info, + setting, + get_type); + } + } g_set_error_literal (error, 1, 0, _("don't know how to get the property value")); return NULL; From 2de82f11c91ee6bf2a5e3789bb65515ff49fd968 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 13:20:11 +0100 Subject: [PATCH 09/53] cli: add set_func() to NmcPropertyInfo and use for "connection" setting --- clients/cli/settings.c | 367 ++++++++++++++++++++++++----------------- clients/cli/settings.h | 9 + 2 files changed, 225 insertions(+), 151 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index c0fdbe36df..413d1e1eb3 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -34,6 +34,8 @@ #define SETTING_FIELD(setting) { setting, N_(setting), 0, NULL, FALSE, FALSE, 0 } static char *wep_key_type_to_string (NMWepKeyType type); +static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); +static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); /*****************************************************************************/ @@ -73,6 +75,111 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, /*****************************************************************************/ +static gboolean +_set_fcn_nmc (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + return property_info->set_data.set_nmc (setting, property_info->property_name, value, error); +} + +static gboolean +_set_fcn_gobject_string (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + g_object_set (setting, property_info->property_name, value, NULL); + return TRUE; +} + +static gboolean +_set_fcn_gobject_bool (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + gboolean val_bool; + + if (!nmc_string_to_bool (value, &val_bool, error)) + return FALSE; + + g_object_set (setting, property_info->property_name, val_bool, NULL); + return TRUE; +} + +static gboolean +_set_fcn_gobject_trilean (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + long int val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!nmc_string_to_int (value, TRUE, -1, 1, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), value); + return FALSE; + } + + g_object_set (setting, property_info->property_name, val_int, NULL); + return TRUE; +} + +static gboolean +_set_fcn_gobject_int (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + long int val_int; + + if (!nmc_string_to_int (value, TRUE, G_MININT, G_MAXINT, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); + return FALSE; + } + + /* Validate the number according to the property spec */ + if (!validate_int (setting, property_info->property_name, (gint) val_int, error)) + return FALSE; + + g_object_set (setting, property_info->property_name, (gint) val_int, NULL); + return TRUE; +} + +static gboolean +_set_fcn_gobject_uint (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + unsigned long val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!nmc_string_to_uint (value, TRUE, 0, G_MAXUINT, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); + return FALSE; + } + + /* Validate the number according to the property spec */ + if (!validate_uint (setting, property_info->property_name, (guint) val_int, error)) + return FALSE; + + g_object_set (setting, property_info->property_name, (guint) val_int, NULL); + return TRUE; +} + +/*****************************************************************************/ + static const NmcSettingInfo * _meta_find_setting_info_by_name (const char *setting_name) { @@ -1631,22 +1738,6 @@ nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GE return TRUE; } -static gboolean -nmc_property_set_trilean (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - long int val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_int (val, TRUE, -1, 1, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), val); - return FALSE; - } - - g_object_set (setting, prop, val_int, NULL); - return TRUE; -} - static gboolean nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -2633,7 +2724,11 @@ nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyG } static gboolean -nmc_property_connection_set_type (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_connection_type (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { gs_free char *uuid = NULL; @@ -2654,7 +2749,7 @@ nmc_property_connection_set_type (NMSetting *setting, const char *prop, const ch NM_SETTING_CONNECTION_UUID, uuid, NULL); - g_object_set (G_OBJECT (setting), prop, val, NULL); + g_object_set (G_OBJECT (setting), property_info->property_name, value, NULL); return TRUE; } @@ -2700,15 +2795,19 @@ permissions_valid (const char *perm) } static gboolean -nmc_property_connection_set_permissions (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_connection_permissions (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL; guint i = 0; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, " \t,", 0); - if (!verify_string_list (strv, prop, permissions_valid, error)) { + strv = nmc_strsplit_set (value, " \t,", 0); + if (!verify_string_list (strv, property_info->property_name, permissions_valid, error)) { g_strfreev (strv); return FALSE; } @@ -2754,24 +2853,27 @@ nmc_property_connection_describe_permissions (NMSetting *setting, const char *pr "Example: alice bob charlie\n"); } -/* 'master' */ static gboolean -nmc_property_con_set_master (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_connection_master (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!val) + if (!value) ; - else if (!*val) - val = NULL; - else if ( !nm_utils_is_valid_iface_name (val, NULL) - && !nm_utils_is_uuid (val)) { + else if (!*value) + value = NULL; + else if ( !nm_utils_is_valid_iface_name (value, NULL) + && !nm_utils_is_uuid (value)) { g_set_error (error, 1, 0, _("'%s' is not valid master; use ifname or connection UUID"), - val); + value); return FALSE; } - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); return TRUE; } @@ -2789,22 +2891,22 @@ nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const cha return check_and_set_string (setting, prop, val, con_valid_slave_types, error); } - DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types) -/* 'secondaries' */ static gboolean -nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_connection_secondaries (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { const GPtrArray *connections; NMConnection *con; char **strv = NULL, **iter; guint i = 0; - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - connections = nm_client_get_connections (nm_cli.client); - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); for (iter = strv; iter && *iter; iter++) { if (**iter == '\0') continue; @@ -2914,13 +3016,16 @@ nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_ } static gboolean -nmc_property_connection_set_metered (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_connection_metered (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { NMMetered metered; NMCTriStateValue ts_val; - if (!nmc_string_to_tristate (val, &ts_val, error)) + if (!nmc_string_to_tristate (value, &ts_val, error)) return FALSE; switch (ts_val) { @@ -2937,7 +3042,7 @@ nmc_property_connection_set_metered (NMSetting *setting, const char *prop, g_assert_not_reached(); } - g_object_set (setting, prop, metered, NULL); + g_object_set (setting, property_info->property_name, metered, NULL); return TRUE; } @@ -2972,34 +3077,37 @@ nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_typ } static gboolean -nmc_property_connection_set_lldp (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_connection_lldp (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { NMSettingConnectionLldp lldp; gboolean ret; long int t; - if (nmc_string_to_int_base (val, 0, TRUE, + if (nmc_string_to_int_base (value, 0, TRUE, NM_SETTING_CONNECTION_LLDP_DEFAULT, NM_SETTING_CONNECTION_LLDP_ENABLE_RX, &t)) lldp = t; else { - ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), val, + ret = nm_utils_enum_from_str (nm_setting_connection_lldp_get_type (), value, (int *) &lldp, NULL); if (!ret) { - if (g_ascii_strcasecmp (val, "enable") == 0) + if (g_ascii_strcasecmp (value, "enable") == 0) lldp = NM_SETTING_CONNECTION_LLDP_ENABLE_RX; else { g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), - val, "default,disable,enable-rx,enable"); + value, "default,disable,enable-rx,enable"); return FALSE; } } } - g_object_set (setting, prop, lldp, NULL); + g_object_set (setting, property_info->property_name, lldp, NULL); return TRUE; } @@ -6798,136 +6906,37 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_CONNECTION_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (CONNECTION, ID), - NULL, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, UUID), - NULL, - NULL, /* forbid setting/removing UUID */ - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, STABLE_ID), - NULL, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, INTERFACE_NAME), - NULL, - nmc_property_set_ifname, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, TYPE), - NULL, - nmc_property_connection_set_type, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT), - NULL, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_PRIORITY), - NULL, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_RETRIES), - NULL, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, TIMESTAMP), - NULL, - NULL, /* read-only */ - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, READ_ONLY), - NULL, - NULL, /* 'read-only' is read-only :-) */ - NULL, - NULL, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS), NULL, - nmc_property_connection_set_permissions, + NULL, nmc_property_connection_remove_permissions, nmc_property_connection_describe_permissions, NULL, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, ZONE), - NULL, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, MASTER), - NULL, - nmc_property_con_set_master, - NULL, - NULL, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE), NULL, - nmc_property_con_set_slave_type, + NULL, NULL, NULL, nmc_property_con_allowed_slave_type, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, AUTOCONNECT_SLAVES), - NULL, - nmc_property_set_trilean, - NULL, - NULL, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES), NULL, - nmc_property_connection_set_secondaries, + NULL, nmc_property_connection_remove_secondaries, nmc_property_connection_describe_secondaries, NULL, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, GATEWAY_PING_TIMEOUT), - NULL, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, METERED), NULL, - nmc_property_connection_set_metered, + NULL, NULL, nmc_property_connection_describe_metered, nmc_property_connection_allowed_metered, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, LLDP), NULL, - nmc_property_connection_set_lldp, + NULL, NULL, NULL, nmc_property_connection_allowed_lldp, @@ -8561,6 +8570,8 @@ gboolean nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error) { const NmcPropertyFuncs *item; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -8575,6 +8586,27 @@ nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, return item->set_func (setting, prop, val, error); } + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (!val) { + /* No value argument sets default value */ + nmc_property_set_default_value (setting, prop); + return TRUE; + } + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->set_fcn) { + return property_info->set_fcn (setting_info, + property_info, + setting, + val, + error); + } + } + g_set_error_literal (error, 1, 0, _("the property can't be changed")); return FALSE; } @@ -8606,6 +8638,8 @@ gboolean nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error) { const NmcPropertyFuncs *item; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -8615,6 +8649,19 @@ nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error nmc_property_set_default_value (setting, prop); return TRUE; } + + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->set_fcn) { + nmc_property_set_default_value (setting, prop); + return TRUE; + } + } + g_set_error_literal (error, 1, 0, _("the property can't be changed")); return FALSE; } @@ -9855,6 +9902,7 @@ static const NmcPropertyInfo properties_setting_connection[] = { { .property_name = N_ (NM_SETTING_CONNECTION_ID), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_UUID), @@ -9863,27 +9911,34 @@ static const NmcPropertyInfo properties_setting_connection[] = { { .property_name = N_ (NM_SETTING_CONNECTION_STABLE_ID), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_INTERFACE_NAME), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .set_data = { .set_nmc = nmc_property_set_ifname, }, }, { .property_name = N_ (NM_SETTING_CONNECTION_TYPE), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_type, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_retries, }, + .set_fcn = _set_fcn_gobject_int, }, { .property_name = N_ (NM_SETTING_CONNECTION_TIMESTAMP), @@ -9897,41 +9952,51 @@ static const NmcPropertyInfo properties_setting_connection[] = { .property_name = N_ (NM_SETTING_CONNECTION_PERMISSIONS), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_permissions, }, + .set_fcn = _set_fcn_connection_permissions, }, { .property_name = N_ (NM_SETTING_CONNECTION_ZONE), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_MASTER), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_master, }, { .property_name = N_ (NM_SETTING_CONNECTION_SLAVE_TYPE), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .set_data = { .set_nmc = nmc_property_con_set_slave_type, }, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_slaves, }, + .set_fcn = _set_fcn_gobject_trilean, }, { .property_name = N_ (NM_SETTING_CONNECTION_SECONDARIES), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_secondaries, }, { .property_name = N_ (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_uint, }, { .property_name = N_ (NM_SETTING_CONNECTION_METERED), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_metered, }, + .set_fcn = _set_fcn_connection_metered, }, { .property_name = N_ (NM_SETTING_CONNECTION_LLDP), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_lldp, }, + .set_fcn = _set_fcn_connection_lldp, }, }; diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 3735a1f087..6bf45a7814 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -52,6 +52,15 @@ struct _NmcPropertyInfo { const char *(*get_direct) (NMSetting *setting); char *(*get_nmc) (NMSetting *setting, NmcPropertyGetType get_type); } get_data; + + gboolean (*set_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error); + union { + gboolean (*set_nmc) (NMSetting *setting, const char *property_name, const char *value, GError **error); + } set_data; }; struct _NmcSettingInfo { From 850d652cdbc5e9b5f1edb31731484dbff84b065d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 13:20:11 +0100 Subject: [PATCH 10/53] cli: add remove_func() to NmcPropertyInfo and use for "connection" setting --- clients/cli/settings.c | 39 +++++++++++++++++++++++++++++++++++++-- clients/cli/settings.h | 10 ++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 413d1e1eb3..d58f732165 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -180,6 +180,19 @@ _set_fcn_gobject_uint (const NmcSettingInfo *setting_info, /*****************************************************************************/ +static gboolean +_remove_fcn_nmc (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *option, + guint32 idx, + GError **error) +{ + return property_info->remove_data.remove_nmc (setting, property_info->property_name, option, idx, error); +} + +/*****************************************************************************/ + static const NmcSettingInfo * _meta_find_setting_info_by_name (const char *setting_name) { @@ -6909,7 +6922,7 @@ nmc_properties_init (void) nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS), NULL, NULL, - nmc_property_connection_remove_permissions, + NULL, nmc_property_connection_describe_permissions, NULL, NULL); @@ -6923,7 +6936,7 @@ nmc_properties_init (void) nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES), NULL, NULL, - nmc_property_connection_remove_secondaries, + NULL, nmc_property_connection_describe_secondaries, NULL, NULL); @@ -8683,6 +8696,8 @@ nmc_setting_remove_property_option (NMSetting *setting, GError **error) { const NmcPropertyFuncs *item; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -8691,6 +8706,22 @@ nmc_setting_remove_property_option (NMSetting *setting, if (item && item->remove_func) return item->remove_func (setting, prop, option, idx, error); + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->remove_fcn) { + return property_info->remove_fcn (setting_info, + property_info, + setting, + option, + idx, + error); + } + } + return TRUE; } @@ -9953,6 +9984,8 @@ static const NmcPropertyInfo properties_setting_connection[] = { .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_permissions, }, .set_fcn = _set_fcn_connection_permissions, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_connection_remove_permissions, }, }, { .property_name = N_ (NM_SETTING_CONNECTION_ZONE), @@ -9980,6 +10013,8 @@ static const NmcPropertyInfo properties_setting_connection[] = { .property_name = N_ (NM_SETTING_CONNECTION_SECONDARIES), .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_connection_secondaries, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_connection_remove_secondaries, }, }, { .property_name = N_ (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 6bf45a7814..531783585a 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -61,6 +61,16 @@ struct _NmcPropertyInfo { union { gboolean (*set_nmc) (NMSetting *setting, const char *property_name, const char *value, GError **error); } set_data; + + gboolean (*remove_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *option, + guint32 idx, + GError **error); + union { + gboolean (*remove_nmc) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); + } remove_data; }; struct _NmcSettingInfo { From 10119aa3a370aa812b9f01a7cc457178a7374f3a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 13:20:11 +0100 Subject: [PATCH 11/53] cli: add remove_func() to NmcPropertyInfo and use for "connection" setting --- clients/cli/settings.c | 78 ++++++++++++++++++------------------------ clients/cli/settings.h | 2 ++ 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index d58f732165..d8bdc19917 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -2857,15 +2857,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions, nm_setting_connection_remove_permission, _validate_and_remove_connection_permission) -static const char * -nmc_property_connection_describe_permissions (NMSetting *setting, const char *prop) -{ - return _("Enter a list of user permissions. This is a list of user names formatted as:\n" - " [user:], [user:],...\n" - "The items can be separated by commas or spaces.\n\n" - "Example: alice bob charlie\n"); -} - static gboolean _set_fcn_connection_master (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -2989,17 +2980,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_secondaries, nm_setting_connection_remove_secondary, _validate_and_remove_connection_secondary) -static const char * -nmc_property_connection_describe_secondaries (NMSetting *setting, const char *prop) -{ - return _("Enter secondary connections that should be activated when this connection is\n" - "activated. Connections can be specified either by UUID or ID (name). nmcli\n" - "transparently translates names to UUIDs. Note that NetworkManager only supports\n" - "VPNs as secondary connections at the moment.\n" - "The items can be separated by commas or spaces.\n\n" - "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n"); -} - /* 'metered' */ static char * nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type) @@ -3059,16 +3039,6 @@ _set_fcn_connection_metered (const NmcSettingInfo *setting_info, return TRUE; } -static const char * -nmc_property_connection_describe_metered (NMSetting *setting, const char *prop) -{ - return _("Enter a value which indicates whether the connection is subject to a data\n" - "quota, usage costs or other limitations. Accepted options are:\n" - "'true','yes','on' to set the connection as metered\n" - "'false','no','off' to set the connection as not metered\n" - "'unknown' to let NetworkManager choose a value using some heuristics\n"); -} - static const char *metered_valid_values[] = { "yes", "no", "unknown", NULL }; DEFINE_ALLOWED_VAL_FUNC (nmc_property_connection_allowed_metered, metered_valid_values) @@ -6919,13 +6889,6 @@ nmc_properties_init (void) NULL, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, PERMISSIONS), - NULL, - NULL, - NULL, - nmc_property_connection_describe_permissions, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE), NULL, NULL, @@ -6933,18 +6896,11 @@ nmc_properties_init (void) NULL, nmc_property_con_allowed_slave_type, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, SECONDARIES), - NULL, - NULL, - NULL, - nmc_property_connection_describe_secondaries, - NULL, - NULL); nmc_add_prop_funcs (GLUE (CONNECTION, METERED), NULL, NULL, NULL, - nmc_property_connection_describe_metered, + NULL, nmc_property_connection_allowed_metered, NULL); nmc_add_prop_funcs (GLUE (CONNECTION, LLDP), @@ -8793,6 +8749,8 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) const char *nmcli_desc = NULL; const char *nmcli_desc_title = ""; const char *nmcli_nl = ""; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); @@ -8805,8 +8763,20 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) nmcli_desc = item->describe_func (setting, prop); nmcli_desc_title = _("[nmcli specific description]"); nmcli_nl = "\n"; + } else if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->describe_message) { + nmcli_desc = _(property_info->describe_message); + nmcli_desc_title = _("[nmcli specific description]"); + nmcli_nl = "\n"; + } } + return g_strdup_printf ("%s\n%s\n%s%s%s%s", setting_desc_title, setting_desc ? setting_desc : "", @@ -9986,6 +9956,11 @@ static const NmcPropertyInfo properties_setting_connection[] = { .set_fcn = _set_fcn_connection_permissions, .remove_fcn = _remove_fcn_nmc, .remove_data = { .remove_nmc = nmc_property_connection_remove_permissions, }, + .describe_message = + N_ ("Enter a list of user permissions. This is a list of user names formatted as:\n" + " [user:], [user:],...\n" + "The items can be separated by commas or spaces.\n\n" + "Example: alice bob charlie\n"), }, { .property_name = N_ (NM_SETTING_CONNECTION_ZONE), @@ -10015,6 +9990,13 @@ static const NmcPropertyInfo properties_setting_connection[] = { .set_fcn = _set_fcn_connection_secondaries, .remove_fcn = _remove_fcn_nmc, .remove_data = { .remove_nmc = nmc_property_connection_remove_secondaries, }, + .describe_message = + N_ ("Enter secondary connections that should be activated when this connection is\n" + "activated. Connections can be specified either by UUID or ID (name). nmcli\n" + "transparently translates names to UUIDs. Note that NetworkManager only supports\n" + "VPNs as secondary connections at the moment.\n" + "The items can be separated by commas or spaces.\n\n" + "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n"), }, { .property_name = N_ (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), @@ -10026,6 +10008,12 @@ static const NmcPropertyInfo properties_setting_connection[] = { .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_metered, }, .set_fcn = _set_fcn_connection_metered, + .describe_message = + N_ ("Enter a value which indicates whether the connection is subject to a data\n" + "quota, usage costs or other limitations. Accepted options are:\n" + "'true','yes','on' to set the connection as metered\n" + "'false','no','off' to set the connection as not metered\n" + "'unknown' to let NetworkManager choose a value using some heuristics\n"), }, { .property_name = N_ (NM_SETTING_CONNECTION_LLDP), diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 531783585a..1ab46aaf92 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -71,6 +71,8 @@ struct _NmcPropertyInfo { union { gboolean (*remove_nmc) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); } remove_data; + + const char *describe_message; }; struct _NmcSettingInfo { From cb66cf96d741a093abc7fa4e97f49a7651949282 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 13:20:11 +0100 Subject: [PATCH 12/53] cli: add values_func() to NmcPropertyInfo and use for "connection" setting --- clients/cli/common.c | 2 +- clients/cli/common.h | 2 +- clients/cli/connections.c | 13 ++++---- clients/cli/settings.c | 62 +++++++++++++++------------------------ clients/cli/settings.h | 4 ++- clients/cli/utils.c | 2 +- clients/cli/utils.h | 2 +- 7 files changed, 38 insertions(+), 49 deletions(-) diff --git a/clients/cli/common.c b/clients/cli/common.c index 3e28eee7a9..e3f00482e2 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -1500,7 +1500,7 @@ nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) * See e.g. http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC49 */ char * -nmc_rl_gen_func_basic (const char *text, int state, const char **words) +nmc_rl_gen_func_basic (const char *text, int state, const char *const*words) { static int list_idx, len; const char *name; diff --git a/clients/cli/common.h b/clients/cli/common.h index 3a598f631c..d755879a53 100644 --- a/clients/cli/common.h +++ b/clients/cli/common.h @@ -65,7 +65,7 @@ char *nmc_unique_connection_name (const GPtrArray *connections, void nmc_cleanup_readline (void); char *nmc_readline (const char *prompt_fmt, ...) G_GNUC_PRINTF (1, 2); char *nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) G_GNUC_PRINTF (2, 3); -char *nmc_rl_gen_func_basic (const char *text, int state, const char **words); +char *nmc_rl_gen_func_basic (const char *text, int state, const char *const*words); char *nmc_rl_gen_func_ifnames (const char *text, int state); gboolean nmc_get_in_readline (void); void nmc_set_in_readline (gboolean in_readline); diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 95c8d8435d..d02768fea5 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -5705,12 +5705,12 @@ should_complete_vpn_uuids (const char *prompt, const char *line) return _get_and_check_property (prompt, line, uuid_properties, NULL, NULL); } -static const char ** +static const char *const* get_allowed_property_values (void) { NMSetting *setting; char *property; - const char **avals = NULL; + const char *const*avals = NULL; get_setting_and_property (rl_prompt, rl_line_buffer, &setting, &property); if (setting && property) @@ -5781,7 +5781,7 @@ static char * gen_property_values (const char *text, int state) { char *ret = NULL; - const char **avals; + const char *const*avals; avals = get_allowed_property_values (); if (avals) @@ -6662,7 +6662,8 @@ property_edit_submenu (NmCli *nmc, * single values: : both SET and ADD sets the new value */ if (!cmd_property_arg) { - const char **avals = nmc_setting_get_property_allowed_values (curr_setting, prop_name); + const char *const*avals = nmc_setting_get_property_allowed_values (curr_setting, prop_name); + if (avals) { char *avals_str = nmc_util_strv_for_display (avals, FALSE); g_print (_("Allowed values for '%s' property: %s\n"), @@ -7074,7 +7075,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t if (menu_ctx.level == 1) { const char *prop_name; char *prop_val_user = NULL; - const char **avals; + const char *const*avals; GError *tmp_err = NULL; prop_name = ask_check_property (cmd_arg, @@ -7141,7 +7142,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t /* Ask for value */ if (!cmd_arg_v) { - const char **avals = nmc_setting_get_property_allowed_values (ss, prop_name); + const char *const*avals = nmc_setting_get_property_allowed_values (ss, prop_name); if (avals) { char *avals_str = nmc_util_strv_for_display (avals, FALSE); g_print (_("Allowed values for '%s' property: %s\n"), diff --git a/clients/cli/settings.c b/clients/cli/settings.c index d8bdc19917..4ac791b394 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -1456,14 +1456,14 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) } #define DEFINE_ALLOWED_VAL_FUNC(def_func, valid_values) \ - static const char ** \ + static const char *const* \ def_func (NMSetting *setting, const char *prop) \ { \ return valid_values; \ } #define DEFINE_ALLOWED_FOR_ENUMS(def_func, get_type_func, min, max) \ - static const char ** \ + static const char *const* \ def_func (NMSetting *setting, const char *prop) \ { \ static const char **words = NULL; \ @@ -2654,7 +2654,7 @@ nmc_property_bond_describe_options (NMSetting *setting, const char *prop) return desc; } -static const char ** +static const char *const* nmc_property_bond_allowed_options (NMSetting *setting, const char *prop) { return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting)); @@ -2895,8 +2895,6 @@ nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const cha return check_and_set_string (setting, prop, val, con_valid_slave_types, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_types) - static gboolean _set_fcn_connection_secondaries (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -3039,9 +3037,6 @@ _set_fcn_connection_metered (const NmcSettingInfo *setting_info, return TRUE; } -static const char *metered_valid_values[] = { "yes", "no", "unknown", NULL }; -DEFINE_ALLOWED_VAL_FUNC (nmc_property_connection_allowed_metered, metered_valid_values) - static char * nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type) { @@ -3094,10 +3089,6 @@ _set_fcn_connection_lldp (const NmcSettingInfo *setting_info, return TRUE; } -static const char *lldp_valid_values[] = { "default", "disable", "enable-rx", NULL }; -DEFINE_ALLOWED_VAL_FUNC (nmc_property_connection_allowed_lldp, lldp_valid_values) - - /* --- NM_SETTING_DCB_SETTING_NAME property functions --- */ static char * dcb_flags_to_string (NMSettingDcbFlags flags) @@ -5384,7 +5375,7 @@ DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options, NM_SETTING_WIRED, nm_setting_wired_remove_s390_option) -static const char ** +static const char *const* nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop) { return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting)); @@ -5974,7 +5965,7 @@ typedef char * (*NmcPropertyGetFunc) (NMSetting *, NmcPropertyGetTyp typedef gboolean (*NmcPropertySetFunc) (NMSetting *, const char *, const char *, GError **); typedef gboolean (*NmcPropertyRemoveFunc) (NMSetting *, const char *, const char *, guint32, GError **); typedef const char * (*NmcPropertyDescribeFunc) (NMSetting *, const char *); -typedef const char ** (*NmcPropertyValuesFunc) (NMSetting *, const char *); +typedef const char *const* (*NmcPropertyValuesFunc) (NMSetting *, const char *); typedef struct { /* The order of the fields is important as they correspond @@ -6889,28 +6880,6 @@ nmc_properties_init (void) NULL, NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, SLAVE_TYPE), - NULL, - NULL, - NULL, - NULL, - nmc_property_con_allowed_slave_type, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, METERED), - NULL, - NULL, - NULL, - NULL, - nmc_property_connection_allowed_metered, - NULL); - nmc_add_prop_funcs (GLUE (CONNECTION, LLDP), - NULL, - NULL, - NULL, - NULL, - nmc_property_connection_allowed_lldp, - NULL); - /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */ nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS), nmc_property_dcb_get_app_fcoe_flags, @@ -8715,11 +8684,13 @@ nmc_setting_get_valid_properties (NMSetting *setting) /* * Return allowed values for 'prop' as a string. */ -const char ** +const char *const* nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) { const NmcPropertyFuncs *item; + const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); @@ -8727,7 +8698,17 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) if (item && item->values_func) return item->values_func (setting, prop); - return NULL; + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); + + if (property_info->is_name) { + /* NmcPropertyFuncs would not register the "name" property. + * For the moment, skip it from get_property_val(). */ + } else if (property_info->values_static) + return property_info->values_static; + } + +return NULL; } #include "settings-docs.c" @@ -9893,6 +9874,8 @@ setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, N /*****************************************************************************/ +#define VALUES_STATIC(...) (((const char *[]) { __VA_ARGS__, NULL })) + static const NmcPropertyInfo properties_setting_connection[] = { { .property_name = N_ ("name"), @@ -9977,6 +9960,7 @@ static const NmcPropertyInfo properties_setting_connection[] = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_nmc, .set_data = { .set_nmc = nmc_property_con_set_slave_type, }, + .values_static = con_valid_slave_types, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), @@ -10014,12 +9998,14 @@ static const NmcPropertyInfo properties_setting_connection[] = { "'true','yes','on' to set the connection as metered\n" "'false','no','off' to set the connection as not metered\n" "'unknown' to let NetworkManager choose a value using some heuristics\n"), + .values_static = VALUES_STATIC ("yes", "no", "unknown"), }, { .property_name = N_ (NM_SETTING_CONNECTION_LLDP), .get_fcn = _get_fcn_nmc, .get_data = { .get_nmc = nmc_property_connection_get_lldp, }, .set_fcn = _set_fcn_connection_lldp, + .values_static = VALUES_STATIC ("default", "disable", "enable-rx"), }, }; diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 1ab46aaf92..2cf53936ee 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -73,6 +73,8 @@ struct _NmcPropertyInfo { } remove_data; const char *describe_message; + + const char *const*values_static; }; struct _NmcSettingInfo { @@ -104,7 +106,7 @@ void nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMCo char **nmc_setting_get_valid_properties (NMSetting *setting); char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop); -const char **nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop); +const char *const*nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop); char *nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error); diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 0bdeac87ee..4252cd2cb4 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -677,7 +677,7 @@ finish: * Returns: a newly allocated string. Caller must free it with g_free(). */ char * -nmc_util_strv_for_display (const char **strv, gboolean brackets) +nmc_util_strv_for_display (const char *const*strv, gboolean brackets) { GString *result; guint i = 0; diff --git a/clients/cli/utils.h b/clients/cli/utils.h index d889962df7..d1dac09929 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -81,7 +81,7 @@ char *nmc_get_user_input (const char *ask_str); int nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote, char ***argv, int *argc); const char *nmc_string_is_valid (const char *input, const char **allowed, GError **error); -char * nmc_util_strv_for_display (const char **strv, gboolean brackets); +char * nmc_util_strv_for_display (const char *const*strv, gboolean brackets); char **nmc_strsplit_set (const char *str, const char *delimiter, int max_tokens); int nmc_string_screen_width (const char *start, const char *end); void set_val_str (NmcOutputField fields_array[], guint32 index, char *value); From f7937c8f4a35e9c04002e289f1ae1478c338d1c2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 15:45:28 +0100 Subject: [PATCH 13/53] cli: generate all-properties list from NmcSettingInfo It's redundant information that requires us to declare it in the static meta data. Generate it instead as needed. --- clients/cli/settings.c | 40 +++++++++++++++++----------------------- clients/cli/settings.h | 3 ++- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 4ac791b394..6bd4f4f675 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -8805,6 +8805,21 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) #define GET_SECRET(show, setting, func) \ (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) +static char * +_all_properties (const NmcSettingInfo *setting_info) +{ + GString *str; + guint i; + + str = g_string_sized_new (250); + for (i = 0; i < setting_info->properties_num; i++) { + if (str->len) + g_string_append_c (str, ','); + g_string_append (str, setting_info->properties[i].property_name); + } + return g_string_free (str, FALSE); +} + static gboolean _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -8812,13 +8827,14 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm NmcOutputField *arr; guint i; size_t tmpl_len; + gs_free char *s_all = NULL; g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE); tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1); tmpl = g_memdup (_get_nmc_output_fields (setting_info), tmpl_len); - nmc->print_fields.indices = parse_output_fields (one_prop ?: setting_info->all_properties, + nmc->print_fields.indices = parse_output_fields (one_prop ?: (s_all = _all_properties (setting_info)), tmpl, FALSE, NULL, NULL); arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); g_ptr_array_add (nmc->output_data, arr); @@ -10009,27 +10025,6 @@ static const NmcPropertyInfo properties_setting_connection[] = { }, }; -#define NMC_FIELDS_SETTING_CONNECTION_ALL "name"","\ - NM_SETTING_CONNECTION_ID","\ - NM_SETTING_CONNECTION_UUID","\ - NM_SETTING_CONNECTION_STABLE_ID","\ - NM_SETTING_CONNECTION_INTERFACE_NAME","\ - NM_SETTING_CONNECTION_TYPE","\ - NM_SETTING_CONNECTION_AUTOCONNECT","\ - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY","\ - NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES","\ - NM_SETTING_CONNECTION_TIMESTAMP","\ - NM_SETTING_CONNECTION_READ_ONLY","\ - NM_SETTING_CONNECTION_PERMISSIONS","\ - NM_SETTING_CONNECTION_ZONE","\ - NM_SETTING_CONNECTION_MASTER","\ - NM_SETTING_CONNECTION_SLAVE_TYPE","\ - NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES","\ - NM_SETTING_CONNECTION_SECONDARIES","\ - NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT","\ - NM_SETTING_CONNECTION_METERED","\ - NM_SETTING_CONNECTION_LLDP - const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], @@ -10064,7 +10059,6 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { .get_setting_details = _get_setting_details, .properties = properties_setting_connection, .properties_num = G_N_ELEMENTS (properties_setting_connection), - .all_properties = NMC_FIELDS_SETTING_CONNECTION_ALL, }, [NM_META_SETTING_TYPE_DCB] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DCB], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 2cf53936ee..89a9c7c6d1 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -84,9 +84,10 @@ struct _NmcSettingInfo { NmCli *nmc, const char *one_prop, gboolean secrets); + /* the order of the properties matter. The first *must* be the + * "name", and then the order is as they are listed by default. */ const NmcPropertyInfo *properties; guint properties_num; - const char *all_properties; }; extern const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM]; From c023edc3bbef50cd51bd265c13a9c517bdb2848c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 16:22:25 +0100 Subject: [PATCH 14/53] cli: remove GLUE macros that hide names It's useful to see the entire name not having a macro construct it. Otherwise, the usage is not grepable. --- clients/cli/settings.c | 568 ++++++++++++++++++++--------------------- 1 file changed, 282 insertions(+), 286 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 6bd4f4f675..57c9db165d 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -6362,10 +6362,6 @@ _nmc_add_prop_funcs (const char *key, _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \ } G_STMT_END -/* concatenate setting name and property name */ -#define GLUE(A,B) "" NM_SETTING_##A##_SETTING_NAME "" NM_SETTING_##A##_##B "" -#define GLUE_IP(A,B) "" NM_SETTING_IP##A##_CONFIG_SETTING_NAME "" NM_SETTING_IP_CONFIG_##B "" - void nmc_properties_init (void) { @@ -6376,308 +6372,308 @@ nmc_properties_init (void) nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); /* Add editable properties for NM_SETTING_802_1X_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (802_1X, EAP), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_EAP, nmc_property_802_1X_get_eap, nmc_property_802_1X_set_eap, nmc_property_802_1X_remove_eap, NULL, nmc_property_802_1X_allowed_eap, NULL); - nmc_add_prop_funcs (GLUE (802_1X, IDENTITY), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_IDENTITY, nmc_property_802_1X_get_identity, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, ANONYMOUS_IDENTITY), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_ANONYMOUS_IDENTITY, nmc_property_802_1X_get_anonymous_identity, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PAC_FILE), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PAC_FILE, nmc_property_802_1X_get_pac_file, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CA_CERT), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT, nmc_property_802_1X_get_ca_cert, nmc_property_802_1X_set_ca_cert, NULL, nmc_property_802_1X_describe_ca_cert, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CA_CERT_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT_PASSWORD, nmc_property_802_1X_get_ca_cert_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CA_CERT_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS, nmc_property_802_1X_get_ca_cert_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CA_PATH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_PATH, nmc_property_802_1X_get_ca_path, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, SUBJECT_MATCH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_SUBJECT_MATCH, nmc_property_802_1X_get_subject_match, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, ALTSUBJECT_MATCHES), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_ALTSUBJECT_MATCHES, nmc_property_802_1X_get_altsubject_matches, nmc_property_802_1X_set_altsubject_matches, nmc_property_802_1X_remove_altsubject_matches, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, DOMAIN_SUFFIX_MATCH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, nmc_property_802_1X_get_domain_suffix_match, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT, nmc_property_802_1X_get_client_cert_full, nmc_property_802_1X_set_client_cert, NULL, nmc_property_802_1X_describe_client_cert, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT_PASSWORD, nmc_property_802_1X_get_client_cert_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, CLIENT_CERT_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS, nmc_property_802_1X_get_client_cert_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPVER), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_PEAPVER, nmc_property_802_1X_get_phase1_peapver, nmc_property_802_1X_set_phase1_peapver, NULL, NULL, nmc_property_802_1X_allowed_phase1_peapver, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE1_PEAPLABEL), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_PEAPLABEL, nmc_property_802_1X_get_phase1_peaplabel, nmc_property_802_1X_set_phase1_peaplabel, NULL, NULL, nmc_property_802_1X_allowed_phase1_peaplabel, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE1_FAST_PROVISIONING), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, nmc_property_802_1X_get_phase1_fast_provisioning, nmc_property_802_1X_set_phase1_fast_provisioning, NULL, NULL, nmc_property_802_1X_allowed_phase1_fast_provisioning, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE1_AUTH_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, nmc_property_802_1X_get_phase1_auth_flags, nmc_property_802_1X_set_phase1_auth_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_AUTH, nmc_property_802_1X_get_phase2_auth, nmc_property_802_1X_set_phase2_auth, NULL, NULL, nmc_property_802_1X_allowed_phase2_auth, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_AUTHEAP), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_AUTHEAP, nmc_property_802_1X_get_phase2_autheap, nmc_property_802_1X_set_phase2_autheap, NULL, NULL, nmc_property_802_1X_allowed_phase2_autheap, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT, nmc_property_802_1X_get_phase2_ca_cert, nmc_property_802_1X_set_phase2_ca_cert, NULL, nmc_property_802_1X_describe_phase2_ca_cert, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD, nmc_property_802_1X_get_phase2_ca_cert_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_CERT_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS, nmc_property_802_1X_get_phase2_ca_cert_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CA_PATH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_PATH, nmc_property_802_1X_get_phase2_ca_path, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_SUBJECT_MATCH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, nmc_property_802_1X_get_phase2_subject_match, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_ALTSUBJECT_MATCHES), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, nmc_property_802_1X_get_phase2_altsubject_matches, nmc_property_802_1X_set_phase2_altsubject_matches, nmc_property_802_1X_remove_phase2_altsubject_matches, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_DOMAIN_SUFFIX_MATCH), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, nmc_property_802_1X_get_phase2_domain_suffix_match, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT, nmc_property_802_1X_get_phase2_client_cert_full, nmc_property_802_1X_set_phase2_client_cert, NULL, nmc_property_802_1X_describe_phase2_client_cert, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD, nmc_property_802_1X_get_phase2_client_cert_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_CLIENT_CERT_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS, nmc_property_802_1X_get_phase2_client_cert_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD, nmc_property_802_1X_get_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_FLAGS, nmc_property_802_1X_get_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_RAW, nmc_property_802_1X_get_password_raw, nmc_property_802_1X_set_password_raw, NULL, nmc_property_802_1X_describe_password_raw, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PASSWORD_RAW_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, nmc_property_802_1X_get_password_raw_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY, nmc_property_802_1X_get_private_key_full, nmc_property_802_1X_set_private_key, NULL, nmc_property_802_1X_describe_private_key, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, nmc_property_802_1X_get_private_key_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PRIVATE_KEY_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS, nmc_property_802_1X_get_private_key_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, nmc_property_802_1X_get_phase2_private_key_full, nmc_property_802_1X_set_phase2_private_key, NULL, nmc_property_802_1X_describe_private_key, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, nmc_property_802_1X_get_phase2_private_key_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, nmc_property_802_1X_get_phase2_private_key_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PIN), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PIN, nmc_property_802_1X_get_pin, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, PIN_FLAGS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PIN_FLAGS, nmc_property_802_1X_get_pin_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, SYSTEM_CA_CERTS), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_SYSTEM_CA_CERTS, nmc_property_802_1X_get_system_ca_certs, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (802_1X, AUTH_TIMEOUT), + nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_AUTH_TIMEOUT, nmc_property_802_1X_get_auth_timeout, nmc_property_set_int, NULL, @@ -6686,49 +6682,49 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (ADSL, USERNAME), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_USERNAME, nmc_property_adsl_get_username, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (ADSL, PASSWORD), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PASSWORD, nmc_property_adsl_get_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (ADSL, PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PASSWORD_FLAGS, nmc_property_adsl_get_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (ADSL, PROTOCOL), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PROTOCOL, nmc_property_adsl_get_protocol, nmc_property_adsl_set_protocol, NULL, NULL, nmc_property_adsl_allowed_protocol, NULL); - nmc_add_prop_funcs (GLUE (ADSL, ENCAPSULATION), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_ENCAPSULATION, nmc_property_adsl_get_encapsulation, nmc_property_adsl_set_encapsulation, NULL, NULL, nmc_property_adsl_allowed_encapsulation, NULL); - nmc_add_prop_funcs (GLUE (ADSL, VPI), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_VPI, nmc_property_adsl_get_vpi, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (ADSL, VCI), + nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_VCI, nmc_property_adsl_get_vci, nmc_property_set_uint, NULL, @@ -6737,14 +6733,14 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (BLUETOOTH, BDADDR), + nmc_add_prop_funcs (NM_SETTING_BLUETOOTH_SETTING_NAME""NM_SETTING_BLUETOOTH_BDADDR, nmc_property_bluetooth_get_bdaddr, nmc_property_set_mac, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BLUETOOTH, TYPE), + nmc_add_prop_funcs (NM_SETTING_BLUETOOTH_SETTING_NAME""NM_SETTING_BLUETOOTH_TYPE, nmc_property_bluetooth_get_type, nmc_property_bluetooth_set_type, NULL, @@ -6753,7 +6749,7 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_BOND_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (BOND, OPTIONS), + nmc_add_prop_funcs (NM_SETTING_BOND_SETTING_NAME""NM_SETTING_BOND_OPTIONS, nmc_property_bond_get_options, nmc_property_bond_set_options, nmc_property_bond_remove_option_options, @@ -6762,49 +6758,49 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (BRIDGE, MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MAC_ADDRESS, nmc_property_bridge_get_mac_address, nmc_property_set_mac, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, STP), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_STP, nmc_property_bridge_get_stp, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, PRIORITY), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_PRIORITY, nmc_property_bridge_get_priority, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, FORWARD_DELAY), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_FORWARD_DELAY, nmc_property_bridge_get_forward_delay, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, HELLO_TIME), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_HELLO_TIME, nmc_property_bridge_get_hello_time, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, MAX_AGE), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MAX_AGE, nmc_property_bridge_get_max_age, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, AGEING_TIME), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_AGEING_TIME, nmc_property_bridge_get_ageing_time, nmc_property_set_uint, NULL, @@ -6812,7 +6808,7 @@ nmc_properties_init (void) NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE, MULTICAST_SNOOPING), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MULTICAST_SNOOPING, nmc_property_bridge_get_multicast_snooping, nmc_property_set_bool, NULL, @@ -6821,21 +6817,21 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PRIORITY), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_PRIORITY, nmc_property_bridge_port_get_priority, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE_PORT, PATH_COST), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_PATH_COST, nmc_property_bridge_port_get_path_cost, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (BRIDGE_PORT, HAIRPIN_MODE), + nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, nmc_property_bridge_port_get_hairpin_mode, nmc_property_set_bool, NULL, @@ -6844,35 +6840,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_CDMA_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (CDMA, NUMBER), + nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_NUMBER, nmc_property_cdma_get_number, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (CDMA, USERNAME), + nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_USERNAME, nmc_property_cdma_get_username, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (CDMA, PASSWORD), + nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_PASSWORD, nmc_property_cdma_get_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (CDMA, PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_PASSWORD_FLAGS, nmc_property_cdma_get_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (CDMA, MTU), + nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_MTU, nmc_property_cdma_get_mtu, nmc_property_set_uint, NULL, @@ -6881,105 +6877,105 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_FLAGS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_FLAGS, nmc_property_dcb_get_app_fcoe_flags, nmc_property_dcb_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_MODE), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_MODE, nmc_property_dcb_get_app_fcoe_mode, nmc_property_dcb_set_app_fcoe_mode, NULL, NULL, nmc_property_dcb_allowed_app_fcoe_modes, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_FCOE_PRIORITY), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_PRIORITY, nmc_property_dcb_get_app_fcoe_priority, nmc_property_dcb_set_priority, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_FLAGS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_ISCSI_FLAGS, nmc_property_dcb_get_app_iscsi_flags, nmc_property_dcb_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_ISCSI_PRIORITY), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_ISCSI_PRIORITY, nmc_property_dcb_get_app_iscsi_priority, nmc_property_dcb_set_priority, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_FIP_FLAGS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FIP_FLAGS, nmc_property_dcb_get_app_fip_flags, nmc_property_dcb_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, APP_FIP_PRIORITY), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FIP_PRIORITY, nmc_property_dcb_get_app_fip_priority, nmc_property_dcb_set_priority, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL_FLAGS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, nmc_property_dcb_get_pfc_flags, nmc_property_dcb_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_FLOW_CONTROL), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, nmc_property_dcb_get_pfc, nmc_property_dcb_set_pfc, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_FLAGS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, nmc_property_dcb_get_pg_flags, nmc_property_dcb_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_ID), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_ID, nmc_property_dcb_get_pg_group_id, nmc_property_dcb_set_pg_group_id, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_GROUP_BANDWIDTH), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, nmc_property_dcb_get_pg_group_bandwidth, nmc_property_dcb_set_pg_group_bandwidth, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_BANDWIDTH), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_BANDWIDTH, nmc_property_dcb_get_pg_bandwidth, nmc_property_dcb_set_pg_bandwidth, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_STRICT_BANDWIDTH), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, nmc_property_dcb_get_pg_strict, nmc_property_dcb_set_pg_strict, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (DCB, PRIORITY_TRAFFIC_CLASS), + nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, nmc_property_dcb_get_pg_traffic_class, nmc_property_dcb_set_pg_traffic_class, NULL, @@ -6988,91 +6984,91 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (GSM, NUMBER), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_NUMBER, nmc_property_gsm_get_number, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, USERNAME), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_USERNAME, nmc_property_gsm_get_username, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, PASSWORD), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PASSWORD, nmc_property_gsm_get_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PASSWORD_FLAGS, nmc_property_gsm_get_password_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, APN), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_APN, nmc_property_gsm_get_apn, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, NETWORK_ID), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_NETWORK_ID, nmc_property_gsm_get_network_id, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, PIN), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PIN, nmc_property_gsm_get_pin, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, PIN_FLAGS), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PIN_FLAGS, nmc_property_gsm_get_pin_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, HOME_ONLY), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_HOME_ONLY, nmc_property_gsm_get_home_only, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, DEVICE_ID), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_DEVICE_ID, nmc_property_gsm_get_device_id, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, SIM_ID), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_SIM_ID, nmc_property_gsm_get_sim_id, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, SIM_OPERATOR_ID), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_SIM_OPERATOR_ID, nmc_property_gsm_get_sim_operator_id, nmc_property_gsm_set_sim_operator_id, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (GSM, MTU), + nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_MTU, nmc_property_gsm_get_mtu, nmc_property_set_uint, NULL, @@ -7081,35 +7077,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_INFINIBAND_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (INFINIBAND, MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_MAC_ADDRESS, nmc_property_ib_get_mac_address, nmc_property_ib_set_mac, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (INFINIBAND, MTU), + nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_MTU, nmc_property_ib_get_mtu, nmc_property_set_mtu, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (INFINIBAND, TRANSPORT_MODE), + nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_TRANSPORT_MODE, nmc_property_ib_get_transport_mode, nmc_property_ib_set_transport_mode, NULL, NULL, nmc_property_ib_allowed_transport_mode, NULL); - nmc_add_prop_funcs (GLUE (INFINIBAND, P_KEY), + nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_P_KEY, nmc_property_ib_get_p_key, nmc_property_ib_set_p_key, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (INFINIBAND, PARENT), + nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_PARENT, nmc_property_ib_get_parent, nmc_property_set_ifname, NULL, @@ -7118,133 +7114,133 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_IP4_CONFIG_SETTING_NAME */ - nmc_add_prop_funcs (GLUE_IP (4, METHOD), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_METHOD, nmc_property_ipv4_get_method, nmc_property_ipv4_set_method, NULL, NULL, nmc_property_ipv4_allowed_method, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DNS), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS, nmc_property_ipv4_get_dns, nmc_property_ipv4_set_dns, nmc_property_ipv4_remove_dns, nmc_property_ipv4_describe_dns, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DNS_SEARCH), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_SEARCH, nmc_property_ipv4_get_dns_search, nmc_property_ipv4_set_dns_search, nmc_property_ipv4_remove_dns_search, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DNS_OPTIONS), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_OPTIONS, nmc_property_ipv4_get_dns_options, nmc_property_ipv4_set_dns_options, nmc_property_ipv4_remove_dns_option, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DNS_PRIORITY), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_PRIORITY, nmc_property_ipv4_get_dns_priority, nmc_property_set_int, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, ADDRESSES), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ADDRESSES, nmc_property_ip_get_addresses, nmc_property_ipv4_set_addresses, nmc_property_ipv4_remove_addresses, nmc_property_ipv4_describe_addresses, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, GATEWAY), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_GATEWAY, nmc_property_ipv4_get_gateway, nmc_property_ipv4_set_gateway, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, ROUTES), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTES, nmc_property_ipv4_get_routes, nmc_property_ipv4_set_routes, nmc_property_ipv4_remove_routes, nmc_property_ipv4_describe_routes, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, ROUTE_METRIC), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTE_METRIC, nmc_property_ipv4_get_route_metric, nmc_property_set_int64, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_ROUTES), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, nmc_property_ipv4_get_ignore_auto_routes, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, IGNORE_AUTO_DNS), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, nmc_property_ipv4_get_ignore_auto_dns, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_CLIENT_ID), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, nmc_property_ipv4_get_dhcp_client_id, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DHCP_TIMEOUT), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, nmc_property_ipv4_get_dhcp_timeout, nmc_property_set_int, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DHCP_SEND_HOSTNAME), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, nmc_property_ipv4_get_dhcp_send_hostname, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DHCP_HOSTNAME), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, nmc_property_ipv4_get_dhcp_hostname, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP4_CONFIG, DHCP_FQDN), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP4_CONFIG_DHCP_FQDN, nmc_property_ipv4_get_dhcp_fqdn, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, NEVER_DEFAULT), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_NEVER_DEFAULT, nmc_property_ipv4_get_never_default, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, MAY_FAIL), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_MAY_FAIL, nmc_property_ipv4_get_may_fail, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (4, DAD_TIMEOUT), + nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DAD_TIMEOUT, nmc_property_ipv4_get_dad_timeout, nmc_property_set_int, NULL, @@ -7253,126 +7249,126 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_IP6_CONFIG_SETTING_NAME */ - nmc_add_prop_funcs (GLUE_IP (6, METHOD), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_METHOD, nmc_property_ipv6_get_method, nmc_property_ipv6_set_method, NULL, NULL, nmc_property_ipv6_allowed_method, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DNS), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS, nmc_property_ipv6_get_dns, nmc_property_ipv6_set_dns, nmc_property_ipv6_remove_dns, nmc_property_ipv6_describe_dns, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DNS_SEARCH), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_SEARCH, nmc_property_ipv6_get_dns_search, nmc_property_ipv6_set_dns_search, nmc_property_ipv6_remove_dns_search, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DNS_OPTIONS), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_OPTIONS, nmc_property_ipv6_get_dns_options, nmc_property_ipv6_set_dns_options, nmc_property_ipv6_remove_dns_option, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DNS_PRIORITY), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_PRIORITY, nmc_property_ipv6_get_dns_priority, nmc_property_set_int, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, ADDRESSES), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ADDRESSES, nmc_property_ip_get_addresses, nmc_property_ipv6_set_addresses, nmc_property_ipv6_remove_addresses, nmc_property_ipv6_describe_addresses, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, GATEWAY), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_GATEWAY, nmc_property_ipv6_get_gateway, nmc_property_ipv6_set_gateway, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, ROUTES), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTES, nmc_property_ipv6_get_routes, nmc_property_ipv6_set_routes, nmc_property_ipv6_remove_routes, nmc_property_ipv6_describe_routes, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, ROUTE_METRIC), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTE_METRIC, nmc_property_ipv6_get_route_metric, nmc_property_set_int64, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_ROUTES), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, nmc_property_ipv6_get_ignore_auto_routes, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, IGNORE_AUTO_DNS), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, nmc_property_ipv6_get_ignore_auto_dns, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, NEVER_DEFAULT), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_NEVER_DEFAULT, nmc_property_ipv6_get_never_default, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, MAY_FAIL), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_MAY_FAIL, nmc_property_ipv6_get_may_fail, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP6_CONFIG, IP6_PRIVACY), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_IP6_PRIVACY, nmc_property_ipv6_get_ip6_privacy, nmc_property_ipv6_set_ip6_privacy, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP6_CONFIG, ADDR_GEN_MODE), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, nmc_property_ipv6_get_addr_gen_mode, nmc_property_ipv6_set_addr_gen_mode, NULL, NULL, nmc_property_ipv6_allowed_addr_gen_mode, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DHCP_SEND_HOSTNAME), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, nmc_property_ipv6_get_dhcp_send_hostname, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE_IP (6, DHCP_HOSTNAME), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, nmc_property_ipv6_get_dhcp_hostname, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP6_CONFIG, TOKEN), + nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_TOKEN, nmc_property_ipv6_get_token, nmc_property_set_string, NULL, @@ -7381,21 +7377,21 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (OLPC_MESH, SSID), + nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_SSID, nmc_property_olpc_get_ssid, nmc_property_set_ssid, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (OLPC_MESH, CHANNEL), + nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_CHANNEL, nmc_property_olpc_get_channel, nmc_property_olpc_set_channel, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (OLPC_MESH, DHCP_ANYCAST_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, nmc_property_olpc_get_anycast_address, nmc_property_set_mac, NULL, @@ -7404,126 +7400,126 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_PPP_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (PPP, NOAUTH), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NOAUTH, nmc_property_ppp_get_noauth, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REFUSE_EAP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_EAP, nmc_property_ppp_get_refuse_eap, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REFUSE_PAP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_PAP, nmc_property_ppp_get_refuse_pap, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REFUSE_CHAP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_CHAP, nmc_property_ppp_get_refuse_chap, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_MSCHAP, nmc_property_ppp_get_refuse_mschap, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REFUSE_MSCHAPV2), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_MSCHAPV2, nmc_property_ppp_get_refuse_mschapv2, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, NOBSDCOMP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NOBSDCOMP, nmc_property_ppp_get_nobsdcomp, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, NODEFLATE), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NODEFLATE, nmc_property_ppp_get_nodeflate, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, NO_VJ_COMP), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NO_VJ_COMP, nmc_property_ppp_get_no_vj_comp, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REQUIRE_MPPE, nmc_property_ppp_get_require_mppe, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, REQUIRE_MPPE_128), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REQUIRE_MPPE_128, nmc_property_ppp_get_require_mppe_128, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, MPPE_STATEFUL), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MPPE_STATEFUL, nmc_property_ppp_get_mppe_stateful, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, CRTSCTS), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_CRTSCTS, nmc_property_ppp_get_crtscts, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, BAUD), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_BAUD, nmc_property_ppp_get_baud, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, MRU), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MRU, nmc_property_ppp_get_mru, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, MTU), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MTU, nmc_property_ppp_get_mtu, nmc_property_set_mtu, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_FAILURE), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_LCP_ECHO_FAILURE, nmc_property_ppp_get_lcp_echo_failure, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPP, LCP_ECHO_INTERVAL), + nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_LCP_ECHO_INTERVAL, nmc_property_ppp_get_lcp_echo_interval, nmc_property_set_uint, NULL, @@ -7532,28 +7528,28 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_PPPOE_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (PPPOE, SERVICE), + nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_SERVICE, nmc_property_pppoe_get_service, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPPOE, USERNAME), + nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_USERNAME, nmc_property_pppoe_get_username, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD), + nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_PASSWORD, nmc_property_pppoe_get_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PPPOE, PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_PASSWORD_FLAGS, nmc_property_pppoe_get_password_flags, nmc_property_set_secret_flags, NULL, @@ -7562,35 +7558,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (SERIAL, BAUD), + nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BAUD, nmc_property_serial_get_baud, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (SERIAL, BITS), + nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BITS, nmc_property_serial_get_bits, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (SERIAL, PARITY), + nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_PARITY, nmc_property_serial_get_parity, nmc_property_serial_set_parity, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (SERIAL, STOPBITS), + nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_STOPBITS, nmc_property_serial_get_stopbits, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (SERIAL, SEND_DELAY), + nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_SEND_DELAY, nmc_property_serial_get_send_delay, nmc_property_set_uint, NULL, @@ -7599,7 +7595,7 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (TEAM, CONFIG), + nmc_add_prop_funcs (NM_SETTING_TEAM_SETTING_NAME""NM_SETTING_TEAM_CONFIG, nmc_property_team_get_config, nmc_property_team_set_config, NULL, @@ -7608,7 +7604,7 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_TEAM_PORT_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (TEAM_PORT, CONFIG), + nmc_add_prop_funcs (NM_SETTING_TEAM_PORT_SETTING_NAME""NM_SETTING_TEAM_PORT_CONFIG, nmc_property_team_port_get_config, nmc_property_team_set_config, NULL, @@ -7617,35 +7613,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (VLAN, PARENT), + nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_PARENT, nmc_property_vlan_get_parent, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VLAN, ID), + nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_ID, nmc_property_vlan_get_id, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VLAN, FLAGS), + nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_FLAGS, nmc_property_vlan_get_flags, nmc_property_set_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VLAN, INGRESS_PRIORITY_MAP), + nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, nmc_property_vlan_get_ingress_priority_map, nmc_property_vlan_set_ingress_priority_map, nmc_property_vlan_remove_ingress_priority_map, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VLAN, EGRESS_PRIORITY_MAP), + nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, nmc_property_vlan_get_egress_priority_map, nmc_property_vlan_set_egress_priority_map, nmc_property_vlan_remove_egress_priority_map, @@ -7654,35 +7650,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_VPN_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (VPN, SERVICE_TYPE), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_SERVICE_TYPE, nmc_property_vpn_get_service_type, nmc_property_set_vpn_service, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VPN, USER_NAME), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_USER_NAME, nmc_property_vpn_get_user_name, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VPN, DATA), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_DATA, nmc_property_vpn_get_data, nmc_property_vpn_set_data, nmc_property_vpn_remove_option_data, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VPN, SECRETS), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_SECRETS, nmc_property_vpn_get_secrets, nmc_property_vpn_set_secrets, nmc_property_vpn_remove_option_secret, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VPN, PERSISTENT), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_PERSISTENT, nmc_property_vpn_get_persistent, nmc_property_set_bool, NULL, @@ -7690,7 +7686,7 @@ nmc_properties_init (void) NULL, NULL); - nmc_add_prop_funcs (GLUE (VPN, TIMEOUT), + nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_TIMEOUT, nmc_property_vpn_get_timeout, nmc_property_set_uint, NULL, @@ -7699,14 +7695,14 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_WIMAX_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (WIMAX, NETWORK_NAME), + nmc_add_prop_funcs (NM_SETTING_WIMAX_SETTING_NAME""NM_SETTING_WIMAX_NETWORK_NAME, nmc_property_wimax_get_network_name, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIMAX, MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_WIMAX_SETTING_NAME""NM_SETTING_WIMAX_MAC_ADDRESS, nmc_property_wimax_get_mac_address, nmc_property_set_mac, NULL, @@ -7715,98 +7711,98 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (WIRED, PORT), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_PORT, nmc_property_wired_get_port, NULL, /* nmc_property_wired_set_port, */ NULL, NULL, NULL, /* nmc_property_wired_allowed_port, */ NULL); - nmc_add_prop_funcs (GLUE (WIRED, SPEED), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_SPEED, nmc_property_wired_get_speed, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, DUPLEX), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_DUPLEX, nmc_property_wired_get_duplex, nmc_property_wired_set_duplex, NULL, NULL, nmc_property_wired_allowed_duplex, NULL); - nmc_add_prop_funcs (GLUE (WIRED, AUTO_NEGOTIATE), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_AUTO_NEGOTIATE, nmc_property_wired_get_auto_negotiate, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MAC_ADDRESS, nmc_property_wired_get_mac_address, nmc_property_set_mac, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, CLONED_MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_CLONED_MAC_ADDRESS, nmc_property_wired_get_cloned_mac_address, nmc_property_set_mac_cloned, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, GENERATE_MAC_ADDRESS_MASK), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, nmc_property_wired_get_generate_mac_address_mask, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, MAC_ADDRESS_BLACKLIST), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, nmc_property_wired_get_mac_address_blacklist, nmc_property_wired_set_mac_address_blacklist, nmc_property_wired_remove_mac_address_blacklist, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, MTU), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MTU, nmc_property_wired_get_mtu, nmc_property_set_mtu, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, S390_SUBCHANNELS), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_SUBCHANNELS, nmc_property_wired_get_s390_subchannels, nmc_property_wired_set_s390_subchannels, NULL, nmc_property_wired_describe_s390_subchannels, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, S390_NETTYPE), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_NETTYPE, nmc_property_wired_get_s390_nettype, nmc_property_wired_set_s390_nettype, NULL, NULL, nmc_property_wired_allowed_s390_nettype, NULL); - nmc_add_prop_funcs (GLUE (WIRED, S390_OPTIONS), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_OPTIONS, nmc_property_wired_get_s390_options, nmc_property_wired_set_s390_options, nmc_property_wired_remove_option_s390_options, nmc_property_wired_describe_s390_options, nmc_property_wired_allowed_s390_options, NULL); - nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_WAKE_ON_LAN, nmc_property_wired_get_wake_on_lan, nmc_property_wired_set_wake_on_lan, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRED, WAKE_ON_LAN_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, nmc_property_wired_get_wake_on_lan_password, nmc_property_set_mac, NULL, @@ -7815,35 +7811,35 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (WIRELESS, SSID), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_SSID, nmc_property_wireless_get_ssid, nmc_property_set_ssid, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, MODE), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MODE, nmc_property_wireless_get_mode, nmc_property_wifi_set_mode, NULL, NULL, nmc_property_wifi_allowed_mode, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, BAND), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_BAND, nmc_property_wireless_get_band, nmc_property_wifi_set_band, NULL, NULL, nmc_property_wifi_allowed_band, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, CHANNEL), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_CHANNEL, nmc_property_wireless_get_channel, nmc_property_wifi_set_channel, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, BSSID), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_BSSID, nmc_property_wireless_get_bssid, nmc_property_set_mac, NULL, @@ -7854,77 +7850,77 @@ nmc_properties_init (void) * Do not allow setting 'rate' and 'tx-power'. They are not implemented in * NM core, nor in ifcfg-rh plugin (thus not preserved over re-reading). */ - nmc_add_prop_funcs (GLUE (WIRELESS, RATE), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_RATE, nmc_property_wireless_get_rate, NULL, /* editing rate disabled */ NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, TX_POWER), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_TX_POWER, nmc_property_wireless_get_tx_power, NULL, /* editing tx-power disabled */ NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS, nmc_property_wireless_get_mac_address, nmc_property_set_mac, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, CLONED_MAC_ADDRESS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, nmc_property_wireless_get_cloned_mac_address, nmc_property_set_mac_cloned, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, GENERATE_MAC_ADDRESS_MASK), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, nmc_property_wireless_get_generate_mac_address_mask, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_BLACKLIST), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, nmc_property_wireless_get_mac_address_blacklist, nmc_property_wireless_set_mac_address_blacklist, nmc_property_wireless_remove_mac_address_blacklist, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, SEEN_BSSIDS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_SEEN_BSSIDS, nmc_property_wireless_get_seen_bssids, NULL, /* read-only */ NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, MTU), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MTU, nmc_property_wireless_get_mtu, nmc_property_set_mtu, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, HIDDEN), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_HIDDEN, nmc_property_wireless_get_hidden, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, POWERSAVE), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_POWERSAVE, nmc_property_wireless_get_powersave, nmc_property_wireless_set_powersave, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS, MAC_ADDRESS_RANDOMIZATION), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, nmc_property_wireless_get_mac_address_randomization, nmc_property_wireless_set_mac_address_randomization, NULL, @@ -7933,119 +7929,119 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, KEY_MGMT), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, nmc_property_wifi_sec_get_key_mgmt, nmc_property_wifi_sec_set_key_mgmt, NULL, NULL, nmc_property_wifi_sec_allowed_key_mgmt, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_TX_KEYIDX), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, nmc_property_wifi_sec_get_wep_tx_keyidx, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, AUTH_ALG), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, nmc_property_wifi_sec_get_auth_alg, nmc_property_wifi_sec_set_auth_alg, NULL, NULL, nmc_property_wifi_sec_allowed_auth_alg, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PROTO), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PROTO, nmc_property_wifi_sec_get_proto, nmc_property_wifi_sec_set_proto, nmc_property_wifi_sec_remove_proto, NULL, nmc_property_wifi_sec_allowed_proto, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PAIRWISE), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PAIRWISE, nmc_property_wifi_sec_get_pairwise, nmc_property_wifi_sec_set_pairwise, nmc_property_wifi_sec_remove_pairwise, NULL, nmc_property_wifi_sec_allowed_pairwise, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, GROUP), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_GROUP, nmc_property_wifi_sec_get_group, nmc_property_wifi_sec_set_group, nmc_property_wifi_sec_remove_group, NULL, nmc_property_wifi_sec_allowed_group, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_USERNAME), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, nmc_property_wifi_sec_get_leap_username, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY0), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, nmc_property_wifi_sec_get_wep_key0, nmc_property_wifi_set_wep_key, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY1), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, nmc_property_wifi_sec_get_wep_key1, nmc_property_wifi_set_wep_key, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY2), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, nmc_property_wifi_sec_get_wep_key2, nmc_property_wifi_set_wep_key, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY3), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, nmc_property_wifi_sec_get_wep_key3, nmc_property_wifi_set_wep_key, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_FLAGS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, nmc_property_wifi_sec_get_wep_key_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, WEP_KEY_TYPE), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, nmc_property_wifi_sec_get_wep_key_type, nmc_property_wifi_set_wep_key_type, NULL, nmc_property_wifi_describe_wep_key_type, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PSK, nmc_property_wifi_sec_get_psk, nmc_property_wifi_set_psk, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, PSK_FLAGS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, nmc_property_wifi_sec_get_psk_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, nmc_property_wifi_sec_get_leap_password, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, LEAP_PASSWORD_FLAGS), + nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, nmc_property_wifi_sec_get_leap_password_flags, nmc_property_set_secret_flags, NULL, @@ -8054,42 +8050,42 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (TUN, MODE), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MODE, nmc_property_tun_get_mode, nmc_property_tun_set_mode, NULL, NULL, nmc_property_tun_allowed_mode, NULL); - nmc_add_prop_funcs (GLUE (TUN, OWNER), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_OWNER, nmc_property_tun_get_owner, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (TUN, GROUP), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_GROUP, nmc_property_tun_get_group, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (TUN, PI), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_PI, nmc_property_tun_get_pi, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (TUN, VNET_HDR), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_VNET_HDR, nmc_property_tun_get_vnet_hdr, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (TUN, MULTI_QUEUE), + nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MULTI_QUEUE, nmc_property_tun_get_multi_queue, nmc_property_set_bool, NULL, @@ -8098,84 +8094,84 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_IP_TUNNEL_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (IP_TUNNEL, MODE), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_MODE, nmc_property_ip_tunnel_get_mode, nmc_property_ip_tunnel_set_mode, NULL, NULL, nmc_property_ip_tunnel_allowed_mode, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, PARENT), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_PARENT, nmc_property_ip_tunnel_get_parent, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, LOCAL), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_LOCAL, nmc_property_ip_tunnel_get_local, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, REMOTE), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_REMOTE, nmc_property_ip_tunnel_get_remote, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, TTL), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_TTL, nmc_property_ip_tunnel_get_ttl, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, TOS), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_TOS, nmc_property_ip_tunnel_get_tos, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, PATH_MTU_DISCOVERY), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY, nmc_property_ip_tunnel_get_path_mtu_discovery, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, INPUT_KEY), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_INPUT_KEY, nmc_property_ip_tunnel_get_input_key, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, OUTPUT_KEY), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_OUTPUT_KEY, nmc_property_ip_tunnel_get_output_key, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, ENCAPSULATION_LIMIT), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT, nmc_property_ip_tunnel_get_encapsulation_limit, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, FLOW_LABEL), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_FLOW_LABEL, nmc_property_ip_tunnel_get_flow_label, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (IP_TUNNEL, MTU), + nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_MTU, nmc_property_ip_tunnel_get_mtu, nmc_property_set_uint, NULL, @@ -8184,56 +8180,56 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_MACSEC_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (MACSEC, PARENT), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_PARENT, nmc_property_macsec_get_parent, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, MODE), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MODE, nmc_property_macsec_get_mode, nmc_property_macsec_set_mode, NULL, NULL, nmc_property_macsec_allowed_mode, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, ENCRYPT), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_ENCRYPT, nmc_property_macsec_get_encrypt, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, MKA_CAK), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CAK, nmc_property_macsec_get_mka_cak, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, MKA_CAK_FLAGS), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CAK_FLAGS, nmc_property_macsec_get_mka_cak_flags, nmc_property_set_secret_flags, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, MKA_CKN), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CKN, nmc_property_macsec_get_mka_ckn, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, PORT), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_PORT, nmc_property_macsec_get_port, nmc_property_set_int, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACSEC, VALIDATION), + nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_VALIDATION, nmc_property_macsec_get_validation, nmc_property_macsec_set_validation, NULL, @@ -8242,28 +8238,28 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_MACVLAN_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (MACVLAN, PARENT), + nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_PARENT, nmc_property_macvlan_get_parent, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACVLAN, MODE), + nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_MODE, nmc_property_macvlan_get_mode, nmc_property_macvlan_set_mode, NULL, NULL, nmc_property_macvlan_allowed_mode, NULL); - nmc_add_prop_funcs (GLUE (MACVLAN, PROMISCUOUS), + nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_PROMISCUOUS, nmc_property_macvlan_get_promiscuous, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (MACVLAN, TAP), + nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_TAP, nmc_property_macvlan_get_tap, nmc_property_set_bool, NULL, @@ -8272,112 +8268,112 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_VXLAN_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (VXLAN, PARENT), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_PARENT, nmc_property_vxlan_get_parent, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, ID), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_ID, nmc_property_vxlan_get_id, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, LOCAL), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LOCAL, nmc_property_vxlan_get_local, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, REMOTE), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_REMOTE, nmc_property_vxlan_get_remote, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MIN), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_SOURCE_PORT_MIN, nmc_property_vxlan_get_source_port_min, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, SOURCE_PORT_MAX), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_SOURCE_PORT_MAX, nmc_property_vxlan_get_source_port_max, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, DESTINATION_PORT), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_DESTINATION_PORT, nmc_property_vxlan_get_destination_port, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, TOS), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_TOS, nmc_property_vxlan_get_tos, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, TTL), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_TTL, nmc_property_vxlan_get_ttl, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, AGEING), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_AGEING, nmc_property_vxlan_get_ageing, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, LIMIT), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LIMIT, nmc_property_vxlan_get_limit, nmc_property_set_uint, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, LEARNING), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LEARNING, nmc_property_vxlan_get_learning, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, PROXY), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_PROXY, nmc_property_vxlan_get_proxy, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, RSC), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_RSC, nmc_property_vxlan_get_rsc, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, L2_MISS), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_L2_MISS, nmc_property_vxlan_get_l2_miss, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (VXLAN, L3_MISS), + nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_L3_MISS, nmc_property_vxlan_get_l3_miss, nmc_property_set_bool, NULL, @@ -8386,28 +8382,28 @@ nmc_properties_init (void) NULL); /* Add editable properties for NM_SETTING_PROXY_SETTING_NAME */ - nmc_add_prop_funcs (GLUE (PROXY, METHOD), + nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_METHOD, nmc_property_proxy_get_method, nmc_property_proxy_set_method, NULL, NULL, nmc_property_proxy_allowed_method, NULL); - nmc_add_prop_funcs (GLUE (PROXY, BROWSER_ONLY), + nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_BROWSER_ONLY, nmc_property_proxy_get_browser_only, nmc_property_set_bool, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PROXY, PAC_URL), + nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_PAC_URL, nmc_property_proxy_get_pac_url, nmc_property_set_string, NULL, NULL, NULL, NULL); - nmc_add_prop_funcs (GLUE (PROXY, PAC_SCRIPT), + nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_PAC_SCRIPT, nmc_property_proxy_get_pac_script, nmc_property_proxy_set_pac_script, NULL, From 40f47dbb06b6ac58efac38191943c359ea2284b5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 15:52:03 +0100 Subject: [PATCH 15/53] cli: add property-info for NMSettingIP4Config and NMSettingIP6Config --- clients/cli/connections.c | 4 +- clients/cli/nmcli.c | 4 +- clients/cli/settings.c | 1148 ++++++++++++++++--------------------- clients/cli/settings.h | 17 +- 4 files changed, 511 insertions(+), 662 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d02768fea5..e497735b1a 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -168,8 +168,8 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_802_1X_SETTING_NAME, nmc_fields_setting_8021X + 1), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, nmc_fields_setting_wireless_security + 1), /* 4 */ - SETTING_FIELD (NM_SETTING_IP4_CONFIG_SETTING_NAME, nmc_fields_setting_ip4_config + 1), /* 5 */ - SETTING_FIELD (NM_SETTING_IP6_CONFIG_SETTING_NAME, nmc_fields_setting_ip6_config + 1), /* 6 */ + SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), + SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ SETTING_FIELD (NM_SETTING_PPP_SETTING_NAME, nmc_fields_setting_ppp + 1), /* 8 */ SETTING_FIELD (NM_SETTING_PPPOE_SETTING_NAME, nmc_fields_setting_pppoe + 1), /* 9 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 630fe871e6..bb47fb4f26 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -151,8 +151,8 @@ complete_fields (const char *prefix) complete_field (h, "802-1x", nmc_fields_setting_8021X); complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); complete_field (h, "802-11-wireless-security", nmc_fields_setting_wireless_security); - complete_field (h, "ipv4", nmc_fields_setting_ip4_config); - complete_field (h, "ipv6", nmc_fields_setting_ip6_config); + complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); + complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); complete_field (h, "serial", nmc_fields_setting_serial); complete_field (h, "ppp", nmc_fields_setting_ppp); complete_field (h, "pppoe", nmc_fields_setting_pppoe); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 57c9db165d..8a8080c422 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -36,6 +36,7 @@ static char *wep_key_type_to_string (NMWepKeyType type); static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); +static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error); /*****************************************************************************/ @@ -73,6 +74,33 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, return s; } +static char * +_get_fcn_gobject_with_default (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + const char *s; + char *s_full; + GValue val = G_VALUE_INIT; + + if (property_info->get_data.get_gobject_with_default_fcn (setting)) { + if (get_type == NMC_PROPERTY_GET_PARSABLE) + return g_strdup (""); + return g_strdup (_("(default)")); + } + + g_value_init (&val, G_TYPE_STRING); + g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); + s = g_value_get_string (&val); + if (get_type == NMC_PROPERTY_GET_PARSABLE) + s_full = g_strdup (s && *s ? s : " "); + else + s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); + g_value_unset (&val); + return s_full; +} + /*****************************************************************************/ static gboolean @@ -154,6 +182,30 @@ _set_fcn_gobject_int (const NmcSettingInfo *setting_info, return TRUE; } +static gboolean +_set_fcn_gobject_int64 (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + long val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if (!nmc_string_to_int (value, FALSE, 0, 0, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); + return FALSE; + } + + /* Validate the number according to the property spec */ + if (!validate_int64 (setting, property_info->property_name, (gint64) val_int, error)) + return FALSE; + + g_object_set (setting, property_info->property_name, (gint64) val_int, NULL); + return TRUE; +} + static gboolean _set_fcn_gobject_uint (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -193,6 +245,30 @@ _remove_fcn_nmc (const NmcSettingInfo *setting_info, /*****************************************************************************/ +static const char *const* +_values_fcn_gobject_enum (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info) +{ + static GHashTable *cache = NULL; + const char **v; + + if (G_UNLIKELY (!cache)) + cache = g_hash_table_new (NULL, NULL); + + v = g_hash_table_lookup (cache, property_info); + if (!v) { + bool has_minmax = property_info->values_data.gobject_enum.has_minmax; + + v = nm_utils_enum_get_values (property_info->values_data.gobject_enum.get_gtype (), + has_minmax ? property_info->values_data.gobject_enum.min : G_MININT, + has_minmax ? property_info->values_data.gobject_enum.max : G_MAXINT); + g_hash_table_insert (cache, (gpointer) property_info, v); + } + return (const char *const*) v; +} + +/*****************************************************************************/ + static const NmcSettingInfo * _meta_find_setting_info_by_name (const char *setting_name) { @@ -540,94 +616,6 @@ NmcOutputField nmc_fields_setting_wireless_security[] = { NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD","\ NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS -/* Available fields for NM_SETTING_IP4_CONFIG_SETTING_NAME */ -NmcOutputField nmc_fields_setting_ip4_config[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_METHOD), /* 1 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS), /* 2 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_SEARCH), /* 3 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_OPTIONS), /* 4 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_PRIORITY), /* 5 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ADDRESSES), /* 6 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_GATEWAY), /* 7 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTES), /* 8 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTE_METRIC), /* 9 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), /* 10 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), /* 11 */ - SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), /* 12 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT), /* 13 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 14 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 15 */ - SETTING_FIELD (NM_SETTING_IP4_CONFIG_DHCP_FQDN), /* 16 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 17 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 18 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DAD_TIMEOUT), /* 19 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_IP4_CONFIG_ALL "name"","\ - NM_SETTING_IP_CONFIG_METHOD","\ - NM_SETTING_IP_CONFIG_DNS","\ - NM_SETTING_IP_CONFIG_DNS_SEARCH","\ - NM_SETTING_IP_CONFIG_DNS_OPTIONS","\ - NM_SETTING_IP_CONFIG_DNS_PRIORITY","\ - NM_SETTING_IP_CONFIG_ADDRESSES","\ - NM_SETTING_IP_CONFIG_GATEWAY","\ - NM_SETTING_IP_CONFIG_ROUTES","\ - NM_SETTING_IP_CONFIG_ROUTE_METRIC","\ - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES","\ - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS","\ - NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID","\ - NM_SETTING_IP_CONFIG_DHCP_TIMEOUT","\ - NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME","\ - NM_SETTING_IP_CONFIG_DHCP_HOSTNAME","\ - NM_SETTING_IP4_CONFIG_DHCP_FQDN","\ - NM_SETTING_IP_CONFIG_NEVER_DEFAULT","\ - NM_SETTING_IP_CONFIG_MAY_FAIL","\ - NM_SETTING_IP_CONFIG_DAD_TIMEOUT - -/* Available fields for NM_SETTING_IP6_CONFIG_SETTING_NAME */ -NmcOutputField nmc_fields_setting_ip6_config[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_METHOD), /* 1 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS), /* 2 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_SEARCH), /* 3 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_OPTIONS), /* 4 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DNS_PRIORITY), /* 5 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ADDRESSES), /* 6 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_GATEWAY), /* 7 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTES), /* 8 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_ROUTE_METRIC), /* 9 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), /* 10 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), /* 11 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), /* 12 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_MAY_FAIL), /* 13 */ - SETTING_FIELD (NM_SETTING_IP6_CONFIG_IP6_PRIVACY), /* 14 */ - SETTING_FIELD (NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE), /* 15 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), /* 16 */ - SETTING_FIELD (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), /* 17 */ - SETTING_FIELD (NM_SETTING_IP6_CONFIG_TOKEN), /* 18 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_IP6_CONFIG_ALL "name"","\ - NM_SETTING_IP_CONFIG_METHOD","\ - NM_SETTING_IP_CONFIG_DNS","\ - NM_SETTING_IP_CONFIG_DNS_SEARCH","\ - NM_SETTING_IP_CONFIG_DNS_OPTIONS","\ - NM_SETTING_IP_CONFIG_DNS_PRIORITY","\ - NM_SETTING_IP_CONFIG_ADDRESSES","\ - NM_SETTING_IP_CONFIG_GATEWAY","\ - NM_SETTING_IP_CONFIG_ROUTES","\ - NM_SETTING_IP_CONFIG_ROUTE_METRIC","\ - NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES","\ - NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS","\ - NM_SETTING_IP_CONFIG_NEVER_DEFAULT","\ - NM_SETTING_IP_CONFIG_MAY_FAIL","\ - NM_SETTING_IP6_CONFIG_IP6_PRIVACY","\ - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE","\ - NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME","\ - NM_SETTING_IP_CONFIG_DHCP_HOSTNAME","\ - NM_SETTING_IP6_CONFIG_TOKEN - /* Available fields for NM_SETTING_SERIAL_SETTING_NAME */ NmcOutputField nmc_fields_setting_serial[] = { SETTING_FIELD ("name"), /* 0 */ @@ -1697,26 +1685,6 @@ nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GEr return TRUE; } -static gboolean -nmc_property_set_int64 (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - long val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_int (val, FALSE, 0, 0, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_int64 (setting, prop, (gint64) val_int, error)) - return FALSE; - - g_object_set (setting, prop, (gint64) val_int, NULL); - return TRUE; -} - static gboolean nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -3663,14 +3631,11 @@ _parse_ip_address (int family, const char *address, GError **error) return ipaddr; } -DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP_CONFIG_METHOD) -DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP_CONFIG_DNS) -DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH) -DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv4_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting)) -DEFINE_GETTER (nmc_property_ipv4_get_dns_priority, NM_SETTING_IP_CONFIG_DNS_PRIORITY) - static char * -nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip_config_addresses (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); GString *printable; @@ -3695,7 +3660,10 @@ nmc_property_ip_get_addresses (NMSetting *setting, NmcPropertyGetType get_type) } static char * -nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip_config_routes (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); GString *printable; @@ -3764,25 +3732,10 @@ nmc_property_ipvx_get_routes (NMSetting *setting, NmcPropertyGetType get_type) } static char * -nmc_property_ipv4_get_routes (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_ipvx_get_routes (setting, get_type); -} - -DEFINE_GETTER (nmc_property_ipv4_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY) -DEFINE_GETTER (nmc_property_ipv4_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC) -DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES) -DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS) -DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID) -DEFINE_GETTER (nmc_property_ipv4_get_dhcp_timeout, NM_SETTING_IP_CONFIG_DHCP_TIMEOUT) -DEFINE_GETTER (nmc_property_ipv4_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME) -DEFINE_GETTER (nmc_property_ipv4_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME) -DEFINE_GETTER (nmc_property_ipv4_get_dhcp_fqdn, NM_SETTING_IP4_CONFIG_DHCP_FQDN) -DEFINE_GETTER (nmc_property_ipv4_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT) -DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL) - -static char * -nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip4_config_dad_timeout (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); gint dad_timeout; @@ -3801,7 +3754,6 @@ nmc_property_ipv4_get_dad_timeout (NMSetting *setting, NmcPropertyGetType get_ty } } -/* 'method' */ static const char *ipv4_valid_methods[] = { NM_SETTING_IP4_CONFIG_METHOD_AUTO, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL, @@ -3812,27 +3764,32 @@ static const char *ipv4_valid_methods[] = { }; static gboolean -nmc_property_ipv4_set_method (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_method (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { /* Silently accept "static" and convert to "manual" */ - if (val && strlen (val) > 1 && matches (val, "static")) - val = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; + if (value && strlen (value) > 1 && matches (value, "static")) + value = NM_SETTING_IP4_CONFIG_METHOD_MANUAL; - return check_and_set_string (setting, prop, val, ipv4_valid_methods, error); + return check_and_set_string (setting, property_info->property_name, value, ipv4_valid_methods, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods) - -/* 'dns' */ static gboolean -nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_dns (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter, *addr; guint32 ip4_addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); for (iter = strv; iter && *iter; iter++) { addr = g_strstrip (*iter); if (inet_pton (AF_INET, addr, &ip4_addr) < 1) { @@ -3870,24 +3827,20 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns, nm_setting_ip_config_remove_dns, _validate_and_remove_ipv4_dns) -static const char * -nmc_property_ipv4_describe_dns (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv4 addresses of DNS servers.\n\n" - "Example: 8.8.8.8, 8.8.4.4\n"); -} - -/* 'dns-search' */ static gboolean -nmc_property_ipv4_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_dns_search (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL; guint i = 0; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, " \t,", 0); - if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) { + strv = nmc_strsplit_set (value, " \t,", 0); + if (!verify_string_list (strv, property_info->property_name, nmc_util_is_domain, error)) { g_strfreev (strv); return FALSE; } @@ -3919,9 +3872,12 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search, nm_setting_ip_config_remove_dns_search, _validate_and_remove_ipv4_dns_search) -/* 'dns-options' */ static gboolean -nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_dns_options (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL; guint i = 0; @@ -3929,7 +3885,7 @@ nmc_property_ipv4_set_dns_options (NMSetting *setting, const char *prop, const c g_return_val_if_fail (error == NULL || *error == NULL, FALSE); nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE); - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); while (strv && strv[i]) nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]); g_strfreev (strv); @@ -3965,14 +3921,18 @@ _parse_ipv4_address (const char *address, GError **error) } static gboolean -nmc_property_ipv4_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_addresses (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter; NMIPAddress *ip4addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, ",", 0); + strv = nmc_strsplit_set (value, ",", 0); for (iter = strv; iter && *iter; iter++) { ip4addr = _parse_ipv4_address (*iter, error); if (!ip4addr) { @@ -4011,38 +3971,31 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses, nm_setting_ip_config_remove_address, _validate_and_remove_ipv4_address) -static const char * -nmc_property_ipv4_describe_addresses (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv4 addresses formatted as:\n" - " ip[/prefix], ip[/prefix],...\n" - "Missing prefix is regarded as prefix of 32.\n\n" - "Example: 192.168.1.5/24, 10.0.0.11/24\n"); -} - -/* 'gateway' */ static gboolean -nmc_property_ipv4_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_gateway (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { NMIPAddress *ip4addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (strchr (val, '/')) { + if (strchr (value, '/')) { g_set_error (error, 1, 0, - _("invalid gateway address '%s'"), val); + _("invalid gateway address '%s'"), value); return FALSE; } - ip4addr = _parse_ipv4_address (val, error); + ip4addr = _parse_ipv4_address (value, error); if (!ip4addr) return FALSE; - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); nm_ip_address_unref (ip4addr); return TRUE; } -/* 'routes' */ static NMIPRoute * _parse_ipv4_route (const char *route, GError **error) { @@ -4050,14 +4003,18 @@ _parse_ipv4_route (const char *route, GError **error) } static gboolean -nmc_property_ipv4_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip4_config_routes (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter; NMIPRoute *ip4route; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, ",", 0); + strv = nmc_strsplit_set (value, ",", 0); for (iter = strv; iter && *iter; iter++) { ip4route = _parse_ipv4_route (*iter, error); if (!ip4route) { @@ -4095,44 +4052,11 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes, nm_setting_ip_config_remove_route, _validate_and_remove_ipv4_route) -static const char * -nmc_property_ipv4_describe_routes (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv4 routes formatted as:\n" - " ip[/prefix] [next-hop] [metric],...\n\n" - "Missing prefix is regarded as a prefix of 32.\n" - "Missing next-hop is regarded as 0.0.0.0.\n" - "Missing metric means default (NM/kernel will set a default value).\n\n" - "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n" - " 10.1.2.0/24\n"); -} - - -/* --- NM_SETTING_IP6_CONFIG_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP_CONFIG_METHOD) -DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP_CONFIG_DNS) -DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP_CONFIG_DNS_SEARCH) -DEFINE_GETTER_WITH_DEFAULT (nmc_property_ipv6_get_dns_options, NM_SETTING_IP_CONFIG_DNS_OPTIONS, !nm_setting_ip_config_has_dns_options ((NMSettingIPConfig *) setting)) -DEFINE_GETTER (nmc_property_ipv6_get_dns_priority, NM_SETTING_IP_CONFIG_DNS_PRIORITY) - static char * -nmc_property_ipv6_get_routes (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_ipvx_get_routes (setting, get_type); -} - -DEFINE_GETTER (nmc_property_ipv6_get_gateway, NM_SETTING_IP_CONFIG_GATEWAY) -DEFINE_GETTER (nmc_property_ipv6_get_route_metric, NM_SETTING_IP_CONFIG_ROUTE_METRIC) -DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES) -DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS) -DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP_CONFIG_NEVER_DEFAULT) -DEFINE_GETTER (nmc_property_ipv6_get_may_fail, NM_SETTING_IP_CONFIG_MAY_FAIL) -DEFINE_GETTER (nmc_property_ipv6_get_dhcp_send_hostname, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME) -DEFINE_GETTER (nmc_property_ipv6_get_dhcp_hostname, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME) -DEFINE_GETTER (nmc_property_ipv6_get_token, NM_SETTING_IP6_CONFIG_TOKEN) - -static char * -nmc_property_ipv6_get_ip6_privacy (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip6_config_ip6_privacy (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting); return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type); @@ -4150,27 +4074,32 @@ static const char *ipv6_valid_methods[] = { }; static gboolean -nmc_property_ipv6_set_method (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_method (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { /* Silently accept "static" and convert to "manual" */ - if (val && strlen (val) > 1 && matches (val, "static")) - val = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + if (value && strlen (value) > 1 && matches (value, "static")) + value = NM_SETTING_IP6_CONFIG_METHOD_MANUAL; - return check_and_set_string (setting, prop, val, ipv6_valid_methods, error); + return check_and_set_string (setting, property_info->property_name, value, ipv6_valid_methods, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods) - -/* 'dns' */ static gboolean -nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_dns (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter, *addr; struct in6_addr ip6_addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); for (iter = strv; iter && *iter; iter++) { addr = g_strstrip (*iter); if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) { @@ -4208,30 +4137,20 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns, nm_setting_ip_config_remove_dns, _validate_and_remove_ipv6_dns) -static const char * -nmc_property_ipv6_describe_dns (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv6 addresses of DNS servers. If the IPv6 " - "configuration method is 'auto' these DNS servers are appended " - "to those (if any) returned by automatic configuration. DNS " - "servers cannot be used with the 'shared' or 'link-local' IPv6 " - "configuration methods, as there is no upstream network. In " - "all other IPv6 configuration methods, these DNS " - "servers are used as the only DNS servers for this connection.\n\n" - "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n"); -} - -/* 'dns-search' */ static gboolean -nmc_property_ipv6_set_dns_search (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_dns_search (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL; guint i = 0; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, " \t,", 0); - if (!verify_string_list (strv, prop, nmc_util_is_domain, error)) { + strv = nmc_strsplit_set (value, " \t,", 0); + if (!verify_string_list (strv, property_info->property_name, nmc_util_is_domain, error)) { g_strfreev (strv); return FALSE; } @@ -4263,9 +4182,12 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search, nm_setting_ip_config_remove_dns_search, _validate_and_remove_ipv6_dns_search) -/* 'dns-options' */ static gboolean -nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_dns_options (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL; guint i = 0; @@ -4273,7 +4195,7 @@ nmc_property_ipv6_set_dns_options (NMSetting *setting, const char *prop, const c g_return_val_if_fail (error == NULL || *error == NULL, FALSE); nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE); - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); while (strv && strv[i]) nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i++]); g_strfreev (strv); @@ -4309,14 +4231,18 @@ _parse_ipv6_address (const char *address, GError **error) } static gboolean -nmc_property_ipv6_set_addresses (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_addresses (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter; NMIPAddress *ip6addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, ",", 0); + strv = nmc_strsplit_set (value, ",", 0); for (iter = strv; iter && *iter; iter++) { ip6addr = _parse_ipv6_address (*iter, error); if (!ip6addr) { @@ -4354,38 +4280,31 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses, nm_setting_ip_config_remove_address, _validate_and_remove_ipv6_address) -static const char * -nmc_property_ipv6_describe_addresses (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv6 addresses formatted as:\n" - " ip[/prefix], ip[/prefix],...\n" - "Missing prefix is regarded as prefix of 128.\n\n" - "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n"); -} - -/* 'gateway' */ static gboolean -nmc_property_ipv6_set_gateway (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_gateway (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { NMIPAddress *ip6addr; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (strchr (val, '/')) { + if (strchr (value, '/')) { g_set_error (error, 1, 0, - _("invalid gateway address '%s'"), val); + _("invalid gateway address '%s'"), value); return FALSE; } - ip6addr = _parse_ipv6_address (val, error); + ip6addr = _parse_ipv6_address (value, error); if (!ip6addr) return FALSE; - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); nm_ip_address_unref (ip6addr); return TRUE; } -/* 'routes' */ static NMIPRoute * _parse_ipv6_route (const char *route, GError **error) { @@ -4393,14 +4312,18 @@ _parse_ipv6_route (const char *route, GError **error) } static gboolean -nmc_property_ipv6_set_routes (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_routes (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { char **strv = NULL, **iter; NMIPRoute *ip6route; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - strv = nmc_strsplit_set (val, ",", 0); + strv = nmc_strsplit_set (value, ",", 0); for (iter = strv; iter && *iter; iter++) { ip6route = _parse_ipv6_route (*iter, error); if (!ip6route) { @@ -4438,44 +4361,38 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes, nm_setting_ip_config_remove_route, _validate_and_remove_ipv6_route) -static const char * -nmc_property_ipv6_describe_routes (NMSetting *setting, const char *prop) -{ - return _("Enter a list of IPv6 routes formatted as:\n" - " ip[/prefix] [next-hop] [metric],...\n\n" - "Missing prefix is regarded as a prefix of 128.\n" - "Missing next-hop is regarded as \"::\".\n" - "Missing metric means default (NM/kernel will set a default value).\n\n" - "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n" - " abbe::/64 55\n"); -} - static gboolean -nmc_property_ipv6_set_ip6_privacy (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_ip6_config_ip6_privacy (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { unsigned long val_int; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_uint (val, FALSE, 0, 0, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a number"), val); + if (!nmc_string_to_uint (value, FALSE, 0, 0, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a number"), value); return FALSE; } if ( val_int != NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR && val_int != NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR) { - g_set_error (error, 1, 0, _("'%s' is not valid; use 0, 1, or 2"), val); + g_set_error (error, 1, 0, _("'%s' is not valid; use 0, 1, or 2"), value); return FALSE; } - g_object_set (setting, prop, val_int, NULL); + g_object_set (setting, property_info->property_name, val_int, NULL); return TRUE; } -/* 'addr_gen_mode' */ static char * -nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting); NMSettingIP6ConfigAddrGenMode addr_gen_mode; @@ -4486,27 +4403,25 @@ nmc_property_ipv6_get_addr_gen_mode (NMSetting *setting, NmcPropertyGetType get_ static gboolean -nmc_property_ipv6_set_addr_gen_mode (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; - if (!nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), val, + if (!nm_utils_enum_from_str (nm_setting_ip6_config_addr_gen_mode_get_type (), value, (int *) &addr_gen_mode, NULL)) { g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), - val, "eui64,stable-privacy"); + value, "eui64,stable-privacy"); return FALSE; } - g_object_set (setting, prop, addr_gen_mode, NULL); + g_object_set (setting, property_info->property_name, addr_gen_mode, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_ipv6_allowed_addr_gen_mode, - nm_setting_ip6_config_addr_gen_mode_get_type, - G_MININT, G_MAXINT) - - /* --- NM_SETTING_MACSEC_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_macsec_get_parent, NM_SETTING_MACSEC_PARENT) DEFINE_GETTER (nmc_property_macsec_get_encrypt, NM_SETTING_MACSEC_ENCRYPT) @@ -7113,269 +7028,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_IP4_CONFIG_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_METHOD, - nmc_property_ipv4_get_method, - nmc_property_ipv4_set_method, - NULL, - NULL, - nmc_property_ipv4_allowed_method, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS, - nmc_property_ipv4_get_dns, - nmc_property_ipv4_set_dns, - nmc_property_ipv4_remove_dns, - nmc_property_ipv4_describe_dns, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_SEARCH, - nmc_property_ipv4_get_dns_search, - nmc_property_ipv4_set_dns_search, - nmc_property_ipv4_remove_dns_search, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_OPTIONS, - nmc_property_ipv4_get_dns_options, - nmc_property_ipv4_set_dns_options, - nmc_property_ipv4_remove_dns_option, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_PRIORITY, - nmc_property_ipv4_get_dns_priority, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ADDRESSES, - nmc_property_ip_get_addresses, - nmc_property_ipv4_set_addresses, - nmc_property_ipv4_remove_addresses, - nmc_property_ipv4_describe_addresses, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_GATEWAY, - nmc_property_ipv4_get_gateway, - nmc_property_ipv4_set_gateway, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTES, - nmc_property_ipv4_get_routes, - nmc_property_ipv4_set_routes, - nmc_property_ipv4_remove_routes, - nmc_property_ipv4_describe_routes, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTE_METRIC, - nmc_property_ipv4_get_route_metric, - nmc_property_set_int64, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, - nmc_property_ipv4_get_ignore_auto_routes, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, - nmc_property_ipv4_get_ignore_auto_dns, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, - nmc_property_ipv4_get_dhcp_client_id, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, - nmc_property_ipv4_get_dhcp_timeout, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, - nmc_property_ipv4_get_dhcp_send_hostname, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, - nmc_property_ipv4_get_dhcp_hostname, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP4_CONFIG_DHCP_FQDN, - nmc_property_ipv4_get_dhcp_fqdn, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_NEVER_DEFAULT, - nmc_property_ipv4_get_never_default, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_MAY_FAIL, - nmc_property_ipv4_get_may_fail, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP4_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DAD_TIMEOUT, - nmc_property_ipv4_get_dad_timeout, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_IP6_CONFIG_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_METHOD, - nmc_property_ipv6_get_method, - nmc_property_ipv6_set_method, - NULL, - NULL, - nmc_property_ipv6_allowed_method, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS, - nmc_property_ipv6_get_dns, - nmc_property_ipv6_set_dns, - nmc_property_ipv6_remove_dns, - nmc_property_ipv6_describe_dns, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_SEARCH, - nmc_property_ipv6_get_dns_search, - nmc_property_ipv6_set_dns_search, - nmc_property_ipv6_remove_dns_search, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_OPTIONS, - nmc_property_ipv6_get_dns_options, - nmc_property_ipv6_set_dns_options, - nmc_property_ipv6_remove_dns_option, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DNS_PRIORITY, - nmc_property_ipv6_get_dns_priority, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ADDRESSES, - nmc_property_ip_get_addresses, - nmc_property_ipv6_set_addresses, - nmc_property_ipv6_remove_addresses, - nmc_property_ipv6_describe_addresses, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_GATEWAY, - nmc_property_ipv6_get_gateway, - nmc_property_ipv6_set_gateway, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTES, - nmc_property_ipv6_get_routes, - nmc_property_ipv6_set_routes, - nmc_property_ipv6_remove_routes, - nmc_property_ipv6_describe_routes, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_ROUTE_METRIC, - nmc_property_ipv6_get_route_metric, - nmc_property_set_int64, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, - nmc_property_ipv6_get_ignore_auto_routes, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, - nmc_property_ipv6_get_ignore_auto_dns, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_NEVER_DEFAULT, - nmc_property_ipv6_get_never_default, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_MAY_FAIL, - nmc_property_ipv6_get_may_fail, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_IP6_PRIVACY, - nmc_property_ipv6_get_ip6_privacy, - nmc_property_ipv6_set_ip6_privacy, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, - nmc_property_ipv6_get_addr_gen_mode, - nmc_property_ipv6_set_addr_gen_mode, - NULL, - NULL, - nmc_property_ipv6_allowed_addr_gen_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, - nmc_property_ipv6_get_dhcp_send_hostname, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, - nmc_property_ipv6_get_dhcp_hostname, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP6_CONFIG_SETTING_NAME""NM_SETTING_IP6_CONFIG_TOKEN, - nmc_property_ipv6_get_token, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_SSID, nmc_property_olpc_get_ssid, @@ -8700,6 +8352,9 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ + } else if (property_info->values_fcn) { + return property_info->values_fcn (setting_info, + property_info); } else if (property_info->values_static) return property_info->values_static; } @@ -9043,93 +8698,6 @@ setting_wireless_security_details (const NmcSettingInfo *setting_info, NMSetting return TRUE; } -static gboolean -setting_ip4_config_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (s_ip4), FALSE); - - tmpl = nmc_fields_setting_ip4_config; - tmpl_len = sizeof (nmc_fields_setting_ip4_config); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP4_CONFIG_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ipv4_get_method (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_ipv4_get_dns (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_ipv4_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_ipv4_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_ipv4_get_dns_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_ipv4_get_gateway (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_ipv4_get_routes (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_ipv4_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_ipv4_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_ipv4_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_ipv4_get_dhcp_client_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_ipv4_get_dhcp_timeout (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_ipv4_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_ipv4_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_ipv4_get_dhcp_fqdn (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 17, nmc_property_ipv4_get_never_default (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 18, nmc_property_ipv4_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 19, nmc_property_ipv4_get_dad_timeout (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_ip6_config_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (s_ip6), FALSE); - - tmpl = nmc_fields_setting_ip6_config; - tmpl_len = sizeof (nmc_fields_setting_ip6_config); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP6_CONFIG_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ipv6_get_method (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_ipv6_get_dns (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_ipv6_get_dns_search (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_ipv6_get_dns_options (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_ipv6_get_dns_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_ip_get_addresses (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_ipv6_get_gateway (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_ipv6_get_routes (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_ipv6_get_route_metric (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_ipv6_get_ignore_auto_routes (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_ipv6_get_ignore_auto_dns (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_ipv6_get_never_default (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_ipv6_get_may_fail (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_ipv6_get_ip6_privacy (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_ipv6_get_addr_gen_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_ipv6_get_dhcp_send_hostname (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 17, nmc_property_ipv6_get_dhcp_hostname (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 18, nmc_property_ipv6_get_token (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -9886,15 +9454,23 @@ setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, N /*****************************************************************************/ +#define PROPERTY_INFO_NAME() \ + { \ + .property_name = N_ ("name"), \ + .is_name = TRUE, \ + .get_fcn = _get_fcn_direct, \ + .get_data = { .get_direct = nm_setting_get_name, }, \ + } + #define VALUES_STATIC(...) (((const char *[]) { __VA_ARGS__, NULL })) +#define GET_WITH_DEFAULT_FCN(type, func) \ + /* macro that returns @func as const (gboolean(*)(NMSetting*)) type, but checks + * that the actual type is (gboolean(*)(type *)). */ \ + ((gboolean (*) (NMSetting *)) ((sizeof (func == ((gboolean (*) (type *)) func))) ? func : func) ) + static const NmcPropertyInfo properties_setting_connection[] = { - { - .property_name = N_ ("name"), - .is_name = TRUE, - .get_fcn = _get_fcn_direct, - .get_data = { .get_direct = nm_setting_get_name, }, - }, + PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_CONNECTION_ID), .get_fcn = _get_fcn_gobject, @@ -10021,6 +9597,267 @@ static const NmcPropertyInfo properties_setting_connection[] = { }, }; +static const NmcPropertyInfo properties_setting_ip4_config[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_method, + .values_static = ipv4_valid_methods, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_dns, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns, }, + .describe_message = + N_ ("Enter a list of IPv4 addresses of DNS servers.\n\n" + "Example: 8.8.8.8, 8.8.4.4\n"), + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_SEARCH), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_dns_search, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns_search, }, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_OPTIONS), + .get_fcn = _get_fcn_gobject_with_default, + .get_data = { .get_gobject_with_default_fcn = GET_WITH_DEFAULT_FCN (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), }, + .set_fcn = _set_fcn_ip4_config_dns_options, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns_option, }, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_PRIORITY), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ADDRESSES), + .get_fcn = _get_fcn_ip_config_addresses, + .set_fcn = _set_fcn_ip4_config_addresses, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv4_remove_addresses, }, + .describe_message = + N_ ("Enter a list of IPv4 addresses formatted as:\n" + " ip[/prefix], ip[/prefix],...\n" + "Missing prefix is regarded as prefix of 32.\n\n" + "Example: 192.168.1.5/24, 10.0.0.11/24\n"), + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_GATEWAY), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_gateway, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTES), + .get_fcn = _get_fcn_ip_config_routes, + .set_fcn = _set_fcn_ip4_config_routes, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv4_remove_routes, }, + .describe_message = + N_ ("Enter a list of IPv4 routes formatted as:\n" + " ip[/prefix] [next-hop] [metric],...\n\n" + "Missing prefix is regarded as a prefix of 32.\n" + "Missing next-hop is regarded as 0.0.0.0.\n" + "Missing metric means default (NM/kernel will set a default value).\n\n" + "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n" + " 10.1.2.0/24\n"), + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTE_METRIC), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int64, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP4_CONFIG_DHCP_FQDN), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_MAY_FAIL), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DAD_TIMEOUT), + .get_fcn = _get_fcn_ip4_config_dad_timeout, + .set_fcn = _set_fcn_gobject_int, + }, +}; + +static const NmcPropertyInfo properties_setting_ip6_config[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_method, + .values_static = ipv6_valid_methods, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_dns, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns, }, + .describe_message = + N_ ("Enter a list of IPv6 addresses of DNS servers. If the IPv6 " + "configuration method is 'auto' these DNS servers are appended " + "to those (if any) returned by automatic configuration. DNS " + "servers cannot be used with the 'shared' or 'link-local' IPv6 " + "configuration methods, as there is no upstream network. In " + "all other IPv6 configuration methods, these DNS " + "servers are used as the only DNS servers for this connection.\n\n" + "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n") + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_SEARCH), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_dns_search, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns_search, }, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_OPTIONS), + .get_fcn = _get_fcn_gobject_with_default, + .get_data = { .get_gobject_with_default_fcn = GET_WITH_DEFAULT_FCN (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), }, + .set_fcn = _set_fcn_ip6_config_dns_options, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns_option, }, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_PRIORITY), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ADDRESSES), + .get_fcn = _get_fcn_ip_config_addresses, + .set_fcn = _set_fcn_ip6_config_addresses, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv6_remove_addresses, }, + .describe_message = + N_ ("Enter a list of IPv6 addresses formatted as:\n" + " ip[/prefix], ip[/prefix],...\n" + "Missing prefix is regarded as prefix of 128.\n\n" + "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n"), + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_GATEWAY), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_gateway, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTES), + .get_fcn = _get_fcn_ip_config_routes, + .set_fcn = _set_fcn_ip6_config_routes, + .remove_fcn = _remove_fcn_nmc, + .remove_data = { .remove_nmc = nmc_property_ipv6_remove_routes, }, + .describe_message = + N_ ("Enter a list of IPv6 routes formatted as:\n" + " ip[/prefix] [next-hop] [metric],...\n\n" + "Missing prefix is regarded as a prefix of 128.\n" + "Missing next-hop is regarded as \"::\".\n" + "Missing metric means default (NM/kernel will set a default value).\n\n" + "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n" + " abbe::/64 55\n"), + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTE_METRIC), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int64, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_MAY_FAIL), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP6_CONFIG_IP6_PRIVACY), + .get_fcn = _get_fcn_ip6_config_ip6_privacy, + .set_fcn = _set_fcn_ip6_config_ip6_privacy, + }, + { + .property_name = N_ (NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE), + .get_fcn = _get_fcn_ip6_config_addr_gen_mode, + .set_fcn = _set_fcn_ip6_config_addr_gen_mode, + .values_fcn = _values_fcn_gobject_enum, + .values_data = { + .gobject_enum = { + .get_gtype = nm_setting_ip6_config_addr_gen_mode_get_type, + }, + }, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP6_CONFIG_TOKEN), + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, + }, +}; + const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], @@ -10052,7 +9889,6 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_CONNECTION] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CONNECTION], - .get_setting_details = _get_setting_details, .properties = properties_setting_connection, .properties_num = G_N_ELEMENTS (properties_setting_connection), }, @@ -10070,11 +9906,13 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_IP4_CONFIG] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP4_CONFIG], - .get_setting_details = setting_ip4_config_details, + .properties = properties_setting_ip4_config, + .properties_num = G_N_ELEMENTS (properties_setting_ip4_config), }, [NM_META_SETTING_TYPE_IP6_CONFIG] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP6_CONFIG], - .get_setting_details = setting_ip6_config_details, + .properties = properties_setting_ip6_config, + .properties_num = G_N_ELEMENTS (properties_setting_ip6_config), }, [NM_META_SETTING_TYPE_IP_TUNNEL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP_TUNNEL], @@ -10162,8 +10000,8 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean g_return_val_if_fail (meta_setting_info, FALSE); setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; - g_return_val_if_fail (setting_info && setting_info->get_setting_details, FALSE); + g_return_val_if_fail (setting_info, FALSE); - return setting_info->get_setting_details (setting_info, setting, nmc, one_prop, secrets); + return (setting_info->get_setting_details ?: _get_setting_details) (setting_info, setting, nmc, one_prop, secrets); } diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 89a9c7c6d1..544de35ef8 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -51,6 +51,7 @@ struct _NmcPropertyInfo { union { const char *(*get_direct) (NMSetting *setting); char *(*get_nmc) (NMSetting *setting, NmcPropertyGetType get_type); + gboolean (*get_gobject_with_default_fcn) (NMSetting *setting); } get_data; gboolean (*set_fcn) (const NmcSettingInfo *setting_info, @@ -74,7 +75,19 @@ struct _NmcPropertyInfo { const char *describe_message; - const char *const*values_static; + const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info); + union { + union { + struct { + GType (*get_gtype) (void); + bool has_minmax:1; + int min; + int max; + } gobject_enum; + } values_data; + const char *const*values_static; + }; }; struct _NmcSettingInfo { @@ -137,8 +150,6 @@ extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_8021X[]; extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_wireless_security[]; -extern NmcOutputField nmc_fields_setting_ip4_config[]; -extern NmcOutputField nmc_fields_setting_ip6_config[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_ppp[]; extern NmcOutputField nmc_fields_setting_pppoe[]; From b9029a798e2847eb736d8afd887984281481ba0d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 09:57:02 +0200 Subject: [PATCH 16/53] cli: add NmcPropertyType structure We shall not only have a PropertyInfo. Most properties share common behavior, that is, they have a type. Move the function pointers to a NmcPropertyType structure, so that it can be reused for multiple properties. This promotes the idea that properties have a (limited) set of types with some type specific behaviors. Contrary, to having each property re-implement fully it's type. E.g. instead of having various property re-define their full behavior as an "bool", have one property type "bool" which can be attached to a property. --- clients/cli/settings.c | 575 +++++++++++++++++++++++++---------------- clients/cli/settings.h | 92 +++---- 2 files changed, 395 insertions(+), 272 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 8a8080c422..87564f6e8a 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -41,12 +41,13 @@ static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val /*****************************************************************************/ static char * -_get_fcn_direct (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_name (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) { - return g_strdup (property_info->get_data.get_direct (setting)); + nm_assert (nm_streq0 (nm_setting_get_name (setting), setting_info->general->setting_name)); + return g_strdup (setting_info->general->setting_name); } static char * @@ -55,7 +56,34 @@ _get_fcn_nmc (const NmcSettingInfo *setting_info, NMSetting *setting, NmcPropertyGetType get_type) { - return property_info->get_data.get_nmc (setting, get_type); + return property_info->property_typ_data->nmc.get_fcn (setting, get_type); +} + +static char * +_get_fcn_nmc_with_default (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + const char *s; + char *s_full; + GValue val = G_VALUE_INIT; + + if (property_info->property_typ_data->nmc.get_fcn_with_default (setting)) { + if (get_type == NMC_PROPERTY_GET_PARSABLE) + return g_strdup (""); + return g_strdup (_("(default)")); + } + + g_value_init (&val, G_TYPE_STRING); + g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); + s = g_value_get_string (&val); + if (get_type == NMC_PROPERTY_GET_PARSABLE) + s_full = g_strdup (s && *s ? s : " "); + else + s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); + g_value_unset (&val); + return s_full; } static char * @@ -74,33 +102,6 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, return s; } -static char * -_get_fcn_gobject_with_default (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) -{ - const char *s; - char *s_full; - GValue val = G_VALUE_INIT; - - if (property_info->get_data.get_gobject_with_default_fcn (setting)) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) - return g_strdup (""); - return g_strdup (_("(default)")); - } - - g_value_init (&val, G_TYPE_STRING); - g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); - s = g_value_get_string (&val); - if (get_type == NMC_PROPERTY_GET_PARSABLE) - s_full = g_strdup (s && *s ? s : " "); - else - s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); - g_value_unset (&val); - return s_full; -} - /*****************************************************************************/ static gboolean @@ -110,7 +111,7 @@ _set_fcn_nmc (const NmcSettingInfo *setting_info, const char *value, GError **error) { - return property_info->set_data.set_nmc (setting, property_info->property_name, value, error); + return property_info->property_typ_data->nmc.set_fcn (setting, property_info->property_name, value, error); } static gboolean @@ -240,14 +241,14 @@ _remove_fcn_nmc (const NmcSettingInfo *setting_info, guint32 idx, GError **error) { - return property_info->remove_data.remove_nmc (setting, property_info->property_name, option, idx, error); + return property_info->property_typ_data->nmc.remove_fcn (setting, property_info->property_name, option, idx, error); } /*****************************************************************************/ static const char *const* -_values_fcn_gobject_enum (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info) +_values_fcn_nmc_gobject_enum (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info) { static GHashTable *cache = NULL; const char **v; @@ -257,11 +258,11 @@ _values_fcn_gobject_enum (const NmcSettingInfo *setting_info, v = g_hash_table_lookup (cache, property_info); if (!v) { - bool has_minmax = property_info->values_data.gobject_enum.has_minmax; + bool has_minmax = property_info->property_typ_data->nmc.values_data.gobject_enum.has_minmax; - v = nm_utils_enum_get_values (property_info->values_data.gobject_enum.get_gtype (), - has_minmax ? property_info->values_data.gobject_enum.min : G_MININT, - has_minmax ? property_info->values_data.gobject_enum.max : G_MAXINT); + v = nm_utils_enum_get_values ( property_info->property_typ_data->nmc.values_data.gobject_enum.get_gtype (), + has_minmax ? property_info->property_typ_data->nmc.values_data.gobject_enum.min : G_MININT, + has_minmax ? property_info->property_typ_data->nmc.values_data.gobject_enum.max : G_MAXINT); g_hash_table_insert (cache, (gpointer) property_info, v); } return (const char *const*) v; @@ -2849,7 +2850,6 @@ _set_fcn_connection_master (const NmcSettingInfo *setting_info, return TRUE; } -/* 'slave-type' */ static const char *con_valid_slave_types[] = { NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BRIDGE_SETTING_NAME, @@ -5015,7 +5015,6 @@ _validate_vpn_hash_value (const char *option, const char *value, GError **error) return value; } -/* 'data' */ DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data, NM_SETTING_VPN, NMSettingVpn, @@ -5026,7 +5025,6 @@ DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data, NM_SETTING_VPN, nm_setting_vpn_remove_data_item) -/* 'secrets' */ DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets, NM_SETTING_VPN, NMSettingVpn, @@ -8109,11 +8107,11 @@ get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_t if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ - } else if (property_info->get_fcn) { - return property_info->get_fcn (setting_info, - property_info, - setting, - get_type); + } else if (property_info->property_type->get_fcn) { + return property_info->property_type->get_fcn (setting_info, + property_info, + setting, + get_type); } } @@ -8184,12 +8182,12 @@ nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ - } else if (property_info->set_fcn) { - return property_info->set_fcn (setting_info, - property_info, - setting, - val, - error); + } else if (property_info->property_type->set_fcn) { + return property_info->property_type->set_fcn (setting_info, + property_info, + setting, + val, + error); } } @@ -8242,7 +8240,7 @@ nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ - } else if (property_info->set_fcn) { + } else if (property_info->property_type->set_fcn) { nmc_property_set_default_value (setting, prop); return TRUE; } @@ -8285,13 +8283,13 @@ nmc_setting_remove_property_option (NMSetting *setting, if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ - } else if (property_info->remove_fcn) { - return property_info->remove_fcn (setting_info, - property_info, - setting, - option, - idx, - error); + } else if (property_info->property_type->remove_fcn) { + return property_info->property_type->remove_fcn (setting_info, + property_info, + setting, + option, + idx, + error); } } @@ -8352,11 +8350,11 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) if (property_info->is_name) { /* NmcPropertyFuncs would not register the "name" property. * For the moment, skip it from get_property_val(). */ - } else if (property_info->values_fcn) { - return property_info->values_fcn (setting_info, - property_info); - } else if (property_info->values_static) - return property_info->values_static; + } else if (property_info->property_type->values_fcn) { + return property_info->property_type->values_fcn (setting_info, + property_info); + } else if (property_info->property_typ_data && property_info->property_typ_data->values_static) + return property_info->property_typ_data->values_static; } return NULL; @@ -8494,10 +8492,10 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm for (i = 0; i < setting_info->properties_num; i++) { const NmcPropertyInfo *property_info = &setting_info->properties[i]; - set_val_str (arr, i, property_info->get_fcn (setting_info, - property_info, - setting, - NMC_PROPERTY_GET_PRETTY)); + set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, + property_info, + setting, + NMC_PROPERTY_GET_PRETTY)); } g_ptr_array_add (nmc->output_data, arr); @@ -9454,17 +9452,68 @@ setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, N /*****************************************************************************/ +#define DEFINE_PROPERTY_TYPE(...) \ + (&((NmcPropertyType) { __VA_ARGS__ } )) + +#define DEFINE_PROPERTY_TYP_DATA(...) \ + (&((NmcPropertyTypData) { __VA_ARGS__ } )) + +#define DEFINE_PROPERTY_TYP_DATA_SUBTYPE(type, ...) \ + DEFINE_PROPERTY_TYP_DATA ( \ + .type = { __VA_ARGS__ }, \ + ) + +#define DEFINE_PROPERTY_TYP_DATA_WITH_ARG1(type, arg1, ...) \ + DEFINE_PROPERTY_TYP_DATA ( \ + arg1, \ + .type = { __VA_ARGS__ }, \ + ) + +static const NmcPropertyType _pt_name = { + .get_fcn = _get_fcn_name, +}; + +static const NmcPropertyType _pt_gobject_readonly = { + .get_fcn = _get_fcn_gobject, +}; + +static const NmcPropertyType _pt_gobject_string = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_string, +}; + +static const NmcPropertyType _pt_gobject_bool = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_bool, +}; + +static const NmcPropertyType _pt_gobject_int = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int, +}; + +static const NmcPropertyType _pt_gobject_int64 = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_int64, +}; + +static const NmcPropertyType _pt_gobject_uint = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_uint, +}; + +/*****************************************************************************/ + #define PROPERTY_INFO_NAME() \ { \ .property_name = N_ ("name"), \ .is_name = TRUE, \ - .get_fcn = _get_fcn_direct, \ - .get_data = { .get_direct = nm_setting_get_name, }, \ + .property_type = &_pt_name, \ } #define VALUES_STATIC(...) (((const char *[]) { __VA_ARGS__, NULL })) -#define GET_WITH_DEFAULT_FCN(type, func) \ +#define GET_FCN_WITH_DEFAULT(type, func) \ /* macro that returns @func as const (gboolean(*)(NMSetting*)) type, but checks * that the actual type is (gboolean(*)(type *)). */ \ ((gboolean (*) (NMSetting *)) ((sizeof (func == ((gboolean (*) (type *)) func))) ? func : func) ) @@ -9473,95 +9522,110 @@ static const NmcPropertyInfo properties_setting_connection[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_CONNECTION_ID), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_UUID), - .get_fcn = _get_fcn_gobject, + .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject ), }, { .property_name = N_ (NM_SETTING_CONNECTION_STABLE_ID), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_INTERFACE_NAME), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .set_data = { .set_nmc = nmc_property_set_ifname, }, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_set_ifname, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_TYPE), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_connection_type, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_type, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int, + .property_type = &_pt_gobject_int, }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), - .get_fcn = _get_fcn_nmc, - .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_retries, }, - .set_fcn = _set_fcn_gobject_int, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_gobject_int, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_connection_get_autoconnect_retries, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_TIMESTAMP), - .get_fcn = _get_fcn_gobject, + .property_type = &_pt_gobject_readonly, }, { .property_name = N_ (NM_SETTING_CONNECTION_READ_ONLY), - .get_fcn = _get_fcn_gobject, + .property_type = &_pt_gobject_readonly, }, { .property_name = N_ (NM_SETTING_CONNECTION_PERMISSIONS), - .get_fcn = _get_fcn_nmc, - .get_data = { .get_nmc = nmc_property_connection_get_permissions, }, - .set_fcn = _set_fcn_connection_permissions, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_connection_remove_permissions, }, .describe_message = N_ ("Enter a list of user permissions. This is a list of user names formatted as:\n" " [user:], [user:],...\n" "The items can be separated by commas or spaces.\n\n" "Example: alice bob charlie\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_connection_permissions, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_connection_get_permissions, + .remove_fcn = nmc_property_connection_remove_permissions, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_ZONE), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_CONNECTION_MASTER), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_connection_master, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_master, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_SLAVE_TYPE), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .set_data = { .set_nmc = nmc_property_con_set_slave_type, }, - .values_static = con_valid_slave_types, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = con_valid_slave_types, + .set_fcn = nmc_property_con_set_slave_type, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), - .get_fcn = _get_fcn_nmc, - .get_data = { .get_nmc = nmc_property_connection_get_autoconnect_slaves, }, - .set_fcn = _set_fcn_gobject_trilean, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_gobject_trilean, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_connection_get_autoconnect_slaves, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_SECONDARIES), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_connection_secondaries, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_connection_remove_secondaries, }, .describe_message = N_ ("Enter secondary connections that should be activated when this connection is\n" "activated. Connections can be specified either by UUID or ID (name). nmcli\n" @@ -9569,31 +9633,46 @@ static const NmcPropertyInfo properties_setting_connection[] = { "VPNs as secondary connections at the moment.\n" "The items can be separated by commas or spaces.\n\n" "Example: private-openvpn, fe6ba5d8-c2fc-4aae-b2e3-97efddd8d9a7\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_connection_secondaries, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_connection_remove_secondaries, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_uint, + .property_type = &_pt_gobject_uint, }, { .property_name = N_ (NM_SETTING_CONNECTION_METERED), - .get_fcn = _get_fcn_nmc, - .get_data = { .get_nmc = nmc_property_connection_get_metered, }, - .set_fcn = _set_fcn_connection_metered, .describe_message = N_ ("Enter a value which indicates whether the connection is subject to a data\n" "quota, usage costs or other limitations. Accepted options are:\n" "'true','yes','on' to set the connection as metered\n" "'false','no','off' to set the connection as not metered\n" "'unknown' to let NetworkManager choose a value using some heuristics\n"), - .values_static = VALUES_STATIC ("yes", "no", "unknown"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_connection_metered, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = VALUES_STATIC ("yes", "no", "unknown"), + .get_fcn = nmc_property_connection_get_metered, + ), }, { .property_name = N_ (NM_SETTING_CONNECTION_LLDP), - .get_fcn = _get_fcn_nmc, - .get_data = { .get_nmc = nmc_property_connection_get_lldp, }, - .set_fcn = _set_fcn_connection_lldp, - .values_static = VALUES_STATIC ("default", "disable", "enable-rx"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_connection_lldp, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = VALUES_STATIC ("default", "disable", "enable-rx"), + .get_fcn = nmc_property_connection_get_lldp, + ), }, }; @@ -9601,63 +9680,80 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip4_config_method, - .values_static = ipv4_valid_methods, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_method, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = ipv4_valid_methods, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip4_config_dns, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns, }, .describe_message = N_ ("Enter a list of IPv4 addresses of DNS servers.\n\n" "Example: 8.8.8.8, 8.8.4.4\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_dns, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv4_remove_dns, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_SEARCH), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip4_config_dns_search, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns_search, }, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_dns_search, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv4_remove_dns_search, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_OPTIONS), - .get_fcn = _get_fcn_gobject_with_default, - .get_data = { .get_gobject_with_default_fcn = GET_WITH_DEFAULT_FCN (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), }, - .set_fcn = _set_fcn_ip4_config_dns_options, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv4_remove_dns_option, }, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc_with_default, + .set_fcn = _set_fcn_ip4_config_dns_options, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn_with_default = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), + .remove_fcn = nmc_property_ipv4_remove_dns_option, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_PRIORITY), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int, + .property_type = &_pt_gobject_int, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ADDRESSES), - .get_fcn = _get_fcn_ip_config_addresses, - .set_fcn = _set_fcn_ip4_config_addresses, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv4_remove_addresses, }, .describe_message = N_ ("Enter a list of IPv4 addresses formatted as:\n" " ip[/prefix], ip[/prefix],...\n" "Missing prefix is regarded as prefix of 32.\n\n" "Example: 192.168.1.5/24, 10.0.0.11/24\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip_config_addresses, + .set_fcn = _set_fcn_ip4_config_addresses, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv4_remove_addresses, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_GATEWAY), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip4_config_gateway, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip4_config_gateway, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTES), - .get_fcn = _get_fcn_ip_config_routes, - .set_fcn = _set_fcn_ip4_config_routes, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv4_remove_routes, }, .describe_message = N_ ("Enter a list of IPv4 routes formatted as:\n" " ip[/prefix] [next-hop] [metric],...\n\n" @@ -9666,61 +9762,61 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { "Missing metric means default (NM/kernel will set a default value).\n\n" "Examples: 192.168.2.0/24 192.168.2.1 3, 10.1.0.0/16 10.0.0.254\n" " 10.1.2.0/24\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip_config_routes, + .set_fcn = _set_fcn_ip4_config_routes, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv4_remove_routes, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTE_METRIC), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int64, + .property_type = &_pt_gobject_int64, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int, + .property_type = &_pt_gobject_int, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_IP4_CONFIG_DHCP_FQDN), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_MAY_FAIL), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DAD_TIMEOUT), - .get_fcn = _get_fcn_ip4_config_dad_timeout, - .set_fcn = _set_fcn_gobject_int, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip4_config_dad_timeout, + .set_fcn = _set_fcn_gobject_int, + ), }, }; @@ -9728,16 +9824,16 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip6_config_method, - .values_static = ipv6_valid_methods, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_method, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = ipv6_valid_methods, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip6_config_dns, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns, }, .describe_message = N_ ("Enter a list of IPv6 addresses of DNS servers. If the IPv6 " "configuration method is 'auto' these DNS servers are appended " @@ -9746,51 +9842,68 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { "configuration methods, as there is no upstream network. In " "all other IPv6 configuration methods, these DNS " "servers are used as the only DNS servers for this connection.\n\n" - "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n") + "Example: 2607:f0d0:1002:51::4, 2607:f0d0:1002:51::1\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_dns, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv6_remove_dns, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_SEARCH), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip6_config_dns_search, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns_search, }, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_dns_search, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv6_remove_dns_search, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_OPTIONS), - .get_fcn = _get_fcn_gobject_with_default, - .get_data = { .get_gobject_with_default_fcn = GET_WITH_DEFAULT_FCN (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), }, - .set_fcn = _set_fcn_ip6_config_dns_options, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv6_remove_dns_option, }, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc_with_default, + .set_fcn = _set_fcn_ip6_config_dns_options, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn_with_default = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), + .remove_fcn = nmc_property_ipv6_remove_dns_option, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DNS_PRIORITY), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int, + .property_type = &_pt_gobject_int, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ADDRESSES), - .get_fcn = _get_fcn_ip_config_addresses, - .set_fcn = _set_fcn_ip6_config_addresses, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv6_remove_addresses, }, .describe_message = N_ ("Enter a list of IPv6 addresses formatted as:\n" " ip[/prefix], ip[/prefix],...\n" "Missing prefix is regarded as prefix of 128.\n\n" "Example: 2607:f0d0:1002:51::4/64, 1050:0:0:0:5:600:300c:326b\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip_config_addresses, + .set_fcn = _set_fcn_ip6_config_addresses, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv6_remove_addresses, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_GATEWAY), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_ip6_config_gateway, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_ip6_config_gateway, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTES), - .get_fcn = _get_fcn_ip_config_routes, - .set_fcn = _set_fcn_ip6_config_routes, - .remove_fcn = _remove_fcn_nmc, - .remove_data = { .remove_nmc = nmc_property_ipv6_remove_routes, }, .describe_message = N_ ("Enter a list of IPv6 routes formatted as:\n" " ip[/prefix] [next-hop] [metric],...\n\n" @@ -9799,62 +9912,68 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { "Missing metric means default (NM/kernel will set a default value).\n\n" "Examples: 2001:db8:beef:2::/64 2001:db8:beef::2, 2001:db8:beef:3::/64 2001:db8:beef::3 2\n" " abbe::/64 55\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip_config_routes, + .set_fcn = _set_fcn_ip6_config_routes, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .remove_fcn = nmc_property_ipv6_remove_routes, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_ROUTE_METRIC), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_int64, + .property_type = &_pt_gobject_int64, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_NEVER_DEFAULT), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_MAY_FAIL), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP6_CONFIG_IP6_PRIVACY), - .get_fcn = _get_fcn_ip6_config_ip6_privacy, - .set_fcn = _set_fcn_ip6_config_ip6_privacy, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip6_config_ip6_privacy, + .set_fcn = _set_fcn_ip6_config_ip6_privacy, + ), }, { .property_name = N_ (NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE), - .get_fcn = _get_fcn_ip6_config_addr_gen_mode, - .set_fcn = _set_fcn_ip6_config_addr_gen_mode, - .values_fcn = _values_fcn_gobject_enum, - .values_data = { - .gobject_enum = { - .get_gtype = nm_setting_ip6_config_addr_gen_mode_get_type, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_ip6_config_addr_gen_mode, + .set_fcn = _set_fcn_ip6_config_addr_gen_mode, + .values_fcn = _values_fcn_nmc_gobject_enum, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .values_data = { + .gobject_enum = { + .get_gtype = nm_setting_ip6_config_addr_gen_mode_get_type, + }, }, - }, + ), }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_bool, + .property_type = &_pt_gobject_bool, }, { .property_name = N_ (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, { .property_name = N_ (NM_SETTING_IP6_CONFIG_TOKEN), - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_string, + .property_type = &_pt_gobject_string, }, }; diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 544de35ef8..7e4d802276 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -32,8 +32,52 @@ typedef enum { NMC_PROPERTY_GET_PARSABLE, } NmcPropertyGetType; -typedef struct _NmcSettingInfo NmcSettingInfo; -typedef struct _NmcPropertyInfo NmcPropertyInfo; +typedef struct _NmcSettingInfo NmcSettingInfo; +typedef struct _NmcPropertyInfo NmcPropertyInfo; +typedef struct _NmcPropertyType NmcPropertyType; +typedef struct _NmcPropertyTypData NmcPropertyTypData; + +struct _NmcPropertyType { + char *(*get_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type); + gboolean (*set_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error); + gboolean (*remove_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *option, + guint32 idx, + GError **error); + const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info); +}; + +struct _NmcPropertyTypData { + union { + struct { + union { + char *(*get_fcn) (NMSetting *setting, NmcPropertyGetType get_type); + gboolean (*get_fcn_with_default) (NMSetting *setting); + }; + gboolean (*set_fcn) (NMSetting *setting, const char *property_name, const char *value, GError **error); + gboolean (*remove_fcn) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); + union { + struct { + GType (*get_gtype) (void); + bool has_minmax:1; + int min; + int max; + } gobject_enum; + } values_data; + } nmc; + }; + const char *const*values_static; +}; struct _NmcPropertyInfo { const char *property_name; @@ -44,50 +88,10 @@ struct _NmcPropertyInfo { * group_list/setting_info. */ bool is_name:1; - char *(*get_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type); - union { - const char *(*get_direct) (NMSetting *setting); - char *(*get_nmc) (NMSetting *setting, NmcPropertyGetType get_type); - gboolean (*get_gobject_with_default_fcn) (NMSetting *setting); - } get_data; - - gboolean (*set_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error); - union { - gboolean (*set_nmc) (NMSetting *setting, const char *property_name, const char *value, GError **error); - } set_data; - - gboolean (*remove_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *option, - guint32 idx, - GError **error); - union { - gboolean (*remove_nmc) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); - } remove_data; - const char *describe_message; - const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info); - union { - union { - struct { - GType (*get_gtype) (void); - bool has_minmax:1; - int min; - int max; - } gobject_enum; - } values_data; - const char *const*values_static; - }; + const NmcPropertyType *property_type; + const NmcPropertyTypData *property_typ_data; }; struct _NmcSettingInfo { From 89b568569560c6fbf9c20337d945bc8d03277c74 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 25 Mar 2017 15:52:03 +0100 Subject: [PATCH 17/53] cli: add property-info for NMSettingProxy --- clients/cli/connections.c | 8 +-- clients/cli/nmcli.c | 1 + clients/cli/settings.c | 134 ++++++++++++++------------------------ clients/cli/settings.h | 18 ++--- 4 files changed, 65 insertions(+), 96 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index e497735b1a..f51a018ac8 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -163,13 +163,13 @@ NmcOutputField nmc_fields_con_show[] = { /* Available settings for 'connection show ' - profile part */ NmcOutputField nmc_fields_settings_names[] = { - SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), + SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), SETTING_FIELD (NM_SETTING_WIRED_SETTING_NAME, nmc_fields_setting_wired + 1), /* 1 */ SETTING_FIELD (NM_SETTING_802_1X_SETTING_NAME, nmc_fields_setting_8021X + 1), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, nmc_fields_setting_wireless_security + 1), /* 4 */ - SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), - SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), + SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ + SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ SETTING_FIELD (NM_SETTING_PPP_SETTING_NAME, nmc_fields_setting_ppp + 1), /* 8 */ SETTING_FIELD (NM_SETTING_PPPOE_SETTING_NAME, nmc_fields_setting_pppoe + 1), /* 9 */ @@ -193,7 +193,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_MACSEC_SETTING_NAME, nmc_fields_setting_macsec + 1), /* 27 */ SETTING_FIELD (NM_SETTING_MACVLAN_SETTING_NAME, nmc_fields_setting_macvlan + 1), /* 28 */ SETTING_FIELD (NM_SETTING_VXLAN_SETTING_NAME, nmc_fields_setting_vxlan + 1), /* 29 */ - SETTING_FIELD (NM_SETTING_PROXY_SETTING_NAME, nmc_fields_setting_proxy + 1), /* 30 */ + SETTING_FIELD_TYPE (NM_SETTING_PROXY_SETTING_NAME, NM_META_SETTING_TYPE_PROXY), /* 30 */ SETTING_FIELD (NM_SETTING_DUMMY_SETTING_NAME, nmc_fields_setting_dummy + 1), /* 31 */ {NULL, NULL, 0, NULL, NULL, FALSE, FALSE, 0} }; diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index bb47fb4f26..073e4f2b78 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -175,6 +175,7 @@ complete_fields (const char *prefix) complete_field (h, "ip-tunnel", nmc_fields_setting_ip_tunnel); complete_field (h, "macvlan", nmc_fields_setting_macvlan); complete_field (h, "vxlan", nmc_fields_setting_vxlan); + complete_field_new (h, "proxy", NM_META_SETTING_TYPE_PROXY); g_hash_table_foreach (h, complete_one, (gpointer) prefix); g_hash_table_destroy (h); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 87564f6e8a..3d6b816599 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -246,6 +246,13 @@ _remove_fcn_nmc (const NmcSettingInfo *setting_info, /*****************************************************************************/ +static const char *const* +_values_fcn_nmc (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info) +{ + return property_info->property_typ_data->nmc.values_fcn (NULL, property_info->property_name); +} + static const char *const* _values_fcn_nmc_gobject_enum (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info) @@ -1085,21 +1092,8 @@ NmcOutputField nmc_fields_setting_vxlan[] = { NM_SETTING_VXLAN_L2_MISS","\ NM_SETTING_VXLAN_L3_MISS -/* Available fields for NM_SETTING_PROXY_SETTING_NAME */ -NmcOutputField nmc_fields_setting_proxy[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_PROXY_METHOD), /* 1 */ - SETTING_FIELD (NM_SETTING_PROXY_BROWSER_ONLY), /* 2 */ - SETTING_FIELD (NM_SETTING_PROXY_PAC_URL), /* 3 */ - SETTING_FIELD (NM_SETTING_PROXY_PAC_SCRIPT), /* 4 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_PROXY_ALL "name"","\ - NM_SETTING_PROXY_METHOD","\ - NM_SETTING_PROXY_BROWSER_ONLY","\ - NM_SETTING_PROXY_PAC_URL","\ - NM_SETTING_PROXY_PAC_SCRIPT -/*----------------------------------------------------------------------------*/ +/*****************************************************************************/ + static char * wep_key_type_to_string (NMWepKeyType type) { @@ -4629,11 +4623,6 @@ DEFINE_GETTER (nmc_property_pppoe_get_password, NM_SETTING_PPPOE_PASSWORD) DEFINE_SECRET_FLAGS_GETTER (nmc_property_pppoe_get_password_flags, NM_SETTING_PPPOE_PASSWORD_FLAGS) -/* --- NM_SETTING_PROXY_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_proxy_get_browser_only, NM_SETTING_PROXY_BROWSER_ONLY) -DEFINE_GETTER (nmc_property_proxy_get_pac_url, NM_SETTING_PROXY_PAC_URL) -DEFINE_GETTER (nmc_property_proxy_get_pac_script, NM_SETTING_PROXY_PAC_SCRIPT) - static char * nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type) { @@ -5847,7 +5836,7 @@ nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val return TRUE; } -/*----------------------------------------------------------------------------*/ +/*****************************************************************************/ static void nmc_value_transform_bool_string (const GValue *src_value, @@ -5870,7 +5859,7 @@ register_nmcli_value_transforms (void) g_value_register_transform_func (G_TYPE_CHAR, G_TYPE_STRING, nmc_value_transform_char_string); } -/*----------------------------------------------------------------------------*/ +/*****************************************************************************/ /* Main hash table storing function pointer for manipulating properties */ static GHashTable *nmc_properties = NULL; @@ -6246,7 +6235,7 @@ nmc_setting_custom_init (NMSetting *setting) } } -/*----------------------------------------------------------------------------*/ +/*****************************************************************************/ static inline void _nmc_add_prop_funcs (const char *key, @@ -8030,36 +8019,6 @@ nmc_properties_init (void) NULL, NULL, NULL); - - /* Add editable properties for NM_SETTING_PROXY_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_METHOD, - nmc_property_proxy_get_method, - nmc_property_proxy_set_method, - NULL, - NULL, - nmc_property_proxy_allowed_method, - NULL); - nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_BROWSER_ONLY, - nmc_property_proxy_get_browser_only, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_PAC_URL, - nmc_property_proxy_get_pac_url, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PROXY_SETTING_NAME""NM_SETTING_PROXY_PAC_SCRIPT, - nmc_property_proxy_get_pac_script, - nmc_property_proxy_set_pac_script, - NULL, - NULL, - NULL, - NULL); } void @@ -8449,7 +8408,7 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) return FALSE; } -/*----------------------------------------------------------------------------*/ +/*****************************************************************************/ #define GET_SECRET(show, setting, func) \ (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) @@ -9421,35 +9380,6 @@ setting_vxlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, N return TRUE; } -static gboolean -setting_proxy_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_PROXY (s_proxy), FALSE); - - tmpl = nmc_fields_setting_proxy; - tmpl_len = sizeof (nmc_fields_setting_proxy); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PROXY_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_proxy_get_method (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_proxy_get_browser_only (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_proxy_get_pac_url (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_proxy_get_pac_script (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - /*****************************************************************************/ #define DEFINE_PROPERTY_TYPE(...) \ @@ -9977,6 +9907,41 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { }, }; +static const NmcPropertyInfo properties_setting_proxy[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_PROXY_METHOD), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_proxy_get_method, + .set_fcn = nmc_property_proxy_set_method, + .values_fcn = nmc_property_proxy_allowed_method, + ), + }, + { + .property_name = N_ (NM_SETTING_PROXY_BROWSER_ONLY), + .property_type = &_pt_gobject_bool + }, + { + .property_name = N_ (NM_SETTING_PROXY_PAC_URL), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_PROXY_PAC_SCRIPT), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_proxy_set_pac_script, + ), + }, +}; + const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], @@ -10059,7 +10024,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_PROXY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PROXY], - .get_setting_details = setting_proxy_details, + .properties = properties_setting_proxy, + .properties_num = G_N_ELEMENTS (properties_setting_proxy), }, [NM_META_SETTING_TYPE_SERIAL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_SERIAL], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 7e4d802276..8f84439b1c 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -67,13 +67,16 @@ struct _NmcPropertyTypData { gboolean (*set_fcn) (NMSetting *setting, const char *property_name, const char *value, GError **error); gboolean (*remove_fcn) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); union { - struct { - GType (*get_gtype) (void); - bool has_minmax:1; - int min; - int max; - } gobject_enum; - } values_data; + union { + struct { + GType (*get_gtype) (void); + bool has_minmax:1; + int min; + int max; + } gobject_enum; + } values_data; + const char *const* (*values_fcn) (NMSetting *setting, const char *prop); + }; } nmc; }; const char *const*values_static; @@ -177,7 +180,6 @@ extern NmcOutputField nmc_fields_setting_ip_tunnel[]; extern NmcOutputField nmc_fields_setting_macvlan[]; extern NmcOutputField nmc_fields_setting_macsec[]; extern NmcOutputField nmc_fields_setting_vxlan[]; -extern NmcOutputField nmc_fields_setting_proxy[]; extern NmcOutputField nmc_fields_setting_dummy[]; #endif /* NMC_SETTINGS_H */ From a89e9a0a6f5c390ced7fb0417c57fdd9a6643718 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 18/53] cli: add property-info for NMSettingDcb --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 320 ++++++++++++++++---------------------- clients/cli/settings.h | 1 - 4 files changed, 134 insertions(+), 191 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index f51a018ac8..2ba4bc9568 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -187,7 +187,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_BRIDGE_PORT_SETTING_NAME, nmc_fields_setting_bridge_port + 1), /* 21 */ SETTING_FIELD (NM_SETTING_TEAM_SETTING_NAME, nmc_fields_setting_team + 1), /* 22 */ SETTING_FIELD (NM_SETTING_TEAM_PORT_SETTING_NAME, nmc_fields_setting_team_port + 1), /* 23 */ - SETTING_FIELD (NM_SETTING_DCB_SETTING_NAME, nmc_fields_setting_dcb + 1), /* 24 */ + SETTING_FIELD_TYPE (NM_SETTING_DCB_SETTING_NAME, NM_META_SETTING_TYPE_DCB), /* 24 */ SETTING_FIELD (NM_SETTING_TUN_SETTING_NAME, nmc_fields_setting_tun + 1), /* 25 */ SETTING_FIELD (NM_SETTING_IP_TUNNEL_SETTING_NAME, nmc_fields_setting_ip_tunnel + 1), /* 26 */ SETTING_FIELD (NM_SETTING_MACSEC_SETTING_NAME, nmc_fields_setting_macsec + 1), /* 27 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 073e4f2b78..f6c4df45c3 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -170,7 +170,7 @@ complete_fields (const char *prefix) complete_field (h, "bridge-port", nmc_fields_setting_bridge_port); complete_field (h, "team", nmc_fields_setting_team); complete_field (h, "team-port", nmc_fields_setting_team_port); - complete_field (h, "dcb", nmc_fields_setting_dcb); + complete_field_new (h, "dcb", NM_META_SETTING_TYPE_DCB); complete_field (h, "tun", nmc_fields_setting_tun); complete_field (h, "ip-tunnel", nmc_fields_setting_ip_tunnel); complete_field (h, "macvlan", nmc_fields_setting_macvlan); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 3d6b816599..b6ebcdedcb 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -921,43 +921,6 @@ NmcOutputField nmc_fields_setting_team_port[] = { #define NMC_FIELDS_SETTING_TEAM_PORT_ALL "name"","\ NM_SETTING_TEAM_PORT_CONFIG -/* Available fields for NM_SETTING_DCB_SETTING_NAME */ -NmcOutputField nmc_fields_setting_dcb[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_FLAGS), /* 1 */ - SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_PRIORITY), /* 2 */ - SETTING_FIELD (NM_SETTING_DCB_APP_FCOE_MODE), /* 3 */ - SETTING_FIELD (NM_SETTING_DCB_APP_ISCSI_FLAGS), /* 4 */ - SETTING_FIELD (NM_SETTING_DCB_APP_ISCSI_PRIORITY), /* 5 */ - SETTING_FIELD (NM_SETTING_DCB_APP_FIP_FLAGS), /* 6 */ - SETTING_FIELD (NM_SETTING_DCB_APP_FIP_PRIORITY), /* 7 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), /* 8 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), /* 9 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), /* 10 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_ID), /* 11 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), /* 12 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_BANDWIDTH), /* 13 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), /* 14 */ - SETTING_FIELD (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), /* 15 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_DCB_ALL "name"","\ - NM_SETTING_DCB_APP_FCOE_FLAGS","\ - NM_SETTING_DCB_APP_FCOE_PRIORITY","\ - NM_SETTING_DCB_APP_FCOE_MODE","\ - NM_SETTING_DCB_APP_ISCSI_FLAGS","\ - NM_SETTING_DCB_APP_ISCSI_PRIORITY","\ - NM_SETTING_DCB_APP_FIP_FLAGS","\ - NM_SETTING_DCB_APP_FIP_PRIORITY","\ - NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS","\ - NM_SETTING_DCB_PRIORITY_FLOW_CONTROL","\ - NM_SETTING_DCB_PRIORITY_GROUP_FLAGS","\ - NM_SETTING_DCB_PRIORITY_GROUP_ID","\ - NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH","\ - NM_SETTING_DCB_PRIORITY_BANDWIDTH","\ - NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH","\ - NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS - /* Available fields for NM_SETTING_DUMMY_SETTING_NAME */ NmcOutputField nmc_fields_setting_dummy[] = { SETTING_FIELD ("name"), /* 0 */ @@ -3426,9 +3389,6 @@ nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_dcb_allowed_app_fcoe_modes, _dcb_valid_fcoe_modes) - - /* --- NM_SETTING_GSM_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER) DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME) @@ -6778,113 +6738,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_DCB_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_FLAGS, - nmc_property_dcb_get_app_fcoe_flags, - nmc_property_dcb_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_MODE, - nmc_property_dcb_get_app_fcoe_mode, - nmc_property_dcb_set_app_fcoe_mode, - NULL, - NULL, - nmc_property_dcb_allowed_app_fcoe_modes, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FCOE_PRIORITY, - nmc_property_dcb_get_app_fcoe_priority, - nmc_property_dcb_set_priority, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_ISCSI_FLAGS, - nmc_property_dcb_get_app_iscsi_flags, - nmc_property_dcb_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_ISCSI_PRIORITY, - nmc_property_dcb_get_app_iscsi_priority, - nmc_property_dcb_set_priority, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FIP_FLAGS, - nmc_property_dcb_get_app_fip_flags, - nmc_property_dcb_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_APP_FIP_PRIORITY, - nmc_property_dcb_get_app_fip_priority, - nmc_property_dcb_set_priority, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, - nmc_property_dcb_get_pfc_flags, - nmc_property_dcb_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, - nmc_property_dcb_get_pfc, - nmc_property_dcb_set_pfc, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, - nmc_property_dcb_get_pg_flags, - nmc_property_dcb_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_ID, - nmc_property_dcb_get_pg_group_id, - nmc_property_dcb_set_pg_group_id, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, - nmc_property_dcb_get_pg_group_bandwidth, - nmc_property_dcb_set_pg_group_bandwidth, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_BANDWIDTH, - nmc_property_dcb_get_pg_bandwidth, - nmc_property_dcb_set_pg_bandwidth, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, - nmc_property_dcb_get_pg_strict, - nmc_property_dcb_set_pg_strict, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_DCB_SETTING_NAME""NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, - nmc_property_dcb_get_pg_traffic_class, - nmc_property_dcb_set_pg_traffic_class, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_NUMBER, nmc_property_gsm_get_number, @@ -9169,46 +9022,6 @@ setting_team_port_details (const NmcSettingInfo *setting_info, NMSetting *settin return TRUE; } -static gboolean -setting_dcb_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_DCB (s_dcb), FALSE); - - tmpl = nmc_fields_setting_dcb; - tmpl_len = sizeof (nmc_fields_setting_dcb); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_DCB_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_dcb_get_app_fcoe_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_dcb_get_app_fcoe_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_dcb_get_app_fcoe_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_dcb_get_app_iscsi_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_dcb_get_app_iscsi_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_dcb_get_app_fip_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_dcb_get_app_fip_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_dcb_get_pfc_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_dcb_get_pfc (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_dcb_get_pg_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_dcb_get_pg_group_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_dcb_get_pg_group_bandwidth (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_dcb_get_pg_bandwidth (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_dcb_get_pg_strict (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_dcb_get_pg_traffic_class (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_tun_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -9432,6 +9245,11 @@ static const NmcPropertyType _pt_gobject_uint = { .set_fcn = _set_fcn_gobject_uint, }; +static const NmcPropertyType _pt_nmc_getset = { + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, +}; + /*****************************************************************************/ #define PROPERTY_INFO_NAME() \ @@ -9606,6 +9424,131 @@ static const NmcPropertyInfo properties_setting_connection[] = { }, }; +static const NmcPropertyInfo properties_setting_dcb[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_DCB_APP_FCOE_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_fcoe_flags, + .set_fcn = nmc_property_dcb_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_FCOE_PRIORITY), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_fcoe_priority, + .set_fcn = nmc_property_dcb_set_priority, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_FCOE_MODE), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _dcb_valid_fcoe_modes, + .get_fcn = nmc_property_dcb_get_app_fcoe_mode, + .set_fcn = nmc_property_dcb_set_app_fcoe_mode, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_ISCSI_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_iscsi_flags, + .set_fcn = nmc_property_dcb_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_ISCSI_PRIORITY), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_iscsi_priority, + .set_fcn = nmc_property_dcb_set_priority, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_FIP_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_fip_flags, + .set_fcn = nmc_property_dcb_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_APP_FIP_PRIORITY), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_app_fip_priority, + .set_fcn = nmc_property_dcb_set_priority, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pfc_flags, + .set_fcn = nmc_property_dcb_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pfc, + .set_fcn = nmc_property_dcb_set_pfc, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_flags, + .set_fcn = nmc_property_dcb_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_ID), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_group_id, + .set_fcn = nmc_property_dcb_set_pg_group_id, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_group_bandwidth, + .set_fcn = nmc_property_dcb_set_pg_group_bandwidth, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_BANDWIDTH), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_bandwidth, + .set_fcn = nmc_property_dcb_set_pg_bandwidth, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_strict, + .set_fcn = nmc_property_dcb_set_pg_strict, + ), + }, + { + .property_name = N_ (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_dcb_get_pg_traffic_class, + .set_fcn = nmc_property_dcb_set_pg_traffic_class, + ), + }, +}; + static const NmcPropertyInfo properties_setting_ip4_config[] = { PROPERTY_INFO_NAME(), { @@ -9978,7 +9921,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_DCB] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DCB], - .get_setting_details = setting_dcb_details, + .properties = properties_setting_dcb, + .properties_num = G_N_ELEMENTS (properties_setting_dcb), }, [NM_META_SETTING_TYPE_GSM] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_GSM], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 8f84439b1c..7a113b5d87 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -174,7 +174,6 @@ extern NmcOutputField nmc_fields_setting_bridge[]; extern NmcOutputField nmc_fields_setting_bridge_port[]; extern NmcOutputField nmc_fields_setting_team[]; extern NmcOutputField nmc_fields_setting_team_port[]; -extern NmcOutputField nmc_fields_setting_dcb[]; extern NmcOutputField nmc_fields_setting_tun[]; extern NmcOutputField nmc_fields_setting_ip_tunnel[]; extern NmcOutputField nmc_fields_setting_macvlan[]; From 09d127b4731ae46be80872d5c9632a265d56e7a1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 19/53] cli: add property-info for NMSettingPppoe --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 184 +++++++++++++++++++------------------- clients/cli/settings.h | 3 +- 4 files changed, 96 insertions(+), 95 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 2ba4bc9568..378b23e842 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -172,7 +172,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ SETTING_FIELD (NM_SETTING_PPP_SETTING_NAME, nmc_fields_setting_ppp + 1), /* 8 */ - SETTING_FIELD (NM_SETTING_PPPOE_SETTING_NAME, nmc_fields_setting_pppoe + 1), /* 9 */ + SETTING_FIELD_TYPE (NM_SETTING_PPPOE_SETTING_NAME, NM_META_SETTING_TYPE_PPPOE), /* 9 */ SETTING_FIELD (NM_SETTING_GSM_SETTING_NAME, nmc_fields_setting_gsm + 1), /* 10 */ SETTING_FIELD (NM_SETTING_CDMA_SETTING_NAME, nmc_fields_setting_cdma + 1), /* 11 */ SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, nmc_fields_setting_bluetooth + 1), /* 12 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index f6c4df45c3..bec6e67538 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -155,7 +155,7 @@ complete_fields (const char *prefix) complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); complete_field (h, "serial", nmc_fields_setting_serial); complete_field (h, "ppp", nmc_fields_setting_ppp); - complete_field (h, "pppoe", nmc_fields_setting_pppoe); + complete_field_new (h, "pppoe", NM_META_SETTING_TYPE_PPPOE); complete_field (h, "adsl", nmc_fields_setting_adsl); complete_field (h, "gsm", nmc_fields_setting_gsm); complete_field (h, "cdma", nmc_fields_setting_cdma); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index b6ebcdedcb..5b16eb88b1 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -37,6 +37,13 @@ static char *wep_key_type_to_string (NMWepKeyType type); static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error); +static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type); + +#define ALL_SECRET_FLAGS \ + (NM_SETTING_SECRET_FLAG_NONE | \ + NM_SETTING_SECRET_FLAG_AGENT_OWNED | \ + NM_SETTING_SECRET_FLAG_NOT_SAVED | \ + NM_SETTING_SECRET_FLAG_NOT_REQUIRED) /*****************************************************************************/ @@ -102,6 +109,22 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, return s; } +static char * +_get_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + guint v; + GValue val = G_VALUE_INIT; + + g_value_init (&val, G_TYPE_UINT); + g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); + v = g_value_get_uint (&val); + g_value_unset (&val); + return secret_flags_to_string (v, get_type); +} + /*****************************************************************************/ static gboolean @@ -231,6 +254,40 @@ _set_fcn_gobject_uint (const NmcSettingInfo *setting_info, return TRUE; } +static gboolean +_set_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + char **strv = NULL, **iter; + unsigned long flags = 0, val_int; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + strv = nmc_strsplit_set (value, " \t,", 0); + for (iter = strv; iter && *iter; iter++) { + if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"), + *iter, ALL_SECRET_FLAGS); + g_strfreev (strv); + return FALSE; + } + flags += val_int; + } + g_strfreev (strv); + + /* Validate the flags number */ + if (flags > ALL_SECRET_FLAGS) { + flags = ALL_SECRET_FLAGS; + g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), value); + } + + g_object_set (setting, property_info->property_name, (guint) flags, NULL); + return TRUE; +} + /*****************************************************************************/ static gboolean @@ -684,21 +741,6 @@ NmcOutputField nmc_fields_setting_ppp[] = { NM_SETTING_PPP_LCP_ECHO_FAILURE","\ NM_SETTING_PPP_LCP_ECHO_INTERVAL -/* Available fields for NM_SETTING_PPPOE_SETTING_NAME */ -NmcOutputField nmc_fields_setting_pppoe[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_PPPOE_SERVICE), /* 1 */ - SETTING_FIELD (NM_SETTING_PPPOE_USERNAME), /* 2 */ - SETTING_FIELD (NM_SETTING_PPPOE_PASSWORD), /* 3 */ - SETTING_FIELD (NM_SETTING_PPPOE_PASSWORD_FLAGS), /* 4 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_PPPOE_ALL "name"","\ - NM_SETTING_PPPOE_SERVICE","\ - NM_SETTING_PPPOE_USERNAME","\ - NM_SETTING_PPPOE_PASSWORD","\ - NM_SETTING_PPPOE_PASSWORD_FLAGS - /* Available fields for NM_SETTING_ADSL_SETTING_NAME */ NmcOutputField nmc_fields_setting_adsl[] = { SETTING_FIELD ("name"), /* 0 */ @@ -1744,12 +1786,6 @@ nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, return TRUE; } -#define ALL_SECRET_FLAGS \ - (NM_SETTING_SECRET_FLAG_NONE | \ - NM_SETTING_SECRET_FLAG_AGENT_OWNED | \ - NM_SETTING_SECRET_FLAG_NOT_SAVED | \ - NM_SETTING_SECRET_FLAG_NOT_REQUIRED) - static gboolean nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -4576,13 +4612,6 @@ DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_failure, NM_SETTING_PPP_LCP_ECHO_FA DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_interval, NM_SETTING_PPP_LCP_ECHO_INTERVAL) -/* --- NM_SETTING_PPPOE_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_pppoe_get_service, NM_SETTING_PPPOE_SERVICE) -DEFINE_GETTER (nmc_property_pppoe_get_username, NM_SETTING_PPPOE_USERNAME) -DEFINE_GETTER (nmc_property_pppoe_get_password, NM_SETTING_PPPOE_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_pppoe_get_password_flags, NM_SETTING_PPPOE_PASSWORD_FLAGS) - - static char * nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type) { @@ -7019,36 +7048,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_PPPOE_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_SERVICE, - nmc_property_pppoe_get_service, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_USERNAME, - nmc_property_pppoe_get_username, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_PASSWORD, - nmc_property_pppoe_get_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPPOE_SETTING_NAME""NM_SETTING_PPPOE_PASSWORD_FLAGS, - nmc_property_pppoe_get_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BAUD, nmc_property_serial_get_baud, @@ -8304,10 +8303,13 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm for (i = 0; i < setting_info->properties_num; i++) { const NmcPropertyInfo *property_info = &setting_info->properties[i]; - set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, - property_info, - setting, - NMC_PROPERTY_GET_PRETTY)); + if (!property_info->is_secret || secrets) { + set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, + property_info, + setting, + NMC_PROPERTY_GET_PRETTY)); + } else + set_val_str (arr, i, g_strdup (_(""))); } g_ptr_array_add (nmc->output_data, arr); @@ -8581,35 +8583,6 @@ setting_ppp_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmC return TRUE; } -static gboolean -setting_pppoe_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingPppoe *s_pppoe = NM_SETTING_PPPOE (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_PPPOE (s_pppoe), FALSE); - - tmpl = nmc_fields_setting_pppoe; - tmpl_len = sizeof (nmc_fields_setting_pppoe); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPPOE_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_pppoe_get_service (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_pppoe_get_username (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_pppoe_get_password)); - set_val_str (arr, 4, nmc_property_pppoe_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_gsm_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -9245,6 +9218,11 @@ static const NmcPropertyType _pt_gobject_uint = { .set_fcn = _set_fcn_gobject_uint, }; +static const NmcPropertyType _pt_gobject_secret_flags = { + .get_fcn = _get_fcn_gobject_secret_flags, + .set_fcn = _set_fcn_gobject_secret_flags, +}; + static const NmcPropertyType _pt_nmc_getset = { .get_fcn = _get_fcn_nmc, .set_fcn = _set_fcn_nmc, @@ -9850,6 +9828,27 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { }, }; +static const NmcPropertyInfo properties_setting_pppoe[] = { + PROPERTY_INFO_NAME (), + { + .property_name = N_ (NM_SETTING_PPPOE_SERVICE), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_PPPOE_USERNAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_PPPOE_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_PPPOE_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, +}; + static const NmcPropertyInfo properties_setting_proxy[] = { PROPERTY_INFO_NAME(), { @@ -9960,7 +9959,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_PPPOE] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPPOE], - .get_setting_details = setting_pppoe_details, + .properties = properties_setting_pppoe, + .properties_num = G_N_ELEMENTS (properties_setting_pppoe), }, [NM_META_SETTING_TYPE_PPP] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPP], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 7a113b5d87..b71acb5adf 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -91,6 +91,8 @@ struct _NmcPropertyInfo { * group_list/setting_info. */ bool is_name:1; + bool is_secret:1; + const char *describe_message; const NmcPropertyType *property_type; @@ -159,7 +161,6 @@ extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_wireless_security[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_ppp[]; -extern NmcOutputField nmc_fields_setting_pppoe[]; extern NmcOutputField nmc_fields_setting_adsl[]; extern NmcOutputField nmc_fields_setting_gsm[]; extern NmcOutputField nmc_fields_setting_cdma[]; From d530bffb6c72d9a3570f7761432c5e0b0c6b7369 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 15:14:08 +0200 Subject: [PATCH 20/53] cli: add property-info for NMSettingWirelessSecurity --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 392 +++++++++++++++----------------------- clients/cli/settings.h | 1 - 4 files changed, 152 insertions(+), 245 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 378b23e842..55df0b7562 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -167,7 +167,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_WIRED_SETTING_NAME, nmc_fields_setting_wired + 1), /* 1 */ SETTING_FIELD (NM_SETTING_802_1X_SETTING_NAME, nmc_fields_setting_8021X + 1), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, nmc_fields_setting_wireless_security + 1), /* 4 */ + SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS_SECURITY), /* 4 */ SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index bec6e67538..7074f519f6 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -150,7 +150,7 @@ complete_fields (const char *prefix) complete_field (h, "802-3-ethernet", nmc_fields_setting_wired); complete_field (h, "802-1x", nmc_fields_setting_8021X); complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); - complete_field (h, "802-11-wireless-security", nmc_fields_setting_wireless_security); + complete_field_new (h, "802-11-wireless-security", NM_META_SETTING_TYPE_WIRELESS_SECURITY); complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); complete_field (h, "serial", nmc_fields_setting_serial); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 5b16eb88b1..a49a174a6f 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -640,47 +640,6 @@ NmcOutputField nmc_fields_setting_wireless[] = { NM_SETTING_WIRELESS_HIDDEN"," \ NM_SETTING_WIRELESS_POWERSAVE -/* Available fields for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */ -NmcOutputField nmc_fields_setting_wireless_security[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), /* 1 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), /* 2 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), /* 3 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PROTO), /* 4 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PAIRWISE), /* 5 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_GROUP), /* 6 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), /* 7 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), /* 8 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), /* 9 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), /* 10 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), /* 11 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), /* 12 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), /* 13 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PSK), /* 14 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), /* 15 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), /* 16 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), /* 17 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL "name"","\ - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT","\ - NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX","\ - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG","\ - NM_SETTING_WIRELESS_SECURITY_PROTO","\ - NM_SETTING_WIRELESS_SECURITY_PAIRWISE","\ - NM_SETTING_WIRELESS_SECURITY_GROUP","\ - NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY0","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY1","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY2","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY3","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS","\ - NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE","\ - NM_SETTING_WIRELESS_SECURITY_PSK","\ - NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS","\ - NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD","\ - NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS - /* Available fields for NM_SETTING_SERIAL_SETTING_NAME */ NmcOutputField nmc_fields_setting_serial[] = { SETTING_FIELD ("name"), /* 0 */ @@ -5517,21 +5476,6 @@ nmc_property_wireless_set_mac_address_randomization (NMSetting *setting, return TRUE; } - -/* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_wifi_sec_get_key_mgmt, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) -DEFINE_GETTER (nmc_property_wifi_sec_get_wep_tx_keyidx, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX) -DEFINE_GETTER (nmc_property_wifi_sec_get_auth_alg, NM_SETTING_WIRELESS_SECURITY_AUTH_ALG) -DEFINE_GETTER (nmc_property_wifi_sec_get_proto, NM_SETTING_WIRELESS_SECURITY_PROTO) -DEFINE_GETTER (nmc_property_wifi_sec_get_pairwise, NM_SETTING_WIRELESS_SECURITY_PAIRWISE) -DEFINE_GETTER (nmc_property_wifi_sec_get_group, NM_SETTING_WIRELESS_SECURITY_GROUP) -DEFINE_GETTER (nmc_property_wifi_sec_get_leap_username, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_wep_key_flags, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS) -DEFINE_GETTER (nmc_property_wifi_sec_get_psk, NM_SETTING_WIRELESS_SECURITY_PSK) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_psk_flags, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS) -DEFINE_GETTER (nmc_property_wifi_sec_get_leap_password, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_wifi_sec_get_leap_password_flags, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS) - static char * nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type) { @@ -5576,8 +5520,6 @@ nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_key_mgmt, wifi_sec_valid_key_mgmts) - /* 'auth-alg' */ static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL }; @@ -5587,8 +5529,6 @@ nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_auth_alg, wifi_sec_valid_auth_algs) - /* 'proto' */ static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL }; @@ -5626,9 +5566,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_proto, nm_setting_wireless_security_remove_proto, _validate_and_remove_wifi_sec_proto) -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_proto, wifi_sec_valid_protos) - -/* 'pairwise' */ static const char *wifi_sec_valid_pairwises[] = { "tkip", "ccmp", NULL }; DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise, @@ -5665,8 +5602,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_pairwise, nm_setting_wireless_security_remove_pairwise, _validate_and_remove_wifi_sec_pairwise) -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_pairwise, wifi_sec_valid_pairwises) - /* 'group' */ static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL }; @@ -5703,7 +5638,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_group, nm_setting_wireless_security_get_num_groups, nm_setting_wireless_security_remove_group, _validate_and_remove_wifi_sec_group) -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_sec_allowed_group, wifi_sec_valid_groups) /* 'wep-key' */ static gboolean @@ -5799,18 +5733,6 @@ nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const return TRUE; } -static const char * -nmc_property_wifi_describe_wep_key_type (NMSetting *setting, const char *prop) -{ - static char *desc = NULL; - - if (G_UNLIKELY (desc == NULL)) { - desc = g_strdup_printf (_("Enter the type of WEP keys. The accepted values are: " - "0 or unknown, 1 or key, and 2 or passphrase.\n")); - } - return desc; -} - /* 'psk' */ static gboolean nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error) @@ -7419,127 +7341,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - nmc_property_wifi_sec_get_key_mgmt, - nmc_property_wifi_sec_set_key_mgmt, - NULL, - NULL, - nmc_property_wifi_sec_allowed_key_mgmt, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, - nmc_property_wifi_sec_get_wep_tx_keyidx, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - nmc_property_wifi_sec_get_auth_alg, - nmc_property_wifi_sec_set_auth_alg, - NULL, - NULL, - nmc_property_wifi_sec_allowed_auth_alg, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PROTO, - nmc_property_wifi_sec_get_proto, - nmc_property_wifi_sec_set_proto, - nmc_property_wifi_sec_remove_proto, - NULL, - nmc_property_wifi_sec_allowed_proto, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PAIRWISE, - nmc_property_wifi_sec_get_pairwise, - nmc_property_wifi_sec_set_pairwise, - nmc_property_wifi_sec_remove_pairwise, - NULL, - nmc_property_wifi_sec_allowed_pairwise, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_GROUP, - nmc_property_wifi_sec_get_group, - nmc_property_wifi_sec_set_group, - nmc_property_wifi_sec_remove_group, - NULL, - nmc_property_wifi_sec_allowed_group, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, - nmc_property_wifi_sec_get_leap_username, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, - nmc_property_wifi_sec_get_wep_key0, - nmc_property_wifi_set_wep_key, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, - nmc_property_wifi_sec_get_wep_key1, - nmc_property_wifi_set_wep_key, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, - nmc_property_wifi_sec_get_wep_key2, - nmc_property_wifi_set_wep_key, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, - nmc_property_wifi_sec_get_wep_key3, - nmc_property_wifi_set_wep_key, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, - nmc_property_wifi_sec_get_wep_key_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, - nmc_property_wifi_sec_get_wep_key_type, - nmc_property_wifi_set_wep_key_type, - NULL, - nmc_property_wifi_describe_wep_key_type, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PSK, - nmc_property_wifi_sec_get_psk, - nmc_property_wifi_set_psk, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, - nmc_property_wifi_sec_get_psk_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, - nmc_property_wifi_sec_get_leap_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME""NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, - nmc_property_wifi_sec_get_leap_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MODE, nmc_property_tun_get_mode, @@ -8468,48 +8269,6 @@ setting_wireless_details (const NmcSettingInfo *setting_info, NMSetting *setting return TRUE; } -static gboolean -setting_wireless_security_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_WIRELESS_SECURITY (s_wireless_sec), FALSE); - - tmpl = nmc_fields_setting_wireless_security; - tmpl_len = sizeof (nmc_fields_setting_wireless_security); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_SECURITY_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wifi_sec_get_key_mgmt (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_wifi_sec_get_wep_tx_keyidx (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_wifi_sec_get_auth_alg (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_wifi_sec_get_proto (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_wifi_sec_get_pairwise (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_wifi_sec_get_group (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_wifi_sec_get_leap_username (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key0)); - set_val_str (arr, 9, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key1)); - set_val_str (arr, 10, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key2)); - set_val_str (arr, 11, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_wep_key3)); - set_val_str (arr, 12, nmc_property_wifi_sec_get_wep_key_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_wifi_sec_get_wep_key_type (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_psk)); - set_val_str (arr, 15, nmc_property_wifi_sec_get_psk_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, GET_SECRET (secrets, setting, nmc_property_wifi_sec_get_leap_password)); - set_val_str (arr, 17, nmc_property_wifi_sec_get_leap_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -9884,6 +9643,154 @@ static const NmcPropertyInfo properties_setting_proxy[] = { }, }; +static const NmcPropertyInfo properties_setting_wireless_security[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = wifi_sec_valid_key_mgmts, + .set_fcn = nmc_property_wifi_sec_set_key_mgmt, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = wifi_sec_valid_auth_algs, + .set_fcn = nmc_property_wifi_sec_set_auth_alg, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PROTO), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = wifi_sec_valid_protos, + .set_fcn = nmc_property_wifi_sec_set_proto, + .remove_fcn = nmc_property_wifi_sec_remove_proto, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PAIRWISE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = wifi_sec_valid_pairwises, + .set_fcn = nmc_property_wifi_sec_set_pairwise, + .remove_fcn = nmc_property_wifi_sec_remove_pairwise, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_GROUP), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = wifi_sec_valid_groups, + .set_fcn = nmc_property_wifi_sec_set_group, + .remove_fcn = nmc_property_wifi_sec_remove_group, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), + .is_secret = TRUE, + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wifi_sec_get_wep_key0, + .set_fcn = nmc_property_wifi_set_wep_key, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), + .is_secret = TRUE, + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wifi_sec_get_wep_key1, + .set_fcn = nmc_property_wifi_set_wep_key, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), + .is_secret = TRUE, + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wifi_sec_get_wep_key2, + .set_fcn = nmc_property_wifi_set_wep_key, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), + .is_secret = TRUE, + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wifi_sec_get_wep_key3, + .set_fcn = nmc_property_wifi_set_wep_key, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE), + .describe_message = + N_ ("Enter the type of WEP keys. The accepted values are: " + "0 or unknown, 1 or key, and 2 or passphrase.\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wifi_sec_get_wep_key_type, + .set_fcn = nmc_property_wifi_set_wep_key_type, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PSK), + .is_secret = TRUE, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wifi_set_psk, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, +}; + const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], @@ -10013,7 +9920,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_WIRELESS_SECURITY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS_SECURITY], - .get_setting_details = setting_wireless_security_details, + .properties = properties_setting_wireless_security, + .properties_num = G_N_ELEMENTS (properties_setting_wireless_security), }, }; diff --git a/clients/cli/settings.h b/clients/cli/settings.h index b71acb5adf..bf6ac4c8e8 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -158,7 +158,6 @@ gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_8021X[]; extern NmcOutputField nmc_fields_setting_wireless[]; -extern NmcOutputField nmc_fields_setting_wireless_security[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_ppp[]; extern NmcOutputField nmc_fields_setting_adsl[]; From 6bf1d6fc163de9f69338af99641bd49f246f32b7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 15:14:08 +0200 Subject: [PATCH 21/53] cli: add property-info for NMSetting8021x --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 918 ++++++++++++++------------------------ clients/cli/settings.h | 1 - 4 files changed, 325 insertions(+), 598 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 55df0b7562..7813115644 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -165,7 +165,7 @@ NmcOutputField nmc_fields_con_show[] = { NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), SETTING_FIELD (NM_SETTING_WIRED_SETTING_NAME, nmc_fields_setting_wired + 1), /* 1 */ - SETTING_FIELD (NM_SETTING_802_1X_SETTING_NAME, nmc_fields_setting_8021X + 1), /* 2 */ + SETTING_FIELD_TYPE (NM_SETTING_802_1X_SETTING_NAME, NM_META_SETTING_TYPE_802_1X), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS_SECURITY), /* 4 */ SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 7074f519f6..e27496e923 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -148,7 +148,7 @@ complete_fields (const char *prefix) complete_field_new (h, "connection", NM_META_SETTING_TYPE_CONNECTION); complete_field (h, "802-3-ethernet", nmc_fields_setting_wired); - complete_field (h, "802-1x", nmc_fields_setting_8021X); + complete_field_new (h, "802-1x", NM_META_SETTING_TYPE_802_1X); complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); complete_field_new (h, "802-11-wireless-security", NM_META_SETTING_TYPE_WIRELESS_SECURITY); complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index a49a174a6f..f7ac4086ae 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -506,101 +506,6 @@ NmcOutputField nmc_fields_setting_wired[] = { NM_SETTING_WIRED_WAKE_ON_LAN","\ NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD -/* Available fields for NM_SETTING_802_1X_SETTING_NAME */ -NmcOutputField nmc_fields_setting_8021X[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_802_1X_EAP), /* 1 */ - SETTING_FIELD (NM_SETTING_802_1X_IDENTITY), /* 2 */ - SETTING_FIELD (NM_SETTING_802_1X_ANONYMOUS_IDENTITY), /* 3 */ - SETTING_FIELD (NM_SETTING_802_1X_PAC_FILE), /* 4 */ - SETTING_FIELD (NM_SETTING_802_1X_CA_CERT), /* 5 */ - SETTING_FIELD (NM_SETTING_802_1X_CA_CERT_PASSWORD), /* 6 */ - SETTING_FIELD (NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS), /* 7 */ - SETTING_FIELD (NM_SETTING_802_1X_CA_PATH), /* 8 */ - SETTING_FIELD (NM_SETTING_802_1X_SUBJECT_MATCH), /* 9 */ - SETTING_FIELD (NM_SETTING_802_1X_ALTSUBJECT_MATCHES), /* 10 */ - SETTING_FIELD (NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), /* 11 */ - SETTING_FIELD (NM_SETTING_802_1X_CLIENT_CERT), /* 12 */ - SETTING_FIELD (NM_SETTING_802_1X_CLIENT_CERT_PASSWORD), /* 13 */ - SETTING_FIELD (NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS), /* 14 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE1_PEAPVER), /* 15 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE1_PEAPLABEL), /* 16 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), /* 17 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE1_AUTH_FLAGS), /* 18 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_AUTH), /* 19 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_AUTHEAP), /* 20 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD), /* 21 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS), /* 22 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_CERT), /* 23 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CA_PATH), /* 24 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), /* 25 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), /* 26 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH), /* 27 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CLIENT_CERT), /* 28 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD), /* 29 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS), /* 30 */ - SETTING_FIELD (NM_SETTING_802_1X_PASSWORD), /* 31 */ - SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_FLAGS), /* 32 */ - SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_RAW), /* 33 */ - SETTING_FIELD (NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), /* 34 */ - SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY), /* 35 */ - SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), /* 36 */ - SETTING_FIELD (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), /* 37 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), /* 38 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), /* 39 */ - SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), /* 40 */ - SETTING_FIELD (NM_SETTING_802_1X_PIN), /* 41 */ - SETTING_FIELD (NM_SETTING_802_1X_PIN_FLAGS), /* 42 */ - SETTING_FIELD (NM_SETTING_802_1X_SYSTEM_CA_CERTS), /* 43 */ - SETTING_FIELD (NM_SETTING_802_1X_AUTH_TIMEOUT), /* 44 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_802_1X_ALL "name"","\ - NM_SETTING_802_1X_EAP","\ - NM_SETTING_802_1X_IDENTITY","\ - NM_SETTING_802_1X_ANONYMOUS_IDENTITY","\ - NM_SETTING_802_1X_PAC_FILE","\ - NM_SETTING_802_1X_CA_CERT","\ - NM_SETTING_802_1X_CA_CERT_PASSWORD","\ - NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_CA_PATH","\ - NM_SETTING_802_1X_SUBJECT_MATCH","\ - NM_SETTING_802_1X_ALTSUBJECT_MATCHES","\ - NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH","\ - NM_SETTING_802_1X_CLIENT_CERT","\ - NM_SETTING_802_1X_CLIENT_CERT_PASSWORD","\ - NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PHASE1_PEAPVER","\ - NM_SETTING_802_1X_PHASE1_PEAPLABEL","\ - NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING","\ - NM_SETTING_802_1X_PHASE1_AUTH_FLAGS","\ - NM_SETTING_802_1X_PHASE2_AUTH","\ - NM_SETTING_802_1X_PHASE2_AUTHEAP","\ - NM_SETTING_802_1X_PHASE2_CA_CERT","\ - NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD","\ - NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PHASE2_CA_PATH","\ - NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH","\ - NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES","\ - NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH","\ - NM_SETTING_802_1X_PHASE2_CLIENT_CERT","\ - NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD","\ - NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PASSWORD","\ - NM_SETTING_802_1X_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PASSWORD_RAW","\ - NM_SETTING_802_1X_PASSWORD_RAW_FLAGS","\ - NM_SETTING_802_1X_PRIVATE_KEY","\ - NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD","\ - NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY","\ - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD","\ - NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS","\ - NM_SETTING_802_1X_PIN","\ - NM_SETTING_802_1X_PIN_FLAGS","\ - NM_SETTING_802_1X_SYSTEM_CA_CERTS","\ - NM_SETTING_802_1X_AUTH_TIMEOUT - /* Available fields for NM_SETTING_WIRELESS_SETTING_NAME */ NmcOutputField nmc_fields_setting_wireless[] = { SETTING_FIELD ("name"), /* 0 */ @@ -1839,44 +1744,6 @@ done: /* === GetFunc, SetFunc, RemoveFunc, DescribeFunc, ValuesFunc functions for all properties of all settings === */ -/* --- NM_SETTING_802_1X_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_802_1X_get_eap, NM_SETTING_802_1X_EAP) -DEFINE_GETTER (nmc_property_802_1X_get_identity, NM_SETTING_802_1X_IDENTITY) -DEFINE_GETTER (nmc_property_802_1X_get_anonymous_identity, NM_SETTING_802_1X_ANONYMOUS_IDENTITY) -DEFINE_GETTER (nmc_property_802_1X_get_pac_file, NM_SETTING_802_1X_PAC_FILE) -DEFINE_GETTER (nmc_property_802_1X_get_ca_cert_password, NM_SETTING_802_1X_CA_CERT_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_ca_cert_password_flags, NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_ca_path, NM_SETTING_802_1X_CA_PATH) -DEFINE_GETTER (nmc_property_802_1X_get_subject_match, NM_SETTING_802_1X_SUBJECT_MATCH) -DEFINE_GETTER (nmc_property_802_1X_get_altsubject_matches, NM_SETTING_802_1X_ALTSUBJECT_MATCHES) -DEFINE_GETTER (nmc_property_802_1X_get_domain_suffix_match, NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH) -DEFINE_GETTER (nmc_property_802_1X_get_client_cert_password, NM_SETTING_802_1X_CLIENT_CERT_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_client_cert_password_flags, NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_phase1_peapver, NM_SETTING_802_1X_PHASE1_PEAPVER) -DEFINE_GETTER (nmc_property_802_1X_get_phase1_peaplabel, NM_SETTING_802_1X_PHASE1_PEAPLABEL) -DEFINE_GETTER (nmc_property_802_1X_get_phase1_fast_provisioning, NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_auth, NM_SETTING_802_1X_PHASE2_AUTH) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_autheap, NM_SETTING_802_1X_PHASE2_AUTHEAP) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_ca_cert_password, NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_phase2_ca_cert_password_flags, NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_ca_path, NM_SETTING_802_1X_PHASE2_CA_PATH) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_subject_match, NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_altsubject_matches, NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_domain_suffix_match, NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_client_cert_password, NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_phase2_client_cert_password_flags, NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_password, NM_SETTING_802_1X_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_password_flags, NM_SETTING_802_1X_PASSWORD_FLAGS) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_password_raw_flags, NM_SETTING_802_1X_PASSWORD_RAW_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_private_key_password, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_private_key_password_flags, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_phase2_private_key_password, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_phase2_private_key_password_flags, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_pin, NM_SETTING_802_1X_PIN) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_802_1X_get_pin_flags, NM_SETTING_802_1X_PIN_FLAGS) -DEFINE_GETTER (nmc_property_802_1X_get_system_ca_certs, NM_SETTING_802_1X_SYSTEM_CA_CERTS) -DEFINE_GETTER (nmc_property_802_1X_get_auth_timeout, NM_SETTING_802_1X_AUTH_TIMEOUT) - static char * nmc_property_802_1X_get_ca_cert (NMSetting *setting, NmcPropertyGetType get_type) { @@ -2160,20 +2027,9 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap, nm_setting_802_1x_remove_eap_method, _validate_and_remove_eap_method) -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_eap, valid_eap) - /* 'ca-cert' */ DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert) -static const char * -nmc_property_802_1X_describe_ca_cert (NMSetting *setting, const char *prop) -{ - return _("Enter file path to CA certificate (optionally prefixed with file://).\n" - " [file://]\n" - "Note that nmcli does not support specifying certificates as raw blob data.\n" - "Example: /home/cimrman/cacert.crt\n"); -} - /* 'altsubject-matches' */ DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match) @@ -2197,32 +2053,10 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches, nm_setting_802_1x_remove_altsubject_match, _validate_and_remove_altsubject_match) -/* 'client-cert' */ DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert) -static const char * -nmc_property_802_1X_describe_client_cert (NMSetting *setting, const char *prop) -{ - return _("Enter file path to client certificate (optionally prefixed with file://).\n" - " [file://]\n" - "Note that nmcli does not support specifying certificates as raw blob data.\n" - "Example: /home/cimrman/jara.crt\n"); -} - -/* 'phase2-ca-cert' */ DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert) -static const char * -nmc_property_802_1X_describe_phase2_ca_cert (NMSetting *setting, const char *prop) -{ - return _("Enter file path to CA certificate for inner authentication (optionally prefixed\n" - "with file://).\n" - " [file://]\n" - "Note that nmcli does not support specifying certificates as raw blob data.\n" - "Example: /home/cimrman/ca-zweite-phase.crt\n"); -} - -/* 'phase2-altsubject-matches' */ DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match) static gboolean @@ -2245,39 +2079,16 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matc nm_setting_802_1x_remove_phase2_altsubject_match, _validate_and_remove_phase2_altsubject_match) -/* 'phase2-client-cert' */ DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert) -static const char * -nmc_property_802_1X_describe_phase2_client_cert (NMSetting *setting, const char *prop) -{ - return _("Enter file path to client certificate for inner authentication (optionally prefixed\n" - "with file://).\n" - " [file://]\n" - "Note that nmcli does not support specifying certificates as raw blob data.\n" - "Example: /home/cimrman/jara-zweite-phase.crt\n"); -} - -/* 'private-key' */ DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_private_key, nm_setting_802_1x_get_private_key_password, nm_setting_802_1x_set_private_key) -/* 'phase2-private-key' */ DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key, nm_setting_802_1x_get_phase2_private_key_password, nm_setting_802_1x_set_phase2_private_key) -static const char * -nmc_property_802_1X_describe_private_key (NMSetting *setting, const char *prop) -{ - return _("Enter path to a private key and the key password (if not set yet):\n" - " [file://] []\n" - "Note that nmcli does not support specifying private key as raw blob data.\n" - "Example: /home/cimrman/jara-priv-key Dardanely\n"); -} - -/* 'phase1-peapver' */ static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL }; static gboolean @@ -2286,8 +2097,6 @@ nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, co return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peapver, _802_1X_valid_phase1_peapvers) - /* 'phase1-peaplabel' */ static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL }; @@ -2297,9 +2106,6 @@ nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_peaplabel, _802_1X_valid_phase1_peaplabels) - -/* 'phase1-fast-provisioning' */ static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL }; static gboolean @@ -2308,9 +2114,6 @@ nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase1_fast_provisioning, _802_1X_valid_phase1_fast_provisionings) - -/* 'phase2-auth' */ static const char *_802_1X_valid_phase2_auths[] = { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL }; @@ -2320,9 +2123,6 @@ nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_auth, _802_1X_valid_phase2_auths) - -/* 'phase2-autheap' */ static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL }; static gboolean nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error) @@ -2330,27 +2130,12 @@ nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, co return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_802_1X_allowed_phase2_autheap, _802_1X_valid_phase2_autheaps) - -/* 'password-raw' */ static gboolean nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error) { return nmc_property_set_byte_array (setting, prop, val, error); } -static const char * -nmc_property_802_1X_describe_password_raw (NMSetting *setting, const char *prop) -{ - return _("Enter bytes as a list of hexadecimal values.\n" - "Two formats are accepted:\n" - "(a) a string of hexadecimal digits, where each two digits represent one byte\n" - "(b) space-separated list of bytes written as hexadecimal digits " - "(with optional 0x/0X prefix, and optional leading 0).\n\n" - "Examples: ab0455a6ea3a74C2\n" - " ab 4 55 0xa6 ea 3a 74 C2\n"); -} - static char * nmc_property_802_1X_get_phase1_auth_flags (NMSetting *setting, NmcPropertyGetType get_type) { @@ -6184,316 +5969,6 @@ nmc_properties_init (void) /* create properties hash table */ nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); - /* Add editable properties for NM_SETTING_802_1X_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_EAP, - nmc_property_802_1X_get_eap, - nmc_property_802_1X_set_eap, - nmc_property_802_1X_remove_eap, - NULL, - nmc_property_802_1X_allowed_eap, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_IDENTITY, - nmc_property_802_1X_get_identity, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_ANONYMOUS_IDENTITY, - nmc_property_802_1X_get_anonymous_identity, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PAC_FILE, - nmc_property_802_1X_get_pac_file, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT, - nmc_property_802_1X_get_ca_cert, - nmc_property_802_1X_set_ca_cert, - NULL, - nmc_property_802_1X_describe_ca_cert, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT_PASSWORD, - nmc_property_802_1X_get_ca_cert_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS, - nmc_property_802_1X_get_ca_cert_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CA_PATH, - nmc_property_802_1X_get_ca_path, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_SUBJECT_MATCH, - nmc_property_802_1X_get_subject_match, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_ALTSUBJECT_MATCHES, - nmc_property_802_1X_get_altsubject_matches, - nmc_property_802_1X_set_altsubject_matches, - nmc_property_802_1X_remove_altsubject_matches, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, - nmc_property_802_1X_get_domain_suffix_match, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT, - nmc_property_802_1X_get_client_cert_full, - nmc_property_802_1X_set_client_cert, - NULL, - nmc_property_802_1X_describe_client_cert, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT_PASSWORD, - nmc_property_802_1X_get_client_cert_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS, - nmc_property_802_1X_get_client_cert_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_PEAPVER, - nmc_property_802_1X_get_phase1_peapver, - nmc_property_802_1X_set_phase1_peapver, - NULL, - NULL, - nmc_property_802_1X_allowed_phase1_peapver, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_PEAPLABEL, - nmc_property_802_1X_get_phase1_peaplabel, - nmc_property_802_1X_set_phase1_peaplabel, - NULL, - NULL, - nmc_property_802_1X_allowed_phase1_peaplabel, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, - nmc_property_802_1X_get_phase1_fast_provisioning, - nmc_property_802_1X_set_phase1_fast_provisioning, - NULL, - NULL, - nmc_property_802_1X_allowed_phase1_fast_provisioning, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, - nmc_property_802_1X_get_phase1_auth_flags, - nmc_property_802_1X_set_phase1_auth_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_AUTH, - nmc_property_802_1X_get_phase2_auth, - nmc_property_802_1X_set_phase2_auth, - NULL, - NULL, - nmc_property_802_1X_allowed_phase2_auth, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_AUTHEAP, - nmc_property_802_1X_get_phase2_autheap, - nmc_property_802_1X_set_phase2_autheap, - NULL, - NULL, - nmc_property_802_1X_allowed_phase2_autheap, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT, - nmc_property_802_1X_get_phase2_ca_cert, - nmc_property_802_1X_set_phase2_ca_cert, - NULL, - nmc_property_802_1X_describe_phase2_ca_cert, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD, - nmc_property_802_1X_get_phase2_ca_cert_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS, - nmc_property_802_1X_get_phase2_ca_cert_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CA_PATH, - nmc_property_802_1X_get_phase2_ca_path, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, - nmc_property_802_1X_get_phase2_subject_match, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, - nmc_property_802_1X_get_phase2_altsubject_matches, - nmc_property_802_1X_set_phase2_altsubject_matches, - nmc_property_802_1X_remove_phase2_altsubject_matches, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, - nmc_property_802_1X_get_phase2_domain_suffix_match, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT, - nmc_property_802_1X_get_phase2_client_cert_full, - nmc_property_802_1X_set_phase2_client_cert, - NULL, - nmc_property_802_1X_describe_phase2_client_cert, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD, - nmc_property_802_1X_get_phase2_client_cert_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS, - nmc_property_802_1X_get_phase2_client_cert_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD, - nmc_property_802_1X_get_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_FLAGS, - nmc_property_802_1X_get_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_RAW, - nmc_property_802_1X_get_password_raw, - nmc_property_802_1X_set_password_raw, - NULL, - nmc_property_802_1X_describe_password_raw, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, - nmc_property_802_1X_get_password_raw_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY, - nmc_property_802_1X_get_private_key_full, - nmc_property_802_1X_set_private_key, - NULL, - nmc_property_802_1X_describe_private_key, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, - nmc_property_802_1X_get_private_key_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS, - nmc_property_802_1X_get_private_key_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - nmc_property_802_1X_get_phase2_private_key_full, - nmc_property_802_1X_set_phase2_private_key, - NULL, - nmc_property_802_1X_describe_private_key, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, - nmc_property_802_1X_get_phase2_private_key_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, - nmc_property_802_1X_get_phase2_private_key_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PIN, - nmc_property_802_1X_get_pin, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_PIN_FLAGS, - nmc_property_802_1X_get_pin_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_SYSTEM_CA_CERTS, - nmc_property_802_1X_get_system_ca_certs, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_802_1X_SETTING_NAME""NM_SETTING_802_1X_AUTH_TIMEOUT, - nmc_property_802_1X_get_auth_timeout, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_USERNAME, nmc_property_adsl_get_username, @@ -8159,75 +7634,6 @@ setting_wired_details (const NmcSettingInfo *setting_info, NMSetting *setting, N return TRUE; } -static gboolean -setting_802_1X_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_802_1X (s_8021x), FALSE); - - tmpl = nmc_fields_setting_8021X; - tmpl_len = sizeof (nmc_fields_setting_8021X); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_802_1X_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_802_1X_get_eap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_802_1X_get_identity (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_802_1X_get_anonymous_identity (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_802_1X_get_pac_file (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_802_1X_get_ca_cert (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, GET_SECRET (secrets, setting, nmc_property_802_1X_get_ca_cert_password)); - set_val_str (arr, 7, nmc_property_802_1X_get_ca_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_802_1X_get_ca_path (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_802_1X_get_subject_match (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_802_1X_get_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_802_1X_get_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_802_1X_get_client_cert (setting, NMC_PROPERTY_GET_PRETTY, secrets)); - set_val_str (arr, 13, GET_SECRET (secrets, setting, nmc_property_802_1X_get_client_cert_password)); - set_val_str (arr, 14, nmc_property_802_1X_get_client_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_802_1X_get_phase1_peapver (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_802_1X_get_phase1_peaplabel (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 17, nmc_property_802_1X_get_phase1_fast_provisioning (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 18, nmc_property_802_1X_get_phase1_auth_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 19, nmc_property_802_1X_get_phase2_auth (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 20, nmc_property_802_1X_get_phase2_autheap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 21, nmc_property_802_1X_get_phase2_ca_cert (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 22, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_ca_cert_password)); - set_val_str (arr, 23, nmc_property_802_1X_get_phase2_ca_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 24, nmc_property_802_1X_get_phase2_ca_path (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 25, nmc_property_802_1X_get_phase2_subject_match (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 26, nmc_property_802_1X_get_phase2_altsubject_matches (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 27, nmc_property_802_1X_get_phase2_domain_suffix_match (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 28, nmc_property_802_1X_get_phase2_client_cert (setting, NMC_PROPERTY_GET_PRETTY, secrets)); - set_val_str (arr, 29, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_client_cert_password)); - set_val_str (arr, 30, nmc_property_802_1X_get_phase2_client_cert_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 31, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password)); - set_val_str (arr, 32, nmc_property_802_1X_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 33, GET_SECRET (secrets, setting, nmc_property_802_1X_get_password_raw)); - set_val_str (arr, 34, nmc_property_802_1X_get_password_raw_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 35, nmc_property_802_1X_get_private_key (setting, NMC_PROPERTY_GET_PRETTY, secrets)); - set_val_str (arr, 36, GET_SECRET (secrets, setting, nmc_property_802_1X_get_private_key_password)); - set_val_str (arr, 37, nmc_property_802_1X_get_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 38, nmc_property_802_1X_get_phase2_private_key (setting, NMC_PROPERTY_GET_PRETTY, secrets)); - set_val_str (arr, 39, GET_SECRET (secrets, setting, nmc_property_802_1X_get_phase2_private_key_password)); - set_val_str (arr, 40, nmc_property_802_1X_get_phase2_private_key_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 41, GET_SECRET (secrets, setting, nmc_property_802_1X_get_pin)); - set_val_str (arr, 42, nmc_property_802_1X_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 43, nmc_property_802_1X_get_system_ca_certs (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 44, nmc_property_802_1X_get_auth_timeout (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_wireless_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -9003,6 +8409,327 @@ static const NmcPropertyType _pt_nmc_getset = { * that the actual type is (gboolean(*)(type *)). */ \ ((gboolean (*) (NMSetting *)) ((sizeof (func == ((gboolean (*) (type *)) func))) ? func : func) ) +static const NmcPropertyInfo properties_setting_802_1x[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_802_1X_EAP), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = valid_eap, + .set_fcn = nmc_property_802_1X_set_eap, + .remove_fcn = nmc_property_802_1X_remove_eap, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_IDENTITY), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_ANONYMOUS_IDENTITY), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PAC_FILE), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_CA_CERT), + .describe_message = + N_ ("Enter file path to CA certificate (optionally prefixed with file://).\n" + " [file://]\n" + "Note that nmcli does not support specifying certificates as raw blob data.\n" + "Example: /home/cimrman/cacert.crt\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_ca_cert, + .set_fcn = nmc_property_802_1X_set_ca_cert, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_CA_CERT_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_CA_PATH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_SUBJECT_MATCH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_ALTSUBJECT_MATCHES), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_802_1X_set_altsubject_matches, + .remove_fcn = nmc_property_802_1X_remove_altsubject_matches, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_CLIENT_CERT), + .describe_message = + N_ ("Enter file path to client certificate (optionally prefixed with file://).\n" + " [file://]\n" + "Note that nmcli does not support specifying certificates as raw blob data.\n" + "Example: /home/cimrman/jara.crt\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_client_cert_full, + .set_fcn = nmc_property_802_1X_set_client_cert, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_CLIENT_CERT_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE1_PEAPVER), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _802_1X_valid_phase1_peapvers, + .set_fcn = nmc_property_802_1X_set_phase1_peapver, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE1_PEAPLABEL), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _802_1X_valid_phase1_peaplabels, + .set_fcn = nmc_property_802_1X_set_phase1_peaplabel, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _802_1X_valid_phase1_fast_provisionings, + .set_fcn = nmc_property_802_1X_set_phase1_fast_provisioning, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE1_AUTH_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_phase1_auth_flags, + .set_fcn = nmc_property_802_1X_set_phase1_auth_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_AUTH), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _802_1X_valid_phase2_auths, + .set_fcn = nmc_property_802_1X_set_phase2_auth, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_AUTHEAP), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = _802_1X_valid_phase2_autheaps, + .set_fcn = nmc_property_802_1X_set_phase2_autheap, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CA_CERT), + .describe_message = + N_ ("Enter file path to CA certificate for inner authentication (optionally prefixed\n" + "with file://).\n" + " [file://]\n" + "Note that nmcli does not support specifying certificates as raw blob data.\n" + "Example: /home/cimrman/ca-zweite-phase.crt\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_phase2_ca_cert, + .set_fcn = nmc_property_802_1X_set_phase2_ca_cert, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CA_PATH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_802_1X_set_phase2_altsubject_matches, + .remove_fcn = nmc_property_802_1X_remove_phase2_altsubject_matches, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CLIENT_CERT), + .describe_message = + N_ ("Enter file path to client certificate for inner authentication (optionally prefixed\n" + "with file://).\n" + " [file://]\n" + "Note that nmcli does not support specifying certificates as raw blob data.\n" + "Example: /home/cimrman/jara-zweite-phase.crt\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_phase2_client_cert_full, + .set_fcn = nmc_property_802_1X_set_phase2_client_cert, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PASSWORD_RAW), + .is_secret = TRUE, + .describe_message = + N_ ("Enter bytes as a list of hexadecimal values.\n" + "Two formats are accepted:\n" + "(a) a string of hexadecimal digits, where each two digits represent one byte\n" + "(b) space-separated list of bytes written as hexadecimal digits " + "(with optional 0x/0X prefix, and optional leading 0).\n\n" + "Examples: ab0455a6ea3a74C2\n" + " ab 4 55 0xa6 ea 3a 74 C2\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_password_raw, + .set_fcn = nmc_property_802_1X_set_password_raw, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PASSWORD_RAW_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PRIVATE_KEY), + .describe_message = + N_ ("Enter path to a private key and the key password (if not set yet):\n" + " [file://] []\n" + "Note that nmcli does not support specifying private key as raw blob data.\n" + "Example: /home/cimrman/jara-priv-key Dardanely\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_private_key_full, + .set_fcn = nmc_property_802_1X_set_private_key, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY), + .describe_message = + N_ ("Enter path to a private key and the key password (if not set yet):\n" + " [file://] []\n" + "Note that nmcli does not support specifying private key as raw blob data.\n" + "Example: /home/cimrman/jara-priv-key Dardanely\n"), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_802_1X_get_phase2_private_key_full, + .set_fcn = nmc_property_802_1X_set_phase2_private_key, + ), + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PIN), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_802_1X_PIN_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_802_1X_SYSTEM_CA_CERTS), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_802_1X_AUTH_TIMEOUT), + .property_type = &_pt_gobject_int, + }, +}; + static const NmcPropertyInfo properties_setting_connection[] = { PROPERTY_INFO_NAME(), { @@ -9794,7 +9521,8 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], - .get_setting_details = setting_802_1X_details, + .properties = properties_setting_802_1x, + .properties_num = G_N_ELEMENTS (properties_setting_802_1x), }, [NM_META_SETTING_TYPE_ADSL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_ADSL], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index bf6ac4c8e8..668276fc95 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -156,7 +156,6 @@ gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue * gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); extern NmcOutputField nmc_fields_setting_wired[]; -extern NmcOutputField nmc_fields_setting_8021X[]; extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_ppp[]; From f34ef5d1fe3d75000fed99ad06ac1df9f744c424 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 22/53] cli: add property-info for NMSettingPpp --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 332 +++++++++++--------------------------- clients/cli/settings.h | 1 - 4 files changed, 97 insertions(+), 240 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 7813115644..bb31f08664 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -171,7 +171,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ - SETTING_FIELD (NM_SETTING_PPP_SETTING_NAME, nmc_fields_setting_ppp + 1), /* 8 */ + SETTING_FIELD_TYPE (NM_SETTING_PPP_SETTING_NAME, NM_META_SETTING_TYPE_PPP), /* 8 */ SETTING_FIELD_TYPE (NM_SETTING_PPPOE_SETTING_NAME, NM_META_SETTING_TYPE_PPPOE), /* 9 */ SETTING_FIELD (NM_SETTING_GSM_SETTING_NAME, nmc_fields_setting_gsm + 1), /* 10 */ SETTING_FIELD (NM_SETTING_CDMA_SETTING_NAME, nmc_fields_setting_cdma + 1), /* 11 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index e27496e923..d531a7fb86 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -154,7 +154,7 @@ complete_fields (const char *prefix) complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); complete_field (h, "serial", nmc_fields_setting_serial); - complete_field (h, "ppp", nmc_fields_setting_ppp); + complete_field_new (h, "ppp", NM_META_SETTING_TYPE_PPP); complete_field_new (h, "pppoe", NM_META_SETTING_TYPE_PPPOE); complete_field (h, "adsl", nmc_fields_setting_adsl); complete_field (h, "gsm", nmc_fields_setting_gsm); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index f7ac4086ae..115c307f4a 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -254,6 +254,18 @@ _set_fcn_gobject_uint (const NmcSettingInfo *setting_info, return TRUE; } +static gboolean +_set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + if (nm_streq0 (value, "auto")) + value = "0"; + return _set_fcn_gobject_uint (setting_info, property_info, setting, value, error); +} + static gboolean _set_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -562,49 +574,6 @@ NmcOutputField nmc_fields_setting_serial[] = { NM_SETTING_SERIAL_STOPBITS","\ NM_SETTING_SERIAL_SEND_DELAY -/* Available fields for NM_SETTING_PPP_SETTING_NAME */ -NmcOutputField nmc_fields_setting_ppp[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_PPP_NOAUTH), /* 1 */ - SETTING_FIELD (NM_SETTING_PPP_REFUSE_EAP), /* 2 */ - SETTING_FIELD (NM_SETTING_PPP_REFUSE_PAP), /* 3 */ - SETTING_FIELD (NM_SETTING_PPP_REFUSE_CHAP), /* 4 */ - SETTING_FIELD (NM_SETTING_PPP_REFUSE_MSCHAP), /* 5 */ - SETTING_FIELD (NM_SETTING_PPP_REFUSE_MSCHAPV2), /* 6 */ - SETTING_FIELD (NM_SETTING_PPP_NOBSDCOMP), /* 7 */ - SETTING_FIELD (NM_SETTING_PPP_NODEFLATE), /* 8 */ - SETTING_FIELD (NM_SETTING_PPP_NO_VJ_COMP), /* 9 */ - SETTING_FIELD (NM_SETTING_PPP_REQUIRE_MPPE), /* 10 */ - SETTING_FIELD (NM_SETTING_PPP_REQUIRE_MPPE_128), /* 11 */ - SETTING_FIELD (NM_SETTING_PPP_MPPE_STATEFUL), /* 12 */ - SETTING_FIELD (NM_SETTING_PPP_CRTSCTS), /* 13 */ - SETTING_FIELD (NM_SETTING_PPP_BAUD), /* 14 */ - SETTING_FIELD (NM_SETTING_PPP_MRU), /* 15 */ - SETTING_FIELD (NM_SETTING_PPP_MTU), /* 16 */ - SETTING_FIELD (NM_SETTING_PPP_LCP_ECHO_FAILURE), /* 17 */ - SETTING_FIELD (NM_SETTING_PPP_LCP_ECHO_INTERVAL), /* 18 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_PPP_ALL "name"","\ - NM_SETTING_PPP_NOAUTH","\ - NM_SETTING_PPP_REFUSE_EAP","\ - NM_SETTING_PPP_REFUSE_PAP","\ - NM_SETTING_PPP_REFUSE_CHAP","\ - NM_SETTING_PPP_REFUSE_MSCHAP","\ - NM_SETTING_PPP_REFUSE_MSCHAPV2","\ - NM_SETTING_PPP_NOBSDCOMP","\ - NM_SETTING_PPP_NODEFLATE","\ - NM_SETTING_PPP_NO_VJ_COMP","\ - NM_SETTING_PPP_REQUIRE_MPPE","\ - NM_SETTING_PPP_REQUIRE_MPPE_128","\ - NM_SETTING_PPP_MPPE_STATEFUL","\ - NM_SETTING_PPP_CRTSCTS","\ - NM_SETTING_PPP_BAUD","\ - NM_SETTING_PPP_MRU","\ - NM_SETTING_PPP_MTU","\ - NM_SETTING_PPP_LCP_ECHO_FAILURE","\ - NM_SETTING_PPP_LCP_ECHO_INTERVAL - /* Available fields for NM_SETTING_ADSL_SETTING_NAME */ NmcOutputField nmc_fields_setting_adsl[] = { SETTING_FIELD ("name"), /* 0 */ @@ -4334,28 +4303,6 @@ nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char return TRUE; } - -/* --- NM_SETTING_PPP_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_ppp_get_noauth, NM_SETTING_PPP_NOAUTH) -DEFINE_GETTER (nmc_property_ppp_get_refuse_eap, NM_SETTING_PPP_REFUSE_EAP) -DEFINE_GETTER (nmc_property_ppp_get_refuse_pap, NM_SETTING_PPP_REFUSE_PAP) -DEFINE_GETTER (nmc_property_ppp_get_refuse_chap, NM_SETTING_PPP_REFUSE_CHAP) -DEFINE_GETTER (nmc_property_ppp_get_refuse_mschap, NM_SETTING_PPP_REFUSE_MSCHAP) -DEFINE_GETTER (nmc_property_ppp_get_refuse_mschapv2, NM_SETTING_PPP_REFUSE_MSCHAPV2) -DEFINE_GETTER (nmc_property_ppp_get_nobsdcomp, NM_SETTING_PPP_NOBSDCOMP) -DEFINE_GETTER (nmc_property_ppp_get_nodeflate, NM_SETTING_PPP_NODEFLATE) -DEFINE_GETTER (nmc_property_ppp_get_no_vj_comp, NM_SETTING_PPP_NO_VJ_COMP) -DEFINE_GETTER (nmc_property_ppp_get_require_mppe, NM_SETTING_PPP_REQUIRE_MPPE) -DEFINE_GETTER (nmc_property_ppp_get_require_mppe_128, NM_SETTING_PPP_REQUIRE_MPPE_128) -DEFINE_GETTER (nmc_property_ppp_get_mppe_stateful, NM_SETTING_PPP_MPPE_STATEFUL) -DEFINE_GETTER (nmc_property_ppp_get_crtscts, NM_SETTING_PPP_CRTSCTS) -DEFINE_GETTER (nmc_property_ppp_get_baud, NM_SETTING_PPP_BAUD) -DEFINE_GETTER (nmc_property_ppp_get_mru, NM_SETTING_PPP_MRU) -DEFINE_GETTER (nmc_property_ppp_get_mtu, NM_SETTING_PPP_MTU) -DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_failure, NM_SETTING_PPP_LCP_ECHO_FAILURE) -DEFINE_GETTER (nmc_property_ppp_get_lcp_echo_interval, NM_SETTING_PPP_LCP_ECHO_INTERVAL) - - static char * nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type) { @@ -6317,134 +6264,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_PPP_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NOAUTH, - nmc_property_ppp_get_noauth, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_EAP, - nmc_property_ppp_get_refuse_eap, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_PAP, - nmc_property_ppp_get_refuse_pap, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_CHAP, - nmc_property_ppp_get_refuse_chap, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_MSCHAP, - nmc_property_ppp_get_refuse_mschap, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REFUSE_MSCHAPV2, - nmc_property_ppp_get_refuse_mschapv2, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NOBSDCOMP, - nmc_property_ppp_get_nobsdcomp, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NODEFLATE, - nmc_property_ppp_get_nodeflate, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_NO_VJ_COMP, - nmc_property_ppp_get_no_vj_comp, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REQUIRE_MPPE, - nmc_property_ppp_get_require_mppe, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_REQUIRE_MPPE_128, - nmc_property_ppp_get_require_mppe_128, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MPPE_STATEFUL, - nmc_property_ppp_get_mppe_stateful, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_CRTSCTS, - nmc_property_ppp_get_crtscts, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_BAUD, - nmc_property_ppp_get_baud, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MRU, - nmc_property_ppp_get_mru, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_MTU, - nmc_property_ppp_get_mtu, - nmc_property_set_mtu, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_LCP_ECHO_FAILURE, - nmc_property_ppp_get_lcp_echo_failure, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_PPP_SETTING_NAME""NM_SETTING_PPP_LCP_ECHO_INTERVAL, - nmc_property_ppp_get_lcp_echo_interval, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BAUD, nmc_property_serial_get_baud, @@ -7705,49 +7524,6 @@ setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, return TRUE; } -static gboolean -setting_ppp_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingPpp *s_ppp = NM_SETTING_PPP (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_PPP (s_ppp), FALSE); - - tmpl = nmc_fields_setting_ppp; - tmpl_len = sizeof (nmc_fields_setting_ppp); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_PPP_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ppp_get_noauth (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_ppp_get_refuse_eap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_ppp_get_refuse_pap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_ppp_get_refuse_chap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_ppp_get_refuse_mschap (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_ppp_get_refuse_mschapv2 (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_ppp_get_nobsdcomp (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_ppp_get_nodeflate (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_ppp_get_no_vj_comp (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_ppp_get_require_mppe (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_ppp_get_require_mppe_128 (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_ppp_get_mppe_stateful (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_ppp_get_crtscts (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_ppp_get_baud (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_ppp_get_mru (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_ppp_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 17, nmc_property_ppp_get_lcp_echo_failure (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 18, nmc_property_ppp_get_lcp_echo_interval (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_gsm_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -8383,6 +8159,11 @@ static const NmcPropertyType _pt_gobject_uint = { .set_fcn = _set_fcn_gobject_uint, }; +static const NmcPropertyType _pt_gobject_mtu = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_mtu, +}; + static const NmcPropertyType _pt_gobject_secret_flags = { .get_fcn = _get_fcn_gobject_secret_flags, .set_fcn = _set_fcn_gobject_secret_flags, @@ -9335,6 +9116,82 @@ static const NmcPropertyInfo properties_setting_pppoe[] = { }, }; +static const NmcPropertyInfo properties_setting_ppp[] = { + PROPERTY_INFO_NAME (), + { + .property_name = N_ (NM_SETTING_PPP_NOAUTH), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REFUSE_EAP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REFUSE_PAP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REFUSE_CHAP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REFUSE_MSCHAP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REFUSE_MSCHAPV2), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_NOBSDCOMP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_NODEFLATE), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_NO_VJ_COMP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REQUIRE_MPPE), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_REQUIRE_MPPE_128), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_MPPE_STATEFUL), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_CRTSCTS), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_PPP_BAUD), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_PPP_MRU), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_PPP_MTU), + .property_type = &_pt_gobject_mtu, + }, + { + .property_name = N_ (NM_SETTING_PPP_LCP_ECHO_FAILURE), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_PPP_LCP_ECHO_INTERVAL), + .property_type = &_pt_gobject_uint, + }, +}; + static const NmcPropertyInfo properties_setting_proxy[] = { PROPERTY_INFO_NAME(), { @@ -9599,7 +9456,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_PPP] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPP], - .get_setting_details = setting_ppp_details, + .properties = properties_setting_ppp, + .properties_num = G_N_ELEMENTS (properties_setting_ppp), }, [NM_META_SETTING_TYPE_PROXY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PROXY], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 668276fc95..8f6f6223ea 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -158,7 +158,6 @@ gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_serial[]; -extern NmcOutputField nmc_fields_setting_ppp[]; extern NmcOutputField nmc_fields_setting_adsl[]; extern NmcOutputField nmc_fields_setting_gsm[]; extern NmcOutputField nmc_fields_setting_cdma[]; From 9c6f70f9e0f2243ea13f1b584d04a312d82caf2e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 23/53] cli: add property-info for NMSettingAdsl --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 170 +++++++++++--------------------------- clients/cli/settings.h | 1 - 4 files changed, 51 insertions(+), 124 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index bb31f08664..decaf4e406 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -182,7 +182,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_INFINIBAND_SETTING_NAME, nmc_fields_setting_infiniband + 1), /* 16 */ SETTING_FIELD (NM_SETTING_BOND_SETTING_NAME, nmc_fields_setting_bond + 1), /* 17 */ SETTING_FIELD (NM_SETTING_VLAN_SETTING_NAME, nmc_fields_setting_vlan + 1), /* 18 */ - SETTING_FIELD (NM_SETTING_ADSL_SETTING_NAME, nmc_fields_setting_adsl + 1), /* 19 */ + SETTING_FIELD_TYPE (NM_SETTING_ADSL_SETTING_NAME, NM_META_SETTING_TYPE_ADSL), /* 19 */ SETTING_FIELD (NM_SETTING_BRIDGE_SETTING_NAME, nmc_fields_setting_bridge + 1), /* 20 */ SETTING_FIELD (NM_SETTING_BRIDGE_PORT_SETTING_NAME, nmc_fields_setting_bridge_port + 1), /* 21 */ SETTING_FIELD (NM_SETTING_TEAM_SETTING_NAME, nmc_fields_setting_team + 1), /* 22 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index d531a7fb86..5a4be31cd5 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -156,7 +156,7 @@ complete_fields (const char *prefix) complete_field (h, "serial", nmc_fields_setting_serial); complete_field_new (h, "ppp", NM_META_SETTING_TYPE_PPP); complete_field_new (h, "pppoe", NM_META_SETTING_TYPE_PPPOE); - complete_field (h, "adsl", nmc_fields_setting_adsl); + complete_field_new (h, "adsl", NM_META_SETTING_TYPE_ADSL); complete_field (h, "gsm", nmc_fields_setting_gsm); complete_field (h, "cdma", nmc_fields_setting_cdma); complete_field (h, "bluetooth", nmc_fields_setting_bluetooth); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 115c307f4a..08ef8c89ed 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -574,27 +574,6 @@ NmcOutputField nmc_fields_setting_serial[] = { NM_SETTING_SERIAL_STOPBITS","\ NM_SETTING_SERIAL_SEND_DELAY -/* Available fields for NM_SETTING_ADSL_SETTING_NAME */ -NmcOutputField nmc_fields_setting_adsl[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_ADSL_USERNAME), /* 1 */ - SETTING_FIELD (NM_SETTING_ADSL_PASSWORD), /* 2 */ - SETTING_FIELD (NM_SETTING_ADSL_PASSWORD_FLAGS), /* 3 */ - SETTING_FIELD (NM_SETTING_ADSL_PROTOCOL), /* 4 */ - SETTING_FIELD (NM_SETTING_ADSL_ENCAPSULATION), /* 5 */ - SETTING_FIELD (NM_SETTING_ADSL_VPI), /* 6 */ - SETTING_FIELD (NM_SETTING_ADSL_VCI), /* 7 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_ADSL_ALL "name"","\ - NM_SETTING_ADSL_USERNAME","\ - NM_SETTING_ADSL_PASSWORD","\ - NM_SETTING_ADSL_PASSWORD_FLAGS","\ - NM_SETTING_ADSL_PROTOCOL","\ - NM_SETTING_ADSL_ENCAPSULATION","\ - NM_SETTING_ADSL_VPI","\ - NM_SETTING_ADSL_VCI - /* Available fields for NM_SETTING_GSM_SETTING_NAME */ NmcOutputField nmc_fields_setting_gsm[] = { SETTING_FIELD ("name"), /* 0 */ @@ -2158,16 +2137,6 @@ nmc_property_802_1X_set_phase1_auth_flags (NMSetting *setting, const char *prop, } -/* --- NM_SETTING_ADSL_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_adsl_get_username, NM_SETTING_ADSL_USERNAME) -DEFINE_GETTER (nmc_property_adsl_get_password, NM_SETTING_ADSL_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_adsl_get_password_flags, NM_SETTING_ADSL_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_adsl_get_protocol, NM_SETTING_ADSL_PROTOCOL) -DEFINE_GETTER (nmc_property_adsl_get_encapsulation, NM_SETTING_ADSL_ENCAPSULATION) -DEFINE_GETTER (nmc_property_adsl_get_vpi, NM_SETTING_ADSL_VPI) -DEFINE_GETTER (nmc_property_adsl_get_vci, NM_SETTING_ADSL_VCI) - -/* 'protocol' */ static const char *adsl_valid_protocols[] = { NM_SETTING_ADSL_PROTOCOL_PPPOA, NM_SETTING_ADSL_PROTOCOL_PPPOE, @@ -2181,9 +2150,6 @@ nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char return check_and_set_string (setting, prop, val, adsl_valid_protocols, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_protocol, adsl_valid_protocols) - -/* 'encapsulation' */ static const char *adsl_valid_encapsulations[] = { NM_SETTING_ADSL_ENCAPSULATION_VCMUX, NM_SETTING_ADSL_ENCAPSULATION_LLC, @@ -2196,9 +2162,6 @@ nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error); } -DEFINE_ALLOWED_VAL_FUNC (nmc_property_adsl_allowed_encapsulation, adsl_valid_encapsulations) - - /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR) DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE) @@ -5916,57 +5879,6 @@ nmc_properties_init (void) /* create properties hash table */ nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); - /* Add editable properties for NM_SETTING_ADSL_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_USERNAME, - nmc_property_adsl_get_username, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PASSWORD, - nmc_property_adsl_get_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PASSWORD_FLAGS, - nmc_property_adsl_get_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_PROTOCOL, - nmc_property_adsl_get_protocol, - nmc_property_adsl_set_protocol, - NULL, - NULL, - nmc_property_adsl_allowed_protocol, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_ENCAPSULATION, - nmc_property_adsl_get_encapsulation, - nmc_property_adsl_set_encapsulation, - NULL, - NULL, - nmc_property_adsl_allowed_encapsulation, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_VPI, - nmc_property_adsl_get_vpi, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_ADSL_SETTING_NAME""NM_SETTING_ADSL_VCI, - nmc_property_adsl_get_vci, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_BLUETOOTH_SETTING_NAME""NM_SETTING_BLUETOOTH_BDADDR, nmc_property_bluetooth_get_bdaddr, @@ -7791,38 +7703,6 @@ setting_vlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm return TRUE; } -static gboolean -setting_adsl_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingAdsl *s_adsl = NM_SETTING_ADSL (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE); - - tmpl = nmc_fields_setting_adsl; - tmpl_len = sizeof (nmc_fields_setting_adsl); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_ADSL_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_adsl_get_username (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, GET_SECRET (secrets, setting, nmc_property_adsl_get_password)); - set_val_str (arr, 3, nmc_property_adsl_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_adsl_get_protocol (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_adsl_get_encapsulation (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_adsl_get_vpi (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_adsl_get_vci (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_bridge_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -8511,6 +8391,53 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { }, }; +static const NmcPropertyInfo properties_setting_adsl[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_ADSL_USERNAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_ADSL_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_ADSL_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_ADSL_PROTOCOL), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = adsl_valid_protocols, + .set_fcn = nmc_property_adsl_set_protocol, + ), + }, + { + .property_name = N_ (NM_SETTING_ADSL_ENCAPSULATION), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .values_static = adsl_valid_encapsulations, + .set_fcn = nmc_property_adsl_set_encapsulation, + ), + }, + { + .property_name = N_ (NM_SETTING_ADSL_VPI), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_ADSL_VCI), + .property_type = &_pt_gobject_uint, + }, +}; + static const NmcPropertyInfo properties_setting_connection[] = { PROPERTY_INFO_NAME(), { @@ -9383,7 +9310,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_ADSL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_ADSL], - .get_setting_details = setting_adsl_details, + .properties = properties_setting_adsl, + .properties_num = G_N_ELEMENTS (properties_setting_adsl), }, [NM_META_SETTING_TYPE_BLUETOOTH] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BLUETOOTH], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 8f6f6223ea..fcae242ddb 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -158,7 +158,6 @@ gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_serial[]; -extern NmcOutputField nmc_fields_setting_adsl[]; extern NmcOutputField nmc_fields_setting_gsm[]; extern NmcOutputField nmc_fields_setting_cdma[]; extern NmcOutputField nmc_fields_setting_bluetooth[]; From d07acc753cf5735aefc2742d93ffa4166772323e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 18:51:45 +0200 Subject: [PATCH 24/53] cli: let string property-type handle checking values --- clients/cli/settings.c | 232 +++++++++-------------------------------- 1 file changed, 47 insertions(+), 185 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 08ef8c89ed..451cf26ac0 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -144,6 +144,14 @@ _set_fcn_gobject_string (const NmcSettingInfo *setting_info, const char *value, GError **error) { + if ( property_info->property_typ_data + && property_info->property_typ_data->values_static) { + value = nmc_string_is_valid (value, + (const char **) property_info->property_typ_data->values_static, + error); + if (!value) + return FALSE; + } g_object_set (setting, property_info->property_name, value, NULL); return TRUE; } @@ -2037,47 +2045,6 @@ DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key, nm_setting_802_1x_get_phase2_private_key_password, nm_setting_802_1x_set_phase2_private_key) -static const char *_802_1X_valid_phase1_peapvers[] = { "0", "1", NULL }; - -static gboolean -nmc_property_802_1X_set_phase1_peapver (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peapvers, error); -} - -/* 'phase1-peaplabel' */ -static const char *_802_1X_valid_phase1_peaplabels[] = { "0", "1", NULL }; - -static gboolean -nmc_property_802_1X_set_phase1_peaplabel (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_peaplabels, error); -} - -static const char *_802_1X_valid_phase1_fast_provisionings[] = { "0", "1", "2", "3", NULL }; - -static gboolean -nmc_property_802_1X_set_phase1_fast_provisioning (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _802_1X_valid_phase1_fast_provisionings, error); -} - -static const char *_802_1X_valid_phase2_auths[] = - { "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls", NULL }; - -static gboolean -nmc_property_802_1X_set_phase2_auth (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_auths, error); -} - -static const char *_802_1X_valid_phase2_autheaps[] = { "md5", "mschapv2", "otp", "gtc", "tls", NULL }; -static gboolean -nmc_property_802_1X_set_phase2_autheap (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _802_1X_valid_phase2_autheaps, error); -} - static gboolean nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -2136,32 +2103,6 @@ nmc_property_802_1X_set_phase1_auth_flags (NMSetting *setting, const char *prop, return TRUE; } - -static const char *adsl_valid_protocols[] = { - NM_SETTING_ADSL_PROTOCOL_PPPOA, - NM_SETTING_ADSL_PROTOCOL_PPPOE, - NM_SETTING_ADSL_PROTOCOL_IPOATM, - NULL -}; - -static gboolean -nmc_property_adsl_set_protocol (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, adsl_valid_protocols, error); -} - -static const char *adsl_valid_encapsulations[] = { - NM_SETTING_ADSL_ENCAPSULATION_VCMUX, - NM_SETTING_ADSL_ENCAPSULATION_LLC, - NULL -}; - -static gboolean -nmc_property_adsl_set_encapsulation (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, adsl_valid_encapsulations, error); -} - /* --- NM_SETTING_BLUETOOTH_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR) DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE) @@ -2519,19 +2460,6 @@ _set_fcn_connection_master (const NmcSettingInfo *setting_info, return TRUE; } -static const char *con_valid_slave_types[] = { - NM_SETTING_BOND_SETTING_NAME, - NM_SETTING_BRIDGE_SETTING_NAME, - NM_SETTING_TEAM_SETTING_NAME, - NULL -}; - -static gboolean -nmc_property_con_set_slave_type (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, con_valid_slave_types, error); -} - static gboolean _set_fcn_connection_secondaries (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -2829,7 +2757,6 @@ dcb_app_priority_to_string (gint priority) DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS) DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY) -DEFINE_GETTER (nmc_property_dcb_get_app_fcoe_mode, NM_SETTING_DCB_APP_FCOE_MODE) DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS) DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY) DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS) @@ -3090,17 +3017,6 @@ nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, con return TRUE; } -/* 'app-fcoe-mode' */ -static const char *_dcb_valid_fcoe_modes[] = { NM_SETTING_DCB_FCOE_MODE_FABRIC, - NM_SETTING_DCB_FCOE_MODE_VN2VN, - NULL }; - -static gboolean -nmc_property_dcb_set_app_fcoe_mode (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, _dcb_valid_fcoe_modes, error); -} - /* --- NM_SETTING_GSM_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER) DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME) @@ -5206,24 +5122,6 @@ nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType g return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (s_wireless_sec)); } -/* 'key-mgmt' */ -static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL }; - -static gboolean -nmc_property_wifi_sec_set_key_mgmt (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wifi_sec_valid_key_mgmts, error); -} - -/* 'auth-alg' */ -static const char *wifi_sec_valid_auth_algs[] = { "open", "shared", "leap", NULL }; - -static gboolean -nmc_property_wifi_sec_set_auth_alg (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wifi_sec_valid_auth_algs, error); -} - /* 'proto' */ static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL }; @@ -8167,35 +8065,23 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { }, { .property_name = N_ (NM_SETTING_802_1X_PHASE1_PEAPVER), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _802_1X_valid_phase1_peapvers, - .set_fcn = nmc_property_802_1X_set_phase1_peapver, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("0", "1"), ), }, { .property_name = N_ (NM_SETTING_802_1X_PHASE1_PEAPLABEL), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _802_1X_valid_phase1_peaplabels, - .set_fcn = nmc_property_802_1X_set_phase1_peaplabel, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("0", "1"), ), }, { .property_name = N_ (NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _802_1X_valid_phase1_fast_provisionings, - .set_fcn = nmc_property_802_1X_set_phase1_fast_provisioning, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("0", "1", "2", "3"), ), }, { @@ -8208,24 +8094,16 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { }, { .property_name = N_ (NM_SETTING_802_1X_PHASE2_AUTH), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _802_1X_valid_phase2_auths, - .set_fcn = nmc_property_802_1X_set_phase2_auth, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5", "tls"), ), }, { .property_name = N_ (NM_SETTING_802_1X_PHASE2_AUTHEAP), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _802_1X_valid_phase2_autheaps, - .set_fcn = nmc_property_802_1X_set_phase2_autheap, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("md5", "mschapv2", "otp", "gtc", "tls"), ), }, { @@ -8408,24 +8286,19 @@ static const NmcPropertyInfo properties_setting_adsl[] = { }, { .property_name = N_ (NM_SETTING_ADSL_PROTOCOL), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = adsl_valid_protocols, - .set_fcn = nmc_property_adsl_set_protocol, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_ADSL_PROTOCOL_PPPOA, + NM_SETTING_ADSL_PROTOCOL_PPPOE, + NM_SETTING_ADSL_PROTOCOL_IPOATM), ), }, { .property_name = N_ (NM_SETTING_ADSL_ENCAPSULATION), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = adsl_valid_encapsulations, - .set_fcn = nmc_property_adsl_set_encapsulation, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_ADSL_ENCAPSULATION_VCMUX, + NM_SETTING_ADSL_ENCAPSULATION_LLC), ), }, { @@ -8525,13 +8398,11 @@ static const NmcPropertyInfo properties_setting_connection[] = { }, { .property_name = N_ (NM_SETTING_CONNECTION_SLAVE_TYPE), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = con_valid_slave_types, - .set_fcn = nmc_property_con_set_slave_type, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_BOND_SETTING_NAME, + NM_SETTING_BRIDGE_SETTING_NAME, + NM_SETTING_TEAM_SETTING_NAME), ), }, { @@ -8616,11 +8487,10 @@ static const NmcPropertyInfo properties_setting_dcb[] = { }, { .property_name = N_ (NM_SETTING_DCB_APP_FCOE_MODE), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = _dcb_valid_fcoe_modes, - .get_fcn = nmc_property_dcb_get_app_fcoe_mode, - .set_fcn = nmc_property_dcb_set_app_fcoe_mode, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_DCB_FCOE_MODE_FABRIC, + NM_SETTING_DCB_FCOE_MODE_VN2VN), ), }, { @@ -9158,13 +9028,9 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = wifi_sec_valid_key_mgmts, - .set_fcn = nmc_property_wifi_sec_set_key_mgmt, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap"), ), }, { @@ -9173,13 +9039,9 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_AUTH_ALG), - .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = wifi_sec_valid_auth_algs, - .set_fcn = nmc_property_wifi_sec_set_auth_alg, + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("open", "shared", "leap"), ), }, { From 486dc1e59607deaa24227af863941c1c06fe0eac Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 25/53] cli: add property-info for NMSettingWimax --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 101 +++++++++++++++----------------------- clients/cli/settings.h | 1 - 4 files changed, 42 insertions(+), 64 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index decaf4e406..d56cd5b8ae 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -178,7 +178,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, nmc_fields_setting_bluetooth + 1), /* 12 */ SETTING_FIELD (NM_SETTING_OLPC_MESH_SETTING_NAME, nmc_fields_setting_olpc_mesh + 1), /* 13 */ SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, nmc_fields_setting_vpn + 1), /* 14 */ - SETTING_FIELD (NM_SETTING_WIMAX_SETTING_NAME, nmc_fields_setting_wimax + 1), /* 15 */ + SETTING_FIELD_TYPE (NM_SETTING_WIMAX_SETTING_NAME, NM_META_SETTING_TYPE_WIMAX), /* 15 */ SETTING_FIELD (NM_SETTING_INFINIBAND_SETTING_NAME, nmc_fields_setting_infiniband + 1), /* 16 */ SETTING_FIELD (NM_SETTING_BOND_SETTING_NAME, nmc_fields_setting_bond + 1), /* 17 */ SETTING_FIELD (NM_SETTING_VLAN_SETTING_NAME, nmc_fields_setting_vlan + 1), /* 18 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 5a4be31cd5..5d5e5c5b60 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -162,7 +162,7 @@ complete_fields (const char *prefix) complete_field (h, "bluetooth", nmc_fields_setting_bluetooth); complete_field (h, "802-11-olpc-mesh", nmc_fields_setting_olpc_mesh); complete_field (h, "vpn", nmc_fields_setting_vpn); - complete_field (h, "wimax", nmc_fields_setting_wimax); + complete_field_new (h, "wimax", NM_META_SETTING_TYPE_WIMAX); complete_field (h, "infiniband", nmc_fields_setting_infiniband); complete_field (h, "bond", nmc_fields_setting_bond); complete_field (h, "vlan", nmc_fields_setting_vlan); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 451cf26ac0..285399bc7f 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -274,6 +274,27 @@ _set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, return _set_fcn_gobject_uint (setting_info, property_info, setting, value, error); } +static gboolean +_set_fcn_gobject_mac (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + gboolean is_cloned_mac = FALSE; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + if ( (!is_cloned_mac || !NM_CLONED_MAC_IS_SPECIAL (value)) + && !nm_utils_hwaddr_valid (value, ETH_ALEN)) { + g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); + return FALSE; + } + + g_object_set (setting, property_info->property_name, value, NULL); + return TRUE; +} + static gboolean _set_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -675,17 +696,6 @@ NmcOutputField nmc_fields_setting_vpn[] = { NM_SETTING_VPN_PERSISTENT","\ NM_SETTING_VPN_TIMEOUT -/* Available fields for NM_SETTING_WIMAX_SETTING_NAME */ -NmcOutputField nmc_fields_setting_wimax[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_WIMAX_MAC_ADDRESS), /* 1 */ - SETTING_FIELD (NM_SETTING_WIMAX_NETWORK_NAME), /* 2 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_WIMAX_ALL "name"","\ - NM_SETTING_WIMAX_MAC_ADDRESS","\ - NM_SETTING_WIMAX_NETWORK_NAME - /* Available fields for NM_SETTING_INFINIBAND_SETTING_NAME */ NmcOutputField nmc_fields_setting_infiniband[] = { SETTING_FIELD ("name"), /* 0 */ @@ -4602,12 +4612,6 @@ DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC) DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS) DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS) - -/* --- NM_SETTING_WIMAX_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_wimax_get_network_name, NM_SETTING_WIMAX_NETWORK_NAME) -DEFINE_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS) - - /* --- NM_SETTING_WIRED_SETTING_NAME property functions --- */ DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT) DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE) @@ -6211,22 +6215,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_WIMAX_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_WIMAX_SETTING_NAME""NM_SETTING_WIMAX_NETWORK_NAME, - nmc_property_wimax_get_network_name, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIMAX_SETTING_NAME""NM_SETTING_WIMAX_MAC_ADDRESS, - nmc_property_wimax_get_mac_address, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_PORT, nmc_property_wired_get_port, @@ -7488,33 +7476,6 @@ setting_vpn_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmC return TRUE; } -static gboolean -setting_wimax_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingWimax *s_wimax = NM_SETTING_WIMAX (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_WIMAX (s_wimax), FALSE); - - tmpl = nmc_fields_setting_wimax; - tmpl_len = sizeof (nmc_fields_setting_wimax); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIMAX_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wimax_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_wimax_get_network_name (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_infiniband_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -7942,6 +7903,11 @@ static const NmcPropertyType _pt_gobject_mtu = { .set_fcn = _set_fcn_gobject_mtu, }; +static const NmcPropertyType _pt_gobject_mac = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_mac, +}; + static const NmcPropertyType _pt_gobject_secret_flags = { .get_fcn = _get_fcn_gobject_secret_flags, .set_fcn = _set_fcn_gobject_secret_flags, @@ -9024,6 +8990,18 @@ static const NmcPropertyInfo properties_setting_proxy[] = { }, }; +static const NmcPropertyInfo properties_setting_wimax[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_WIMAX_MAC_ADDRESS), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_WIMAX_NETWORK_NAME), + .property_type = &_pt_gobject_mac, + }, +}; + static const NmcPropertyInfo properties_setting_wireless_security[] = { PROPERTY_INFO_NAME(), { @@ -9284,7 +9262,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_WIMAX] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIMAX], - .get_setting_details = setting_wimax_details, + .properties = properties_setting_wimax, + .properties_num = G_N_ELEMENTS (properties_setting_wimax), }, [NM_META_SETTING_TYPE_WIRED] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRED], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index fcae242ddb..7c032fa4d3 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -163,7 +163,6 @@ extern NmcOutputField nmc_fields_setting_cdma[]; extern NmcOutputField nmc_fields_setting_bluetooth[]; extern NmcOutputField nmc_fields_setting_olpc_mesh[]; extern NmcOutputField nmc_fields_setting_vpn[]; -extern NmcOutputField nmc_fields_setting_wimax[]; extern NmcOutputField nmc_fields_setting_infiniband[]; extern NmcOutputField nmc_fields_setting_bond[]; extern NmcOutputField nmc_fields_setting_vlan[]; From 84aa6bad892b46b926697049a2543b342d8c7c8e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 26/53] cli: add property-info for NMSettingWired --- clients/cli/connections.c | 4 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 463 ++++++++++++++------------------------ clients/cli/settings.h | 11 +- 4 files changed, 188 insertions(+), 292 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d56cd5b8ae..a07fbccbeb 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -163,8 +163,8 @@ NmcOutputField nmc_fields_con_show[] = { /* Available settings for 'connection show ' - profile part */ NmcOutputField nmc_fields_settings_names[] = { - SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), - SETTING_FIELD (NM_SETTING_WIRED_SETTING_NAME, nmc_fields_setting_wired + 1), /* 1 */ + SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), /* 0 */ + SETTING_FIELD_TYPE (NM_SETTING_WIRED_SETTING_NAME, NM_META_SETTING_TYPE_WIRED), /* 1 */ SETTING_FIELD_TYPE (NM_SETTING_802_1X_SETTING_NAME, NM_META_SETTING_TYPE_802_1X), /* 2 */ SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS_SECURITY), /* 4 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 5d5e5c5b60..c7f7444c8f 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -147,7 +147,7 @@ complete_fields (const char *prefix) complete_field (h, NULL, nmc_fields_dev_lldp_list); complete_field_new (h, "connection", NM_META_SETTING_TYPE_CONNECTION); - complete_field (h, "802-3-ethernet", nmc_fields_setting_wired); + complete_field_new (h, "802-3-ethernet", NM_META_SETTING_TYPE_WIRED); complete_field_new (h, "802-1x", NM_META_SETTING_TYPE_802_1X); complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); complete_field_new (h, "802-11-wireless-security", NM_META_SETTING_TYPE_WIRELESS_SECURITY); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 285399bc7f..310cb639ef 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -109,6 +109,28 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, return s; } +static char * +_get_fcn_gobject_mtu (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + NmcPropertyGetType get_type) +{ + guint32 mtu; + + if ( !property_info->property_typ_data + || !property_info->property_typ_data->mtu.get_fcn) + return _get_fcn_gobject (setting_info, property_info, setting, get_type); + + mtu = property_info->property_typ_data->mtu.get_fcn (setting); + if (mtu == 0) { + if (get_type == NMC_PROPERTY_GET_PARSABLE) + return g_strdup ("auto"); + else + return g_strdup (_("auto")); + } + return g_strdup_printf ("%u", (unsigned) mtu); +} + static char * _get_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -274,6 +296,23 @@ _set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, return _set_fcn_gobject_uint (setting_info, property_info, setting, value, error); } +static gboolean +_set_fcn_gobject_mac_impl (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + gboolean is_cloned_mac, + GError **error) +{ + if ( (!is_cloned_mac || !NM_CLONED_MAC_IS_SPECIAL (value)) + && !nm_utils_hwaddr_valid (value, ETH_ALEN)) { + g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); + return FALSE; + } + g_object_set (setting, property_info->property_name, value, NULL); + return TRUE; +} + static gboolean _set_fcn_gobject_mac (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -281,18 +320,17 @@ _set_fcn_gobject_mac (const NmcSettingInfo *setting_info, const char *value, GError **error) { - gboolean is_cloned_mac = FALSE; + return _set_fcn_gobject_mac_impl (setting_info, property_info, setting, value, FALSE, error); +} - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if ( (!is_cloned_mac || !NM_CLONED_MAC_IS_SPECIAL (value)) - && !nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); - return FALSE; - } - - g_object_set (setting, property_info->property_name, value, NULL); - return TRUE; +static gboolean +_set_fcn_gobject_mac_cloned (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info, + NMSetting *setting, + const char *value, + GError **error) +{ + return _set_fcn_gobject_mac_impl (setting_info, property_info, setting, value, TRUE, error); } static gboolean @@ -512,41 +550,6 @@ _get_nmc_output_fields (const NmcSettingInfo *setting_info) /*****************************************************************************/ -/* Available fields for NM_SETTING_WIRED_SETTING_NAME */ -NmcOutputField nmc_fields_setting_wired[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_WIRED_PORT), /* 1 */ - SETTING_FIELD (NM_SETTING_WIRED_SPEED), /* 2 */ - SETTING_FIELD (NM_SETTING_WIRED_DUPLEX), /* 3 */ - SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE), /* 4 */ - SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS), /* 5 */ - SETTING_FIELD (NM_SETTING_WIRED_CLONED_MAC_ADDRESS), /* 6 */ - SETTING_FIELD (NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), /* 7 */ - SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), /* 8 */ - SETTING_FIELD (NM_SETTING_WIRED_MTU), /* 9 */ - SETTING_FIELD (NM_SETTING_WIRED_S390_SUBCHANNELS), /* 10 */ - SETTING_FIELD (NM_SETTING_WIRED_S390_NETTYPE), /* 11 */ - SETTING_FIELD (NM_SETTING_WIRED_S390_OPTIONS), /* 12 */ - SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN), /* 13 */ - SETTING_FIELD (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), /* 14 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_WIRED_ALL "name"","\ - NM_SETTING_WIRED_PORT","\ - NM_SETTING_WIRED_SPEED","\ - NM_SETTING_WIRED_DUPLEX","\ - NM_SETTING_WIRED_AUTO_NEGOTIATE","\ - NM_SETTING_WIRED_MAC_ADDRESS","\ - NM_SETTING_WIRED_CLONED_MAC_ADDRESS","\ - NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK","\ - NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST","\ - NM_SETTING_WIRED_MTU","\ - NM_SETTING_WIRED_S390_SUBCHANNELS","\ - NM_SETTING_WIRED_S390_NETTYPE","\ - NM_SETTING_WIRED_S390_OPTIONS","\ - NM_SETTING_WIRED_WAKE_ON_LAN","\ - NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD - /* Available fields for NM_SETTING_WIRELESS_SETTING_NAME */ NmcOutputField nmc_fields_setting_wireless[] = { SETTING_FIELD ("name"), /* 0 */ @@ -4612,55 +4615,6 @@ DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC) DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS) DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS) -/* --- NM_SETTING_WIRED_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT) -DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE) -DEFINE_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_wired_get_generate_mac_address_mask, NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK) -DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST) -DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS) -DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE) -DEFINE_GETTER (nmc_property_wired_get_s390_options, NM_SETTING_WIRED_S390_OPTIONS) -DEFINE_GETTER (nmc_property_wired_get_wake_on_lan_password, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD) - -static char * -nmc_property_wired_get_speed (NMSetting *setting, NmcPropertyGetType get_type) -{ - NMSettingWired *s_wired = NM_SETTING_WIRED (setting); - guint32 speed; - - speed = nm_setting_wired_get_speed (s_wired); - return g_strdup_printf ("%d", speed); -} - -static char * -nmc_property_wired_get_duplex (NMSetting *setting, NmcPropertyGetType get_type) -{ - NMSettingWired *s_wired = NM_SETTING_WIRED (setting); - const char *str; - - str = nm_setting_wired_get_duplex (s_wired); - if (!str) - return NULL; - else - return g_strdup (str); - -} - -static char * -nmc_property_wired_get_mtu (NMSetting *setting, NmcPropertyGetType get_type) -{ - NMSettingWired *s_wired = NM_SETTING_WIRED (setting); - int mtu; - - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu == 0) - return g_strdup (_("auto")); - else - return g_strdup_printf ("%d", mtu); -} - static char * nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4721,36 +4675,6 @@ nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop, return TRUE; } -#if 0 --/* -- * Do not allow setting 'port' for now. It is not implemented in -- * NM core, nor in ifcfg-rh plugin. Enable this when it gets done. -- */ -/* 'port' */ -static const char *wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL }; - -static gboolean -nmc_property_wired_set_port (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wired_valid_ports, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_port, wired_valid_ports) -#endif - -/* 'duplex' */ -static const char *wired_valid_duplexes[] = { "half", "full", NULL }; - -static gboolean -nmc_property_wired_set_duplex (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wired_valid_duplexes, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_duplex, wired_valid_duplexes) - - -/* 'mac-address-blacklist' */ DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist, NM_SETTING_WIRED, nm_setting_wired_add_mac_blacklist_item) @@ -4800,26 +4724,6 @@ nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, c return TRUE; } -static const char * -nmc_property_wired_describe_s390_subchannels (NMSetting *setting, const char *prop) -{ - return _("Enter a list of subchannels (comma or space separated).\n\n" - "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n"); -} - -/* 's390-nettype' */ -static const char *wired_valid_s390_nettypes[] = { "qeth", "lcs", "ctc", NULL }; - -static gboolean -nmc_property_wired_set_s390_nettype (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wired_valid_s390_nettypes, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wired_allowed_s390_nettype, wired_valid_s390_nettypes) - -/* 's390-options' */ -/* Validate value of 's390-options' */ static const char * _validate_s390_option_value (const char *option, const char *value, GError **error) { @@ -4847,14 +4751,17 @@ nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop) } static const char * -nmc_property_wired_describe_s390_options (NMSetting *setting, const char *prop) +_describe_fcn_wired_s390_options (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info) { static char *desc = NULL; const char **valid_options; char *options_str; if (G_UNLIKELY (desc == NULL)) { - valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting)); + gs_unref_object NMSetting *s = nm_setting_wired_new (); + + valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (s)); options_str = g_strjoinv (", ", (char **) valid_options); desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n" @@ -6215,106 +6122,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_WIRED_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_PORT, - nmc_property_wired_get_port, - NULL, /* nmc_property_wired_set_port, */ - NULL, - NULL, - NULL, /* nmc_property_wired_allowed_port, */ - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_SPEED, - nmc_property_wired_get_speed, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_DUPLEX, - nmc_property_wired_get_duplex, - nmc_property_wired_set_duplex, - NULL, - NULL, - nmc_property_wired_allowed_duplex, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_AUTO_NEGOTIATE, - nmc_property_wired_get_auto_negotiate, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MAC_ADDRESS, - nmc_property_wired_get_mac_address, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_CLONED_MAC_ADDRESS, - nmc_property_wired_get_cloned_mac_address, - nmc_property_set_mac_cloned, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, - nmc_property_wired_get_generate_mac_address_mask, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, - nmc_property_wired_get_mac_address_blacklist, - nmc_property_wired_set_mac_address_blacklist, - nmc_property_wired_remove_mac_address_blacklist, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_MTU, - nmc_property_wired_get_mtu, - nmc_property_set_mtu, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_SUBCHANNELS, - nmc_property_wired_get_s390_subchannels, - nmc_property_wired_set_s390_subchannels, - NULL, - nmc_property_wired_describe_s390_subchannels, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_NETTYPE, - nmc_property_wired_get_s390_nettype, - nmc_property_wired_set_s390_nettype, - NULL, - NULL, - nmc_property_wired_allowed_s390_nettype, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_S390_OPTIONS, - nmc_property_wired_get_s390_options, - nmc_property_wired_set_s390_options, - nmc_property_wired_remove_option_s390_options, - nmc_property_wired_describe_s390_options, - nmc_property_wired_allowed_s390_options, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_WAKE_ON_LAN, - nmc_property_wired_get_wake_on_lan, - nmc_property_wired_set_wake_on_lan, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRED_SETTING_NAME""NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, - nmc_property_wired_get_wake_on_lan_password, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_SSID, nmc_property_wireless_get_ssid, @@ -7212,45 +7019,6 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm return TRUE; } -static gboolean -setting_wired_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingWired *s_wired = NM_SETTING_WIRED (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_WIRED (s_wired), FALSE); - - tmpl = nmc_fields_setting_wired; - tmpl_len = sizeof (nmc_fields_setting_wired); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRED_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wired_get_port (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_wired_get_speed (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_wired_get_duplex (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_wired_get_auto_negotiate (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_wired_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_wired_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_wired_get_generate_mac_address_mask (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_wired_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_wired_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_wired_get_s390_subchannels (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_wired_get_s390_nettype (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_wired_get_s390_options (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_wired_get_wake_on_lan (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_wired_get_wake_on_lan_password (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_wireless_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -7899,7 +7667,7 @@ static const NmcPropertyType _pt_gobject_uint = { }; static const NmcPropertyType _pt_gobject_mtu = { - .get_fcn = _get_fcn_gobject, + .get_fcn = _get_fcn_gobject_mtu, .set_fcn = _set_fcn_gobject_mtu, }; @@ -7908,6 +7676,11 @@ static const NmcPropertyType _pt_gobject_mac = { .set_fcn = _set_fcn_gobject_mac, }; +static const NmcPropertyType _pt_gobject_mac_cloned = { + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_gobject_mac_cloned, +}; + static const NmcPropertyType _pt_gobject_secret_flags = { .get_fcn = _get_fcn_gobject_secret_flags, .set_fcn = _set_fcn_gobject_secret_flags, @@ -7934,6 +7707,11 @@ static const NmcPropertyType _pt_nmc_getset = { * that the actual type is (gboolean(*)(type *)). */ \ ((gboolean (*) (NMSetting *)) ((sizeof (func == ((gboolean (*) (type *)) func))) ? func : func) ) +#define MTU_GET_FCN(type, func) \ + /* macro that returns @func as const (guint32(*)(NMSetting*)) type, but checks + * that the actual type is (guint32(*)(type *)). */ \ + ((guint32 (*) (NMSetting *)) ((sizeof (func == ((guint32 (*) (type *)) func))) ? func : func) ) + static const NmcPropertyInfo properties_setting_802_1x[] = { PROPERTY_INFO_NAME(), { @@ -8944,6 +8722,9 @@ static const NmcPropertyInfo properties_setting_ppp[] = { { .property_name = N_ (NM_SETTING_PPP_MTU), .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingPpp, nm_setting_ppp_get_mtu), + ), }, { .property_name = N_ (NM_SETTING_PPP_LCP_ECHO_FAILURE), @@ -9002,6 +8783,111 @@ static const NmcPropertyInfo properties_setting_wimax[] = { }, }; +static const NmcPropertyInfo properties_setting_wired[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_WIRED_PORT), + /* Do not allow setting 'port' for now. It is not implemented in + * NM core, nor in ifcfg-rh plugin. Enable this when it gets done. + * wired_valid_ports[] = { "tp", "aui", "bnc", "mii", NULL }; + */ + .property_type = &_pt_gobject_readonly, + }, + { + .property_name = N_ (NM_SETTING_WIRED_SPEED), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_WIRED_DUPLEX), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("half", "full"), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_AUTO_NEGOTIATE), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_WIRED_MAC_ADDRESS), + .property_type = &_pt_gobject_mac, + }, + { + .property_name = N_ (NM_SETTING_WIRED_CLONED_MAC_ADDRESS), + .property_type = &_pt_gobject_mac_cloned, + }, + { + .property_name = N_ (NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wired_set_mac_address_blacklist, + .remove_fcn = nmc_property_wired_remove_mac_address_blacklist, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_MTU), + .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingWired, nm_setting_wired_get_mtu), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_S390_SUBCHANNELS), + .describe_message = + N_ ("Enter a list of subchannels (comma or space separated).\n\n" + "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n"), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wired_set_s390_subchannels, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_S390_NETTYPE), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("qeth", "lcs", "ctc"), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_S390_OPTIONS), + .property_type = DEFINE_PROPERTY_TYPE ( + .describe_fcn = _describe_fcn_wired_s390_options, + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wired_set_s390_options, + .remove_fcn = nmc_property_wired_remove_option_s390_options, + .values_fcn = nmc_property_wired_allowed_s390_options, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_WAKE_ON_LAN), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wired_get_wake_on_lan, + .set_fcn = nmc_property_wired_set_wake_on_lan, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD), + .property_type = &_pt_gobject_mac, + }, +}; + static const NmcPropertyInfo properties_setting_wireless_security[] = { PROPERTY_INFO_NAME(), { @@ -9267,7 +9153,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_WIRED] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRED], - .get_setting_details = setting_wired_details, + .properties = properties_setting_wired, + .properties_num = G_N_ELEMENTS (properties_setting_wired), }, [NM_META_SETTING_TYPE_WIRELESS] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 7c032fa4d3..c12f858a24 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -38,6 +38,11 @@ typedef struct _NmcPropertyType NmcPropertyType; typedef struct _NmcPropertyTypData NmcPropertyTypData; struct _NmcPropertyType { + + /* FIXME: the function should return an allocated string. */ + const char *(*describe_fcn) (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info); + char *(*get_fcn) (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, @@ -53,6 +58,8 @@ struct _NmcPropertyType { const char *option, guint32 idx, GError **error); + + /* FIXME: the function should return an allocated string. */ const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info); }; @@ -78,6 +85,9 @@ struct _NmcPropertyTypData { const char *const* (*values_fcn) (NMSetting *setting, const char *prop); }; } nmc; + struct { + guint32 (*get_fcn) (NMSetting *setting); + } mtu; }; const char *const*values_static; }; @@ -155,7 +165,6 @@ gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue * gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); -extern NmcOutputField nmc_fields_setting_wired[]; extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_gsm[]; From 10fca1ae3a78dc20178951f4197cc59e7df754ba Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 27/53] cli: add property-info for NMSettingWireless --- clients/cli/connections.c | 2 +- clients/cli/nmcli.c | 2 +- clients/cli/settings.c | 371 +++++++++++--------------------------- clients/cli/settings.h | 1 - 4 files changed, 112 insertions(+), 264 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index a07fbccbeb..bf7f1165f6 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -166,7 +166,7 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD_TYPE (NM_SETTING_CONNECTION_SETTING_NAME, NM_META_SETTING_TYPE_CONNECTION), /* 0 */ SETTING_FIELD_TYPE (NM_SETTING_WIRED_SETTING_NAME, NM_META_SETTING_TYPE_WIRED), /* 1 */ SETTING_FIELD_TYPE (NM_SETTING_802_1X_SETTING_NAME, NM_META_SETTING_TYPE_802_1X), /* 2 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SETTING_NAME, nmc_fields_setting_wireless + 1), /* 3 */ + SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS), /* 3 */ SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS_SECURITY), /* 4 */ SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index c7f7444c8f..280288f262 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -149,7 +149,7 @@ complete_fields (const char *prefix) complete_field_new (h, "connection", NM_META_SETTING_TYPE_CONNECTION); complete_field_new (h, "802-3-ethernet", NM_META_SETTING_TYPE_WIRED); complete_field_new (h, "802-1x", NM_META_SETTING_TYPE_802_1X); - complete_field (h, "802-11-wireless", nmc_fields_setting_wireless); + complete_field_new (h, "802-11-wireless", NM_META_SETTING_TYPE_WIRELESS); complete_field_new (h, "802-11-wireless-security", NM_META_SETTING_TYPE_WIRELESS_SECURITY); complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 310cb639ef..3badd118c0 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -550,45 +550,6 @@ _get_nmc_output_fields (const NmcSettingInfo *setting_info) /*****************************************************************************/ -/* Available fields for NM_SETTING_WIRELESS_SETTING_NAME */ -NmcOutputField nmc_fields_setting_wireless[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SSID), /* 1 */ - SETTING_FIELD (NM_SETTING_WIRELESS_MODE), /* 2 */ - SETTING_FIELD (NM_SETTING_WIRELESS_BAND), /* 3 */ - SETTING_FIELD (NM_SETTING_WIRELESS_CHANNEL), /* 4 */ - SETTING_FIELD (NM_SETTING_WIRELESS_BSSID), /* 5 */ - SETTING_FIELD (NM_SETTING_WIRELESS_RATE), /* 6 */ - SETTING_FIELD (NM_SETTING_WIRELESS_TX_POWER), /* 7 */ - SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS), /* 8 */ - SETTING_FIELD (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), /* 9 */ - SETTING_FIELD (NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK), /* 10 */ - SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), /* 11 */ - SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), /* 12 */ - SETTING_FIELD (NM_SETTING_WIRELESS_MTU), /* 13 */ - SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS), /* 14 */ - SETTING_FIELD (NM_SETTING_WIRELESS_HIDDEN), /* 15 */ - SETTING_FIELD (NM_SETTING_WIRELESS_POWERSAVE), /* 16 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_WIRELESS_ALL "name"","\ - NM_SETTING_WIRELESS_SSID","\ - NM_SETTING_WIRELESS_MODE","\ - NM_SETTING_WIRELESS_BAND","\ - NM_SETTING_WIRELESS_CHANNEL","\ - NM_SETTING_WIRELESS_BSSID","\ - NM_SETTING_WIRELESS_RATE","\ - NM_SETTING_WIRELESS_TX_POWER","\ - NM_SETTING_WIRELESS_MAC_ADDRESS","\ - NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS","\ - NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK","\ - NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST","\ - NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION","\ - NM_SETTING_WIRELESS_MTU","\ - NM_SETTING_WIRELESS_SEEN_BSSIDS","\ - NM_SETTING_WIRELESS_HIDDEN"," \ - NM_SETTING_WIRELESS_POWERSAVE - /* Available fields for NM_SETTING_SERIAL_SETTING_NAME */ NmcOutputField nmc_fields_setting_serial[] = { SETTING_FIELD ("name"), /* 0 */ @@ -1591,12 +1552,6 @@ nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GEr return _property_set_mac (setting, prop, val, FALSE, error); } -static gboolean -nmc_property_set_mac_cloned (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return _property_set_mac (setting, prop, val, TRUE, error); -} - static gboolean nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -4761,6 +4716,7 @@ _describe_fcn_wired_s390_options (const NmcSettingInfo *setting_info, if (G_UNLIKELY (desc == NULL)) { gs_unref_object NMSetting *s = nm_setting_wired_new (); + /* FIXME: we shall not require a dummy setting to get the list of valid options. */ valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (s)); options_str = g_strjoinv (", ", (char **) valid_options); @@ -4774,20 +4730,6 @@ _describe_fcn_wired_s390_options (const NmcSettingInfo *setting_info, } -/* --- NM_SETTING_WIRELESS_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE) -DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND) -DEFINE_GETTER (nmc_property_wireless_get_channel, NM_SETTING_WIRELESS_CHANNEL) -DEFINE_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID) -DEFINE_GETTER (nmc_property_wireless_get_rate, NM_SETTING_WIRELESS_RATE) -DEFINE_GETTER (nmc_property_wireless_get_tx_power, NM_SETTING_WIRELESS_TX_POWER) -DEFINE_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_wireless_get_generate_mac_address_mask, NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK) -DEFINE_GETTER (nmc_property_wireless_get_mac_address_blacklist, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST) -DEFINE_GETTER (nmc_property_wireless_get_seen_bssids, NM_SETTING_WIRELESS_SEEN_BSSIDS) -DEFINE_GETTER (nmc_property_wireless_get_hidden, NM_SETTING_WIRELESS_HIDDEN) - static char * nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4804,19 +4746,6 @@ nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) return ssid_str; } -static char * -nmc_property_wireless_get_mtu (NMSetting *setting, NmcPropertyGetType get_type) -{ - NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); - int mtu; - - mtu = nm_setting_wireless_get_mtu (s_wireless); - if (mtu == 0) - return g_strdup (_("auto")); - else - return g_strdup_printf ("%d", mtu); -} - static char * nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4852,34 +4781,6 @@ nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcProp return g_strdup_printf (_("unknown")); } -/* 'mode' */ -static const char *wifi_valid_modes[] = { - NM_SETTING_WIRELESS_MODE_INFRA, - NM_SETTING_WIRELESS_MODE_ADHOC, - NM_SETTING_WIRELESS_MODE_AP, - NULL -}; - -static gboolean -nmc_property_wifi_set_mode (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wifi_valid_modes, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_mode, wifi_valid_modes) - -/* 'band' */ -static const char *wifi_valid_bands[] = { "a", "bg", NULL }; - -static gboolean -nmc_property_wifi_set_band (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, wifi_valid_bands, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_wifi_allowed_band, wifi_valid_bands) - -/* 'channel' */ static gboolean nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -4931,7 +4832,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wireless_remove_mac_address_blacklis nm_setting_wireless_remove_mac_blacklist_item, _validate_and_remove_wifi_mac_blacklist_item) -/* 'powersave' */ static gboolean nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -6122,124 +6022,6 @@ nmc_properties_init (void) NULL, NULL); - /* Add editable properties for NM_SETTING_WIRELESS_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_SSID, - nmc_property_wireless_get_ssid, - nmc_property_set_ssid, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MODE, - nmc_property_wireless_get_mode, - nmc_property_wifi_set_mode, - NULL, - NULL, - nmc_property_wifi_allowed_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_BAND, - nmc_property_wireless_get_band, - nmc_property_wifi_set_band, - NULL, - NULL, - nmc_property_wifi_allowed_band, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_CHANNEL, - nmc_property_wireless_get_channel, - nmc_property_wifi_set_channel, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_BSSID, - nmc_property_wireless_get_bssid, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - /* - * Do not allow setting 'rate' and 'tx-power'. They are not implemented in - * NM core, nor in ifcfg-rh plugin (thus not preserved over re-reading). - */ - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_RATE, - nmc_property_wireless_get_rate, - NULL, /* editing rate disabled */ - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_TX_POWER, - nmc_property_wireless_get_tx_power, - NULL, /* editing tx-power disabled */ - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS, - nmc_property_wireless_get_mac_address, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, - nmc_property_wireless_get_cloned_mac_address, - nmc_property_set_mac_cloned, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, - nmc_property_wireless_get_generate_mac_address_mask, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, - nmc_property_wireless_get_mac_address_blacklist, - nmc_property_wireless_set_mac_address_blacklist, - nmc_property_wireless_remove_mac_address_blacklist, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_SEEN_BSSIDS, - nmc_property_wireless_get_seen_bssids, - NULL, /* read-only */ - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MTU, - nmc_property_wireless_get_mtu, - nmc_property_set_mtu, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_HIDDEN, - nmc_property_wireless_get_hidden, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_POWERSAVE, - nmc_property_wireless_get_powersave, - nmc_property_wireless_set_powersave, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_WIRELESS_SETTING_NAME""NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, - nmc_property_wireless_get_mac_address_randomization, - nmc_property_wireless_set_mac_address_randomization, - NULL, - NULL, - NULL, - NULL); - /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */ nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MODE, nmc_property_tun_get_mode, @@ -7019,47 +6801,6 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm return TRUE; } -static gboolean -setting_wireless_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE); - - tmpl = nmc_fields_setting_wireless; - tmpl_len = sizeof (nmc_fields_setting_wireless); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_WIRELESS_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_wireless_get_ssid (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_wireless_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_wireless_get_band (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_wireless_get_channel (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_wireless_get_bssid (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_wireless_get_rate (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_wireless_get_tx_power (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_wireless_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_wireless_get_cloned_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_wireless_get_generate_mac_address_mask (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_wireless_get_mac_address_blacklist (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_wireless_get_mac_address_randomization (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_wireless_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - static gboolean setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { @@ -8888,6 +8629,113 @@ static const NmcPropertyInfo properties_setting_wired[] = { }, }; +static const NmcPropertyInfo properties_setting_wireless[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_WIRELESS_SSID), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wireless_get_ssid, + .set_fcn = nmc_property_set_ssid, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_MODE), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_WIRELESS_MODE_INFRA, + NM_SETTING_WIRELESS_MODE_ADHOC, + NM_SETTING_WIRELESS_MODE_AP), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_BAND), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("a", "bg"), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_CHANNEL), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wifi_set_channel, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_BSSID), + .property_type = &_pt_gobject_mac, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_RATE), + /* Do not allow setting 'rate'. It is not implemented in NM core. */ + .property_type = &_pt_gobject_readonly, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_TX_POWER), + /* Do not allow setting 'tx-power'. It is not implemented in NM core. */ + .property_type = &_pt_gobject_readonly, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_MAC_ADDRESS), + .property_type = &_pt_gobject_mac, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), + .property_type = &_pt_gobject_mac_cloned, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_wireless_set_mac_address_blacklist, + .remove_fcn = nmc_property_wireless_remove_mac_address_blacklist, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wireless_get_mac_address_randomization, + .set_fcn = nmc_property_wireless_set_mac_address_randomization, + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_MTU), + .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingWireless, nm_setting_wireless_get_mtu), + ), + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_SEEN_BSSIDS), + .property_type = &_pt_gobject_readonly, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_HIDDEN), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_WIRELESS_POWERSAVE), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_wireless_get_powersave, + .set_fcn = nmc_property_wireless_set_powersave, + ), + }, +}; + static const NmcPropertyInfo properties_setting_wireless_security[] = { PROPERTY_INFO_NAME(), { @@ -9158,7 +9006,8 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_WIRELESS] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS], - .get_setting_details = setting_wireless_details, + .properties = properties_setting_wireless, + .properties_num = G_N_ELEMENTS (properties_setting_wireless), }, [NM_META_SETTING_TYPE_WIRELESS_SECURITY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS_SECURITY], diff --git a/clients/cli/settings.h b/clients/cli/settings.h index c12f858a24..e1c4953d5c 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -165,7 +165,6 @@ gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue * gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); -extern NmcOutputField nmc_fields_setting_wireless[]; extern NmcOutputField nmc_fields_setting_serial[]; extern NmcOutputField nmc_fields_setting_gsm[]; extern NmcOutputField nmc_fields_setting_cdma[]; From e1d60712d93b0cbb7b42d5b78c8f229470e4af50 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 26 Mar 2017 14:30:17 +0200 Subject: [PATCH 28/53] cli: add property-info for the rest --- clients/cli/connections.c | 49 +- clients/cli/nmcli.c | 38 +- clients/cli/settings.c | 3034 +++++++++------------------------- clients/cli/settings.h | 37 +- shared/nm-setting-metadata.c | 5 + shared/nm-setting-metadata.h | 1 + 6 files changed, 830 insertions(+), 2334 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index bf7f1165f6..b750ec97b2 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -148,12 +148,6 @@ NmcOutputField nmc_fields_con_show[] = { #define NMC_FIELDS_CON_SHOW_COMMON "NAME,UUID,TYPE,DEVICE" /* Helper macro to define fields */ -#define SETTING_FIELD(setting, props) \ - { \ - .name = setting, \ - .name_l10n = N_(setting), \ - .group_list = props, \ - } #define SETTING_FIELD_TYPE(setting, setting_type) \ { \ .name = setting, \ @@ -170,34 +164,34 @@ NmcOutputField nmc_fields_settings_names[] = { SETTING_FIELD_TYPE (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_META_SETTING_TYPE_WIRELESS_SECURITY), /* 4 */ SETTING_FIELD_TYPE (NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP4_CONFIG), /* 5 */ SETTING_FIELD_TYPE (NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_META_SETTING_TYPE_IP6_CONFIG), /* 6 */ - SETTING_FIELD (NM_SETTING_SERIAL_SETTING_NAME, nmc_fields_setting_serial + 1), /* 7 */ + SETTING_FIELD_TYPE (NM_SETTING_SERIAL_SETTING_NAME, NM_META_SETTING_TYPE_SERIAL), /* 7 */ SETTING_FIELD_TYPE (NM_SETTING_PPP_SETTING_NAME, NM_META_SETTING_TYPE_PPP), /* 8 */ SETTING_FIELD_TYPE (NM_SETTING_PPPOE_SETTING_NAME, NM_META_SETTING_TYPE_PPPOE), /* 9 */ - SETTING_FIELD (NM_SETTING_GSM_SETTING_NAME, nmc_fields_setting_gsm + 1), /* 10 */ - SETTING_FIELD (NM_SETTING_CDMA_SETTING_NAME, nmc_fields_setting_cdma + 1), /* 11 */ - SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, nmc_fields_setting_bluetooth + 1), /* 12 */ - SETTING_FIELD (NM_SETTING_OLPC_MESH_SETTING_NAME, nmc_fields_setting_olpc_mesh + 1), /* 13 */ - SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, nmc_fields_setting_vpn + 1), /* 14 */ + SETTING_FIELD_TYPE (NM_SETTING_GSM_SETTING_NAME, NM_META_SETTING_TYPE_GSM), /* 10 */ + SETTING_FIELD_TYPE (NM_SETTING_CDMA_SETTING_NAME, NM_META_SETTING_TYPE_CDMA), /* 11 */ + SETTING_FIELD_TYPE (NM_SETTING_BLUETOOTH_SETTING_NAME, NM_META_SETTING_TYPE_BLUETOOTH), /* 12 */ + SETTING_FIELD_TYPE (NM_SETTING_OLPC_MESH_SETTING_NAME, NM_META_SETTING_TYPE_OLPC_MESH), /* 13 */ + SETTING_FIELD_TYPE (NM_SETTING_VPN_SETTING_NAME, NM_META_SETTING_TYPE_VPN), /* 14 */ SETTING_FIELD_TYPE (NM_SETTING_WIMAX_SETTING_NAME, NM_META_SETTING_TYPE_WIMAX), /* 15 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_SETTING_NAME, nmc_fields_setting_infiniband + 1), /* 16 */ - SETTING_FIELD (NM_SETTING_BOND_SETTING_NAME, nmc_fields_setting_bond + 1), /* 17 */ - SETTING_FIELD (NM_SETTING_VLAN_SETTING_NAME, nmc_fields_setting_vlan + 1), /* 18 */ + SETTING_FIELD_TYPE (NM_SETTING_INFINIBAND_SETTING_NAME, NM_META_SETTING_TYPE_INFINIBAND), /* 16 */ + SETTING_FIELD_TYPE (NM_SETTING_BOND_SETTING_NAME, NM_META_SETTING_TYPE_BOND), /* 17 */ + SETTING_FIELD_TYPE (NM_SETTING_VLAN_SETTING_NAME, NM_META_SETTING_TYPE_VLAN), /* 18 */ SETTING_FIELD_TYPE (NM_SETTING_ADSL_SETTING_NAME, NM_META_SETTING_TYPE_ADSL), /* 19 */ - SETTING_FIELD (NM_SETTING_BRIDGE_SETTING_NAME, nmc_fields_setting_bridge + 1), /* 20 */ - SETTING_FIELD (NM_SETTING_BRIDGE_PORT_SETTING_NAME, nmc_fields_setting_bridge_port + 1), /* 21 */ - SETTING_FIELD (NM_SETTING_TEAM_SETTING_NAME, nmc_fields_setting_team + 1), /* 22 */ - SETTING_FIELD (NM_SETTING_TEAM_PORT_SETTING_NAME, nmc_fields_setting_team_port + 1), /* 23 */ + SETTING_FIELD_TYPE (NM_SETTING_BRIDGE_SETTING_NAME, NM_META_SETTING_TYPE_BRIDGE), /* 20 */ + SETTING_FIELD_TYPE (NM_SETTING_BRIDGE_PORT_SETTING_NAME, NM_META_SETTING_TYPE_BRIDGE_PORT), /* 21 */ + SETTING_FIELD_TYPE (NM_SETTING_TEAM_SETTING_NAME, NM_META_SETTING_TYPE_TEAM), /* 22 */ + SETTING_FIELD_TYPE (NM_SETTING_TEAM_PORT_SETTING_NAME, NM_META_SETTING_TYPE_TEAM_PORT), /* 23 */ SETTING_FIELD_TYPE (NM_SETTING_DCB_SETTING_NAME, NM_META_SETTING_TYPE_DCB), /* 24 */ - SETTING_FIELD (NM_SETTING_TUN_SETTING_NAME, nmc_fields_setting_tun + 1), /* 25 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_SETTING_NAME, nmc_fields_setting_ip_tunnel + 1), /* 26 */ - SETTING_FIELD (NM_SETTING_MACSEC_SETTING_NAME, nmc_fields_setting_macsec + 1), /* 27 */ - SETTING_FIELD (NM_SETTING_MACVLAN_SETTING_NAME, nmc_fields_setting_macvlan + 1), /* 28 */ - SETTING_FIELD (NM_SETTING_VXLAN_SETTING_NAME, nmc_fields_setting_vxlan + 1), /* 29 */ + SETTING_FIELD_TYPE (NM_SETTING_TUN_SETTING_NAME, NM_META_SETTING_TYPE_TUN), /* 25 */ + SETTING_FIELD_TYPE (NM_SETTING_IP_TUNNEL_SETTING_NAME, NM_META_SETTING_TYPE_IP_TUNNEL), /* 26 */ + SETTING_FIELD_TYPE (NM_SETTING_MACSEC_SETTING_NAME, NM_META_SETTING_TYPE_MACSEC), /* 27 */ + SETTING_FIELD_TYPE (NM_SETTING_MACVLAN_SETTING_NAME, NM_META_SETTING_TYPE_MACVLAN), /* 28 */ + SETTING_FIELD_TYPE (NM_SETTING_VXLAN_SETTING_NAME, NM_META_SETTING_TYPE_VXLAN), /* 29 */ SETTING_FIELD_TYPE (NM_SETTING_PROXY_SETTING_NAME, NM_META_SETTING_TYPE_PROXY), /* 30 */ - SETTING_FIELD (NM_SETTING_DUMMY_SETTING_NAME, nmc_fields_setting_dummy + 1), /* 31 */ + SETTING_FIELD_TYPE (NM_SETTING_DUMMY_SETTING_NAME, NM_META_SETTING_TYPE_DUMMY), /* 31 */ {NULL, NULL, 0, NULL, NULL, FALSE, FALSE, 0} }; -#define NMC_FIELDS_SETTINGS_NAMES_ALL_X NM_SETTING_CONNECTION_SETTING_NAME","\ +#define NMC_FIELDS_SETTINGS_NAMES_ALL NM_SETTING_CONNECTION_SETTING_NAME","\ NM_SETTING_WIRED_SETTING_NAME","\ NM_SETTING_802_1X_SETTING_NAME","\ NM_SETTING_WIRELESS_SETTING_NAME","\ @@ -227,7 +221,8 @@ NmcOutputField nmc_fields_settings_names[] = { NM_SETTING_MACVLAN_SETTING_NAME"," \ NM_SETTING_VXLAN_SETTING_NAME"," \ NM_SETTING_PROXY_SETTING_NAME -#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X + // NM_SETTING_DUMMY_SETTING_NAME + // NM_SETTING_WIMAX_SETTING_NAME /* Active connection data */ /* Available fields for GENERAL group */ diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index 280288f262..bbc848f7af 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -146,6 +146,8 @@ complete_fields (const char *prefix) complete_field (h, NULL, nmc_fields_dev_show_sections); complete_field (h, NULL, nmc_fields_dev_lldp_list); + /* FIXME: just iterate over the list, but ensure that the setting name + * is identical to setting_info's setting_name. */ complete_field_new (h, "connection", NM_META_SETTING_TYPE_CONNECTION); complete_field_new (h, "802-3-ethernet", NM_META_SETTING_TYPE_WIRED); complete_field_new (h, "802-1x", NM_META_SETTING_TYPE_802_1X); @@ -153,28 +155,30 @@ complete_fields (const char *prefix) complete_field_new (h, "802-11-wireless-security", NM_META_SETTING_TYPE_WIRELESS_SECURITY); complete_field_new (h, "ipv4", NM_META_SETTING_TYPE_IP4_CONFIG); complete_field_new (h, "ipv6", NM_META_SETTING_TYPE_IP6_CONFIG); - complete_field (h, "serial", nmc_fields_setting_serial); + complete_field_new (h, "serial", NM_META_SETTING_TYPE_SERIAL); + complete_field_new (h, "dummy", NM_META_SETTING_TYPE_DUMMY); complete_field_new (h, "ppp", NM_META_SETTING_TYPE_PPP); complete_field_new (h, "pppoe", NM_META_SETTING_TYPE_PPPOE); complete_field_new (h, "adsl", NM_META_SETTING_TYPE_ADSL); - complete_field (h, "gsm", nmc_fields_setting_gsm); - complete_field (h, "cdma", nmc_fields_setting_cdma); - complete_field (h, "bluetooth", nmc_fields_setting_bluetooth); - complete_field (h, "802-11-olpc-mesh", nmc_fields_setting_olpc_mesh); - complete_field (h, "vpn", nmc_fields_setting_vpn); + complete_field_new (h, "gsm", NM_META_SETTING_TYPE_GSM); + complete_field_new (h, "macsec", NM_META_SETTING_TYPE_MACSEC); + complete_field_new (h, "cdma", NM_META_SETTING_TYPE_CDMA); + complete_field_new (h, "bluetooth", NM_META_SETTING_TYPE_BLUETOOTH); + complete_field_new (h, "802-11-olpc-mesh", NM_META_SETTING_TYPE_OLPC_MESH); + complete_field_new (h, "vpn", NM_META_SETTING_TYPE_VPN); complete_field_new (h, "wimax", NM_META_SETTING_TYPE_WIMAX); - complete_field (h, "infiniband", nmc_fields_setting_infiniband); - complete_field (h, "bond", nmc_fields_setting_bond); - complete_field (h, "vlan", nmc_fields_setting_vlan); - complete_field (h, "bridge", nmc_fields_setting_bridge); - complete_field (h, "bridge-port", nmc_fields_setting_bridge_port); - complete_field (h, "team", nmc_fields_setting_team); - complete_field (h, "team-port", nmc_fields_setting_team_port); + complete_field_new (h, "infiniband", NM_META_SETTING_TYPE_INFINIBAND); + complete_field_new (h, "bond", NM_META_SETTING_TYPE_BOND); + complete_field_new (h, "vlan", NM_META_SETTING_TYPE_VLAN); + complete_field_new (h, "bridge", NM_META_SETTING_TYPE_BRIDGE); + complete_field_new (h, "bridge-port", NM_META_SETTING_TYPE_BRIDGE_PORT); + complete_field_new (h, "team", NM_META_SETTING_TYPE_TEAM); + complete_field_new (h, "team-port", NM_META_SETTING_TYPE_TEAM_PORT); complete_field_new (h, "dcb", NM_META_SETTING_TYPE_DCB); - complete_field (h, "tun", nmc_fields_setting_tun); - complete_field (h, "ip-tunnel", nmc_fields_setting_ip_tunnel); - complete_field (h, "macvlan", nmc_fields_setting_macvlan); - complete_field (h, "vxlan", nmc_fields_setting_vxlan); + complete_field_new (h, "tun", NM_META_SETTING_TYPE_TUN); + complete_field_new (h, "ip-tunnel", NM_META_SETTING_TYPE_IP_TUNNEL); + complete_field_new (h, "macvlan", NM_META_SETTING_TYPE_MACVLAN); + complete_field_new (h, "vxlan", NM_META_SETTING_TYPE_VXLAN); complete_field_new (h, "proxy", NM_META_SETTING_TYPE_PROXY); g_hash_table_foreach (h, complete_one, (gpointer) prefix); diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 3badd118c0..27038dd610 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -31,8 +31,6 @@ /*****************************************************************************/ -#define SETTING_FIELD(setting) { setting, N_(setting), 0, NULL, FALSE, FALSE, 0 } - static char *wep_key_type_to_string (NMWepKeyType type); static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); @@ -296,23 +294,6 @@ _set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, return _set_fcn_gobject_uint (setting_info, property_info, setting, value, error); } -static gboolean -_set_fcn_gobject_mac_impl (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - gboolean is_cloned_mac, - GError **error) -{ - if ( (!is_cloned_mac || !NM_CLONED_MAC_IS_SPECIAL (value)) - && !nm_utils_hwaddr_valid (value, ETH_ALEN)) { - g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); - return FALSE; - } - g_object_set (setting, property_info->property_name, value, NULL); - return TRUE; -} - static gboolean _set_fcn_gobject_mac (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -320,17 +301,30 @@ _set_fcn_gobject_mac (const NmcSettingInfo *setting_info, const char *value, GError **error) { - return _set_fcn_gobject_mac_impl (setting_info, property_info, setting, value, FALSE, error); -} + NmcPropertyTypeMacMode mode; + gboolean valid; -static gboolean -_set_fcn_gobject_mac_cloned (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) -{ - return _set_fcn_gobject_mac_impl (setting_info, property_info, setting, value, TRUE, error); + if (property_info->property_typ_data) + mode = property_info->property_typ_data->mac.mode; + else + mode = NMC_PROPERTY_TYPE_MAC_MODE_DEFAULT; + + + if (mode == NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND) + valid = nm_utils_hwaddr_valid (value, INFINIBAND_ALEN); + else { + valid = nm_utils_hwaddr_valid (value, ETH_ALEN) + || ( mode == NMC_PROPERTY_TYPE_MAC_MODE_CLONED + && NM_CLONED_MAC_IS_SPECIAL (value)); + } + + if (!valid) { + g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); + return FALSE; + } + + g_object_set (setting, property_info->property_name, value, NULL); + return TRUE; } static gboolean @@ -550,349 +544,6 @@ _get_nmc_output_fields (const NmcSettingInfo *setting_info) /*****************************************************************************/ -/* Available fields for NM_SETTING_SERIAL_SETTING_NAME */ -NmcOutputField nmc_fields_setting_serial[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_SERIAL_BAUD), /* 1 */ - SETTING_FIELD (NM_SETTING_SERIAL_BITS), /* 2 */ - SETTING_FIELD (NM_SETTING_SERIAL_PARITY), /* 3 */ - SETTING_FIELD (NM_SETTING_SERIAL_STOPBITS), /* 4 */ - SETTING_FIELD (NM_SETTING_SERIAL_SEND_DELAY), /* 5 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_SERIAL_ALL "name"","\ - NM_SETTING_SERIAL_BAUD","\ - NM_SETTING_SERIAL_BITS","\ - NM_SETTING_SERIAL_PARITY","\ - NM_SETTING_SERIAL_STOPBITS","\ - NM_SETTING_SERIAL_SEND_DELAY - -/* Available fields for NM_SETTING_GSM_SETTING_NAME */ -NmcOutputField nmc_fields_setting_gsm[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_GSM_NUMBER), /* 1 */ - SETTING_FIELD (NM_SETTING_GSM_USERNAME), /* 2 */ - SETTING_FIELD (NM_SETTING_GSM_PASSWORD), /* 3 */ - SETTING_FIELD (NM_SETTING_GSM_PASSWORD_FLAGS), /* 4 */ - SETTING_FIELD (NM_SETTING_GSM_APN), /* 5 */ - SETTING_FIELD (NM_SETTING_GSM_NETWORK_ID), /* 6 */ - SETTING_FIELD (NM_SETTING_GSM_PIN), /* 7 */ - SETTING_FIELD (NM_SETTING_GSM_PIN_FLAGS), /* 8 */ - SETTING_FIELD (NM_SETTING_GSM_HOME_ONLY), /* 9 */ - SETTING_FIELD (NM_SETTING_GSM_DEVICE_ID), /* 10 */ - SETTING_FIELD (NM_SETTING_GSM_SIM_ID), /* 11 */ - SETTING_FIELD (NM_SETTING_GSM_SIM_OPERATOR_ID), /* 12 */ - SETTING_FIELD (NM_SETTING_GSM_MTU), /* 13 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_GSM_ALL "name"","\ - NM_SETTING_GSM_NUMBER","\ - NM_SETTING_GSM_USERNAME","\ - NM_SETTING_GSM_PASSWORD","\ - NM_SETTING_GSM_PASSWORD_FLAGS","\ - NM_SETTING_GSM_APN","\ - NM_SETTING_GSM_NETWORK_ID","\ - NM_SETTING_GSM_PIN","\ - NM_SETTING_GSM_PIN_FLAGS","\ - NM_SETTING_GSM_HOME_ONLY","\ - NM_SETTING_GSM_DEVICE_ID","\ - NM_SETTING_GSM_SIM_ID","\ - NM_SETTING_GSM_SIM_OPERATOR_ID","\ - NM_SETTING_GSM_MTU - -/* Available fields for NM_SETTING_CDMA_SETTING_NAME */ -NmcOutputField nmc_fields_setting_cdma[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_CDMA_NUMBER), /* 1 */ - SETTING_FIELD (NM_SETTING_CDMA_USERNAME), /* 2 */ - SETTING_FIELD (NM_SETTING_CDMA_PASSWORD), /* 3 */ - SETTING_FIELD (NM_SETTING_CDMA_PASSWORD_FLAGS), /* 4 */ - SETTING_FIELD (NM_SETTING_CDMA_MTU), /* 5 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_CDMA_ALL "name"","\ - NM_SETTING_CDMA_NUMBER","\ - NM_SETTING_CDMA_USERNAME","\ - NM_SETTING_CDMA_PASSWORD","\ - NM_SETTING_CDMA_PASSWORD_FLAGS","\ - NM_SETTING_CDMA_MTU - -/* Available fields for NM_SETTING_BLUETOOTH_SETTING_NAME */ -NmcOutputField nmc_fields_setting_bluetooth[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_BLUETOOTH_BDADDR), /* 1 */ - SETTING_FIELD (NM_SETTING_BLUETOOTH_TYPE), /* 2 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_BLUETOOTH_ALL "name"","\ - NM_SETTING_BLUETOOTH_BDADDR","\ - NM_SETTING_BLUETOOTH_TYPE - -/* Available fields for NM_SETTING_OLPC_MESH_SETTING_NAME */ -NmcOutputField nmc_fields_setting_olpc_mesh[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_OLPC_MESH_SSID), /* 1 */ - SETTING_FIELD (NM_SETTING_OLPC_MESH_CHANNEL), /* 2 */ - SETTING_FIELD (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), /* 3 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_OLPC_MESH_ALL "name"","\ - NM_SETTING_OLPC_MESH_SSID","\ - NM_SETTING_OLPC_MESH_CHANNEL","\ - NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS - -/* Available fields for NM_SETTING_VPN_SETTING_NAME */ -NmcOutputField nmc_fields_setting_vpn[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_VPN_SERVICE_TYPE), /* 1 */ - SETTING_FIELD (NM_SETTING_VPN_USER_NAME), /* 2 */ - SETTING_FIELD (NM_SETTING_VPN_DATA), /* 3 */ - SETTING_FIELD (NM_SETTING_VPN_SECRETS), /* 4 */ - SETTING_FIELD (NM_SETTING_VPN_PERSISTENT), /* 5 */ - SETTING_FIELD (NM_SETTING_VPN_TIMEOUT), /* 6 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_VPN_ALL "name"","\ - NM_SETTING_VPN_SERVICE_TYPE","\ - NM_SETTING_VPN_USER_NAME","\ - NM_SETTING_VPN_DATA","\ - NM_SETTING_VPN_SECRETS","\ - NM_SETTING_VPN_PERSISTENT","\ - NM_SETTING_VPN_TIMEOUT - -/* Available fields for NM_SETTING_INFINIBAND_SETTING_NAME */ -NmcOutputField nmc_fields_setting_infiniband[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_MAC_ADDRESS), /* 1 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_MTU), /* 2 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_TRANSPORT_MODE), /* 3 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_P_KEY), /* 4 */ - SETTING_FIELD (NM_SETTING_INFINIBAND_PARENT), /* 5 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_INFINIBAND_ALL "name"","\ - NM_SETTING_INFINIBAND_MAC_ADDRESS","\ - NM_SETTING_INFINIBAND_MTU"," \ - NM_SETTING_INFINIBAND_TRANSPORT_MODE"," \ - NM_SETTING_INFINIBAND_P_KEY"," \ - NM_SETTING_INFINIBAND_PARENT - -/* Available fields for NM_SETTING_BOND_SETTING_NAME */ -NmcOutputField nmc_fields_setting_bond[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_BOND_OPTIONS), /* 1 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_BOND_ALL "name"","\ - NM_SETTING_BOND_OPTIONS - -/* Available fields for NM_SETTING_VLAN_SETTING_NAME */ -NmcOutputField nmc_fields_setting_vlan[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_VLAN_PARENT), /* 1 */ - SETTING_FIELD (NM_SETTING_VLAN_ID), /* 2 */ - SETTING_FIELD (NM_SETTING_VLAN_FLAGS), /* 3 */ - SETTING_FIELD (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), /* 4 */ - SETTING_FIELD (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), /* 5 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_VLAN_ALL "name"","\ - NM_SETTING_VLAN_PARENT","\ - NM_SETTING_VLAN_ID","\ - NM_SETTING_VLAN_FLAGS","\ - NM_SETTING_VLAN_INGRESS_PRIORITY_MAP","\ - NM_SETTING_VLAN_EGRESS_PRIORITY_MAP - -/* Available fields for NM_SETTING_BRIDGE_SETTING_NAME */ -NmcOutputField nmc_fields_setting_bridge[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_BRIDGE_MAC_ADDRESS), /* 1 */ - SETTING_FIELD (NM_SETTING_BRIDGE_STP), /* 2 */ - SETTING_FIELD (NM_SETTING_BRIDGE_PRIORITY), /* 3 */ - SETTING_FIELD (NM_SETTING_BRIDGE_FORWARD_DELAY), /* 4 */ - SETTING_FIELD (NM_SETTING_BRIDGE_HELLO_TIME), /* 5 */ - SETTING_FIELD (NM_SETTING_BRIDGE_MAX_AGE), /* 6 */ - SETTING_FIELD (NM_SETTING_BRIDGE_AGEING_TIME), /* 7 */ - SETTING_FIELD (NM_SETTING_BRIDGE_MULTICAST_SNOOPING), /* 8 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_BRIDGE_ALL "name"","\ - NM_SETTING_BRIDGE_MAC_ADDRESS","\ - NM_SETTING_BRIDGE_STP","\ - NM_SETTING_BRIDGE_PRIORITY","\ - NM_SETTING_BRIDGE_FORWARD_DELAY","\ - NM_SETTING_BRIDGE_HELLO_TIME","\ - NM_SETTING_BRIDGE_MAX_AGE","\ - NM_SETTING_BRIDGE_AGEING_TIME","\ - NM_SETTING_BRIDGE_MULTICAST_SNOOPING - -/* Available fields for NM_SETTING_BRIDGE_PORT_SETTING_NAME */ -NmcOutputField nmc_fields_setting_bridge_port[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_BRIDGE_PORT_PRIORITY), /* 1 */ - SETTING_FIELD (NM_SETTING_BRIDGE_PORT_PATH_COST), /* 2 */ - SETTING_FIELD (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE), /* 3 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_BRIDGE_PORT_ALL "name"","\ - NM_SETTING_BRIDGE_PORT_PRIORITY","\ - NM_SETTING_BRIDGE_PORT_PATH_COST","\ - NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE - -/* Available fields for NM_SETTING_TEAM_SETTING_NAME */ -NmcOutputField nmc_fields_setting_team[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_TEAM_CONFIG), /* 1 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_TEAM_ALL "name"","\ - NM_SETTING_TEAM_CONFIG - -/* Available fields for NM_SETTING_TEAM_PORT_SETTING_NAME */ -NmcOutputField nmc_fields_setting_team_port[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_TEAM_PORT_CONFIG), /* 1 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_TEAM_PORT_ALL "name"","\ - NM_SETTING_TEAM_PORT_CONFIG - -/* Available fields for NM_SETTING_DUMMY_SETTING_NAME */ -NmcOutputField nmc_fields_setting_dummy[] = { - SETTING_FIELD ("name"), /* 0 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_DUMMY_ALL "name" - -/* Available fields for NM_SETTING_TUN_SETTING_NAME */ -NmcOutputField nmc_fields_setting_tun[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_TUN_MODE), /* 1 */ - SETTING_FIELD (NM_SETTING_TUN_OWNER), /* 2 */ - SETTING_FIELD (NM_SETTING_TUN_GROUP), /* 3 */ - SETTING_FIELD (NM_SETTING_TUN_PI), /* 4 */ - SETTING_FIELD (NM_SETTING_TUN_VNET_HDR), /* 5 */ - SETTING_FIELD (NM_SETTING_TUN_MULTI_QUEUE), /* 6 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_TUN_ALL "name"","\ - NM_SETTING_TUN_MODE","\ - NM_SETTING_TUN_OWNER","\ - NM_SETTING_TUN_GROUP","\ - NM_SETTING_TUN_PI","\ - NM_SETTING_TUN_VNET_HDR","\ - NM_SETTING_TUN_MULTI_QUEUE - -/* Available fields for NM_SETTING_IP_TUNNEL_SETTING_NAME */ -NmcOutputField nmc_fields_setting_ip_tunnel[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_MODE), /* 1 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_PARENT), /* 2 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_LOCAL), /* 3 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_REMOTE), /* 4 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_TTL), /* 5 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_TOS), /* 6 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), /* 7 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_INPUT_KEY), /* 8 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_OUTPUT_KEY), /* 9 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), /* 10 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_FLOW_LABEL), /* 11 */ - SETTING_FIELD (NM_SETTING_IP_TUNNEL_MTU), /* 12 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_IP_TUNNEL_ALL "name"","\ - NM_SETTING_IP_TUNNEL_MODE","\ - NM_SETTING_IP_TUNNEL_PARENT","\ - NM_SETTING_IP_TUNNEL_LOCAL","\ - NM_SETTING_IP_TUNNEL_REMOTE","\ - NM_SETTING_IP_TUNNEL_TTL","\ - NM_SETTING_IP_TUNNEL_TOS","\ - NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY","\ - NM_SETTING_IP_TUNNEL_INPUT_KEY","\ - NM_SETTING_IP_TUNNEL_OUTPUT_KEY","\ - NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT","\ - NM_SETTING_IP_TUNNEL_FLOW_LABEL","\ - NM_SETTING_IP_TUNNEL_MTU - -/* Available fields for NM_SETTING_MACSEC_SETTING_NAME */ -NmcOutputField nmc_fields_setting_macsec[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_MACSEC_PARENT), /* 1 */ - SETTING_FIELD (NM_SETTING_MACSEC_MODE), /* 2 */ - SETTING_FIELD (NM_SETTING_MACSEC_ENCRYPT), /* 3 */ - SETTING_FIELD (NM_SETTING_MACSEC_MKA_CAK), /* 4 */ - SETTING_FIELD (NM_SETTING_MACSEC_MKA_CAK_FLAGS), /* 5 */ - SETTING_FIELD (NM_SETTING_MACSEC_MKA_CKN), /* 6 */ - SETTING_FIELD (NM_SETTING_MACSEC_PORT), /* 7 */ - SETTING_FIELD (NM_SETTING_MACSEC_VALIDATION), /* 8 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_MACSEC_ALL "name"","\ - NM_SETTING_MACSEC_PARENT","\ - NM_SETTING_MACSEC_MODE","\ - NM_SETTING_MACSEC_ENCRYPT","\ - NM_SETTING_MACSEC_MKA_CAK","\ - NM_SETTING_MACSEC_MKA_CAK_FLAGS","\ - NM_SETTING_MACSEC_MKA_CKN","\ - NM_SETTING_MACSEC_PORT","\ - NM_SETTING_MACSEC_VALIDATION - -/* Available fields for NM_SETTING_MACVLAN_SETTING_NAME */ -NmcOutputField nmc_fields_setting_macvlan[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_MACVLAN_PARENT), /* 1 */ - SETTING_FIELD (NM_SETTING_MACVLAN_MODE), /* 2 */ - SETTING_FIELD (NM_SETTING_MACVLAN_PROMISCUOUS), /* 3 */ - SETTING_FIELD (NM_SETTING_MACVLAN_TAP), /* 4 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_MACVLAN_ALL "name"","\ - NM_SETTING_MACVLAN_PARENT","\ - NM_SETTING_MACVLAN_MODE","\ - NM_SETTING_MACVLAN_PROMISCUOUS","\ - NM_SETTING_MACVLAN_TAP - -/* Available fields for NM_SETTING_VXLAN_SETTING_NAME */ -NmcOutputField nmc_fields_setting_vxlan[] = { - SETTING_FIELD ("name"), /* 0 */ - SETTING_FIELD (NM_SETTING_VXLAN_PARENT), /* 1 */ - SETTING_FIELD (NM_SETTING_VXLAN_ID), /* 2 */ - SETTING_FIELD (NM_SETTING_VXLAN_LOCAL), /* 3 */ - SETTING_FIELD (NM_SETTING_VXLAN_REMOTE), /* 4 */ - SETTING_FIELD (NM_SETTING_VXLAN_SOURCE_PORT_MIN), /* 5 */ - SETTING_FIELD (NM_SETTING_VXLAN_SOURCE_PORT_MAX), /* 6 */ - SETTING_FIELD (NM_SETTING_VXLAN_DESTINATION_PORT), /* 7 */ - SETTING_FIELD (NM_SETTING_VXLAN_TOS), /* 8 */ - SETTING_FIELD (NM_SETTING_VXLAN_TTL), /* 9 */ - SETTING_FIELD (NM_SETTING_VXLAN_AGEING), /* 10 */ - SETTING_FIELD (NM_SETTING_VXLAN_LIMIT), /* 11 */ - SETTING_FIELD (NM_SETTING_VXLAN_LEARNING), /* 12 */ - SETTING_FIELD (NM_SETTING_VXLAN_PROXY), /* 13 */ - SETTING_FIELD (NM_SETTING_VXLAN_RSC), /* 14 */ - SETTING_FIELD (NM_SETTING_VXLAN_L2_MISS), /* 15 */ - SETTING_FIELD (NM_SETTING_VXLAN_L3_MISS), /* 16 */ - {NULL, NULL, 0, NULL, FALSE, FALSE, 0} -}; -#define NMC_FIELDS_SETTING_VXLAN_ALL "name"","\ - NM_SETTING_VXLAN_PARENT","\ - NM_SETTING_VXLAN_ID","\ - NM_SETTING_VXLAN_LOCAL","\ - NM_SETTING_VXLAN_REMOTE","\ - NM_SETTING_VXLAN_SOURCE_PORT_MIN","\ - NM_SETTING_VXLAN_SOURCE_PORT_MAX","\ - NM_SETTING_VXLAN_DESTINATION_PORT","\ - NM_SETTING_VXLAN_TOS","\ - NM_SETTING_VXLAN_TTL","\ - NM_SETTING_VXLAN_AGEING","\ - NM_SETTING_VXLAN_LIMIT","\ - NM_SETTING_VXLAN_LEARNING","\ - NM_SETTING_VXLAN_PROXY","\ - NM_SETTING_VXLAN_RSC","\ - NM_SETTING_VXLAN_L2_MISS","\ - NM_SETTING_VXLAN_L3_MISS - -/*****************************************************************************/ - static char * wep_key_type_to_string (NMWepKeyType type) { @@ -1056,59 +707,6 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) g_string_append_printf (ret_str, "%s = %s", key, value); } - -/* generic helper macros for property functions */ -#define DEFINE_GETTER(func_name, property_name) \ - static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ - { \ - char *s; \ - GValue val = G_VALUE_INIT; \ - g_value_init (&val, G_TYPE_STRING); \ - g_object_get_property (G_OBJECT (setting), property_name, &val); \ - s = g_value_dup_string (&val); \ - g_value_unset (&val); \ - return s; \ - } - -#define DEFINE_GETTER_WITH_DEFAULT(func_name, property_name, check_is_default) \ - static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ - { \ - const char *s; \ - char *s_full; \ - GValue val = G_VALUE_INIT; \ - \ - if ((check_is_default)) { \ - if (get_type == NMC_PROPERTY_GET_PARSABLE) \ - return g_strdup (""); \ - return g_strdup (_("(default)")); \ - } \ - \ - g_value_init (&val, G_TYPE_STRING); \ - g_object_get_property (G_OBJECT (setting), property_name, &val); \ - s = g_value_get_string (&val); \ - if (get_type == NMC_PROPERTY_GET_PARSABLE) \ - s_full = g_strdup (s && *s ? s : " "); \ - else \ - s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); \ - g_value_unset (&val); \ - return s_full; \ - } - -#define DEFINE_SECRET_FLAGS_GETTER(func_name, property_name) \ - static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ - { \ - guint v; \ - GValue val = G_VALUE_INIT; \ - g_value_init (&val, G_TYPE_UINT); \ - g_object_get_property (G_OBJECT (setting), property_name, &val); \ - v = g_value_get_uint (&val); \ - g_value_unset (&val); \ - return secret_flags_to_string (v, get_type); \ - } - #define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \ static gboolean \ def_func (NMSetting *setting, \ @@ -1431,54 +1029,6 @@ check_and_set_string (NMSetting *setting, return TRUE; } -/* --- generic property setter functions --- */ -static gboolean -nmc_property_set_string (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - g_object_set (setting, prop, val, NULL); - return TRUE; -} - -static gboolean -nmc_property_set_uint (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - unsigned long val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_uint (setting, prop, (guint) val_int, error)) - return FALSE; - - g_object_set (setting, prop, (guint) val_int, NULL); - return TRUE; -} - -static gboolean -nmc_property_set_int (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - long int val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_int (val, TRUE, G_MININT, G_MAXINT, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_int (setting, prop, (gint) val_int, error)) - return FALSE; - - g_object_set (setting, prop, (gint) val_int, NULL); - return TRUE; -} - static gboolean nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -1499,20 +1049,6 @@ nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, G return TRUE; } -static gboolean -nmc_property_set_bool (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - gboolean val_bool; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_bool (val, &val_bool, error)) - return FALSE; - - g_object_set (setting, prop, val_bool, NULL); - return TRUE; -} - static gboolean nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -1531,38 +1067,6 @@ nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GE return TRUE; } -static gboolean -_property_set_mac (NMSetting *setting, const char *prop, const char *val, gboolean cloned_mac_addr, GError **error) -{ - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if ( (!cloned_mac_addr || !NM_CLONED_MAC_IS_SPECIAL (val)) - && !nm_utils_hwaddr_valid (val, ETH_ALEN)) { - g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val); - return FALSE; - } - - g_object_set (setting, prop, val, NULL); - return TRUE; -} - -static gboolean -nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return _property_set_mac (setting, prop, val, FALSE, error); -} - -static gboolean -nmc_property_set_mtu (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - const char *mtu = val; - - if (strcmp (mtu, "auto") == 0) - mtu = "0"; - - return nmc_property_set_uint (setting, prop, mtu, error); -} - static gboolean nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -1574,36 +1078,6 @@ nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, return TRUE; } -static gboolean -nmc_property_set_secret_flags (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - char **strv = NULL, **iter; - unsigned long flags = 0, val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - strv = nmc_strsplit_set (val, " \t,", 0); - for (iter = strv; iter && *iter; iter++) { - if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"), - *iter, ALL_SECRET_FLAGS); - g_strfreev (strv); - return FALSE; - } - flags += val_int; - } - g_strfreev (strv); - - /* Validate the flags number */ - if (flags > ALL_SECRET_FLAGS) { - flags = ALL_SECRET_FLAGS; - g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), val); - } - - g_object_set (setting, prop, (guint) flags, NULL); - return TRUE; -} - static gboolean nmc_property_set_vpn_service (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -2071,24 +1545,6 @@ nmc_property_802_1X_set_phase1_auth_flags (NMSetting *setting, const char *prop, return TRUE; } -/* --- NM_SETTING_BLUETOOTH_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR) -DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE) - -/* 'type' */ -static gboolean -nmc_property_bluetooth_set_type (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - const char *types[] = { - NM_SETTING_BLUETOOTH_TYPE_DUN, - NM_SETTING_BLUETOOTH_TYPE_PANU, - NULL }; - - return check_and_set_string (setting, prop, val, types, error); -} - -/* --- NM_SETTING_BOND_SETTING_NAME property functions --- */ -/* 'options' */ static char * nmc_property_bond_get_options (NMSetting *setting, NmcPropertyGetType get_type) { @@ -2174,14 +1630,15 @@ DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options, _validate_and_remove_bond_option) static const char * -nmc_property_bond_describe_options (NMSetting *setting, const char *prop) +_describe_fcn_bond_options (const NmcSettingInfo *setting_info, + const NmcPropertyInfo *property_info) { static char *desc = NULL; const char **valid_options; char *options_str; if (G_UNLIKELY (desc == NULL)) { - valid_options = nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting)); + valid_options = nm_setting_bond_get_valid_options (NULL); options_str = g_strjoinv (", ", (char **) valid_options); desc = g_strdup_printf (_("Enter a list of bonding options formatted as:\n" @@ -2207,32 +1664,6 @@ nmc_property_bond_allowed_options (NMSetting *setting, const char *prop) return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting)); } - -/* --- NM_SETTING_BRIDGE_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP) -DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY) -DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_DELAY) -DEFINE_GETTER (nmc_property_bridge_get_hello_time, NM_SETTING_BRIDGE_HELLO_TIME) -DEFINE_GETTER (nmc_property_bridge_get_max_age, NM_SETTING_BRIDGE_MAX_AGE) -DEFINE_GETTER (nmc_property_bridge_get_ageing_time, NM_SETTING_BRIDGE_AGEING_TIME) -DEFINE_GETTER (nmc_property_bridge_get_multicast_snooping, NM_SETTING_BRIDGE_MULTICAST_SNOOPING) - - -/* --- NM_SETTING_BRIDGE_PORT_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_bridge_port_get_priority, NM_SETTING_BRIDGE_PORT_PRIORITY) -DEFINE_GETTER (nmc_property_bridge_port_get_path_cost, NM_SETTING_BRIDGE_PORT_PATH_COST) -DEFINE_GETTER (nmc_property_bridge_port_get_hairpin_mode, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE) - - -/* --- NM_SETTING_CDMA_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_cdma_get_number, NM_SETTING_CDMA_NUMBER) -DEFINE_GETTER (nmc_property_cdma_get_username, NM_SETTING_CDMA_USERNAME) -DEFINE_GETTER (nmc_property_cdma_get_password, NM_SETTING_CDMA_PASSWORD) -DEFINE_GETTER (nmc_property_cdma_get_mtu, NM_SETTING_CDMA_MTU) - -DEFINE_SECRET_FLAGS_GETTER (nmc_property_cdma_get_password_flags, NM_SETTING_CDMA_PASSWORD_FLAGS) - static char * nmc_property_connection_get_autoconnect_retries (NMSetting *setting, NmcPropertyGetType get_type) { @@ -2985,21 +2416,6 @@ nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, con return TRUE; } -/* --- NM_SETTING_GSM_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_gsm_get_number, NM_SETTING_GSM_NUMBER) -DEFINE_GETTER (nmc_property_gsm_get_username, NM_SETTING_GSM_USERNAME) -DEFINE_GETTER (nmc_property_gsm_get_password, NM_SETTING_GSM_PASSWORD) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_password_flags, NM_SETTING_GSM_PASSWORD_FLAGS) -DEFINE_GETTER (nmc_property_gsm_get_apn, NM_SETTING_GSM_APN) -DEFINE_GETTER (nmc_property_gsm_get_network_id, NM_SETTING_GSM_NETWORK_ID) -DEFINE_GETTER (nmc_property_gsm_get_pin, NM_SETTING_GSM_PIN) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_FLAGS) -DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY) -DEFINE_GETTER (nmc_property_gsm_get_device_id, NM_SETTING_GSM_DEVICE_ID) -DEFINE_GETTER (nmc_property_gsm_get_sim_id, NM_SETTING_GSM_SIM_ID) -DEFINE_GETTER (nmc_property_gsm_get_sim_operator_id, NM_SETTING_GSM_SIM_OPERATOR_ID) -DEFINE_GETTER (nmc_property_gsm_get_mtu, NM_SETTING_GSM_MTU) - static gboolean nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -3025,38 +2441,6 @@ nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, cons return TRUE; } - -/* --- NM_SETTING_INFINIBAND_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS) -DEFINE_GETTER (nmc_property_ib_get_transport_mode, NM_SETTING_INFINIBAND_TRANSPORT_MODE) - -/* 'mac-address' */ -static gboolean -nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) { - g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val); - return FALSE; - } - - g_object_set (setting, prop, val, NULL); - return TRUE; -} - -/* 'transport-mode' */ -static const char *ib_valid_transport_modes[] = { "datagram", "connected", NULL }; - -static gboolean -nmc_property_ib_set_transport_mode (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_set_string (setting, prop, val, ib_valid_transport_modes, error); -} - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_ib_allowed_transport_mode, ib_valid_transport_modes) - -/* 'p-key' */ static gboolean nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -3083,19 +2467,6 @@ nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val } -static char * -nmc_property_ib_get_mtu (NMSetting *setting, NmcPropertyGetType get_type) -{ - NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting); - int mtu; - - mtu = nm_setting_infiniband_get_mtu (s_infiniband); - if (mtu == 0) - return g_strdup (_("auto")); - else - return g_strdup_printf ("%d", mtu); -} - static char * nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type) { @@ -3103,28 +2474,15 @@ nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type) int p_key; p_key = nm_setting_infiniband_get_p_key (s_infiniband); - if (p_key == -1) - return g_strdup (_("default")); - else + if (p_key == -1) { + if (get_type == NMC_PROPERTY_GET_PARSABLE) + return g_strdup ("default"); + else + return g_strdup (_("default")); + } else return g_strdup_printf ("0x%04x", p_key); } -DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT) - - -/* --- NM_SETTING_IP_TUNNEL_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_ip_tunnel_get_parent, NM_SETTING_IP_TUNNEL_PARENT); -DEFINE_GETTER (nmc_property_ip_tunnel_get_local, NM_SETTING_IP_TUNNEL_LOCAL); -DEFINE_GETTER (nmc_property_ip_tunnel_get_remote, NM_SETTING_IP_TUNNEL_REMOTE); -DEFINE_GETTER (nmc_property_ip_tunnel_get_ttl, NM_SETTING_IP_TUNNEL_TTL); -DEFINE_GETTER (nmc_property_ip_tunnel_get_tos, NM_SETTING_IP_TUNNEL_TOS); -DEFINE_GETTER (nmc_property_ip_tunnel_get_path_mtu_discovery, NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY); -DEFINE_GETTER (nmc_property_ip_tunnel_get_input_key, NM_SETTING_IP_TUNNEL_INPUT_KEY); -DEFINE_GETTER (nmc_property_ip_tunnel_get_output_key, NM_SETTING_IP_TUNNEL_OUTPUT_KEY); -DEFINE_GETTER (nmc_property_ip_tunnel_get_encapsulation_limit, NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT); -DEFINE_GETTER (nmc_property_ip_tunnel_get_flow_label, NM_SETTING_IP_TUNNEL_FLOW_LABEL); -DEFINE_GETTER (nmc_property_ip_tunnel_get_mtu, NM_SETTING_IP_TUNNEL_MTU); - static char * nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type) { @@ -3972,15 +3330,6 @@ _set_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, return TRUE; } -/* --- NM_SETTING_MACSEC_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_macsec_get_parent, NM_SETTING_MACSEC_PARENT) -DEFINE_GETTER (nmc_property_macsec_get_encrypt, NM_SETTING_MACSEC_ENCRYPT) -DEFINE_GETTER (nmc_property_macsec_get_mka_cak, NM_SETTING_MACSEC_MKA_CAK) -DEFINE_SECRET_FLAGS_GETTER (nmc_property_macsec_get_mka_cak_flags, NM_SETTING_MACSEC_MKA_CAK_FLAGS) -DEFINE_GETTER (nmc_property_macsec_get_mka_ckn, NM_SETTING_MACSEC_MKA_CKN) -DEFINE_GETTER (nmc_property_macsec_get_port, NM_SETTING_MACSEC_PORT) - -/* 'mode' */ static char * nmc_property_macsec_get_mode (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4054,12 +3403,6 @@ DEFINE_ALLOWED_FOR_ENUMS (nmc_property_macsec_allowed_validation, nm_setting_macsec_validation_get_type, G_MININT, G_MAXINT) - -/* --- NM_SETTING_MACVLAN_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_macvlan_get_parent, NM_SETTING_MACVLAN_PARENT) -DEFINE_GETTER (nmc_property_macvlan_get_promiscuous, NM_SETTING_MACVLAN_PROMISCUOUS) -DEFINE_GETTER (nmc_property_macvlan_get_tap, NM_SETTING_MACVLAN_TAP) - static char * nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4114,11 +3457,6 @@ DEFINE_ALLOWED_FOR_ENUMS (nmc_property_macvlan_allowed_mode, nm_setting_macvlan_mode_get_type, NM_SETTING_MACVLAN_MODE_UNKNOWN + 1, G_MAXINT) - -/* --- NM_SETTING_OLPC_MESH_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_olpc_get_channel, NM_SETTING_OLPC_MESH_CHANNEL) -DEFINE_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS) - static char * nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4208,13 +3546,6 @@ nmc_property_proxy_set_pac_script (NMSetting *setting, const char *prop, return TRUE; } - -/* --- NM_SETTING_SERIAL_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_serial_get_baud, NM_SETTING_SERIAL_BAUD) -DEFINE_GETTER (nmc_property_serial_get_bits, NM_SETTING_SERIAL_BITS) -DEFINE_GETTER (nmc_property_serial_get_stopbits, NM_SETTING_SERIAL_STOPBITS) -DEFINE_GETTER (nmc_property_serial_get_send_delay, NM_SETTING_SERIAL_SEND_DELAY) - static char * nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4251,10 +3582,6 @@ nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char return TRUE; } - -/* --- NM_SETTING_TEAM_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG) - static gboolean nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error) { @@ -4270,29 +3597,6 @@ nmc_property_team_set_config (NMSetting *setting, const char *prop, const char * return TRUE; } -static const char * -nmc_property_team_describe_config (NMSetting *setting, const char *prop) -{ - return _("nmcli can accepts both direct JSON configuration data and a file name containing " - "the configuration. In the latter case the file is read and the contents is put " - "into this property.\n\n" - "Examples: set team.config " - "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n" - " set team.config /etc/my-team.conf\n"); -} - - -/* --- NM_SETTING_TEAM_PORT_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_team_port_get_config, NM_SETTING_TEAM_PORT_CONFIG) - - -/* --- NM_SETTING_TUN_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_tun_get_owner, NM_SETTING_TUN_OWNER); -DEFINE_GETTER (nmc_property_tun_get_group, NM_SETTING_TUN_GROUP); -DEFINE_GETTER (nmc_property_tun_get_pi, NM_SETTING_TUN_PI); -DEFINE_GETTER (nmc_property_tun_get_vnet_hdr, NM_SETTING_TUN_VNET_HDR); -DEFINE_GETTER (nmc_property_tun_get_multi_queue, NM_SETTING_TUN_MULTI_QUEUE); - static char * nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4339,11 +3643,6 @@ static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL }; DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes) - -/* --- NM_SETTING_VLAN_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_vlan_get_parent, NM_SETTING_VLAN_PARENT) -DEFINE_GETTER (nmc_property_vlan_get_id, NM_SETTING_VLAN_ID) - static char * nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4486,11 +3785,6 @@ nmc_property_vlan_remove_egress_priority_map (NMSetting *setting, error); } - -/* --- NM_SETTING_VPN_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_vpn_get_service_type, NM_SETTING_VPN_SERVICE_TYPE) -DEFINE_GETTER (nmc_property_vpn_get_user_name, NM_SETTING_VPN_USER_NAME) - static char * nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4515,10 +3809,6 @@ nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type) return g_string_free (secret_str, FALSE); } -DEFINE_GETTER (nmc_property_vpn_get_persistent, NM_SETTING_VPN_PERSISTENT) -DEFINE_GETTER (nmc_property_vpn_get_timeout, NM_SETTING_VPN_TIMEOUT) - -/* Validate value of vpn 'data' and 'secret' options */ static const char * _validate_vpn_hash_value (const char *option, const char *value, GError **error) { @@ -4551,25 +3841,6 @@ DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret, NM_SETTING_VPN, nm_setting_vpn_remove_secret) - -/* --- NM_SETTING_VXLAN_SETTING_NAME property functions --- */ -DEFINE_GETTER (nmc_property_vxlan_get_parent, NM_SETTING_VXLAN_PARENT) -DEFINE_GETTER (nmc_property_vxlan_get_id, NM_SETTING_VXLAN_ID) -DEFINE_GETTER (nmc_property_vxlan_get_local, NM_SETTING_VXLAN_LOCAL) -DEFINE_GETTER (nmc_property_vxlan_get_remote, NM_SETTING_VXLAN_REMOTE) -DEFINE_GETTER (nmc_property_vxlan_get_source_port_min, NM_SETTING_VXLAN_SOURCE_PORT_MIN) -DEFINE_GETTER (nmc_property_vxlan_get_source_port_max, NM_SETTING_VXLAN_SOURCE_PORT_MAX) -DEFINE_GETTER (nmc_property_vxlan_get_destination_port, NM_SETTING_VXLAN_DESTINATION_PORT) -DEFINE_GETTER (nmc_property_vxlan_get_tos, NM_SETTING_VXLAN_TOS) -DEFINE_GETTER (nmc_property_vxlan_get_ttl, NM_SETTING_VXLAN_TTL) -DEFINE_GETTER (nmc_property_vxlan_get_ageing, NM_SETTING_VXLAN_AGEING) -DEFINE_GETTER (nmc_property_vxlan_get_limit, NM_SETTING_VXLAN_LIMIT) -DEFINE_GETTER (nmc_property_vxlan_get_learning, NM_SETTING_VXLAN_LEARNING) -DEFINE_GETTER (nmc_property_vxlan_get_proxy, NM_SETTING_VXLAN_PROXY) -DEFINE_GETTER (nmc_property_vxlan_get_rsc, NM_SETTING_VXLAN_RSC) -DEFINE_GETTER (nmc_property_vxlan_get_l2_miss, NM_SETTING_VXLAN_L2_MISS) -DEFINE_GETTER (nmc_property_vxlan_get_l3_miss, NM_SETTING_VXLAN_L3_MISS) - static char * nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type) { @@ -4714,10 +3985,8 @@ _describe_fcn_wired_s390_options (const NmcSettingInfo *setting_info, char *options_str; if (G_UNLIKELY (desc == NULL)) { - gs_unref_object NMSetting *s = nm_setting_wired_new (); + valid_options = nm_setting_wired_get_valid_s390_options (NULL); - /* FIXME: we shall not require a dummy setting to get the list of valid options. */ - valid_options = nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (s)); options_str = g_strjoinv (", ", (char **) valid_options); desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n" @@ -5176,27 +4445,6 @@ register_nmcli_value_transforms (void) /*****************************************************************************/ -/* Main hash table storing function pointer for manipulating properties */ -static GHashTable *nmc_properties = NULL; -typedef char * (*NmcPropertyGetFunc) (NMSetting *, NmcPropertyGetType); -typedef gboolean (*NmcPropertySetFunc) (NMSetting *, const char *, const char *, GError **); -typedef gboolean (*NmcPropertyRemoveFunc) (NMSetting *, const char *, const char *, guint32, GError **); -typedef const char * (*NmcPropertyDescribeFunc) (NMSetting *, const char *); -typedef const char *const* (*NmcPropertyValuesFunc) (NMSetting *, const char *); - -typedef struct { - /* The order of the fields is important as they correspond - * to the order as _nmc_add_prop_funcs() passes the arguments. */ -#define NmcPropertyFuncsFields \ - NmcPropertyGetFunc get_func; /* func getting property values */ \ - NmcPropertySetFunc set_func; /* func adding/setting property values */ \ - NmcPropertyRemoveFunc remove_func; /* func removing items from container options */ \ - NmcPropertyDescribeFunc describe_func; /* func returning property description */ \ - NmcPropertyValuesFunc values_func; /* func returning allowed property values */ \ - ; - NmcPropertyFuncsFields -} NmcPropertyFuncs; - NMSetting * nmc_setting_new_for_name (const char *name) { @@ -5552,853 +4800,20 @@ nmc_setting_custom_init (NMSetting *setting) /*****************************************************************************/ -static inline void -_nmc_add_prop_funcs (const char *key, - const NmcPropertyFuncs *item_init) -{ - NmcPropertyFuncs *item; - - item = g_malloc (sizeof (NmcPropertyFuncs)); - *item = *item_init; - g_hash_table_insert (nmc_properties, (gpointer) key, item); -} - -#define nmc_add_prop_funcs(key, ...) \ - G_STMT_START { \ - struct { \ - NmcPropertyFuncsFields; \ - /* The _dummy field is here so that the last argument can be always - * NULL. That means every call to nmc_add_prop_funcs() below ends - * with a separate line "NULL);". */ \ - gpointer _dummy; \ - } _item_init = { \ - __VA_ARGS__ \ - };\ - \ - nm_assert (_item_init._dummy == NULL); \ - _nmc_add_prop_funcs ("" key, (NmcPropertyFuncs *) &_item_init); \ - } G_STMT_END - -void -nmc_properties_init (void) -{ - if (G_LIKELY (nmc_properties)) - return; - - /* create properties hash table */ - nmc_properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); - - /* Add editable properties for NM_SETTING_BLUETOOTH_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_BLUETOOTH_SETTING_NAME""NM_SETTING_BLUETOOTH_BDADDR, - nmc_property_bluetooth_get_bdaddr, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BLUETOOTH_SETTING_NAME""NM_SETTING_BLUETOOTH_TYPE, - nmc_property_bluetooth_get_type, - nmc_property_bluetooth_set_type, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_BOND_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_BOND_SETTING_NAME""NM_SETTING_BOND_OPTIONS, - nmc_property_bond_get_options, - nmc_property_bond_set_options, - nmc_property_bond_remove_option_options, - nmc_property_bond_describe_options, - nmc_property_bond_allowed_options, - NULL); - - /* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MAC_ADDRESS, - nmc_property_bridge_get_mac_address, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_STP, - nmc_property_bridge_get_stp, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_PRIORITY, - nmc_property_bridge_get_priority, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_FORWARD_DELAY, - nmc_property_bridge_get_forward_delay, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_HELLO_TIME, - nmc_property_bridge_get_hello_time, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MAX_AGE, - nmc_property_bridge_get_max_age, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_AGEING_TIME, - nmc_property_bridge_get_ageing_time, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - nmc_add_prop_funcs (NM_SETTING_BRIDGE_SETTING_NAME""NM_SETTING_BRIDGE_MULTICAST_SNOOPING, - nmc_property_bridge_get_multicast_snooping, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_BRIDGE_PORT_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_PRIORITY, - nmc_property_bridge_port_get_priority, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_PATH_COST, - nmc_property_bridge_port_get_path_cost, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_BRIDGE_PORT_SETTING_NAME""NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, - nmc_property_bridge_port_get_hairpin_mode, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_CDMA_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_NUMBER, - nmc_property_cdma_get_number, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_USERNAME, - nmc_property_cdma_get_username, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_PASSWORD, - nmc_property_cdma_get_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_PASSWORD_FLAGS, - nmc_property_cdma_get_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_CDMA_SETTING_NAME""NM_SETTING_CDMA_MTU, - nmc_property_cdma_get_mtu, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_GSM_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_NUMBER, - nmc_property_gsm_get_number, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_USERNAME, - nmc_property_gsm_get_username, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PASSWORD, - nmc_property_gsm_get_password, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PASSWORD_FLAGS, - nmc_property_gsm_get_password_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_APN, - nmc_property_gsm_get_apn, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_NETWORK_ID, - nmc_property_gsm_get_network_id, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PIN, - nmc_property_gsm_get_pin, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_PIN_FLAGS, - nmc_property_gsm_get_pin_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_HOME_ONLY, - nmc_property_gsm_get_home_only, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_DEVICE_ID, - nmc_property_gsm_get_device_id, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_SIM_ID, - nmc_property_gsm_get_sim_id, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_SIM_OPERATOR_ID, - nmc_property_gsm_get_sim_operator_id, - nmc_property_gsm_set_sim_operator_id, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_GSM_SETTING_NAME""NM_SETTING_GSM_MTU, - nmc_property_gsm_get_mtu, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_INFINIBAND_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_MAC_ADDRESS, - nmc_property_ib_get_mac_address, - nmc_property_ib_set_mac, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_MTU, - nmc_property_ib_get_mtu, - nmc_property_set_mtu, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_TRANSPORT_MODE, - nmc_property_ib_get_transport_mode, - nmc_property_ib_set_transport_mode, - NULL, - NULL, - nmc_property_ib_allowed_transport_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_P_KEY, - nmc_property_ib_get_p_key, - nmc_property_ib_set_p_key, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_INFINIBAND_SETTING_NAME""NM_SETTING_INFINIBAND_PARENT, - nmc_property_ib_get_parent, - nmc_property_set_ifname, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_OLPC_MESH_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_SSID, - nmc_property_olpc_get_ssid, - nmc_property_set_ssid, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_CHANNEL, - nmc_property_olpc_get_channel, - nmc_property_olpc_set_channel, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_OLPC_MESH_SETTING_NAME""NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, - nmc_property_olpc_get_anycast_address, - nmc_property_set_mac, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_SERIAL_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BAUD, - nmc_property_serial_get_baud, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_BITS, - nmc_property_serial_get_bits, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_PARITY, - nmc_property_serial_get_parity, - nmc_property_serial_set_parity, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_STOPBITS, - nmc_property_serial_get_stopbits, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_SERIAL_SETTING_NAME""NM_SETTING_SERIAL_SEND_DELAY, - nmc_property_serial_get_send_delay, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_TEAM_SETTING_NAME""NM_SETTING_TEAM_CONFIG, - nmc_property_team_get_config, - nmc_property_team_set_config, - NULL, - nmc_property_team_describe_config, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_TEAM_PORT_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_TEAM_PORT_SETTING_NAME""NM_SETTING_TEAM_PORT_CONFIG, - nmc_property_team_port_get_config, - nmc_property_team_set_config, - NULL, - nmc_property_team_describe_config, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_PARENT, - nmc_property_vlan_get_parent, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_ID, - nmc_property_vlan_get_id, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_FLAGS, - nmc_property_vlan_get_flags, - nmc_property_set_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, - nmc_property_vlan_get_ingress_priority_map, - nmc_property_vlan_set_ingress_priority_map, - nmc_property_vlan_remove_ingress_priority_map, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VLAN_SETTING_NAME""NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, - nmc_property_vlan_get_egress_priority_map, - nmc_property_vlan_set_egress_priority_map, - nmc_property_vlan_remove_egress_priority_map, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_VPN_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_SERVICE_TYPE, - nmc_property_vpn_get_service_type, - nmc_property_set_vpn_service, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_USER_NAME, - nmc_property_vpn_get_user_name, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_DATA, - nmc_property_vpn_get_data, - nmc_property_vpn_set_data, - nmc_property_vpn_remove_option_data, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_SECRETS, - nmc_property_vpn_get_secrets, - nmc_property_vpn_set_secrets, - nmc_property_vpn_remove_option_secret, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_PERSISTENT, - nmc_property_vpn_get_persistent, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - - nmc_add_prop_funcs (NM_SETTING_VPN_SETTING_NAME""NM_SETTING_VPN_TIMEOUT, - nmc_property_vpn_get_timeout, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_TUN_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MODE, - nmc_property_tun_get_mode, - nmc_property_tun_set_mode, - NULL, - NULL, - nmc_property_tun_allowed_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_OWNER, - nmc_property_tun_get_owner, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_GROUP, - nmc_property_tun_get_group, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_PI, - nmc_property_tun_get_pi, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_VNET_HDR, - nmc_property_tun_get_vnet_hdr, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_TUN_SETTING_NAME""NM_SETTING_TUN_MULTI_QUEUE, - nmc_property_tun_get_multi_queue, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_IP_TUNNEL_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_MODE, - nmc_property_ip_tunnel_get_mode, - nmc_property_ip_tunnel_set_mode, - NULL, - NULL, - nmc_property_ip_tunnel_allowed_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_PARENT, - nmc_property_ip_tunnel_get_parent, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_LOCAL, - nmc_property_ip_tunnel_get_local, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_REMOTE, - nmc_property_ip_tunnel_get_remote, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_TTL, - nmc_property_ip_tunnel_get_ttl, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_TOS, - nmc_property_ip_tunnel_get_tos, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY, - nmc_property_ip_tunnel_get_path_mtu_discovery, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_INPUT_KEY, - nmc_property_ip_tunnel_get_input_key, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_OUTPUT_KEY, - nmc_property_ip_tunnel_get_output_key, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT, - nmc_property_ip_tunnel_get_encapsulation_limit, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_FLOW_LABEL, - nmc_property_ip_tunnel_get_flow_label, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_IP_TUNNEL_SETTING_NAME""NM_SETTING_IP_TUNNEL_MTU, - nmc_property_ip_tunnel_get_mtu, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_MACSEC_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_PARENT, - nmc_property_macsec_get_parent, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MODE, - nmc_property_macsec_get_mode, - nmc_property_macsec_set_mode, - NULL, - NULL, - nmc_property_macsec_allowed_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_ENCRYPT, - nmc_property_macsec_get_encrypt, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CAK, - nmc_property_macsec_get_mka_cak, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CAK_FLAGS, - nmc_property_macsec_get_mka_cak_flags, - nmc_property_set_secret_flags, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_MKA_CKN, - nmc_property_macsec_get_mka_ckn, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_PORT, - nmc_property_macsec_get_port, - nmc_property_set_int, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACSEC_SETTING_NAME""NM_SETTING_MACSEC_VALIDATION, - nmc_property_macsec_get_validation, - nmc_property_macsec_set_validation, - NULL, - NULL, - nmc_property_macsec_allowed_validation, - NULL); - - /* Add editable properties for NM_SETTING_MACVLAN_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_PARENT, - nmc_property_macvlan_get_parent, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_MODE, - nmc_property_macvlan_get_mode, - nmc_property_macvlan_set_mode, - NULL, - NULL, - nmc_property_macvlan_allowed_mode, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_PROMISCUOUS, - nmc_property_macvlan_get_promiscuous, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_MACVLAN_SETTING_NAME""NM_SETTING_MACVLAN_TAP, - nmc_property_macvlan_get_tap, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - - /* Add editable properties for NM_SETTING_VXLAN_SETTING_NAME */ - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_PARENT, - nmc_property_vxlan_get_parent, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_ID, - nmc_property_vxlan_get_id, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LOCAL, - nmc_property_vxlan_get_local, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_REMOTE, - nmc_property_vxlan_get_remote, - nmc_property_set_string, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_SOURCE_PORT_MIN, - nmc_property_vxlan_get_source_port_min, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_SOURCE_PORT_MAX, - nmc_property_vxlan_get_source_port_max, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_DESTINATION_PORT, - nmc_property_vxlan_get_destination_port, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_TOS, - nmc_property_vxlan_get_tos, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_TTL, - nmc_property_vxlan_get_ttl, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_AGEING, - nmc_property_vxlan_get_ageing, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LIMIT, - nmc_property_vxlan_get_limit, - nmc_property_set_uint, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_LEARNING, - nmc_property_vxlan_get_learning, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_PROXY, - nmc_property_vxlan_get_proxy, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_RSC, - nmc_property_vxlan_get_rsc, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_L2_MISS, - nmc_property_vxlan_get_l2_miss, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); - nmc_add_prop_funcs (NM_SETTING_VXLAN_SETTING_NAME""NM_SETTING_VXLAN_L3_MISS, - nmc_property_vxlan_get_l3_miss, - nmc_property_set_bool, - NULL, - NULL, - NULL, - NULL); -} - -void -nmc_properties_cleanup () -{ - if (nmc_properties) - g_hash_table_destroy (nmc_properties); -} - -static const NmcPropertyFuncs * -nmc_properties_find (const char *s_name, const char *p_name) -{ - char *key; - gsize p_l, s_l; - - nmc_properties_init (); - - s_l = strlen (s_name); - p_l = strlen (p_name); - key = g_alloca (s_l + p_l + 1); - memcpy (&key[ 0], s_name, s_l); - memcpy (&key[s_l], p_name, p_l + 1); - return (NmcPropertyFuncs *) g_hash_table_lookup (nmc_properties, key); -} - static char * get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error) { - const NmcPropertyFuncs *item; const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item) { - if (item->get_func) - return item->get_func (setting, get_type); - } - if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->get_fcn) { return property_info->property_type->get_fcn (setting_info, @@ -6446,23 +4861,12 @@ nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError gboolean nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error) { - const NmcPropertyFuncs *item; const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->set_func) { - if (!val) { - /* No value argument sets default value */ - nmc_property_set_default_value (setting, prop); - return TRUE; - } - return item->set_func (setting, prop, val, error); - } - if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); @@ -6473,7 +4877,7 @@ nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, } if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->set_fcn) { return property_info->property_type->set_fcn (setting_info, @@ -6514,24 +4918,17 @@ nmc_property_set_default_value (NMSetting *setting, const char *prop) gboolean nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error) { - const NmcPropertyFuncs *item; const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->set_func) { - nmc_property_set_default_value (setting, prop); - return TRUE; - } - if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->set_fcn) { nmc_property_set_default_value (setting, prop); @@ -6559,22 +4956,17 @@ nmc_setting_remove_property_option (NMSetting *setting, guint32 idx, GError **error) { - const NmcPropertyFuncs *item; const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->remove_func) - return item->remove_func (setting, prop, option, idx, error); - if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->remove_fcn) { return property_info->property_type->remove_fcn (setting_info, @@ -6627,21 +5019,16 @@ const char *const* nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) { - const NmcPropertyFuncs *item; const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->values_func) - return item->values_func (setting, prop); - if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->values_fcn) { return property_info->property_type->values_fcn (setting_info, @@ -6650,7 +5037,7 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) return property_info->property_typ_data->values_static; } -return NULL; + return NULL; } #include "settings-docs.c" @@ -6666,7 +5053,6 @@ return NULL; char * nmc_setting_get_property_desc (NMSetting *setting, const char *prop) { - const NmcPropertyFuncs *item; const char *setting_desc = NULL; const char *setting_desc_title = ""; const char *nmcli_desc = NULL; @@ -6681,16 +5067,11 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) if (setting_desc) setting_desc_title = _("[NM property description]"); - item = nmc_properties_find (nm_setting_get_name (setting), prop); - if (item && item->describe_func) { - nmcli_desc = item->describe_func (setting, prop); - nmcli_desc_title = _("[nmcli specific description]"); - nmcli_nl = "\n"; - } else if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); if (property_info->is_name) { - /* NmcPropertyFuncs would not register the "name" property. + /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ } else if (property_info->describe_message) { nmcli_desc = _(property_info->describe_message); @@ -6744,9 +5125,6 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) /*****************************************************************************/ -#define GET_SECRET(show, setting, func) \ - (show ? func (setting, NMC_PROPERTY_GET_PRETTY) : g_strdup (_(""))) - static char * _all_properties (const NmcSettingInfo *setting_info) { @@ -6762,15 +5140,25 @@ _all_properties (const NmcSettingInfo *setting_info) return g_string_free (str, FALSE); } -static gboolean -_get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +gboolean +setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) { + const NMMetaSettingInfo *meta_setting_info; + const NmcSettingInfo *setting_info; gs_free NmcOutputField *tmpl = NULL; NmcOutputField *arr; guint i; size_t tmpl_len; gs_free char *s_all = NULL; + g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); + + meta_setting_info = nm_meta_setting_infos_by_gtype (G_OBJECT_TYPE (setting)); + g_return_val_if_fail (meta_setting_info, FALSE); + + setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + g_return_val_if_fail (setting_info, FALSE); + g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE); tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1); @@ -6801,560 +5189,6 @@ _get_setting_details (const NmcSettingInfo *setting_info, NMSetting *setting, Nm return TRUE; } -static gboolean -setting_serial_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_SERIAL (s_serial), FALSE); - - tmpl = nmc_fields_setting_serial; - tmpl_len = sizeof (nmc_fields_setting_serial); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_SERIAL_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_serial_get_baud (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_serial_get_bits (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_serial_get_parity (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_serial_get_stopbits (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_serial_get_send_delay (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_gsm_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingGsm *s_gsm = NM_SETTING_GSM (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_GSM (s_gsm), FALSE); - - tmpl = nmc_fields_setting_gsm; - tmpl_len = sizeof (nmc_fields_setting_gsm); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_GSM_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_gsm_get_number (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_gsm_get_username (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_gsm_get_password)); - set_val_str (arr, 4, nmc_property_gsm_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_gsm_get_apn (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_gsm_get_network_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, GET_SECRET (secrets, setting, nmc_property_gsm_get_pin)); - set_val_str (arr, 8, nmc_property_gsm_get_pin_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_gsm_get_home_only (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_gsm_get_device_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_gsm_get_sim_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_gsm_get_sim_operator_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_gsm_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_cdma_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingCdma *s_cdma = NM_SETTING_CDMA (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_CDMA (s_cdma), FALSE); - - tmpl = nmc_fields_setting_cdma; - tmpl_len = sizeof (nmc_fields_setting_cdma); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_CDMA_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_cdma_get_number (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_cdma_get_username (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, GET_SECRET (secrets, setting, nmc_property_cdma_get_password)); - set_val_str (arr, 4, nmc_property_cdma_get_password_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_cdma_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_bluetooth_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingBluetooth *s_bluetooth = NM_SETTING_BLUETOOTH (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (s_bluetooth), FALSE); - - tmpl = nmc_fields_setting_bluetooth; - tmpl_len = sizeof (nmc_fields_setting_bluetooth); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BLUETOOTH_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bluetooth_get_bdaddr (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_bluetooth_get_type (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_olpc_mesh_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (s_olpc_mesh), FALSE); - - tmpl = nmc_fields_setting_olpc_mesh; - tmpl_len = sizeof (nmc_fields_setting_olpc_mesh); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_OLPC_MESH_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_olpc_get_ssid (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_olpc_get_channel (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_olpc_get_anycast_address (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_vpn_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingVpn *s_vpn = NM_SETTING_VPN (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_VPN (s_vpn), FALSE); - - tmpl = nmc_fields_setting_vpn; - tmpl_len = sizeof (nmc_fields_setting_vpn); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VPN_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vpn_get_service_type (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_vpn_get_user_name (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_vpn_get_data (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_vpn_get_secrets)); - set_val_str (arr, 5, nmc_property_vpn_get_persistent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_vpn_get_timeout (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_infiniband_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (s_infiniband), FALSE); - - tmpl = nmc_fields_setting_infiniband; - tmpl_len = sizeof (nmc_fields_setting_infiniband); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_INFINIBAND_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ib_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_ib_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_ib_get_transport_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_ib_get_p_key (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_ib_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_bond_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingBond *s_bond = NM_SETTING_BOND (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_BOND (s_bond), FALSE); - - tmpl = nmc_fields_setting_bond; - tmpl_len = sizeof (nmc_fields_setting_bond); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BOND_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bond_get_options (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_vlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_VLAN (s_vlan), FALSE); - - tmpl = nmc_fields_setting_vlan; - tmpl_len = sizeof (nmc_fields_setting_vlan); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VLAN_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_vlan_get_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_vlan_get_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_bridge_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingBridge *s_bridge = NM_SETTING_BRIDGE (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_BRIDGE (s_bridge), FALSE); - - tmpl = nmc_fields_setting_bridge; - tmpl_len = sizeof (nmc_fields_setting_bridge); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_bridge_get_stp (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_bridge_get_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_bridge_get_multicast_snooping (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_bridge_port_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingBridgePort *s_bridge_port = NM_SETTING_BRIDGE_PORT (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (s_bridge_port), FALSE); - - tmpl = nmc_fields_setting_bridge_port; - tmpl_len = sizeof (nmc_fields_setting_bridge_port); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_BRIDGE_PORT_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_bridge_port_get_priority (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_bridge_port_get_path_cost (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_bridge_port_get_hairpin_mode (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_team_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingTeam *s_team = NM_SETTING_TEAM (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_TEAM (s_team), FALSE); - - tmpl = nmc_fields_setting_team; - tmpl_len = sizeof (nmc_fields_setting_team); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_team_get_config (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_team_port_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingTeamPort *s_team_port = NM_SETTING_TEAM_PORT (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (s_team_port), FALSE); - - tmpl = nmc_fields_setting_team_port; - tmpl_len = sizeof (nmc_fields_setting_team_port); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TEAM_PORT_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_team_port_get_config (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_tun_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingTun *s_tun = NM_SETTING_TUN (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_TUN (s_tun), FALSE); - - tmpl = nmc_fields_setting_tun; - tmpl_len = sizeof (nmc_fields_setting_tun); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_TUN_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_tun_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_tun_get_owner (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_tun_get_group (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_tun_get_pi (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_tun_get_vnet_hdr (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_tun_get_multi_queue (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_ip_tunnel_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_IP_TUNNEL (s_ip_tunnel), FALSE); - - tmpl = nmc_fields_setting_ip_tunnel; - tmpl_len = sizeof (nmc_fields_setting_ip_tunnel); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_IP_TUNNEL_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_ip_tunnel_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_ip_tunnel_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_ip_tunnel_get_local (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_ip_tunnel_get_remote (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_ip_tunnel_get_ttl (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_ip_tunnel_get_tos (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_ip_tunnel_get_path_mtu_discovery (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_ip_tunnel_get_input_key (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_ip_tunnel_get_output_key (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_ip_tunnel_get_encapsulation_limit (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_ip_tunnel_get_flow_label (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_ip_tunnel_get_mtu (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_macsec_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingMacsec *s_macsec = NM_SETTING_MACSEC (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_MACSEC (s_macsec), FALSE); - - tmpl = nmc_fields_setting_macsec; - tmpl_len = sizeof (nmc_fields_setting_macsec); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_MACSEC_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_macsec_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_macsec_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_macsec_get_encrypt (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, GET_SECRET (secrets, setting, nmc_property_macsec_get_mka_cak)); - set_val_str (arr, 5, nmc_property_macsec_get_mka_cak_flags (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_macsec_get_mka_ckn (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_macsec_get_port (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_macsec_get_validation (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_macvlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_MACVLAN (s_macvlan), FALSE); - - tmpl = nmc_fields_setting_macvlan; - tmpl_len = sizeof (nmc_fields_setting_macvlan); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_MACVLAN_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_macvlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_macvlan_get_mode (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_macvlan_get_promiscuous (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_macvlan_get_tap (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - -static gboolean -setting_vxlan_details (const NmcSettingInfo *setting_info, NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - NMSettingVxlan *s_vxlan = NM_SETTING_VXLAN (setting); - NmcOutputField *tmpl, *arr; - size_t tmpl_len; - - g_return_val_if_fail (NM_IS_SETTING_VXLAN (s_vxlan), FALSE); - - tmpl = nmc_fields_setting_vxlan; - tmpl_len = sizeof (nmc_fields_setting_vxlan); - nmc->print_fields.indices = parse_output_fields (one_prop ? one_prop : NMC_FIELDS_SETTING_VXLAN_ALL, - tmpl, FALSE, NULL, NULL); - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_FIELD_NAMES); - g_ptr_array_add (nmc->output_data, arr); - - arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); - set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting))); - set_val_str (arr, 1, nmc_property_vxlan_get_parent (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 2, nmc_property_vxlan_get_id (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 3, nmc_property_vxlan_get_local (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 4, nmc_property_vxlan_get_remote (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 5, nmc_property_vxlan_get_source_port_min (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 6, nmc_property_vxlan_get_source_port_max (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 7, nmc_property_vxlan_get_destination_port (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 8, nmc_property_vxlan_get_tos (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 9, nmc_property_vxlan_get_ttl (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 10, nmc_property_vxlan_get_ageing (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 11, nmc_property_vxlan_get_limit (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 12, nmc_property_vxlan_get_learning (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 13, nmc_property_vxlan_get_proxy (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 14, nmc_property_vxlan_get_rsc (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 15, nmc_property_vxlan_get_l2_miss (setting, NMC_PROPERTY_GET_PRETTY)); - set_val_str (arr, 16, nmc_property_vxlan_get_l3_miss (setting, NMC_PROPERTY_GET_PRETTY)); - g_ptr_array_add (nmc->output_data, arr); - - print_data (nmc); /* Print all data */ - - return TRUE; -} - /*****************************************************************************/ #define DEFINE_PROPERTY_TYPE(...) \ @@ -7417,11 +5251,6 @@ static const NmcPropertyType _pt_gobject_mac = { .set_fcn = _set_fcn_gobject_mac, }; -static const NmcPropertyType _pt_gobject_mac_cloned = { - .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_gobject_mac_cloned, -}; - static const NmcPropertyType _pt_gobject_secret_flags = { .get_fcn = _get_fcn_gobject_secret_flags, .set_fcn = _set_fcn_gobject_secret_flags, @@ -7453,6 +5282,14 @@ static const NmcPropertyType _pt_nmc_getset = { * that the actual type is (guint32(*)(type *)). */ \ ((guint32 (*) (NMSetting *)) ((sizeof (func == ((guint32 (*) (type *)) func))) ? func : func) ) +#define TEAM_DESCRIBE_MESSAGE \ + "nmcli can accepts both direct JSON configuration data and a file name containing " \ + "the configuration. In the latter case the file is read and the contents is put " \ + "into this property.\n\n" \ + "Examples: set team.config " \ + "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n" \ + " set team.config /etc/my-team.conf\n" + static const NmcPropertyInfo properties_setting_802_1x[] = { PROPERTY_INFO_NAME(), { @@ -7796,6 +5633,121 @@ static const NmcPropertyInfo properties_setting_adsl[] = { }, }; +static const NmcPropertyInfo properties_setting_bluetooth[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_BLUETOOTH_BDADDR), + .property_type = &_pt_gobject_mac, + }, + { + .property_name = N_ (NM_SETTING_BLUETOOTH_TYPE), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC (NM_SETTING_BLUETOOTH_TYPE_DUN, + NM_SETTING_BLUETOOTH_TYPE_PANU), + ), + }, +}; + +static const NmcPropertyInfo properties_setting_bond[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_BOND_OPTIONS), + .property_type = DEFINE_PROPERTY_TYPE ( + .describe_fcn = _describe_fcn_bond_options, + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_bond_get_options, + .set_fcn = nmc_property_bond_set_options, + .remove_fcn = nmc_property_bond_remove_option_options, + .values_fcn = nmc_property_bond_allowed_options, + ), + }, +}; + +static const NmcPropertyInfo properties_setting_bridge[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_BRIDGE_MAC_ADDRESS), + .property_type = &_pt_gobject_mac, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_STP), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_PRIORITY), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_FORWARD_DELAY), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_HELLO_TIME), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_MAX_AGE), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_AGEING_TIME), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_MULTICAST_SNOOPING), + .property_type = &_pt_gobject_bool, + }, +}; + +static const NmcPropertyInfo properties_setting_bridge_port[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_BRIDGE_PORT_PRIORITY), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_PORT_PATH_COST), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE), + .property_type = &_pt_gobject_bool, + }, +}; + +static const NmcPropertyInfo properties_setting_cdma[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_CDMA_NUMBER), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_CDMA_USERNAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_CDMA_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_CDMA_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_CDMA_MTU), + .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingCdma, nm_setting_cdma_get_mtu), + ), + }, +}; + static const NmcPropertyInfo properties_setting_connection[] = { PROPERTY_INFO_NAME(), { @@ -8076,6 +6028,120 @@ static const NmcPropertyInfo properties_setting_dcb[] = { }, }; +static const NmcPropertyInfo properties_setting_dummy[] = { + PROPERTY_INFO_NAME(), +}; + +static const NmcPropertyInfo properties_setting_gsm[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_GSM_NUMBER), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_USERNAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_PASSWORD), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_PASSWORD_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_GSM_APN), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_NETWORK_ID), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_PIN), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_PIN_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_GSM_HOME_ONLY), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_GSM_DEVICE_ID), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_SIM_ID), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_GSM_SIM_OPERATOR_ID), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_gsm_set_sim_operator_id, + ), + }, + { + .property_name = N_ (NM_SETTING_GSM_MTU), + .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingGsm, nm_setting_gsm_get_mtu), + ), + }, +}; + +static const NmcPropertyInfo properties_setting_infiniband[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_INFINIBAND_MAC_ADDRESS), + .property_type = &_pt_gobject_mac, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, + .mode = NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND, + ), + }, + { + .property_name = N_ (NM_SETTING_INFINIBAND_MTU), + .property_type = &_pt_gobject_mtu, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu, + .get_fcn = MTU_GET_FCN (NMSettingInfiniband, nm_setting_infiniband_get_mtu), + ), + }, + { + .property_name = N_ (NM_SETTING_INFINIBAND_TRANSPORT_MODE), + .property_type = &_pt_gobject_string, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("datagram", "connected"), + ), + }, + { + .property_name = N_ (NM_SETTING_INFINIBAND_P_KEY), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_ib_get_p_key, + .set_fcn = nmc_property_ib_set_p_key, + ), + }, + { + .property_name = N_ (NM_SETTING_INFINIBAND_PARENT), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_set_ifname, + ), + }, +}; + static const NmcPropertyInfo properties_setting_ip4_config[] = { PROPERTY_INFO_NAME(), { @@ -8377,6 +6443,177 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { }, }; +static const NmcPropertyInfo properties_setting_ip_tunnel[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_MODE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_ip_tunnel_get_mode, + .set_fcn = nmc_property_ip_tunnel_set_mode, + .values_fcn = nmc_property_ip_tunnel_allowed_mode, + ), + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_PARENT), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_LOCAL), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_REMOTE), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_TTL), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_TOS), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_INPUT_KEY), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_OUTPUT_KEY), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_FLOW_LABEL), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_IP_TUNNEL_MTU), + .property_type = &_pt_gobject_mtu, + }, +}; + +static const NmcPropertyInfo properties_setting_macsec[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_MACSEC_PARENT), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_MODE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_macsec_get_mode, + .set_fcn = nmc_property_macsec_set_mode, + .values_fcn = nmc_property_macsec_allowed_mode, + ), + }, + { + .property_name = N_ (NM_SETTING_MACSEC_ENCRYPT), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_MKA_CAK), + .is_secret = TRUE, + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_MKA_CAK_FLAGS), + .property_type = &_pt_gobject_secret_flags, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_MKA_CKN), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_PORT), + .property_type = &_pt_gobject_int, + }, + { + .property_name = N_ (NM_SETTING_MACSEC_VALIDATION), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_macsec_get_validation, + .set_fcn = nmc_property_macsec_set_validation, + .values_fcn = nmc_property_macsec_allowed_validation, + ), + }, +}; + +static const NmcPropertyInfo properties_setting_macvlan[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_MACVLAN_PARENT), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_MACVLAN_MODE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_macvlan_get_mode, + .set_fcn = nmc_property_macvlan_set_mode, + .values_fcn = nmc_property_macvlan_allowed_mode, + ), + }, + { + .property_name = N_ (NM_SETTING_MACVLAN_PROMISCUOUS), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_MACVLAN_TAP), + .property_type = &_pt_gobject_bool, + }, +}; + +static const NmcPropertyInfo properties_setting_olpc_mesh[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_OLPC_MESH_SSID), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_olpc_get_ssid, + .set_fcn = nmc_property_set_ssid, + ), + }, + { + .property_name = N_ (NM_SETTING_OLPC_MESH_CHANNEL), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_olpc_set_channel, + ), + }, + { + .property_name = N_ (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), + .property_type = &_pt_gobject_mac, + }, +}; + static const NmcPropertyInfo properties_setting_pppoe[] = { PROPERTY_INFO_NAME (), { @@ -8512,6 +6749,268 @@ static const NmcPropertyInfo properties_setting_proxy[] = { }, }; +static const NmcPropertyInfo properties_setting_team[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_TEAM_CONFIG), + .describe_message = N_ (TEAM_DESCRIBE_MESSAGE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_team_set_config, + ), + }, +}; + +static const NmcPropertyInfo properties_setting_team_port[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_TEAM_PORT_CONFIG), + .describe_message = N_ (TEAM_DESCRIBE_MESSAGE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_team_set_config, + ), + }, +}; + +static const NmcPropertyInfo properties_setting_tun[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_TUN_MODE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .values_fcn = _values_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_tun_get_mode, + .set_fcn = nmc_property_tun_set_mode, + .values_fcn = nmc_property_tun_allowed_mode, + ), + }, + { + .property_name = N_ (NM_SETTING_TUN_OWNER), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_TUN_GROUP), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_TUN_PI), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_TUN_VNET_HDR), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_TUN_MULTI_QUEUE), + .property_type = &_pt_gobject_bool, + }, +}; + +static const NmcPropertyInfo properties_setting_serial[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_SERIAL_BAUD), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_SERIAL_BITS), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_SERIAL_PARITY), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_serial_get_parity, + .set_fcn = nmc_property_serial_set_parity, + ), + }, + { + .property_name = N_ (NM_SETTING_SERIAL_STOPBITS), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_SERIAL_SEND_DELAY), + .property_type = &_pt_gobject_uint, + }, +}; + +static const NmcPropertyInfo properties_setting_vlan[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_VLAN_PARENT), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_VLAN_ID), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VLAN_FLAGS), + .property_type = &_pt_nmc_getset, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_vlan_get_flags, + .set_fcn = nmc_property_set_flags, + ), + }, + { + .property_name = N_ (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_vlan_get_ingress_priority_map, + .set_fcn = nmc_property_vlan_set_ingress_priority_map, + .remove_fcn = nmc_property_vlan_remove_ingress_priority_map, + ), + }, + { + .property_name = N_ (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_vlan_get_egress_priority_map, + .set_fcn = nmc_property_vlan_set_egress_priority_map, + .remove_fcn = nmc_property_vlan_remove_egress_priority_map, + ), + }, +}; + +static const NmcPropertyInfo properties_setting_vpn[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_VPN_SERVICE_TYPE), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_gobject, + .set_fcn = _set_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .set_fcn = nmc_property_set_vpn_service, + ), + }, + { + .property_name = N_ (NM_SETTING_VPN_USER_NAME), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_VPN_DATA), + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_vpn_get_data, + .set_fcn = nmc_property_vpn_set_data, + .remove_fcn = nmc_property_vpn_remove_option_data, + ), + }, + { + .property_name = N_ (NM_SETTING_VPN_SECRETS), + .is_secret = TRUE, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_nmc, + .set_fcn = _set_fcn_nmc, + .remove_fcn = _remove_fcn_nmc, + ), + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, + .get_fcn = nmc_property_vpn_get_secrets, + .set_fcn = nmc_property_vpn_set_secrets, + .remove_fcn = nmc_property_vpn_remove_option_secret, + ), + }, + { + .property_name = N_ (NM_SETTING_VPN_PERSISTENT), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_VPN_TIMEOUT), + .property_type = &_pt_gobject_uint, + }, +}; + +static const NmcPropertyInfo properties_setting_vxlan[] = { + PROPERTY_INFO_NAME(), + { + .property_name = N_ (NM_SETTING_VXLAN_PARENT), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_ID), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_LOCAL), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_REMOTE), + .property_type = &_pt_gobject_string, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_SOURCE_PORT_MIN), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_SOURCE_PORT_MAX), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_DESTINATION_PORT), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_TOS), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_TTL), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_AGEING), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_LIMIT), + .property_type = &_pt_gobject_uint, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_LEARNING), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_PROXY), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_RSC), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_L2_MISS), + .property_type = &_pt_gobject_bool, + }, + { + .property_name = N_ (NM_SETTING_VXLAN_L3_MISS), + .property_type = &_pt_gobject_bool, + }, +}; + static const NmcPropertyInfo properties_setting_wimax[] = { PROPERTY_INFO_NAME(), { @@ -8555,7 +7054,10 @@ static const NmcPropertyInfo properties_setting_wired[] = { }, { .property_name = N_ (NM_SETTING_WIRED_CLONED_MAC_ADDRESS), - .property_type = &_pt_gobject_mac_cloned, + .property_type = &_pt_gobject_mac, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, + .mode = NMC_PROPERTY_TYPE_MAC_MODE_CLONED, + ), }, { .property_name = N_ (NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK), @@ -8685,7 +7187,10 @@ static const NmcPropertyInfo properties_setting_wireless[] = { }, { .property_name = N_ (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), - .property_type = &_pt_gobject_mac_cloned, + .property_type = &_pt_gobject_mac, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, + .mode = NMC_PROPERTY_TYPE_MAC_MODE_CLONED, + ), }, { .property_name = N_ (NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK), @@ -8889,23 +7394,28 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_BLUETOOTH] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BLUETOOTH], - .get_setting_details = setting_bluetooth_details, + .properties = properties_setting_bluetooth, + .properties_num = G_N_ELEMENTS (properties_setting_bluetooth), }, [NM_META_SETTING_TYPE_BOND] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BOND], - .get_setting_details = setting_bond_details, + .properties = properties_setting_bond, + .properties_num = G_N_ELEMENTS (properties_setting_bond), }, [NM_META_SETTING_TYPE_BRIDGE] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE], - .get_setting_details = setting_bridge_details, + .properties = properties_setting_bridge, + .properties_num = G_N_ELEMENTS (properties_setting_bridge), }, [NM_META_SETTING_TYPE_BRIDGE_PORT] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE_PORT], - .get_setting_details = setting_bridge_port_details, + .properties = properties_setting_bridge_port, + .properties_num = G_N_ELEMENTS (properties_setting_bridge_port), }, [NM_META_SETTING_TYPE_CDMA] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CDMA], - .get_setting_details = setting_cdma_details, + .properties = properties_setting_cdma, + .properties_num = G_N_ELEMENTS (properties_setting_cdma), }, [NM_META_SETTING_TYPE_CONNECTION] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CONNECTION], @@ -8917,13 +7427,20 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { .properties = properties_setting_dcb, .properties_num = G_N_ELEMENTS (properties_setting_dcb), }, + [NM_META_SETTING_TYPE_DUMMY] = { + .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DUMMY], + .properties = properties_setting_dummy, + .properties_num = G_N_ELEMENTS (properties_setting_dummy), + }, [NM_META_SETTING_TYPE_GSM] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_GSM], - .get_setting_details = setting_gsm_details, + .properties = properties_setting_gsm, + .properties_num = G_N_ELEMENTS (properties_setting_gsm), }, [NM_META_SETTING_TYPE_INFINIBAND] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_INFINIBAND], - .get_setting_details = setting_infiniband_details, + .properties = properties_setting_infiniband, + .properties_num = G_N_ELEMENTS (properties_setting_infiniband), }, [NM_META_SETTING_TYPE_IP4_CONFIG] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP4_CONFIG], @@ -8937,19 +7454,23 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_IP_TUNNEL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP_TUNNEL], - .get_setting_details = setting_ip_tunnel_details, + .properties = properties_setting_ip_tunnel, + .properties_num = G_N_ELEMENTS (properties_setting_ip_tunnel), }, [NM_META_SETTING_TYPE_MACSEC] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACSEC], - .get_setting_details = setting_macsec_details, + .properties = properties_setting_macsec, + .properties_num = G_N_ELEMENTS (properties_setting_macsec), }, [NM_META_SETTING_TYPE_MACVLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACVLAN], - .get_setting_details = setting_macvlan_details, + .properties = properties_setting_macvlan, + .properties_num = G_N_ELEMENTS (properties_setting_macvlan), }, [NM_META_SETTING_TYPE_OLPC_MESH] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_OLPC_MESH], - .get_setting_details = setting_olpc_mesh_details, + .properties = properties_setting_olpc_mesh, + .properties_num = G_N_ELEMENTS (properties_setting_olpc_mesh), }, [NM_META_SETTING_TYPE_PPPOE] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPPOE], @@ -8968,31 +7489,38 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { }, [NM_META_SETTING_TYPE_SERIAL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_SERIAL], - .get_setting_details = setting_serial_details, + .properties = properties_setting_serial, + .properties_num = G_N_ELEMENTS (properties_setting_serial), }, [NM_META_SETTING_TYPE_TEAM] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM], - .get_setting_details = setting_team_details, + .properties = properties_setting_team, + .properties_num = G_N_ELEMENTS (properties_setting_team), }, [NM_META_SETTING_TYPE_TEAM_PORT] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM_PORT], - .get_setting_details = setting_team_port_details, + .properties = properties_setting_team_port, + .properties_num = G_N_ELEMENTS (properties_setting_team_port), }, [NM_META_SETTING_TYPE_TUN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TUN], - .get_setting_details = setting_tun_details, + .properties = properties_setting_tun, + .properties_num = G_N_ELEMENTS (properties_setting_tun), }, [NM_META_SETTING_TYPE_VLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VLAN], - .get_setting_details = setting_vlan_details, + .properties = properties_setting_vlan, + .properties_num = G_N_ELEMENTS (properties_setting_vlan), }, [NM_META_SETTING_TYPE_VPN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VPN], - .get_setting_details = setting_vpn_details, + .properties = properties_setting_vpn, + .properties_num = G_N_ELEMENTS (properties_setting_vpn), }, [NM_META_SETTING_TYPE_VXLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VXLAN], - .get_setting_details = setting_vxlan_details, + .properties = properties_setting_vxlan, + .properties_num = G_N_ELEMENTS (properties_setting_vxlan), }, [NM_META_SETTING_TYPE_WIMAX] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIMAX], @@ -9015,21 +7543,3 @@ const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { .properties_num = G_N_ELEMENTS (properties_setting_wireless_security), }, }; - -gboolean -setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) -{ - const NMMetaSettingInfo *meta_setting_info; - const NmcSettingInfo *setting_info; - - g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); - - meta_setting_info = nm_meta_setting_infos_by_gtype (G_OBJECT_TYPE (setting)); - g_return_val_if_fail (meta_setting_info, FALSE); - - setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; - g_return_val_if_fail (setting_info, FALSE); - - return (setting_info->get_setting_details ?: _get_setting_details) (setting_info, setting, nmc, one_prop, secrets); -} - diff --git a/clients/cli/settings.h b/clients/cli/settings.h index e1c4953d5c..4ec3158b60 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -32,6 +32,12 @@ typedef enum { NMC_PROPERTY_GET_PARSABLE, } NmcPropertyGetType; +typedef enum { + NMC_PROPERTY_TYPE_MAC_MODE_DEFAULT, + NMC_PROPERTY_TYPE_MAC_MODE_CLONED, + NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND, +} NmcPropertyTypeMacMode; + typedef struct _NmcSettingInfo NmcSettingInfo; typedef struct _NmcPropertyInfo NmcPropertyInfo; typedef struct _NmcPropertyType NmcPropertyType; @@ -88,6 +94,9 @@ struct _NmcPropertyTypData { struct { guint32 (*get_fcn) (NMSetting *setting); } mtu; + struct { + NmcPropertyTypeMacMode mode; + } mac; }; const char *const*values_static; }; @@ -111,11 +120,6 @@ struct _NmcPropertyInfo { struct _NmcSettingInfo { const NMMetaSettingInfo *general; - gboolean (*get_setting_details) (const NmcSettingInfo *setting_info, - NMSetting *setting, - NmCli *nmc, - const char *one_prop, - gboolean secrets); /* the order of the properties matter. The first *must* be the * "name", and then the order is as they are listed by default. */ const NmcPropertyInfo *properties; @@ -126,9 +130,6 @@ extern const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM]; /*****************************************************************************/ -void nmc_properties_init (void); -void nmc_properties_cleanup (void); - NMSetting *nmc_setting_new_for_name (const char *name); void nmc_setting_custom_init (NMSetting *setting); void nmc_setting_ip4_connect_handlers (NMSettingIPConfig *setting); @@ -165,24 +166,4 @@ gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue * gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets); -extern NmcOutputField nmc_fields_setting_serial[]; -extern NmcOutputField nmc_fields_setting_gsm[]; -extern NmcOutputField nmc_fields_setting_cdma[]; -extern NmcOutputField nmc_fields_setting_bluetooth[]; -extern NmcOutputField nmc_fields_setting_olpc_mesh[]; -extern NmcOutputField nmc_fields_setting_vpn[]; -extern NmcOutputField nmc_fields_setting_infiniband[]; -extern NmcOutputField nmc_fields_setting_bond[]; -extern NmcOutputField nmc_fields_setting_vlan[]; -extern NmcOutputField nmc_fields_setting_bridge[]; -extern NmcOutputField nmc_fields_setting_bridge_port[]; -extern NmcOutputField nmc_fields_setting_team[]; -extern NmcOutputField nmc_fields_setting_team_port[]; -extern NmcOutputField nmc_fields_setting_tun[]; -extern NmcOutputField nmc_fields_setting_ip_tunnel[]; -extern NmcOutputField nmc_fields_setting_macvlan[]; -extern NmcOutputField nmc_fields_setting_macsec[]; -extern NmcOutputField nmc_fields_setting_vxlan[]; -extern NmcOutputField nmc_fields_setting_dummy[]; - #endif /* NMC_SETTINGS_H */ diff --git a/shared/nm-setting-metadata.c b/shared/nm-setting-metadata.c index 7e4a4ea9b5..735f90fe1e 100644 --- a/shared/nm-setting-metadata.c +++ b/shared/nm-setting-metadata.c @@ -185,6 +185,11 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = { .setting_name = N_ (NM_SETTING_DCB_SETTING_NAME), .get_setting_gtype = nm_setting_dcb_get_type, }, + [NM_META_SETTING_TYPE_DUMMY] = { + .meta_type = NM_META_SETTING_TYPE_DUMMY, + .setting_name = N_ (NM_SETTING_DUMMY_SETTING_NAME), + .get_setting_gtype = nm_setting_dummy_get_type, + }, [NM_META_SETTING_TYPE_GSM] = { .meta_type = NM_META_SETTING_TYPE_GSM, .setting_name = N_ (NM_SETTING_GSM_SETTING_NAME), diff --git a/shared/nm-setting-metadata.h b/shared/nm-setting-metadata.h index f215730eff..57ef52575f 100644 --- a/shared/nm-setting-metadata.h +++ b/shared/nm-setting-metadata.h @@ -65,6 +65,7 @@ typedef enum { NM_META_SETTING_TYPE_CDMA, NM_META_SETTING_TYPE_CONNECTION, NM_META_SETTING_TYPE_DCB, + NM_META_SETTING_TYPE_DUMMY, NM_META_SETTING_TYPE_GSM, NM_META_SETTING_TYPE_INFINIBAND, NM_META_SETTING_TYPE_IP4_CONFIG, From 4bfb3c8aa7ec879ac33f5e32216e8816112927c1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Mar 2017 17:38:27 +0200 Subject: [PATCH 29/53] cli: refactor indirection to legacy signatures --- clients/cli/settings.c | 64 +++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 27038dd610..7461d12fc9 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -45,6 +45,12 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) /*****************************************************************************/ +#define ARGS_GET_FCN \ + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type + +#define ARGS_SET_FCN \ + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error + static char * _get_fcn_name (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -3842,7 +3848,7 @@ DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret, nm_setting_vpn_remove_secret) static char * -nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wired_wake_on_lan (ARGS_GET_FCN) { NMSettingWired *s_wired = NM_SETTING_WIRED (setting); NMSettingWiredWakeOnLan wol; @@ -3859,21 +3865,20 @@ nmc_property_wired_get_wake_on_lan (NMSetting *setting, NmcPropertyGetType get_t } static gboolean -nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_wired_wake_on_lan (ARGS_SET_FCN) { NMSettingWiredWakeOnLan wol; gs_free char *err_token = NULL; gboolean ret; long int t; - if (nmc_string_to_int_base (val, 0, TRUE, 0, + if (nmc_string_to_int_base (value, 0, TRUE, 0, NM_SETTING_WIRED_WAKE_ON_LAN_ALL | NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS, &t)) wol = (NMSettingWiredWakeOnLan) t; else { - ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), val, + ret = nm_utils_enum_from_str (nm_setting_wired_wake_on_lan_get_type (), value, (int *) &wol, &err_token); if (!ret) { @@ -3897,7 +3902,7 @@ nmc_property_wired_set_wake_on_lan (NMSetting *setting, const char *prop, return FALSE; } - g_object_set (setting, prop, (guint) wol, NULL); + g_object_set (setting, property_info->property_name, (guint) wol, NULL); return TRUE; } @@ -4196,13 +4201,11 @@ nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_t } static char * -nmc_property_wifi_sec_get_wep_key_type (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_security_wep_key_type (ARGS_GET_FCN) { - NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); - return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (s_wireless_sec)); + return wep_key_type_to_string (nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting))); } -/* 'proto' */ static const char *wifi_sec_valid_protos[] = { "wpa", "rsn", NULL }; DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto, @@ -4360,9 +4363,8 @@ nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char return TRUE; } -/* 'wep-key-type' */ static gboolean -nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_security_wep_key_type (ARGS_SET_FCN) { unsigned long type_int; const char *valid_wep_types[] = { "unknown", "key", "passphrase", NULL }; @@ -4372,9 +4374,9 @@ nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_uint (val, TRUE, 0, 2, &type_int)) { - if (!(type_str = nmc_string_is_valid (val, valid_wep_types, NULL))) { - g_set_error (error, 1, 0, _("'%s' not among [0 (unknown), 1 (key), 2 (passphrase)]"), val); + if (!nmc_string_to_uint (value, TRUE, 0, 2, &type_int)) { + if (!(type_str = nmc_string_is_valid (value, valid_wep_types, NULL))) { + g_set_error (error, 1, 0, _("'%s' not among [0 (unknown), 1 (key), 2 (passphrase)]"), value); return FALSE; } if (type_str == valid_wep_types[1]) @@ -4402,21 +4404,18 @@ nmc_property_wifi_set_wep_key_type (NMSetting *setting, const char *prop, const g_print (_("Warning: '%s' is not compatible with '%s' type, please change or delete the key.\n"), NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, wep_key_type_to_string (type)); - g_object_set (setting, prop, type, NULL); + g_object_set (setting, property_info->property_name, type, NULL); return TRUE; } -/* 'psk' */ static gboolean -nmc_property_wifi_set_psk (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_security_psk (ARGS_SET_FCN) { - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nm_utils_wpa_psk_valid (val)) { - g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), val); + if (!nm_utils_wpa_psk_valid (value)) { + g_set_error (error, 1, 0, _("'%s' is not a valid PSK"), value); return FALSE; } - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); return TRUE; } @@ -7119,10 +7118,9 @@ static const NmcPropertyInfo properties_setting_wired[] = { }, { .property_name = N_ (NM_SETTING_WIRED_WAKE_ON_LAN), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wired_get_wake_on_lan, - .set_fcn = nmc_property_wired_set_wake_on_lan, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wired_wake_on_lan, + .set_fcn = _set_fcn_wired_wake_on_lan, ), }, { @@ -7349,10 +7347,9 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { .describe_message = N_ ("Enter the type of WEP keys. The accepted values are: " "0 or unknown, 1 or key, and 2 or passphrase.\n"), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wifi_sec_get_wep_key_type, - .set_fcn = nmc_property_wifi_set_wep_key_type, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_security_wep_key_type, + .set_fcn = _set_fcn_wireless_security_wep_key_type, ), }, { @@ -7360,10 +7357,7 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { .is_secret = TRUE, .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wifi_set_psk, + .set_fcn = _set_fcn_wireless_security_psk, ), }, { From d92b50fc7041addf5bf5612d266e749547fe62b4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Mar 2017 18:00:47 +0200 Subject: [PATCH 30/53] cli: use define for argument lists in settings.c settings.c basically consists of property-type structures and *a lot* of accessors. All these accessors share the same argument list. It is very repetitive to specify it over and over again. Also, there are so many arguments that one is compelled to wrap the lines. All in all it results in a lot of noise that takes the eye from the important code. Also, the argument list is expected to change, so we possibly only have to change one place. --- clients/cli/settings.c | 276 +++++++++-------------------------------- 1 file changed, 57 insertions(+), 219 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 7461d12fc9..0136e848d0 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -45,36 +45,36 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) /*****************************************************************************/ +#define ARGS_DESCRIBE_FCN \ + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info + #define ARGS_GET_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type #define ARGS_SET_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error +#define ARGS_REMOVE_FCN \ + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *option, guint32 idx, GError **error + +#define ARGS_VALUES_FCN \ + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info + static char * -_get_fcn_name (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_name (ARGS_GET_FCN) { nm_assert (nm_streq0 (nm_setting_get_name (setting), setting_info->general->setting_name)); return g_strdup (setting_info->general->setting_name); } static char * -_get_fcn_nmc (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_nmc (ARGS_GET_FCN) { return property_info->property_typ_data->nmc.get_fcn (setting, get_type); } static char * -_get_fcn_nmc_with_default (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_nmc_with_default (ARGS_GET_FCN) { const char *s; char *s_full; @@ -98,10 +98,7 @@ _get_fcn_nmc_with_default (const NmcSettingInfo *setting_info, } static char * -_get_fcn_gobject (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_gobject (ARGS_GET_FCN) { char *s; GValue val = G_VALUE_INIT; @@ -114,10 +111,7 @@ _get_fcn_gobject (const NmcSettingInfo *setting_info, } static char * -_get_fcn_gobject_mtu (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_gobject_mtu (ARGS_GET_FCN) { guint32 mtu; @@ -136,10 +130,7 @@ _get_fcn_gobject_mtu (const NmcSettingInfo *setting_info, } static char * -_get_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_gobject_secret_flags (ARGS_GET_FCN) { guint v; GValue val = G_VALUE_INIT; @@ -154,21 +145,13 @@ _get_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, /*****************************************************************************/ static gboolean -_set_fcn_nmc (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_nmc (ARGS_SET_FCN) { return property_info->property_typ_data->nmc.set_fcn (setting, property_info->property_name, value, error); } static gboolean -_set_fcn_gobject_string (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_string (ARGS_SET_FCN) { if ( property_info->property_typ_data && property_info->property_typ_data->values_static) { @@ -183,11 +166,7 @@ _set_fcn_gobject_string (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_bool (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_bool (ARGS_SET_FCN) { gboolean val_bool; @@ -199,11 +178,7 @@ _set_fcn_gobject_bool (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_trilean (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_trilean (ARGS_SET_FCN) { long int val_int; @@ -219,11 +194,7 @@ _set_fcn_gobject_trilean (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_int (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_int (ARGS_SET_FCN) { long int val_int; @@ -241,11 +212,7 @@ _set_fcn_gobject_int (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_int64 (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_int64 (ARGS_SET_FCN) { long val_int; @@ -265,11 +232,7 @@ _set_fcn_gobject_int64 (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_uint (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_uint (ARGS_SET_FCN) { unsigned long val_int; @@ -289,11 +252,7 @@ _set_fcn_gobject_uint (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_mtu (ARGS_SET_FCN) { if (nm_streq0 (value, "auto")) value = "0"; @@ -301,11 +260,7 @@ _set_fcn_gobject_mtu (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_mac (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_mac (ARGS_SET_FCN) { NmcPropertyTypeMacMode mode; gboolean valid; @@ -334,11 +289,7 @@ _set_fcn_gobject_mac (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_gobject_secret_flags (ARGS_SET_FCN) { char **strv = NULL, **iter; unsigned long flags = 0, val_int; @@ -370,12 +321,7 @@ _set_fcn_gobject_secret_flags (const NmcSettingInfo *setting_info, /*****************************************************************************/ static gboolean -_remove_fcn_nmc (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *option, - guint32 idx, - GError **error) +_remove_fcn_nmc (ARGS_REMOVE_FCN) { return property_info->property_typ_data->nmc.remove_fcn (setting, property_info->property_name, option, idx, error); } @@ -383,15 +329,13 @@ _remove_fcn_nmc (const NmcSettingInfo *setting_info, /*****************************************************************************/ static const char *const* -_values_fcn_nmc (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info) +_values_fcn_nmc (ARGS_VALUES_FCN) { return property_info->property_typ_data->nmc.values_fcn (NULL, property_info->property_name); } static const char *const* -_values_fcn_nmc_gobject_enum (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info) +_values_fcn_nmc_gobject_enum (ARGS_VALUES_FCN) { static GHashTable *cache = NULL; const char **v; @@ -1636,8 +1580,7 @@ DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options, _validate_and_remove_bond_option) static const char * -_describe_fcn_bond_options (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info) +_describe_fcn_bond_options (ARGS_DESCRIBE_FCN) { static char *desc = NULL; const char **valid_options; @@ -1721,11 +1664,7 @@ nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyG } static gboolean -_set_fcn_connection_type (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_type (ARGS_SET_FCN) { gs_free char *uuid = NULL; @@ -1792,11 +1731,7 @@ permissions_valid (const char *perm) } static gboolean -_set_fcn_connection_permissions (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_permissions (ARGS_SET_FCN) { char **strv = NULL; guint i = 0; @@ -1842,11 +1777,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions, _validate_and_remove_connection_permission) static gboolean -_set_fcn_connection_master (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_master (ARGS_SET_FCN) { g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -1866,11 +1797,7 @@ _set_fcn_connection_master (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_connection_secondaries (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_secondaries (ARGS_SET_FCN) { const GPtrArray *connections; NMConnection *con; @@ -1977,11 +1904,7 @@ nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_ } static gboolean -_set_fcn_connection_metered (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_metered (ARGS_SET_FCN) { NMMetered metered; NMCTriStateValue ts_val; @@ -2025,11 +1948,7 @@ nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_typ } static gboolean -_set_fcn_connection_lldp (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_connection_lldp (ARGS_SET_FCN) { NMSettingConnectionLldp lldp; gboolean ret; @@ -2546,10 +2465,7 @@ _parse_ip_address (int family, const char *address, GError **error) } static char * -_get_fcn_ip_config_addresses (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_ip_config_addresses (ARGS_GET_FCN) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); GString *printable; @@ -2574,10 +2490,7 @@ _get_fcn_ip_config_addresses (const NmcSettingInfo *setting_info, } static char * -_get_fcn_ip_config_routes (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_ip_config_routes (ARGS_GET_FCN) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); GString *printable; @@ -2646,10 +2559,7 @@ _get_fcn_ip_config_routes (const NmcSettingInfo *setting_info, } static char * -_get_fcn_ip4_config_dad_timeout (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_ip4_config_dad_timeout (ARGS_GET_FCN) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG (setting); gint dad_timeout; @@ -2678,11 +2588,7 @@ static const char *ipv4_valid_methods[] = { }; static gboolean -_set_fcn_ip4_config_method (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_method (ARGS_SET_FCN) { /* Silently accept "static" and convert to "manual" */ if (value && strlen (value) > 1 && matches (value, "static")) @@ -2692,11 +2598,7 @@ _set_fcn_ip4_config_method (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_ip4_config_dns (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_dns (ARGS_SET_FCN) { char **strv = NULL, **iter, *addr; guint32 ip4_addr; @@ -2742,11 +2644,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns, _validate_and_remove_ipv4_dns) static gboolean -_set_fcn_ip4_config_dns_search (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_dns_search (ARGS_SET_FCN) { char **strv = NULL; guint i = 0; @@ -2787,11 +2685,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search, _validate_and_remove_ipv4_dns_search) static gboolean -_set_fcn_ip4_config_dns_options (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_dns_options (ARGS_SET_FCN) { char **strv = NULL; guint i = 0; @@ -2827,7 +2721,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_option, nm_setting_ip_config_remove_dns_option, _validate_and_remove_ipv4_dns_option) -/* 'addresses' */ static NMIPAddress * _parse_ipv4_address (const char *address, GError **error) { @@ -2835,11 +2728,7 @@ _parse_ipv4_address (const char *address, GError **error) } static gboolean -_set_fcn_ip4_config_addresses (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_addresses (ARGS_SET_FCN) { char **strv = NULL, **iter; NMIPAddress *ip4addr; @@ -2886,11 +2775,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses, _validate_and_remove_ipv4_address) static gboolean -_set_fcn_ip4_config_gateway (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_gateway (ARGS_SET_FCN) { NMIPAddress *ip4addr; @@ -2917,11 +2802,7 @@ _parse_ipv4_route (const char *route, GError **error) } static gboolean -_set_fcn_ip4_config_routes (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip4_config_routes (ARGS_SET_FCN) { char **strv = NULL, **iter; NMIPRoute *ip4route; @@ -2967,10 +2848,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes, _validate_and_remove_ipv4_route) static char * -_get_fcn_ip6_config_ip6_privacy (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_ip6_config_ip6_privacy (ARGS_GET_FCN) { NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting); return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type); @@ -2988,11 +2866,7 @@ static const char *ipv6_valid_methods[] = { }; static gboolean -_set_fcn_ip6_config_method (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_method (ARGS_SET_FCN) { /* Silently accept "static" and convert to "manual" */ if (value && strlen (value) > 1 && matches (value, "static")) @@ -3002,11 +2876,7 @@ _set_fcn_ip6_config_method (const NmcSettingInfo *setting_info, } static gboolean -_set_fcn_ip6_config_dns (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_dns (ARGS_SET_FCN) { char **strv = NULL, **iter, *addr; struct in6_addr ip6_addr; @@ -3052,11 +2922,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns, _validate_and_remove_ipv6_dns) static gboolean -_set_fcn_ip6_config_dns_search (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_dns_search (ARGS_SET_FCN) { char **strv = NULL; guint i = 0; @@ -3097,11 +2963,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search, _validate_and_remove_ipv6_dns_search) static gboolean -_set_fcn_ip6_config_dns_options (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_dns_options (ARGS_SET_FCN) { char **strv = NULL; guint i = 0; @@ -3145,11 +3007,7 @@ _parse_ipv6_address (const char *address, GError **error) } static gboolean -_set_fcn_ip6_config_addresses (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_addresses (ARGS_SET_FCN) { char **strv = NULL, **iter; NMIPAddress *ip6addr; @@ -3195,11 +3053,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses, _validate_and_remove_ipv6_address) static gboolean -_set_fcn_ip6_config_gateway (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_gateway (ARGS_SET_FCN) { NMIPAddress *ip6addr; @@ -3226,11 +3080,7 @@ _parse_ipv6_route (const char *route, GError **error) } static gboolean -_set_fcn_ip6_config_routes (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_routes (ARGS_SET_FCN) { char **strv = NULL, **iter; NMIPRoute *ip6route; @@ -3276,11 +3126,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes, _validate_and_remove_ipv6_route) static gboolean -_set_fcn_ip6_config_ip6_privacy (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_ip6_privacy (ARGS_SET_FCN) { unsigned long val_int; @@ -3303,10 +3149,7 @@ _set_fcn_ip6_config_ip6_privacy (const NmcSettingInfo *setting_info, } static char * -_get_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - NmcPropertyGetType get_type) +_get_fcn_ip6_config_addr_gen_mode (ARGS_GET_FCN) { NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting); NMSettingIP6ConfigAddrGenMode addr_gen_mode; @@ -3317,11 +3160,7 @@ _get_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, static gboolean -_set_fcn_ip6_config_addr_gen_mode (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, - NMSetting *setting, - const char *value, - GError **error) +_set_fcn_ip6_config_addr_gen_mode (ARGS_SET_FCN) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; @@ -3982,8 +3821,7 @@ nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop) } static const char * -_describe_fcn_wired_s390_options (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info) +_describe_fcn_wired_s390_options (ARGS_DESCRIBE_FCN) { static char *desc = NULL; const char **valid_options; From 24434be5a18237402d6cdbc51299771ac628ad3d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Mar 2017 18:48:47 +0200 Subject: [PATCH 31/53] cli: fix intermediate regression of hiding blobs data Restore previous behavior of hiding blobs for certain certificate properties. --- clients/cli/settings.c | 96 +++++++++++++++++------------------------- clients/cli/settings.h | 3 +- 2 files changed, 40 insertions(+), 59 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 0136e848d0..6f84660602 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -43,13 +43,15 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) NM_SETTING_SECRET_FLAG_NOT_SAVED | \ NM_SETTING_SECRET_FLAG_NOT_REQUIRED) +#define HIDDEN_TEXT "" + /*****************************************************************************/ #define ARGS_DESCRIBE_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info #define ARGS_GET_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type, gboolean show_secrets #define ARGS_SET_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error @@ -117,7 +119,7 @@ _get_fcn_gobject_mtu (ARGS_GET_FCN) if ( !property_info->property_typ_data || !property_info->property_typ_data->mtu.get_fcn) - return _get_fcn_gobject (setting_info, property_info, setting, get_type); + return _get_fcn_gobject (setting_info, property_info, setting, get_type, show_secrets); mtu = property_info->property_typ_data->mtu.get_fcn (setting); if (mtu == 0) { @@ -1116,9 +1118,7 @@ nmc_property_802_1X_get_ca_cert (NMSetting *setting, NmcPropertyGetType get_type } static char * -nmc_property_802_1X_get_client_cert (NMSetting *setting, - NmcPropertyGetType get_type, - gboolean show_secrets) +_get_fcn_802_1x_client_cert (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *cert_str = NULL; @@ -1128,7 +1128,7 @@ nmc_property_802_1X_get_client_cert (NMSetting *setting, if (show_secrets) cert_str = bytes_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X)); else - cert_str = g_strdup (_("")); + cert_str = g_strdup (_(HIDDEN_TEXT)); break; case NM_SETTING_802_1X_CK_SCHEME_PATH: cert_str = g_strdup (nm_setting_802_1x_get_client_cert_path (s_8021X)); @@ -1143,12 +1143,6 @@ nmc_property_802_1X_get_client_cert (NMSetting *setting, return cert_str; } -static char * -nmc_property_802_1X_get_client_cert_full (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_802_1X_get_client_cert (setting, get_type, TRUE); -} - static char * nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting, NmcPropertyGetType get_type) { @@ -1173,9 +1167,7 @@ nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting, NmcPropertyGetType g } static char * -nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting, - NmcPropertyGetType get_type, - gboolean show_secrets) +_get_fcn_802_1x_phase2_client_cert (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *cert_str = NULL; @@ -1185,7 +1177,7 @@ nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting, if (show_secrets) cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X)); else - cert_str = g_strdup (_("")); + cert_str = g_strdup (_(HIDDEN_TEXT)); break; case NM_SETTING_802_1X_CK_SCHEME_PATH: cert_str = g_strdup (nm_setting_802_1x_get_phase2_client_cert_path (s_8021X)); @@ -1200,12 +1192,6 @@ nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting, return cert_str; } -static char * -nmc_property_802_1X_get_phase2_client_cert_full (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_802_1X_get_phase2_client_cert (setting, get_type, TRUE); -} - static char * nmc_property_802_1X_get_password_raw (NMSetting *setting, NmcPropertyGetType get_type) { @@ -1214,9 +1200,7 @@ nmc_property_802_1X_get_password_raw (NMSetting *setting, NmcPropertyGetType get } static char * -nmc_property_802_1X_get_private_key (NMSetting *setting, - NmcPropertyGetType get_type, - gboolean show_secrets) +_get_fcn_802_1x_private_key (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *key_str = NULL; @@ -1226,7 +1210,7 @@ nmc_property_802_1X_get_private_key (NMSetting *setting, if (show_secrets) key_str = bytes_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X)); else - key_str = g_strdup (_("")); + key_str = g_strdup (_(HIDDEN_TEXT)); break; case NM_SETTING_802_1X_CK_SCHEME_PATH: key_str = g_strdup (nm_setting_802_1x_get_private_key_path (s_8021X)); @@ -1242,15 +1226,7 @@ nmc_property_802_1X_get_private_key (NMSetting *setting, } static char * -nmc_property_802_1X_get_private_key_full (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_802_1X_get_private_key (setting, get_type, TRUE); -} - -static char * -nmc_property_802_1X_get_phase2_private_key (NMSetting *setting, - NmcPropertyGetType get_type, - gboolean show_secrets) +_get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *key_str = NULL; @@ -1260,7 +1236,7 @@ nmc_property_802_1X_get_phase2_private_key (NMSetting *setting, if (show_secrets) key_str = bytes_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X)); else - key_str = g_strdup (_("")); + key_str = g_strdup (_(HIDDEN_TEXT)); break; case NM_SETTING_802_1X_CK_SCHEME_PATH: key_str = g_strdup (nm_setting_802_1x_get_phase2_private_key_path (s_8021X)); @@ -1275,12 +1251,6 @@ nmc_property_802_1X_get_phase2_private_key (NMSetting *setting, return key_str; } -static char * -nmc_property_802_1X_get_phase2_private_key_full (NMSetting *setting, NmcPropertyGetType get_type) -{ - return nmc_property_802_1X_get_phase2_private_key (setting, get_type, TRUE); -} - #define DEFINE_SETTER_STR_LIST(def_func, set_func) \ static gboolean \ def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ @@ -4638,7 +4608,7 @@ nmc_setting_custom_init (NMSetting *setting) /*****************************************************************************/ static char * -get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, GError **error) +get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, gboolean show_secrets, GError **error) { const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; @@ -4656,7 +4626,8 @@ get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_t return property_info->property_type->get_fcn (setting_info, property_info, setting, - get_type); + get_type, + show_secrets); } } @@ -4674,7 +4645,7 @@ get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_t char * nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error) { - return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, error); + return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, TRUE, error); } /* @@ -4684,7 +4655,7 @@ nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error) char * nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error) { - return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, error); + return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, TRUE, error); } /* @@ -4978,7 +4949,7 @@ _all_properties (const NmcSettingInfo *setting_info) } gboolean -setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean secrets) +setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean show_secrets) { const NMMetaSettingInfo *meta_setting_info; const NmcSettingInfo *setting_info; @@ -5010,13 +4981,14 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean for (i = 0; i < setting_info->properties_num; i++) { const NmcPropertyInfo *property_info = &setting_info->properties[i]; - if (!property_info->is_secret || secrets) { + if (!property_info->is_secret || show_secrets) { set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, property_info, setting, - NMC_PROPERTY_GET_PRETTY)); + NMC_PROPERTY_GET_PRETTY, + show_secrets)); } else - set_val_str (arr, i, g_strdup (_(""))); + set_val_str (arr, i, g_strdup (_(HIDDEN_TEXT))); } g_ptr_array_add (nmc->output_data, arr); @@ -5207,9 +5179,11 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://]\n" "Note that nmcli does not support specifying certificates as raw blob data.\n" "Example: /home/cimrman/jara.crt\n"), - .property_type = &_pt_nmc_getset, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_client_cert, + .set_fcn = _set_fcn_nmc, + ), .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_client_cert_full, .set_fcn = nmc_property_802_1X_set_client_cert, ), }, @@ -5320,9 +5294,11 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://]\n" "Note that nmcli does not support specifying certificates as raw blob data.\n" "Example: /home/cimrman/jara-zweite-phase.crt\n"), - .property_type = &_pt_nmc_getset, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_phase2_client_cert, + .set_fcn = _set_fcn_nmc, + ), .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_phase2_client_cert_full, .set_fcn = nmc_property_802_1X_set_phase2_client_cert, ), }, @@ -5372,9 +5348,11 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://] []\n" "Note that nmcli does not support specifying private key as raw blob data.\n" "Example: /home/cimrman/jara-priv-key Dardanely\n"), - .property_type = &_pt_nmc_getset, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_private_key, + .set_fcn = _set_fcn_nmc, + ), .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_private_key_full, .set_fcn = nmc_property_802_1X_set_private_key, ), }, @@ -5394,9 +5372,11 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://] []\n" "Note that nmcli does not support specifying private key as raw blob data.\n" "Example: /home/cimrman/jara-priv-key Dardanely\n"), - .property_type = &_pt_nmc_getset, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_phase2_private_key, + .set_fcn = _set_fcn_nmc, + ), .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_phase2_private_key_full, .set_fcn = nmc_property_802_1X_set_phase2_private_key, ), }, diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 4ec3158b60..762fc69fbe 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -52,7 +52,8 @@ struct _NmcPropertyType { char *(*get_fcn) (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, - NmcPropertyGetType get_type); + NmcPropertyGetType get_type, + gboolean show_secrets); gboolean (*set_fcn) (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, From 8e74837f148cb0392591d92d0f07b6cc07bb603a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Mar 2017 17:38:27 +0200 Subject: [PATCH 32/53] cli: refactor indirection to legacy signatures (2) --- clients/cli/settings.c | 1409 +++++++++++++++------------------------- clients/cli/settings.h | 27 +- 2 files changed, 534 insertions(+), 902 deletions(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 6f84660602..d4f6efb498 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -31,7 +31,6 @@ /*****************************************************************************/ -static char *wep_key_type_to_string (NMWepKeyType type); static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error); @@ -57,7 +56,7 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error #define ARGS_REMOVE_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *option, guint32 idx, GError **error + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, guint32 idx, GError **error #define ARGS_VALUES_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info @@ -69,12 +68,6 @@ _get_fcn_name (ARGS_GET_FCN) return g_strdup (setting_info->general->setting_name); } -static char * -_get_fcn_nmc (ARGS_GET_FCN) -{ - return property_info->property_typ_data->nmc.get_fcn (setting, get_type); -} - static char * _get_fcn_nmc_with_default (ARGS_GET_FCN) { @@ -82,7 +75,7 @@ _get_fcn_nmc_with_default (ARGS_GET_FCN) char *s_full; GValue val = G_VALUE_INIT; - if (property_info->property_typ_data->nmc.get_fcn_with_default (setting)) { + if (property_info->property_typ_data->subtype.get_with_default.fcn (setting)) { if (get_type == NMC_PROPERTY_GET_PARSABLE) return g_strdup (""); return g_strdup (_("(default)")); @@ -118,10 +111,10 @@ _get_fcn_gobject_mtu (ARGS_GET_FCN) guint32 mtu; if ( !property_info->property_typ_data - || !property_info->property_typ_data->mtu.get_fcn) + || !property_info->property_typ_data->subtype.mtu.get_fcn) return _get_fcn_gobject (setting_info, property_info, setting, get_type, show_secrets); - mtu = property_info->property_typ_data->mtu.get_fcn (setting); + mtu = property_info->property_typ_data->subtype.mtu.get_fcn (setting); if (mtu == 0) { if (get_type == NMC_PROPERTY_GET_PARSABLE) return g_strdup ("auto"); @@ -146,12 +139,6 @@ _get_fcn_gobject_secret_flags (ARGS_GET_FCN) /*****************************************************************************/ -static gboolean -_set_fcn_nmc (ARGS_SET_FCN) -{ - return property_info->property_typ_data->nmc.set_fcn (setting, property_info->property_name, value, error); -} - static gboolean _set_fcn_gobject_string (ARGS_SET_FCN) { @@ -268,7 +255,7 @@ _set_fcn_gobject_mac (ARGS_SET_FCN) gboolean valid; if (property_info->property_typ_data) - mode = property_info->property_typ_data->mac.mode; + mode = property_info->property_typ_data->subtype.mac.mode; else mode = NMC_PROPERTY_TYPE_MAC_MODE_DEFAULT; @@ -322,22 +309,8 @@ _set_fcn_gobject_secret_flags (ARGS_SET_FCN) /*****************************************************************************/ -static gboolean -_remove_fcn_nmc (ARGS_REMOVE_FCN) -{ - return property_info->property_typ_data->nmc.remove_fcn (setting, property_info->property_name, option, idx, error); -} - -/*****************************************************************************/ - static const char *const* -_values_fcn_nmc (ARGS_VALUES_FCN) -{ - return property_info->property_typ_data->nmc.values_fcn (NULL, property_info->property_name); -} - -static const char *const* -_values_fcn_nmc_gobject_enum (ARGS_VALUES_FCN) +_values_fcn_gobject_enum (ARGS_VALUES_FCN) { static GHashTable *cache = NULL; const char **v; @@ -347,11 +320,12 @@ _values_fcn_nmc_gobject_enum (ARGS_VALUES_FCN) v = g_hash_table_lookup (cache, property_info); if (!v) { - bool has_minmax = property_info->property_typ_data->nmc.values_data.gobject_enum.has_minmax; + bool has_minmax = property_info->property_typ_data->subtype.gobject_enum.min + || property_info->property_typ_data->subtype.gobject_enum.max; - v = nm_utils_enum_get_values ( property_info->property_typ_data->nmc.values_data.gobject_enum.get_gtype (), - has_minmax ? property_info->property_typ_data->nmc.values_data.gobject_enum.min : G_MININT, - has_minmax ? property_info->property_typ_data->nmc.values_data.gobject_enum.max : G_MAXINT); + v = nm_utils_enum_get_values ( property_info->property_typ_data->subtype.gobject_enum.get_gtype (), + has_minmax ? property_info->property_typ_data->subtype.gobject_enum.min : G_MININT, + has_minmax ? property_info->property_typ_data->subtype.gobject_enum.max : G_MAXINT); g_hash_table_insert (cache, (gpointer) property_info, v); } return (const char *const*) v; @@ -458,13 +432,18 @@ static const NmcPropertyInfo * _meta_find_property_info_by_setting (NMSetting *setting, const char *property_name, const NmcSettingInfo **out_setting_info) { const NmcSettingInfo *setting_info; + const NmcPropertyInfo *property_info; setting_info = _meta_find_setting_info_by_setting (setting); NM_SET_OUT (out_setting_info, setting_info); if (!setting_info) return NULL; - return _meta_setting_info_find_property_info (setting_info, property_name); + property_info = _meta_setting_info_find_property_info (setting_info, property_name); + + nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), property_name, NULL)); + + return property_info; } /*****************************************************************************/ @@ -663,14 +642,14 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) static gboolean \ def_func (NMSetting *setting, \ const char *prop, \ - const char *val, \ + const char *value, \ const char **valid_strv, \ GError **error) \ { \ char **strv = NULL, **iter; \ const char *item; \ g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ - strv = nmc_strsplit_set (val, " \t,", 0); \ + strv = nmc_strsplit_set (value, " \t,", 0); \ for (iter = strv; iter && *iter; iter++) { \ if (!(item = nmc_string_is_valid (g_strstrip (*iter), valid_strv, error))) { \ g_strfreev (strv); \ @@ -684,7 +663,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) #define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ + def_func (ARGS_SET_FCN) \ { \ char **strv = NULL, **iter; \ const char **(*valid_func1_p) (s_type *) = valid_func1; \ @@ -693,7 +672,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) \ g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ \ - strv = nmc_strsplit_set (val, ",", 0); \ + strv = nmc_strsplit_set (value, ",", 0); \ for (iter = strv; iter && *iter; iter++) { \ char *left = g_strstrip (*iter); \ char *right = strchr (left, '='); \ @@ -726,31 +705,9 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) return TRUE; \ } -#define DEFINE_REMOVER_INDEX(def_func, s_macro, num_func, rem_func) \ - static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \ - { \ - guint32 num; \ - if (option) { \ - g_set_error (error, 1, 0, _("index '%s' is not valid"), option); \ - return FALSE; \ - } \ - num = num_func (s_macro (setting)); \ - if (num == 0) { \ - g_set_error_literal (error, 1, 0, _("no item to remove")); \ - return FALSE; \ - } \ - if (idx >= num) { \ - g_set_error (error, 1, 0, _("index '%d' is not in range <0-%d>"), idx, num - 1); \ - return FALSE; \ - } \ - rem_func (s_macro (setting), idx); \ - return TRUE; \ - } - #define DEFINE_REMOVER_INDEX_OR_VALUE(def_func, s_macro, num_func, rem_func_idx, rem_func_val) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *value, guint32 idx, GError **error) \ + def_func (ARGS_REMOVE_FCN) \ { \ guint32 num; \ if (value) { \ @@ -775,13 +732,13 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) #define DEFINE_REMOVER_OPTION(def_func, s_macro, rem_func) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *option, guint32 idx, GError **error) \ + def_func (ARGS_REMOVE_FCN) \ { \ gboolean success = FALSE; \ - if (option && *option) { \ - success = rem_func (s_macro (setting), option); \ + if (value && *value) { \ + success = rem_func (s_macro (setting), value); \ if (!success) \ - g_set_error (error, 1, 0, _("invalid option '%s'"), option); \ + g_set_error (error, 1, 0, _("invalid option '%s'"), value); \ } else \ g_set_error_literal (error, 1, 0, _("missing option")); \ return success; \ @@ -794,19 +751,9 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) return valid_values; \ } -#define DEFINE_ALLOWED_FOR_ENUMS(def_func, get_type_func, min, max) \ - static const char *const* \ - def_func (NMSetting *setting, const char *prop) \ - { \ - static const char **words = NULL; \ - if (G_UNLIKELY (!words)) \ - words = nm_utils_enum_get_values (get_type_func(), min, max); \ - return words; \ - } - #define DEFINE_SETTER_MAC_BLACKLIST(def_func, s_macro, add_func) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ + def_func (ARGS_SET_FCN) \ { \ guint8 buf[32]; \ char **list = NULL, **iter; \ @@ -814,7 +761,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data) \ g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ \ - list = nmc_strsplit_set (val, " \t,", 0); \ + list = nmc_strsplit_set (value, " \t,", 0); \ for (iter = list; iter && *iter; iter++) { \ if (!nm_utils_hwaddr_aton (*iter, buf, ETH_ALEN)) { \ g_set_error (error, 1, 0, _("'%s' is not a valid MAC"), *iter); \ @@ -856,7 +803,6 @@ verify_string_list (char **strv, return TRUE; } -/* Validate 'val' number against to int property spec */ static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error) { @@ -900,7 +846,6 @@ validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error return success; } -/* Validate 'val' number against to uint property spec */ static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error) { @@ -982,61 +927,61 @@ check_and_set_string (NMSetting *setting, } static gboolean -nmc_property_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_gobject_flags (ARGS_SET_FCN) { unsigned long val_int; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_uint (val, TRUE, 0, G_MAXUINT, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), val); + if (!nmc_string_to_uint (value, TRUE, 0, G_MAXUINT, &val_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); return FALSE; } /* Validate the flags according to the property spec */ - if (!validate_flags (setting, prop, (guint) val_int, error)) + if (!validate_flags (setting, property_info->property_name, (guint) val_int, error)) return FALSE; - g_object_set (setting, prop, (guint) val_int, NULL); + g_object_set (setting, property_info->property_name, (guint) val_int, NULL); return TRUE; } static gboolean -nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_gobject_ssid (ARGS_SET_FCN) { GBytes *ssid; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (strlen (val) > 32) { - g_set_error (error, 1, 0, _("'%s' is not valid"), val); + if (strlen (value) > 32) { + g_set_error (error, 1, 0, _("'%s' is not valid"), value); return FALSE; } - ssid = g_bytes_new (val, strlen (val)); - g_object_set (setting, prop, ssid, NULL); + ssid = g_bytes_new (value, strlen (value)); + g_object_set (setting, property_info->property_name, ssid, NULL); g_bytes_unref (ssid); return TRUE; } static gboolean -nmc_property_set_ifname (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_gobject_ifname (ARGS_SET_FCN) { g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nm_utils_is_valid_iface_name (val, error)) + if (!nm_utils_is_valid_iface_name (value, error)) return FALSE; - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); return TRUE; } static gboolean -nmc_property_set_vpn_service (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_vpn_service_type (ARGS_SET_FCN) { gs_free char *service_name = NULL; - service_name = nm_vpn_plugin_info_list_find_service_type (nm_vpn_get_plugin_infos (), val); - g_object_set (setting, prop, service_name ? : val, NULL); + service_name = nm_vpn_plugin_info_list_find_service_type (nm_vpn_get_plugin_infos (), value); + g_object_set (setting, property_info->property_name, service_name ? : value, NULL); return TRUE; } @@ -1048,7 +993,7 @@ nmc_util_is_domain (const char *domain) } static gboolean -nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *val, GError **error) +nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *value, GError **error) { char **strv = NULL, **iter; char *val_strip; @@ -1060,7 +1005,7 @@ nmc_property_set_byte_array (NMSetting *setting, const char *prop, const char *v g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - val_strip = g_strstrip (g_strdup (val)); + val_strip = g_strstrip (g_strdup (value)); /* First try hex string in the format of AAbbCCDd */ bytes = nm_utils_hexstr2bin (val_strip); @@ -1091,11 +1036,10 @@ done: return success; } -/* === GetFunc, SetFunc, RemoveFunc, DescribeFunc, ValuesFunc - functions for all properties of all settings === */ +/*****************************************************************************/ static char * -nmc_property_802_1X_get_ca_cert (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_802_1x_ca_cert (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *ca_cert_str = NULL; @@ -1144,7 +1088,7 @@ _get_fcn_802_1x_client_cert (ARGS_GET_FCN) } static char * -nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_802_1x_phase2_ca_cert (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); char *phase2_ca_cert_str = NULL; @@ -1193,7 +1137,7 @@ _get_fcn_802_1x_phase2_client_cert (ARGS_GET_FCN) } static char * -nmc_property_802_1X_get_password_raw (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_802_1x_password_raw (ARGS_GET_FCN) { NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting); return bytes_to_string (nm_setting_802_1x_get_password_raw (s_8021X)); @@ -1253,14 +1197,14 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN) #define DEFINE_SETTER_STR_LIST(def_func, set_func) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ + def_func (ARGS_SET_FCN) \ { \ char **strv = NULL; \ guint i = 0; \ \ g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ \ - strv = nmc_strsplit_set (val, " \t,", 0); \ + strv = nmc_strsplit_set (value, " \t,", 0); \ while (strv && strv[i]) \ set_func (NM_SETTING_802_1X (setting), strv[i++]); \ g_strfreev (strv); \ @@ -1269,9 +1213,9 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN) #define DEFINE_SETTER_CERT(def_func, set_func) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ + def_func (ARGS_SET_FCN) \ { \ - char *val_strip = g_strstrip (g_strdup (val)); \ + char *val_strip = g_strstrip (g_strdup (value)); \ char *p = val_strip; \ NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_PATH; \ gboolean success; \ @@ -1288,10 +1232,10 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN) #define DEFINE_SETTER_PRIV_KEY(def_func, pwd_func, set_func) \ static gboolean \ - def_func (NMSetting *setting, const char *prop, const char *val, GError **error) \ + def_func (ARGS_SET_FCN) \ { \ char **strv = NULL; \ - char *val_strip = g_strstrip (g_strdup (val)); \ + char *val_strip = g_strstrip (g_strdup (value)); \ char *p = val_strip; \ const char *path, *password; \ gs_free char *password_free = NULL; \ @@ -1315,18 +1259,6 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN) return success; \ } -/* 'eap' */ -static const char *valid_eap[] = { "leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", NULL }; - -DEFINE_SETTER_STR_LIST_MULTI (check_and_add_802_1X_eap, - NM_SETTING_802_1X, - nm_setting_802_1x_add_eap_method) -static gboolean -nmc_property_802_1X_set_eap (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - return check_and_add_802_1X_eap (setting, prop, val, valid_eap, error); -} - static gboolean _validate_and_remove_eap_method (NMSetting8021x *setting, const char *eap, @@ -1339,17 +1271,15 @@ _validate_and_remove_eap_method (NMSetting8021x *setting, g_set_error (error, 1, 0, _("the property doesn't contain EAP method '%s'"), eap); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_eap, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_802_1x_eap, NM_SETTING_802_1X, nm_setting_802_1x_get_num_eap_methods, nm_setting_802_1x_remove_eap_method, _validate_and_remove_eap_method) -/* 'ca-cert' */ -DEFINE_SETTER_CERT (nmc_property_802_1X_set_ca_cert, nm_setting_802_1x_set_ca_cert) +DEFINE_SETTER_CERT (_set_fcn_802_1x_ca_cert, nm_setting_802_1x_set_ca_cert) -/* 'altsubject-matches' */ -DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_altsubject_matches, nm_setting_802_1x_add_altsubject_match) +DEFINE_SETTER_STR_LIST (_set_fcn_802_1x_altsubject_matches, nm_setting_802_1x_add_altsubject_match) static gboolean _validate_and_remove_altsubject_match (NMSetting8021x *setting, @@ -1365,17 +1295,17 @@ _validate_and_remove_altsubject_match (NMSetting8021x *setting, altsubject_match); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_altsubject_matches, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_802_1x_altsubject_matches, NM_SETTING_802_1X, nm_setting_802_1x_get_num_altsubject_matches, nm_setting_802_1x_remove_altsubject_match, _validate_and_remove_altsubject_match) -DEFINE_SETTER_CERT (nmc_property_802_1X_set_client_cert, nm_setting_802_1x_set_client_cert) +DEFINE_SETTER_CERT (_set_fcn_802_1x_client_cert, nm_setting_802_1x_set_client_cert) -DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert) +DEFINE_SETTER_CERT (_set_fcn_802_1x_phase2_ca_cert, nm_setting_802_1x_set_phase2_ca_cert) -DEFINE_SETTER_STR_LIST (nmc_property_802_1X_set_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match) +DEFINE_SETTER_STR_LIST (_set_fcn_802_1x_phase2_altsubject_matches, nm_setting_802_1x_add_phase2_altsubject_match) static gboolean _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting, @@ -1391,30 +1321,30 @@ _validate_and_remove_phase2_altsubject_match (NMSetting8021x *setting, phase2_altsubject_match); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_802_1X_remove_phase2_altsubject_matches, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_802_1x_phase2_altsubject_matches, NM_SETTING_802_1X, nm_setting_802_1x_get_num_phase2_altsubject_matches, nm_setting_802_1x_remove_phase2_altsubject_match, _validate_and_remove_phase2_altsubject_match) -DEFINE_SETTER_CERT (nmc_property_802_1X_set_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert) +DEFINE_SETTER_CERT (_set_fcn_802_1x_phase2_client_cert, nm_setting_802_1x_set_phase2_client_cert) -DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_private_key, +DEFINE_SETTER_PRIV_KEY (_set_fcn_802_1x_private_key, nm_setting_802_1x_get_private_key_password, nm_setting_802_1x_set_private_key) -DEFINE_SETTER_PRIV_KEY (nmc_property_802_1X_set_phase2_private_key, +DEFINE_SETTER_PRIV_KEY (_set_fcn_802_1x_phase2_private_key, nm_setting_802_1x_get_phase2_private_key_password, nm_setting_802_1x_set_phase2_private_key) static gboolean -nmc_property_802_1X_set_password_raw (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_802_1x_password_raw (ARGS_SET_FCN) { - return nmc_property_set_byte_array (setting, prop, val, error); + return nmc_property_set_byte_array (setting, property_info->property_name, value, error); } static char * -nmc_property_802_1X_get_phase1_auth_flags (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_802_1x_phase1_auth_flags (ARGS_GET_FCN) { NMSetting8021x *s_8021x = NM_SETTING_802_1X (setting); NMSetting8021xAuthFlags flags; @@ -1431,21 +1361,20 @@ nmc_property_802_1X_get_phase1_auth_flags (NMSetting *setting, NmcPropertyGetTyp } static gboolean -nmc_property_802_1X_set_phase1_auth_flags (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_802_1x_phase1_auth_flags (ARGS_SET_FCN) { NMSetting8021xAuthFlags flags; gs_free char *err_token = NULL; gboolean ret; long int t; - if (nmc_string_to_int_base (val, 0, TRUE, + if (nmc_string_to_int_base (value, 0, TRUE, NM_SETTING_802_1X_AUTH_FLAGS_NONE, NM_SETTING_802_1X_AUTH_FLAGS_ALL, &t)) flags = (NMSetting8021xAuthFlags) t; else { - ret = nm_utils_enum_from_str (nm_setting_802_1x_auth_flags_get_type (), val, + ret = nm_utils_enum_from_str (nm_setting_802_1x_auth_flags_get_type (), value, (int *) &flags, &err_token); if (!ret) { @@ -1461,12 +1390,12 @@ nmc_property_802_1X_set_phase1_auth_flags (NMSetting *setting, const char *prop, } } - g_object_set (setting, prop, (guint) flags, NULL); + g_object_set (setting, property_info->property_name, (guint) flags, NULL); return TRUE; } static char * -nmc_property_bond_get_options (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_bond_options (ARGS_GET_FCN) { NMSettingBond *s_bond = NM_SETTING_BOND (setting); GString *bond_options_s; @@ -1511,7 +1440,6 @@ _validate_and_remove_bond_option (NMSettingBond *setting, const char *option) return FALSE; } -/* Validate bonding 'options' values */ static const char * _validate_bond_option_value (const char *option, const char *value, GError **error) { @@ -1539,13 +1467,13 @@ _bond_add_option (NMSettingBond *setting, return nm_setting_bond_add_option (setting, name, value); } -DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options, +DEFINE_SETTER_OPTIONS (_set_fcn_bond_options, NM_SETTING_BOND, NMSettingBond, _bond_add_option, nm_setting_bond_get_valid_options, _validate_bond_option_value) -DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options, +DEFINE_REMOVER_OPTION (_remove_fcn_bond_options, NM_SETTING_BOND, _validate_and_remove_bond_option) @@ -1578,13 +1506,13 @@ _describe_fcn_bond_options (ARGS_DESCRIBE_FCN) } static const char *const* -nmc_property_bond_allowed_options (NMSetting *setting, const char *prop) +_values_fcn_bond_options (ARGS_VALUES_FCN) { - return nm_setting_bond_get_valid_options (NM_SETTING_BOND (setting)); + return nm_setting_bond_get_valid_options (NULL); } static char * -nmc_property_connection_get_autoconnect_retries (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_connection_autoconnect_retires (ARGS_GET_FCN) { NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); gint retries; @@ -1604,7 +1532,7 @@ nmc_property_connection_get_autoconnect_retries (NMSetting *setting, NmcProperty } static char * -nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_connection_permissions (ARGS_GET_FCN) { NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); GString *perm = NULL; @@ -1627,7 +1555,7 @@ nmc_property_connection_get_permissions (NMSetting *setting, NmcPropertyGetType } static char * -nmc_property_connection_get_autoconnect_slaves (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_connection_autoconnect_slaves (ARGS_GET_FCN) { NMSettingConnection *s_con = NM_SETTING_CONNECTION (setting); return autoconnect_slaves_to_string (nm_setting_connection_get_autoconnect_slaves (s_con), get_type); @@ -1659,26 +1587,6 @@ _set_fcn_connection_type (ARGS_SET_FCN) return TRUE; } -#if 0 -/* - * Setting/removing UUID has been forbidden. - * Should it be enabled later, this function can be used. - */ -static gboolean -nmc_property_con_set_uuid (NMSetting *setting, const char *prop, const char *val, GError **error) -{ - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nm_utils_is_uuid (val)) { - g_set_error (error, 1, 0, _("'%s' is not a valid UUID"), val); - return FALSE; - } - g_object_set (setting, prop, val, NULL); - return TRUE; -} -#endif - -/* 'permissions' */ /* define from libnm-core/nm-setting-connection.c */ #define PERM_USER_PREFIX "user:" @@ -1740,7 +1648,7 @@ _validate_and_remove_connection_permission (NMSettingConnection *setting, g_set_error (error, 1, 0, _("the property doesn't contain permission '%s'"), perm); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_permissions, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_connection_permissions, NM_SETTING_CONNECTION, nm_setting_connection_get_num_permissions, nm_setting_connection_remove_permission, @@ -1839,15 +1747,14 @@ _validate_and_remove_connection_secondary (NMSettingConnection *setting, _("the property doesn't contain UUID '%s'"), secondary_uuid); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_connection_remove_secondaries, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_connection_secondaries, NM_SETTING_CONNECTION, nm_setting_connection_get_num_secondaries, nm_setting_connection_remove_secondary, _validate_and_remove_connection_secondary) -/* 'metered' */ static char * -nmc_property_connection_get_metered (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_connection_metered (ARGS_GET_FCN) { NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting); @@ -1901,7 +1808,7 @@ _set_fcn_connection_metered (ARGS_SET_FCN) } static char * -nmc_property_connection_get_lldp (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_connection_lldp (ARGS_GET_FCN) { NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting); NMSettingConnectionLldp lldp; @@ -1948,7 +1855,6 @@ _set_fcn_connection_lldp (ARGS_SET_FCN) return TRUE; } -/* --- NM_SETTING_DCB_SETTING_NAME property functions --- */ static char * dcb_flags_to_string (NMSettingDcbFlags flags) { @@ -1979,7 +1885,7 @@ dcb_flags_to_string (NMSettingDcbFlags flags) #define DEFINE_DCB_FLAGS_GETTER(func_name, property_name) \ static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ + func_name (ARGS_GET_FCN) \ { \ guint v; \ GValue val = G_VALUE_INIT; \ @@ -1998,7 +1904,7 @@ dcb_app_priority_to_string (gint priority) #define DEFINE_DCB_APP_PRIORITY_GETTER(func_name, property_name) \ static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ + func_name (ARGS_GET_FCN) \ { \ int v; \ GValue val = G_VALUE_INIT; \ @@ -2011,12 +1917,12 @@ dcb_app_priority_to_string (gint priority) #define DEFINE_DCB_BOOL_GETTER(func_name, getter_func_name) \ static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ + func_name (ARGS_GET_FCN) \ { \ NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \ GString *str; \ guint i; \ - \ +\ str = g_string_new (NULL); \ for (i = 0; i < 8; i++) { \ if (getter_func_name (s_dcb, i)) \ @@ -2033,7 +1939,7 @@ dcb_app_priority_to_string (gint priority) #define DEFINE_DCB_UINT_GETTER(func_name, getter_func_name) \ static char * \ - func_name (NMSetting *setting, NmcPropertyGetType get_type) \ + func_name (ARGS_GET_FCN) \ { \ NMSettingDcb *s_dcb = NM_SETTING_DCB (setting); \ GString *str; \ @@ -2049,27 +1955,27 @@ dcb_app_priority_to_string (gint priority) return g_string_free (str, FALSE); \ } -DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS) -DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY) -DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS) -DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY) -DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS) -DEFINE_DCB_APP_PRIORITY_GETTER (nmc_property_dcb_get_app_fip_priority, NM_SETTING_DCB_APP_FIP_PRIORITY) +DEFINE_DCB_FLAGS_GETTER (_get_fcn_dcb_app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS) +DEFINE_DCB_APP_PRIORITY_GETTER (_get_fcn_dcb_app_fcoe_priority, NM_SETTING_DCB_APP_FCOE_PRIORITY) +DEFINE_DCB_FLAGS_GETTER (_get_fcn_dcb_app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS) +DEFINE_DCB_APP_PRIORITY_GETTER (_get_fcn_dcb_app_iscsi_priority, NM_SETTING_DCB_APP_ISCSI_PRIORITY) +DEFINE_DCB_FLAGS_GETTER (_get_fcn_dcb_app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS) +DEFINE_DCB_APP_PRIORITY_GETTER (_get_fcn_dcb_app_fip_priority, NM_SETTING_DCB_APP_FIP_PRIORITY) -DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS) -DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pfc, nm_setting_dcb_get_priority_flow_control) +DEFINE_DCB_FLAGS_GETTER (_get_fcn_dcb_priority_flow_control_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS) +DEFINE_DCB_BOOL_GETTER (_get_fcn_dcb_priority_flow_control, nm_setting_dcb_get_priority_flow_control) -DEFINE_DCB_FLAGS_GETTER (nmc_property_dcb_get_pg_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS) -DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_id, nm_setting_dcb_get_priority_group_id) -DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_group_bandwidth, nm_setting_dcb_get_priority_group_bandwidth) -DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_bandwidth, nm_setting_dcb_get_priority_bandwidth) -DEFINE_DCB_BOOL_GETTER (nmc_property_dcb_get_pg_strict, nm_setting_dcb_get_priority_strict_bandwidth) -DEFINE_DCB_UINT_GETTER (nmc_property_dcb_get_pg_traffic_class, nm_setting_dcb_get_priority_traffic_class) +DEFINE_DCB_FLAGS_GETTER (_get_fcn_dcb_priority_group_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS) +DEFINE_DCB_UINT_GETTER (_get_fcn_dcb_priority_group_id, nm_setting_dcb_get_priority_group_id) +DEFINE_DCB_UINT_GETTER (_get_fcn_dcb_priority_group_bandwidth, nm_setting_dcb_get_priority_group_bandwidth) +DEFINE_DCB_UINT_GETTER (_get_fcn_dcb_priority_bandwidth, nm_setting_dcb_get_priority_bandwidth) +DEFINE_DCB_BOOL_GETTER (_get_fcn_dcb_priority_strict, nm_setting_dcb_get_priority_strict_bandwidth) +DEFINE_DCB_UINT_GETTER (_get_fcn_dcb_priority_traffic_class, nm_setting_dcb_get_priority_traffic_class) #define DCB_ALL_FLAGS (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) static gboolean -nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_flags (ARGS_SET_FCN) { char **strv = NULL, **iter; NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; @@ -2078,11 +1984,11 @@ nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *va g_return_val_if_fail (error == NULL || *error == NULL, FALSE); /* Check for overall hex numeric value */ - if (nmc_string_to_int_base (val, 0, TRUE, 0, DCB_ALL_FLAGS, &t)) + if (nmc_string_to_int_base (value, 0, TRUE, 0, DCB_ALL_FLAGS, &t)) flags = (guint) t; else { /* Check for individual flag numbers */ - strv = nmc_strsplit_set (val, " \t,", 0); + strv = nmc_strsplit_set (value, " \t,", 0); for (iter = strv; iter && *iter; iter++) { if (!nmc_string_to_int_base (*iter, 0, TRUE, 0, DCB_ALL_FLAGS, &t)) t = -1; @@ -2110,30 +2016,30 @@ nmc_property_dcb_set_flags (NMSetting *setting, const char *prop, const char *va } /* Validate the flags according to the property spec */ - if (!validate_flags (setting, prop, (guint) flags, error)) + if (!validate_flags (setting, property_info->property_name, (guint) flags, error)) return FALSE; - g_object_set (setting, prop, (guint) flags, NULL); + g_object_set (setting, property_info->property_name, (guint) flags, NULL); return TRUE; } static gboolean -nmc_property_dcb_set_priority (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority (ARGS_SET_FCN) { long int priority = 0; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_int (val, FALSE, -1, 7, &priority)) { - g_set_error (error, 1, 0, _("'%s' is not a DCB app priority"), val); + if (!nmc_string_to_int (value, FALSE, -1, 7, &priority)) { + g_set_error (error, 1, 0, _("'%s' is not a DCB app priority"), value); return FALSE; } /* Validate the number according to the property spec */ - if (!validate_int (setting, prop, (gint) priority, error)) + if (!validate_int (setting, property_info->property_name, (gint) priority, error)) return FALSE; - g_object_set (setting, prop, (gint) priority, NULL); + g_object_set (setting, property_info->property_name, (gint) priority, NULL); return TRUE; } @@ -2197,14 +2103,14 @@ dcb_check_feature_enabled (NMSettingDcb *s_dcb, const char *flags_prop) } static gboolean -nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_flow_control (ARGS_SET_FCN) { guint i = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 1, 0, nums, error)) + if (!dcb_parse_uint_array (value, 1, 0, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2215,14 +2121,14 @@ nmc_property_dcb_set_pfc (NMSetting *setting, const char *prop, const char *val, } static gboolean -nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_group_id (ARGS_SET_FCN) { guint i = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 7, 15, nums, error)) + if (!dcb_parse_uint_array (value, 7, 15, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2233,14 +2139,14 @@ nmc_property_dcb_set_pg_group_id (NMSetting *setting, const char *prop, const ch } static gboolean -nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_group_bandwidth (ARGS_SET_FCN) { guint i = 0, sum = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 100, 0, nums, error)) + if (!dcb_parse_uint_array (value, 100, 0, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2258,14 +2164,14 @@ nmc_property_dcb_set_pg_group_bandwidth (NMSetting *setting, const char *prop, c } static gboolean -nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_bandwidth (ARGS_SET_FCN) { guint i = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 100, 0, nums, error)) + if (!dcb_parse_uint_array (value, 100, 0, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2276,14 +2182,14 @@ nmc_property_dcb_set_pg_bandwidth (NMSetting *setting, const char *prop, const c } static gboolean -nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_strict (ARGS_SET_FCN) { guint i = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 1, 0, nums, error)) + if (!dcb_parse_uint_array (value, 1, 0, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2294,14 +2200,14 @@ nmc_property_dcb_set_pg_strict (NMSetting *setting, const char *prop, const char } static gboolean -nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_dcb_priority_traffic_class (ARGS_SET_FCN) { guint i = 0; guint nums[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!dcb_parse_uint_array (val, 7, 0, nums, error)) + if (!dcb_parse_uint_array (value, 7, 0, nums, error)) return FALSE; for (i = 0; i < 8; i++) @@ -2312,13 +2218,13 @@ nmc_property_dcb_set_pg_traffic_class (NMSetting *setting, const char *prop, con } static gboolean -nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_gsm_sim_operator_id (ARGS_SET_FCN) { - const char *p = val; + const char *p = value; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (strlen (val) != 5 && strlen (val) != 6) { + if (strlen (value) != 5 && strlen (value) != 6) { g_set_error_literal (error, 1, 0, _("SIM operator ID must be a 5 or 6 number MCCMNC code")); return FALSE; } @@ -2331,39 +2237,39 @@ nmc_property_gsm_set_sim_operator_id (NMSetting *setting, const char *prop, cons } g_object_set (G_OBJECT (setting), NM_SETTING_GSM_SIM_OPERATOR_ID, - val, + value, NULL); return TRUE; } static gboolean -nmc_property_ib_set_p_key (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_infiniband_p_key (ARGS_SET_FCN) { gboolean p_key_valid = FALSE; long p_key_int; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!strncasecmp (val, "0x", 2)) - p_key_valid = nmc_string_to_int_base (val + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int); + if (!strncasecmp (value, "0x", 2)) + p_key_valid = nmc_string_to_int_base (value + 2, 16, TRUE, 0, G_MAXUINT16, &p_key_int); else - p_key_valid = nmc_string_to_int (val, TRUE, -1, G_MAXUINT16, &p_key_int); + p_key_valid = nmc_string_to_int (value, TRUE, -1, G_MAXUINT16, &p_key_int); if (!p_key_valid) { - if (strcmp (val, "default") == 0) + if (strcmp (value, "default") == 0) p_key_int = -1; else { - g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), val); + g_set_error (error, 1, 0, _("'%s' is not a valid IBoIP P_Key"), value); return FALSE; } } - g_object_set (setting, prop, (gint) p_key_int, NULL); + g_object_set (setting, property_info->property_name, (gint) p_key_int, NULL); return TRUE; } static char * -nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_infiniband_p_key (ARGS_GET_FCN) { NMSettingInfiniband *s_infiniband = NM_SETTING_INFINIBAND (setting); int p_key; @@ -2379,7 +2285,7 @@ nmc_property_ib_get_p_key (NMSetting *setting, NmcPropertyGetType get_type) } static char * -nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_ip_tunnel_mode (ARGS_GET_FCN) { NMSettingIPTunnel *s_ip_tunnel = NM_SETTING_IP_TUNNEL (setting); NMIPTunnelMode mode; @@ -2389,14 +2295,13 @@ nmc_property_ip_tunnel_get_mode (NMSetting *setting, NmcPropertyGetType get_type } static gboolean -nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_ip_tunnel_mode (ARGS_SET_FCN) { NMIPTunnelMode mode; gboolean ret; - ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), val, - (int *) &mode, NULL); + ret = nm_utils_enum_from_str (nm_ip_tunnel_mode_get_type(), value, + (int *) &mode, NULL); if (!ret) { gs_free const char **values = NULL; @@ -2407,22 +2312,15 @@ nmc_property_ip_tunnel_set_mode (NMSetting *setting, const char *prop, G_MAXINT); values_str = g_strjoinv (",", (char **) values); g_set_error (error, 1, 0, _("invalid mode '%s', use one of %s"), - val, values_str); + value, values_str); return FALSE; } - g_object_set (setting, prop, mode, NULL); + g_object_set (setting, property_info->property_name, mode, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_ip_tunnel_allowed_mode, - nm_ip_tunnel_mode_get_type, - NM_IP_TUNNEL_MODE_UNKNOWN + 1, G_MAXINT) - - -/* --- NM_SETTING_IP4_CONFIG_SETTING_NAME property functions --- */ -/* --- IP4 / IP6 shared functions --- */ static NMIPAddress * _parse_ip_address (int family, const char *address, GError **error) { @@ -2607,7 +2505,7 @@ _validate_and_remove_ipv4_dns (NMSettingIPConfig *setting, g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns, nm_setting_ip_config_remove_dns, @@ -2648,7 +2546,7 @@ _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting, dns_search); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_search, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns_search, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns_searches, nm_setting_ip_config_remove_dns_search, @@ -2685,7 +2583,7 @@ _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting, dns_option); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_dns_option, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns_options, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns_options, nm_setting_ip_config_remove_dns_option, @@ -2738,7 +2636,7 @@ _validate_and_remove_ipv4_address (NMSettingIPConfig *setting, nm_ip_address_unref (ip4addr); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_addresses, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_addresses, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_addresses, nm_setting_ip_config_remove_address, @@ -2811,7 +2709,7 @@ _validate_and_remove_ipv4_route (NMSettingIPConfig *setting, nm_ip_route_unref (ip4route); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv4_remove_routes, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_routes, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_routes, nm_setting_ip_config_remove_route, @@ -2824,7 +2722,6 @@ _get_fcn_ip6_config_ip6_privacy (ARGS_GET_FCN) return ip6_privacy_to_string (nm_setting_ip6_config_get_ip6_privacy (s_ip6), get_type); } -/* 'method' */ static const char *ipv6_valid_methods[] = { NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP6_CONFIG_METHOD_AUTO, @@ -2885,7 +2782,7 @@ _validate_and_remove_ipv6_dns (NMSettingIPConfig *setting, g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_dns, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns, nm_setting_ip_config_remove_dns, @@ -2926,7 +2823,7 @@ _validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting, dns_search); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_search, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_dns_search, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns_searches, nm_setting_ip_config_remove_dns_search, @@ -2963,13 +2860,12 @@ _validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting, dns_option); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_dns_option, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_dns_options, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_dns_options, nm_setting_ip_config_remove_dns_option, _validate_and_remove_ipv6_dns_option) -/* 'addresses' */ static NMIPAddress * _parse_ipv6_address (const char *address, GError **error) { @@ -3016,7 +2912,7 @@ _validate_and_remove_ipv6_address (NMSettingIPConfig *setting, nm_ip_address_unref (ip6addr); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_addresses, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_addresses, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_addresses, nm_setting_ip_config_remove_address, @@ -3089,7 +2985,7 @@ _validate_and_remove_ipv6_route (NMSettingIPConfig *setting, nm_ip_route_unref (ip6route); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_ipv6_remove_routes, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_routes, NM_SETTING_IP_CONFIG, nm_setting_ip_config_get_num_routes, nm_setting_ip_config_remove_route, @@ -3146,7 +3042,7 @@ _set_fcn_ip6_config_addr_gen_mode (ARGS_SET_FCN) } static char * -nmc_property_macsec_get_mode (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_macsec_mode (ARGS_GET_FCN) { NMSettingMacsec *s_macsec = NM_SETTING_MACSEC (setting); NMSettingMacsecMode mode; @@ -3156,34 +3052,28 @@ nmc_property_macsec_get_mode (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_macsec_set_mode (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_macsec_mode (ARGS_SET_FCN) { NMSettingMacsecMode mode; gs_free char *options = NULL; - if (!nm_utils_enum_from_str (nm_setting_macsec_mode_get_type (), val, + if (!nm_utils_enum_from_str (nm_setting_macsec_mode_get_type (), value, (int *) &mode, NULL)) { options = g_strjoinv (",", (char **) nm_utils_enum_get_values (nm_setting_macsec_mode_get_type (), G_MININT, G_MAXINT)); g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), - val, options); + value, options); return FALSE; } - g_object_set (setting, prop, mode, NULL); + g_object_set (setting, property_info->property_name, mode, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_macsec_allowed_mode, - nm_setting_macsec_mode_get_type, - G_MININT, G_MAXINT) - -/* 'validation' */ static char * -nmc_property_macsec_get_validation (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_macsec_validation (ARGS_GET_FCN) { NMSettingMacsec *s_macsec = NM_SETTING_MACSEC (setting); NMSettingMacsecValidation validation; @@ -3193,33 +3083,28 @@ nmc_property_macsec_get_validation (NMSetting *setting, NmcPropertyGetType get_t } static gboolean -nmc_property_macsec_set_validation (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_macsec_validation (ARGS_SET_FCN) { NMSettingMacsecMode validation; gs_free char *options = NULL; - if (!nm_utils_enum_from_str (nm_setting_macsec_validation_get_type (), val, + if (!nm_utils_enum_from_str (nm_setting_macsec_validation_get_type (), value, (int *) &validation, NULL)) { options = g_strjoinv (",", (char **) nm_utils_enum_get_values (nm_setting_macsec_validation_get_type (), G_MININT, G_MAXINT)); g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), - val, options); + value, options); return FALSE; } - g_object_set (setting, prop, validation, NULL); + g_object_set (setting, property_info->property_name, validation, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_macsec_allowed_validation, - nm_setting_macsec_validation_get_type, - G_MININT, G_MAXINT) - static char * -nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_macvlan_mode (ARGS_GET_FCN) { NMSettingMacvlan *s_macvlan = NM_SETTING_MACVLAN (setting); NMSettingMacvlanMode mode; @@ -3238,8 +3123,7 @@ nmc_property_macvlan_get_mode (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_macvlan_mode (ARGS_SET_FCN) { NMSettingMacvlanMode mode; gs_free const char **options = NULL; @@ -3247,10 +3131,10 @@ nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop, long int t; gboolean ret; - if (nmc_string_to_int_base (val, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t)) + if (nmc_string_to_int_base (value, 0, TRUE, 0, _NM_SETTING_MACVLAN_MODE_NUM - 1, &t)) mode = (NMSettingMacvlanMode) t; else { - ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), val, + ret = nm_utils_enum_from_str (nm_setting_macvlan_mode_get_type (), value, (int *) &mode, NULL); if (!ret) { @@ -3259,21 +3143,17 @@ nmc_property_macvlan_set_mode (NMSetting *setting, const char *prop, G_MAXINT); options_str = g_strjoinv (",", (char **) options); g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), - val, options_str); + value, options_str); return FALSE; } } - g_object_set (setting, prop, (guint) mode, NULL); + g_object_set (setting, property_info->property_name, (guint) mode, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_macvlan_allowed_mode, - nm_setting_macvlan_mode_get_type, - NM_SETTING_MACVLAN_MODE_UNKNOWN + 1, G_MAXINT) - static char * -nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_olpc_mesh_ssid (ARGS_GET_FCN) { NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting); GBytes *ssid; @@ -3289,22 +3169,22 @@ nmc_property_olpc_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_olpc_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_olpc_mesh_channel (ARGS_SET_FCN) { unsigned long chan_int; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_uint (val, TRUE, 1, 13, &chan_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid channel; use <1-13>"), val); + if (!nmc_string_to_uint (value, TRUE, 1, 13, &chan_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid channel; use <1-13>"), value); return FALSE; } - g_object_set (setting, prop, chan_int, NULL); + g_object_set (setting, property_info->property_name, chan_int, NULL); return TRUE; } static char * -nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_proxy_method (ARGS_GET_FCN) { NMSettingProxy *s_proxy = NM_SETTING_PROXY (setting); NMSettingProxyMethod method; @@ -3314,13 +3194,12 @@ nmc_property_proxy_get_method (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_proxy_set_method (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_proxy_method (ARGS_SET_FCN) { int method; gboolean ret; - ret = nm_utils_enum_from_str (nm_setting_proxy_method_get_type(), val, + ret = nm_utils_enum_from_str (nm_setting_proxy_method_get_type(), value, &method, NULL); if (!ret) { @@ -3332,37 +3211,32 @@ nmc_property_proxy_set_method (NMSetting *setting, const char *prop, G_MAXINT); values_str = g_strjoinv (",", (char **) values); g_set_error (error, 1, 0, _("invalid method '%s', use one of %s"), - val, values_str); + value, values_str); return FALSE; } - g_object_set (setting, prop, method, NULL); + g_object_set (setting, property_info->property_name, method, NULL); return TRUE; } -DEFINE_ALLOWED_FOR_ENUMS (nmc_property_proxy_allowed_method, - nm_setting_proxy_method_get_type, - NM_SETTING_PROXY_METHOD_NONE, G_MAXINT) - static gboolean -nmc_property_proxy_set_pac_script (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_proxy_pac_script (ARGS_SET_FCN) { char *script = NULL; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_proxy_check_script (val, &script, error)) { + if (!nmc_proxy_check_script (value, &script, error)) { return FALSE; } - g_object_set (setting, prop, script, NULL); + g_object_set (setting, property_info->property_name, script, NULL); g_free (script); return TRUE; } static char * -nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_serial_parity (ARGS_GET_FCN) { NMSettingSerial *s_serial = NM_SETTING_SERIAL (setting); @@ -3378,42 +3252,42 @@ nmc_property_serial_get_parity (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_serial_set_parity (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_serial_parity (ARGS_SET_FCN) { NMSettingSerialParity parity; - if (val[0] == 'E' || val[0] == 'e') + if (value[0] == 'E' || value[0] == 'e') parity = NM_SETTING_SERIAL_PARITY_EVEN; - else if (val[0] == 'O' || val[0] == 'o') + else if (value[0] == 'O' || value[0] == 'o') parity = NM_SETTING_SERIAL_PARITY_ODD; - else if (val[0] == 'N' || val[0] == 'n') + else if (value[0] == 'N' || value[0] == 'n') parity = NM_SETTING_SERIAL_PARITY_NONE; else { - g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), val); + g_set_error (error, 1, 0, _("'%s' is not valid; use [e, o, n]"), value); return FALSE; } - g_object_set (setting, prop, parity, NULL); + g_object_set (setting, property_info->property_name, parity, NULL); return TRUE; } static gboolean -nmc_property_team_set_config (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_team_config (ARGS_SET_FCN) { char *json = NULL; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_team_check_config (val, &json, error)) { + if (!nmc_team_check_config (value, &json, error)) { return FALSE; } - g_object_set (setting, prop, json, NULL); + g_object_set (setting, property_info->property_name, json, NULL); g_free (json); return TRUE; } static char * -nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_tun_mode (ARGS_GET_FCN) { NMSettingTun *s_tun = NM_SETTING_TUN (setting); NMSettingTunMode mode; @@ -3430,65 +3304,59 @@ nmc_property_tun_get_mode (NMSetting *setting, NmcPropertyGetType get_type) } static gboolean -nmc_property_tun_set_mode (NMSetting *setting, const char *prop, - const char *val, GError **error) +_set_fcn_tun_mode (ARGS_SET_FCN) { NMSettingTunMode mode; gboolean ret; long int t; - if (nmc_string_to_int_base (val, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t)) + if (nmc_string_to_int_base (value, 0, TRUE, 0, NM_SETTING_TUN_MODE_TAP, &t)) mode = (NMSettingTunMode) t; else { - ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), val, + ret = nm_utils_enum_from_str (nm_setting_tun_mode_get_type (), value, (int *) &mode, NULL); if (!ret) { g_set_error (error, 1, 0, _("invalid option '%s', use '%s' or '%s'"), - val, "tun", "tap"); + value, "tun", "tap"); return FALSE; } } - g_object_set (setting, prop, (guint) mode, NULL); + g_object_set (setting, property_info->property_name, (guint) mode, NULL); return TRUE; } -static const char *tun_valid_modes[] = { "tun", "tap", "unknown", NULL }; - -DEFINE_ALLOWED_VAL_FUNC (nmc_property_tun_allowed_mode, tun_valid_modes) - static char * -nmc_property_vlan_get_flags (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_vlan_flags (ARGS_GET_FCN) { NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); return vlan_flags_to_string (nm_setting_vlan_get_flags (s_vlan), get_type); } static char * -nmc_property_vlan_get_ingress_priority_map (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_vlan_ingress_priority_map (ARGS_GET_FCN) { NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); return vlan_priorities_to_string (s_vlan, NM_VLAN_INGRESS_MAP); } static char * -nmc_property_vlan_get_egress_priority_map (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_vlan_egress_priority_map (ARGS_GET_FCN) { NMSettingVlan *s_vlan = NM_SETTING_VLAN (setting); return vlan_priorities_to_string (s_vlan, NM_VLAN_EGRESS_MAP); } static gboolean -nmc_property_vlan_set_prio_map (NMSetting *setting, - const char *prop, - const char *val, - NMVlanPriorityMap map_type, - GError **error) +_set_vlan_xgress_priority_map (NMSetting *setting, + const char *value, + NMVlanPriorityMap map_type, + GError **error) { char **prio_map, **p; - prio_map = nmc_vlan_parse_priority_maps (val, map_type, error); + prio_map = nmc_vlan_parse_priority_maps (value, map_type, error); if (!prio_map) return FALSE; @@ -3500,14 +3368,50 @@ nmc_property_vlan_set_prio_map (NMSetting *setting, } static gboolean -nmc_property_vlan_remove_prio_map (NMSetting *setting, - const char *prop, - guint32 idx, - NMVlanPriorityMap map_type, - GError **error) +_set_fcn_vlan_ingress_priority_map (ARGS_SET_FCN) +{ + return _set_vlan_xgress_priority_map (setting, value, NM_VLAN_INGRESS_MAP, error); +} + +static gboolean +_set_fcn_vlan_egress_priority_map (ARGS_SET_FCN) +{ + return _set_vlan_xgress_priority_map (setting, value, NM_VLAN_EGRESS_MAP, error); +} + +static gboolean +_remove_vlan_xgress_priority_map (NMSetting *setting, + const NmcPropertyInfo *property_info, + const char *value, + guint32 idx, + NMVlanPriorityMap map_type, + GError **error) { guint32 num; + /* If value != NULL, remove by value */ + if (value) { + gboolean ret; + char **prio_map; + gs_free char *v = g_strdup (value); + + prio_map = nmc_vlan_parse_priority_maps (v, map_type, error); + if (!prio_map) + return FALSE; + if (prio_map[1]) + g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"), + prio_map[0]); + ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting), + map_type, + prio_map[0]); + + if (!ret) + g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]); + g_strfreev (prio_map); + return ret; + } + + /* Else remove by index */ num = nm_setting_vlan_get_num_priorities (NM_SETTING_VLAN (setting), map_type); if (num == 0) { g_set_error_literal (error, 1, 0, _("no priority to remove")); @@ -3524,84 +3428,29 @@ nmc_property_vlan_remove_prio_map (NMSetting *setting, } static gboolean -nmc_property_vlan_set_ingress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error) +_remove_fcn_vlan_ingress_priority_map (ARGS_REMOVE_FCN) { - return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_INGRESS_MAP, error); + return _remove_vlan_xgress_priority_map (setting, + property_info, + value, + idx, + NM_VLAN_INGRESS_MAP, + error); } static gboolean -nmc_property_vlan_set_egress_priority_map (NMSetting *setting, const char *prop, const char *val, GError **error) +_remove_fcn_vlan_egress_priority_map (ARGS_REMOVE_FCN) { - return nmc_property_vlan_set_prio_map (setting, prop, val, NM_VLAN_EGRESS_MAP, error); -} - -static gboolean -nmc_property_vlan_remove_priority_map (NMSetting *setting, - const char *prop, - const char *value, - guint32 idx, - NMVlanPriorityMap map, - GError **error) -{ - /* If value != NULL, remove by value */ - if (value) { - gboolean ret; - char **prio_map; - char *val = g_strdup (value); - - prio_map = nmc_vlan_parse_priority_maps (val, map, error); - if (!prio_map) - return FALSE; - if (prio_map[1]) - g_print (_("Warning: only one mapping at a time is supported; taking the first one (%s)\n"), - prio_map[0]); - ret = nm_setting_vlan_remove_priority_str_by_value (NM_SETTING_VLAN (setting), - map, - prio_map[0]); - - if (!ret) - g_set_error (error, 1, 0, _("the property doesn't contain mapping '%s'"), prio_map[0]); - g_free (val); - g_strfreev (prio_map); - return ret; - } - - /* Else remove by index */ - return nmc_property_vlan_remove_prio_map (setting, prop, idx, map, error); -} - -static gboolean -nmc_property_vlan_remove_ingress_priority_map (NMSetting *setting, - const char *prop, - const char *value, - guint32 idx, - GError **error) -{ - return nmc_property_vlan_remove_priority_map (setting, - prop, - value, - idx, - NM_VLAN_INGRESS_MAP, - error); -} - -static gboolean -nmc_property_vlan_remove_egress_priority_map (NMSetting *setting, - const char *prop, - const char *value, - guint32 idx, - GError **error) -{ - return nmc_property_vlan_remove_priority_map (setting, - prop, - value, - idx, - NM_VLAN_EGRESS_MAP, - error); + return _remove_vlan_xgress_priority_map (setting, + property_info, + value, + idx, + NM_VLAN_EGRESS_MAP, + error); } static char * -nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_vpn_data (ARGS_GET_FCN) { NMSettingVpn *s_vpn = NM_SETTING_VPN (setting); GString *data_item_str; @@ -3613,7 +3462,7 @@ nmc_property_vpn_get_data (NMSetting *setting, NmcPropertyGetType get_type) } static char * -nmc_property_vpn_get_secrets (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_vpn_secrets (ARGS_GET_FCN) { NMSettingVpn *s_vpn = NM_SETTING_VPN (setting); GString *secret_str; @@ -3636,23 +3485,23 @@ _validate_vpn_hash_value (const char *option, const char *value, GError **error) return value; } -DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_data, +DEFINE_SETTER_OPTIONS (_set_fcn_vpn_data, NM_SETTING_VPN, NMSettingVpn, nm_setting_vpn_add_data_item, NULL, _validate_vpn_hash_value) -DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_data, +DEFINE_REMOVER_OPTION (_remove_fcn_vpn_data, NM_SETTING_VPN, nm_setting_vpn_remove_data_item) -DEFINE_SETTER_OPTIONS (nmc_property_vpn_set_secrets, +DEFINE_SETTER_OPTIONS (_set_fcn_vpn_secrets, NM_SETTING_VPN, NMSettingVpn, nm_setting_vpn_add_secret, NULL, _validate_vpn_hash_value) -DEFINE_REMOVER_OPTION (nmc_property_vpn_remove_option_secret, +DEFINE_REMOVER_OPTION (_remove_fcn_vpn_secrets, NM_SETTING_VPN, nm_setting_vpn_remove_secret) @@ -3715,7 +3564,7 @@ _set_fcn_wired_wake_on_lan (ARGS_SET_FCN) return TRUE; } -DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wired_set_mac_address_blacklist, +DEFINE_SETTER_MAC_BLACKLIST (_set_fcn_wired_mac_address_blacklist, NM_SETTING_WIRED, nm_setting_wired_add_mac_blacklist_item) @@ -3737,29 +3586,28 @@ _validate_and_remove_wired_mac_blacklist_item (NMSettingWired *setting, g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wired_remove_mac_address_blacklist, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_wired_mac_address_blacklist, NM_SETTING_WIRED, nm_setting_wired_get_num_mac_blacklist_items, nm_setting_wired_remove_mac_blacklist_item, _validate_and_remove_wired_mac_blacklist_item) -/* 's390-subchannels' */ static gboolean -nmc_property_wired_set_s390_subchannels (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wired_s390_subchannels (ARGS_SET_FCN) { char **strv = NULL; int len; - strv = nmc_strsplit_set (val, " ,\t", 0); + strv = nmc_strsplit_set (value, " ,\t", 0); len = g_strv_length (strv); if (len != 2 && len != 3) { g_set_error (error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"), - val); + value); g_strfreev (strv); return FALSE; } - g_object_set (setting, prop, strv, NULL); + g_object_set (setting, property_info->property_name, strv, NULL); g_strfreev (strv); return TRUE; } @@ -3774,20 +3622,20 @@ _validate_s390_option_value (const char *option, const char *value, GError **err } return value; } -DEFINE_SETTER_OPTIONS (nmc_property_wired_set_s390_options, +DEFINE_SETTER_OPTIONS (_set_fcn_wired_s390_options, NM_SETTING_WIRED, NMSettingWired, nm_setting_wired_add_s390_option, nm_setting_wired_get_valid_s390_options, _validate_s390_option_value) -DEFINE_REMOVER_OPTION (nmc_property_wired_remove_option_s390_options, +DEFINE_REMOVER_OPTION (_remove_fcn_wired_s390_options, NM_SETTING_WIRED, nm_setting_wired_remove_s390_option) static const char *const* -nmc_property_wired_allowed_s390_options (NMSetting *setting, const char *prop) +_values_fcn__wired_s390_options (ARGS_VALUES_FCN) { - return nm_setting_wired_get_valid_s390_options (NM_SETTING_WIRED (setting)); + return nm_setting_wired_get_valid_s390_options (NULL); } static const char * @@ -3813,7 +3661,7 @@ _describe_fcn_wired_s390_options (ARGS_DESCRIBE_FCN) static char * -nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_ssid (ARGS_GET_FCN) { NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); GBytes *ssid; @@ -3829,7 +3677,7 @@ nmc_property_wireless_get_ssid (NMSetting *setting, NmcPropertyGetType get_type) } static char * -nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_powersave (ARGS_GET_FCN) { NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); NMSettingWirelessPowersave powersave; @@ -3848,7 +3696,7 @@ nmc_property_wireless_get_powersave (NMSetting *setting, NmcPropertyGetType get_ } static char * -nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_mac_address_randomization (ARGS_GET_FCN) { NMSettingWireless *s_wifi = NM_SETTING_WIRELESS (setting); NMSettingMacRandomization randomization = nm_setting_wireless_get_mac_address_randomization (s_wifi); @@ -3864,14 +3712,14 @@ nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcProp } static gboolean -nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_channel (ARGS_SET_FCN) { unsigned long chan_int; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - if (!nmc_string_to_uint (val, FALSE, 0, 0, &chan_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid channel"), val); + if (!nmc_string_to_uint (value, FALSE, 0, 0, &chan_int)) { + g_set_error (error, 1, 0, _("'%s' is not a valid channel"), value); return FALSE; } @@ -3881,12 +3729,11 @@ nmc_property_wifi_set_channel (NMSetting *setting, const char *prop, const char return FALSE; } - g_object_set (setting, prop, chan_int, NULL); + g_object_set (setting, property_info->property_name, chan_int, NULL); return TRUE; } -/* 'mac-address-blacklist' */ -DEFINE_SETTER_MAC_BLACKLIST (nmc_property_wireless_set_mac_address_blacklist, +DEFINE_SETTER_MAC_BLACKLIST (_set_fcn_wireless_mac_address_blacklist, NM_SETTING_WIRELESS, nm_setting_wireless_add_mac_blacklist_item) @@ -3908,14 +3755,14 @@ _validate_and_remove_wifi_mac_blacklist_item (NMSettingWireless *setting, g_set_error (error, 1, 0, _("the property doesn't contain MAC address '%s'"), mac); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wireless_remove_mac_address_blacklist, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_wireless_mac_address_blacklist, NM_SETTING_WIRELESS, nm_setting_wireless_get_num_mac_blacklist_items, nm_setting_wireless_remove_mac_blacklist_item, _validate_and_remove_wifi_mac_blacklist_item) static gboolean -nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_powersave (ARGS_SET_FCN) { NMSettingWirelessPowersave powersave; gs_free const char **options = NULL; @@ -3923,14 +3770,14 @@ nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const long int t; gboolean ret; - if (nmc_string_to_int_base (val, 0, TRUE, + if (nmc_string_to_int_base (value, 0, TRUE, NM_SETTING_WIRELESS_POWERSAVE_DEFAULT, NM_SETTING_WIRELESS_POWERSAVE_LAST, &t)) powersave = (NMSettingWirelessPowersave) t; else { ret = nm_utils_enum_from_str (nm_setting_wireless_powersave_get_type (), - val, + value, (int *) &powersave, NULL); if (!ret) { @@ -3938,34 +3785,31 @@ nmc_property_wireless_set_powersave (NMSetting *setting, const char *prop, const NM_SETTING_WIRELESS_POWERSAVE_DEFAULT, NM_SETTING_WIRELESS_POWERSAVE_LAST); options_str = g_strjoinv (",", (char **) options); - g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), val, options_str); + g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), value, options_str); return FALSE; } } - g_object_set (setting, prop, (guint) powersave, NULL); + g_object_set (setting, property_info->property_name, (guint) powersave, NULL); return TRUE; } static gboolean -nmc_property_wireless_set_mac_address_randomization (NMSetting *setting, - const char *prop, - const char *val, - GError **error) +_set_fcn_wireless_mac_address_randomization (ARGS_SET_FCN) { NMSettingMacRandomization randomization; gs_free char *err_token = NULL; gboolean ret; long int t; - if (nmc_string_to_int_base (val, 0, TRUE, + if (nmc_string_to_int_base (value, 0, TRUE, NM_SETTING_MAC_RANDOMIZATION_DEFAULT, NM_SETTING_MAC_RANDOMIZATION_ALWAYS, &t)) randomization = (NMSettingMacRandomization) t; else { ret = nm_utils_enum_from_str (nm_setting_mac_randomization_get_type (), - val, + value, (int *) &randomization, &err_token); @@ -3976,33 +3820,33 @@ nmc_property_wireless_set_mac_address_randomization (NMSetting *setting, } } - g_object_set (setting, prop, (guint) randomization, NULL); + g_object_set (setting, property_info->property_name, (guint) randomization, NULL); return TRUE; } static char * -nmc_property_wifi_sec_get_wep_key0 (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_security_wep_key0 (ARGS_GET_FCN) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 0)); } static char * -nmc_property_wifi_sec_get_wep_key1 (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_security_wep_key1 (ARGS_GET_FCN) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 1)); } static char * -nmc_property_wifi_sec_get_wep_key2 (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_security_wep_key2 (ARGS_GET_FCN) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 2)); } static char * -nmc_property_wifi_sec_get_wep_key3 (NMSetting *setting, NmcPropertyGetType get_type) +_get_fcn_wireless_security_wep_key3 (ARGS_GET_FCN) { NMSettingWirelessSecurity *s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (setting); return g_strdup (nm_setting_wireless_security_get_wep_key (s_wireless_sec, 3)); @@ -4021,9 +3865,9 @@ DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_proto, nm_setting_wireless_security_add_proto) static gboolean -nmc_property_wifi_sec_set_proto (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_security_proto (ARGS_SET_FCN) { - return check_and_add_wifi_sec_proto (setting, prop, val, wifi_sec_valid_protos, error); + return check_and_add_wifi_sec_proto (setting, property_info->property_name, value, wifi_sec_valid_protos, error); } static gboolean @@ -4044,7 +3888,7 @@ _validate_and_remove_wifi_sec_proto (NMSettingWirelessSecurity *setting, _("the property doesn't contain protocol '%s'"), proto); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_proto, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_wireless_security_proto, NM_SETTING_WIRELESS_SECURITY, nm_setting_wireless_security_get_num_protos, nm_setting_wireless_security_remove_proto, @@ -4057,9 +3901,9 @@ DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_pairwise, nm_setting_wireless_security_add_pairwise) static gboolean -nmc_property_wifi_sec_set_pairwise (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_security_pairwise (ARGS_SET_FCN) { - return check_and_add_wifi_sec_pairwise (setting, prop, val, wifi_sec_valid_pairwises, error); + return check_and_add_wifi_sec_pairwise (setting, property_info->property_name, value, wifi_sec_valid_pairwises, error); } static gboolean @@ -4080,13 +3924,12 @@ _validate_and_remove_wifi_sec_pairwise (NMSettingWirelessSecurity *setting, _("the property doesn't contain protocol '%s'"), pairwise); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_pairwise, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_wireless_security_pairwise, NM_SETTING_WIRELESS_SECURITY, nm_setting_wireless_security_get_num_pairwise, nm_setting_wireless_security_remove_pairwise, _validate_and_remove_wifi_sec_pairwise) -/* 'group' */ static const char *wifi_sec_valid_groups[] = { "wep40", "wep104", "tkip", "ccmp", NULL }; DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group, @@ -4094,9 +3937,9 @@ DEFINE_SETTER_STR_LIST_MULTI (check_and_add_wifi_sec_group, nm_setting_wireless_security_add_group) static gboolean -nmc_property_wifi_sec_set_group (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_security_group (ARGS_SET_FCN) { - return check_and_add_wifi_sec_group (setting, prop, val, wifi_sec_valid_groups, error); + return check_and_add_wifi_sec_group (setting, property_info->property_name, value, wifi_sec_valid_groups, error); } static gboolean @@ -4117,15 +3960,14 @@ _validate_and_remove_wifi_sec_group (NMSettingWirelessSecurity *setting, _("the property doesn't contain protocol '%s'"), group); return ret; } -DEFINE_REMOVER_INDEX_OR_VALUE (nmc_property_wifi_sec_remove_group, +DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_wireless_security_group, NM_SETTING_WIRELESS_SECURITY, nm_setting_wireless_security_get_num_groups, nm_setting_wireless_security_remove_group, _validate_and_remove_wifi_sec_group) -/* 'wep-key' */ static gboolean -nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char *val, GError **error) +_set_fcn_wireless_wep_key (ARGS_SET_FCN) { NMWepKeyType guessed_type = NM_WEP_KEY_TYPE_UNKNOWN; NMWepKeyType type; @@ -4137,34 +3979,34 @@ nmc_property_wifi_set_wep_key (NMSetting *setting, const char *prop, const char type = nm_setting_wireless_security_get_wep_key_type (NM_SETTING_WIRELESS_SECURITY (setting)); /* Guess key type */ - if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_KEY)) + if (nm_utils_wep_key_valid (value, NM_WEP_KEY_TYPE_KEY)) guessed_type = NM_WEP_KEY_TYPE_KEY; - else if (nm_utils_wep_key_valid (val, NM_WEP_KEY_TYPE_PASSPHRASE)) + else if (nm_utils_wep_key_valid (value, NM_WEP_KEY_TYPE_PASSPHRASE)) guessed_type = NM_WEP_KEY_TYPE_PASSPHRASE; if (guessed_type == NM_WEP_KEY_TYPE_UNKNOWN) { - g_set_error (error, 1, 0, _("'%s' is not valid"), val); + g_set_error (error, 1, 0, _("'%s' is not valid"), value); return FALSE; } if (type != NM_WEP_KEY_TYPE_UNKNOWN && type != guessed_type) { - if (nm_utils_wep_key_valid (val, type)) + if (nm_utils_wep_key_valid (value, type)) guessed_type = type; else { g_set_error (error, 1, 0, _("'%s' not compatible with %s '%s', please change the key or set the right %s first."), - val, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_key_type_to_string (type), + value, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, wep_key_type_to_string (type), NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE); return FALSE; } } prev_idx = nm_setting_wireless_security_get_wep_tx_keyidx (NM_SETTING_WIRELESS_SECURITY (setting)); - idx = prop[strlen (prop) - 1] - '0'; + idx = property_info->property_name[strlen (property_info->property_name) - 1] - '0'; g_print (_("WEP key is guessed to be of '%s'\n"), wep_key_type_to_string (guessed_type)); if (idx != prev_idx) g_print (_("WEP key index set to '%d'\n"), idx); - g_object_set (setting, prop, val, NULL); + g_object_set (setting, property_info->property_name, value, NULL); g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, guessed_type, NULL); if (idx != prev_idx) g_object_set (setting, NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, idx, NULL); @@ -4617,8 +4459,6 @@ get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_t g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ @@ -4661,13 +4501,13 @@ nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError /* * Generic function for setting property value. * - * Sets property=val in setting by calling specialized functions. - * If val is NULL then default property value is set. + * Sets property=value in setting by calling specialized functions. + * If value is NULL then default property value is set. * * Returns: TRUE on success; FALSE on failure and sets error */ gboolean -nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, GError **error) +nmc_setting_set_property (NMSetting *setting, const char *prop, const char *value, GError **error) { const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; @@ -4676,9 +4516,8 @@ nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (!val) { + if (!value) { /* No value argument sets default value */ nmc_property_set_default_value (setting, prop); return TRUE; @@ -4691,7 +4530,7 @@ nmc_setting_set_property (NMSetting *setting, const char *prop, const char *val, return property_info->property_type->set_fcn (setting_info, property_info, setting, - val, + value, error); } } @@ -4733,8 +4572,6 @@ nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ @@ -4771,8 +4608,6 @@ nmc_setting_remove_property_option (NMSetting *setting, g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ @@ -4833,8 +4668,6 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ @@ -4876,8 +4709,6 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) setting_desc_title = _("[NM property description]"); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { - nm_assert (property_info == _meta_find_property_info_by_name (nm_setting_get_name (setting), prop, NULL)); - if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ @@ -5008,13 +4839,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean #define DEFINE_PROPERTY_TYP_DATA_SUBTYPE(type, ...) \ DEFINE_PROPERTY_TYP_DATA ( \ - .type = { __VA_ARGS__ }, \ - ) - -#define DEFINE_PROPERTY_TYP_DATA_WITH_ARG1(type, arg1, ...) \ - DEFINE_PROPERTY_TYP_DATA ( \ - arg1, \ - .type = { __VA_ARGS__ }, \ + .subtype = { .type = { __VA_ARGS__ } } , \ ) static const NmcPropertyType _pt_name = { @@ -5065,11 +4890,6 @@ static const NmcPropertyType _pt_gobject_secret_flags = { .set_fcn = _set_fcn_gobject_secret_flags, }; -static const NmcPropertyType _pt_nmc_getset = { - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, -}; - /*****************************************************************************/ #define PROPERTY_INFO_NAME() \ @@ -5105,13 +4925,11 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { .property_name = N_ (NM_SETTING_802_1X_EAP), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, + .set_fcn = _set_fcn_gobject_string, + .remove_fcn = _remove_fcn_802_1x_eap, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, - .values_static = valid_eap, - .set_fcn = nmc_property_802_1X_set_eap, - .remove_fcn = nmc_property_802_1X_remove_eap, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd"), ), }, { @@ -5133,10 +4951,9 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://]\n" "Note that nmcli does not support specifying certificates as raw blob data.\n" "Example: /home/cimrman/cacert.crt\n"), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_ca_cert, - .set_fcn = nmc_property_802_1X_set_ca_cert, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_ca_cert, + .set_fcn = _set_fcn_802_1x_ca_cert, ), }, { @@ -5160,12 +4977,8 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { .property_name = N_ (NM_SETTING_802_1X_ALTSUBJECT_MATCHES), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_altsubject_matches, - .remove_fcn = nmc_property_802_1X_remove_altsubject_matches, + .set_fcn = _set_fcn_802_1x_altsubject_matches, + .remove_fcn = _remove_fcn_802_1x_altsubject_matches, ), }, { @@ -5181,10 +4994,7 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { "Example: /home/cimrman/jara.crt\n"), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_802_1x_client_cert, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_client_cert, + .set_fcn = _set_fcn_802_1x_client_cert, ), }, { @@ -5219,10 +5029,9 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { }, { .property_name = N_ (NM_SETTING_802_1X_PHASE1_AUTH_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_phase1_auth_flags, - .set_fcn = nmc_property_802_1X_set_phase1_auth_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_phase1_auth_flags, + .set_fcn = _set_fcn_802_1x_phase1_auth_flags, ), }, { @@ -5247,10 +5056,9 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { " [file://]\n" "Note that nmcli does not support specifying certificates as raw blob data.\n" "Example: /home/cimrman/ca-zweite-phase.crt\n"), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_phase2_ca_cert, - .set_fcn = nmc_property_802_1X_set_phase2_ca_cert, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_phase2_ca_cert, + .set_fcn = _set_fcn_802_1x_phase2_ca_cert, ), }, { @@ -5274,12 +5082,8 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { .property_name = N_ (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_phase2_altsubject_matches, - .remove_fcn = nmc_property_802_1X_remove_phase2_altsubject_matches, + .set_fcn = _set_fcn_802_1x_phase2_altsubject_matches, + .remove_fcn = _remove_fcn_802_1x_phase2_altsubject_matches, ), }, { @@ -5296,10 +5100,7 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { "Example: /home/cimrman/jara-zweite-phase.crt\n"), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_802_1x_phase2_client_cert, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_phase2_client_cert, + .set_fcn = _set_fcn_802_1x_phase2_client_cert, ), }, { @@ -5331,10 +5132,9 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { "(with optional 0x/0X prefix, and optional leading 0).\n\n" "Examples: ab0455a6ea3a74C2\n" " ab 4 55 0xa6 ea 3a 74 C2\n"), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_802_1X_get_password_raw, - .set_fcn = nmc_property_802_1X_set_password_raw, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_802_1x_password_raw, + .set_fcn = _set_fcn_802_1x_password_raw, ), }, { @@ -5350,10 +5150,7 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { "Example: /home/cimrman/jara-priv-key Dardanely\n"), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_802_1x_private_key, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_private_key, + .set_fcn = _set_fcn_802_1x_private_key, ), }, { @@ -5374,10 +5171,7 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { "Example: /home/cimrman/jara-priv-key Dardanely\n"), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_802_1x_phase2_private_key, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_802_1X_set_phase2_private_key, + .set_fcn = _set_fcn_802_1x_phase2_private_key, ), }, { @@ -5472,15 +5266,10 @@ static const NmcPropertyInfo properties_setting_bond[] = { .property_name = N_ (NM_SETTING_BOND_OPTIONS), .property_type = DEFINE_PROPERTY_TYPE ( .describe_fcn = _describe_fcn_bond_options, - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_bond_get_options, - .set_fcn = nmc_property_bond_set_options, - .remove_fcn = nmc_property_bond_remove_option_options, - .values_fcn = nmc_property_bond_allowed_options, + .get_fcn = _get_fcn_bond_options, + .set_fcn = _set_fcn_bond_options, + .remove_fcn = _remove_fcn_bond_options, + .values_fcn = _values_fcn_bond_options, ), }, }; @@ -5583,10 +5372,7 @@ static const NmcPropertyInfo properties_setting_connection[] = { .property_name = N_ (NM_SETTING_CONNECTION_INTERFACE_NAME), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_set_ifname, + .set_fcn = _set_fcn_gobject_ifname, ), }, { @@ -5607,12 +5393,9 @@ static const NmcPropertyInfo properties_setting_connection[] = { { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, + .get_fcn = _get_fcn_connection_autoconnect_retires, .set_fcn = _set_fcn_gobject_int, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_connection_get_autoconnect_retries, - ), }, { .property_name = N_ (NM_SETTING_CONNECTION_TIMESTAMP), @@ -5630,13 +5413,9 @@ static const NmcPropertyInfo properties_setting_connection[] = { "The items can be separated by commas or spaces.\n\n" "Example: alice bob charlie\n"), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, + .get_fcn = _get_fcn_connection_permissions, .set_fcn = _set_fcn_connection_permissions, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_connection_get_permissions, - .remove_fcn = nmc_property_connection_remove_permissions, + .remove_fcn = _remove_fcn_connection_permissions, ), }, { @@ -5662,12 +5441,9 @@ static const NmcPropertyInfo properties_setting_connection[] = { { .property_name = N_ (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, + .get_fcn = _get_fcn_connection_autoconnect_slaves, .set_fcn = _set_fcn_gobject_trilean, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_connection_get_autoconnect_slaves, - ), }, { .property_name = N_ (NM_SETTING_CONNECTION_SECONDARIES), @@ -5681,10 +5457,7 @@ static const NmcPropertyInfo properties_setting_connection[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_connection_secondaries, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_connection_remove_secondaries, + .remove_fcn = _remove_fcn_connection_secondaries, ), }, { @@ -5700,23 +5473,21 @@ static const NmcPropertyInfo properties_setting_connection[] = { "'false','no','off' to set the connection as not metered\n" "'unknown' to let NetworkManager choose a value using some heuristics\n"), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, + .get_fcn = _get_fcn_connection_metered, .set_fcn = _set_fcn_connection_metered, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( .values_static = VALUES_STATIC ("yes", "no", "unknown"), - .get_fcn = nmc_property_connection_get_metered, ), }, { .property_name = N_ (NM_SETTING_CONNECTION_LLDP), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, + .get_fcn = _get_fcn_connection_lldp, .set_fcn = _set_fcn_connection_lldp, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( .values_static = VALUES_STATIC ("default", "disable", "enable-rx"), - .get_fcn = nmc_property_connection_get_lldp, ), }, }; @@ -5725,18 +5496,16 @@ static const NmcPropertyInfo properties_setting_dcb[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_DCB_APP_FCOE_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_fcoe_flags, - .set_fcn = nmc_property_dcb_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_fcoe_flags, + .set_fcn = _set_fcn_dcb_flags, ), }, { .property_name = N_ (NM_SETTING_DCB_APP_FCOE_PRIORITY), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_fcoe_priority, - .set_fcn = nmc_property_dcb_set_priority, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_fcoe_priority, + .set_fcn = _set_fcn_dcb_priority, ), }, { @@ -5749,98 +5518,86 @@ static const NmcPropertyInfo properties_setting_dcb[] = { }, { .property_name = N_ (NM_SETTING_DCB_APP_ISCSI_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_iscsi_flags, - .set_fcn = nmc_property_dcb_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_iscsi_flags, + .set_fcn = _set_fcn_dcb_flags, ), }, { .property_name = N_ (NM_SETTING_DCB_APP_ISCSI_PRIORITY), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_iscsi_priority, - .set_fcn = nmc_property_dcb_set_priority, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_iscsi_priority, + .set_fcn = _set_fcn_dcb_priority, ), }, { .property_name = N_ (NM_SETTING_DCB_APP_FIP_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_fip_flags, - .set_fcn = nmc_property_dcb_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_fip_flags, + .set_fcn = _set_fcn_dcb_flags, ), }, { .property_name = N_ (NM_SETTING_DCB_APP_FIP_PRIORITY), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_app_fip_priority, - .set_fcn = nmc_property_dcb_set_priority, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_app_fip_priority, + .set_fcn = _set_fcn_dcb_priority, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pfc_flags, - .set_fcn = nmc_property_dcb_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_flow_control_flags, + .set_fcn = _set_fcn_dcb_flags, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pfc, - .set_fcn = nmc_property_dcb_set_pfc, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_flow_control, + .set_fcn = _set_fcn_dcb_priority_flow_control, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_flags, - .set_fcn = nmc_property_dcb_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_group_flags, + .set_fcn = _set_fcn_dcb_flags, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_ID), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_group_id, - .set_fcn = nmc_property_dcb_set_pg_group_id, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_group_id, + .set_fcn = _set_fcn_dcb_priority_group_id, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_group_bandwidth, - .set_fcn = nmc_property_dcb_set_pg_group_bandwidth, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_group_bandwidth, + .set_fcn = _set_fcn_dcb_priority_group_bandwidth, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_BANDWIDTH), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_bandwidth, - .set_fcn = nmc_property_dcb_set_pg_bandwidth, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_bandwidth, + .set_fcn = _set_fcn_dcb_priority_bandwidth, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_strict, - .set_fcn = nmc_property_dcb_set_pg_strict, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_strict, + .set_fcn = _set_fcn_dcb_priority_strict, ), }, { .property_name = N_ (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_dcb_get_pg_traffic_class, - .set_fcn = nmc_property_dcb_set_pg_traffic_class, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_dcb_priority_traffic_class, + .set_fcn = _set_fcn_dcb_priority_traffic_class, ), }, }; @@ -5901,10 +5658,7 @@ static const NmcPropertyInfo properties_setting_gsm[] = { .property_name = N_ (NM_SETTING_GSM_SIM_OPERATOR_ID), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_gsm_set_sim_operator_id, + .set_fcn = _set_fcn_gsm_sim_operator_id, ), }, { @@ -5941,20 +5695,16 @@ static const NmcPropertyInfo properties_setting_infiniband[] = { }, { .property_name = N_ (NM_SETTING_INFINIBAND_P_KEY), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_ib_get_p_key, - .set_fcn = nmc_property_ib_set_p_key, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_infiniband_p_key, + .set_fcn = _set_fcn_infiniband_p_key, ), }, { .property_name = N_ (NM_SETTING_INFINIBAND_PARENT), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_set_ifname, + .set_fcn = _set_fcn_gobject_ifname, ), }, }; @@ -5979,10 +5729,7 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_ip4_config_dns, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv4_remove_dns, + .remove_fcn = _remove_fcn_ipv4_config_dns, ), }, { @@ -5990,10 +5737,7 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_ip4_config_dns_search, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv4_remove_dns_search, + .remove_fcn = _remove_fcn_ipv4_config_dns_search, ), }, { @@ -6001,11 +5745,10 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_nmc_with_default, .set_fcn = _set_fcn_ip4_config_dns_options, - .remove_fcn = _remove_fcn_nmc, + .remove_fcn = _remove_fcn_ipv4_config_dns_options, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn_with_default = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), - .remove_fcn = nmc_property_ipv4_remove_dns_option, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (get_with_default, + .fcn = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), ), }, { @@ -6022,10 +5765,7 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_ip_config_addresses, .set_fcn = _set_fcn_ip4_config_addresses, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv4_remove_addresses, + .remove_fcn = _remove_fcn_ipv4_config_addresses, ), }, { @@ -6048,10 +5788,7 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_ip_config_routes, .set_fcn = _set_fcn_ip4_config_routes, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv4_remove_routes, + .remove_fcn = _remove_fcn_ipv4_config_routes, ), }, { @@ -6129,10 +5866,7 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_ip6_config_dns, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv6_remove_dns, + .remove_fcn = _remove_fcn_ipv6_config_dns, ), }, { @@ -6140,10 +5874,7 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_ip6_config_dns_search, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv6_remove_dns_search, + .remove_fcn = _remove_fcn_ipv6_config_dns_search, ), }, { @@ -6151,11 +5882,10 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_nmc_with_default, .set_fcn = _set_fcn_ip6_config_dns_options, - .remove_fcn = _remove_fcn_nmc, + .remove_fcn = _remove_fcn_ipv6_config_dns_options, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn_with_default = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), - .remove_fcn = nmc_property_ipv6_remove_dns_option, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (get_with_default, + .fcn = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, nm_setting_ip_config_has_dns_options), ), }, { @@ -6172,10 +5902,7 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_ip_config_addresses, .set_fcn = _set_fcn_ip6_config_addresses, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv6_remove_addresses, + .remove_fcn = _remove_fcn_ipv6_config_addresses, ), }, { @@ -6198,10 +5925,7 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_ip_config_routes, .set_fcn = _set_fcn_ip6_config_routes, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .remove_fcn = nmc_property_ipv6_remove_routes, + .remove_fcn = _remove_fcn_ipv6_config_routes, ), }, { @@ -6236,14 +5960,10 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_ip6_config_addr_gen_mode, .set_fcn = _set_fcn_ip6_config_addr_gen_mode, - .values_fcn = _values_fcn_nmc_gobject_enum, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .values_data = { - .gobject_enum = { - .get_gtype = nm_setting_ip6_config_addr_gen_mode_get_type, - }, - }, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_ip6_config_addr_gen_mode_get_type, ), }, { @@ -6265,14 +5985,14 @@ static const NmcPropertyInfo properties_setting_ip_tunnel[] = { { .property_name = N_ (NM_SETTING_IP_TUNNEL_MODE), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_ip_tunnel_mode, + .set_fcn = _set_fcn_ip_tunnel_mode, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_ip_tunnel_get_mode, - .set_fcn = nmc_property_ip_tunnel_set_mode, - .values_fcn = nmc_property_ip_tunnel_allowed_mode, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_ip_tunnel_mode_get_type, + .min = NM_IP_TUNNEL_MODE_UNKNOWN + 1, + .max = G_MAXINT, ), }, { @@ -6330,14 +6050,12 @@ static const NmcPropertyInfo properties_setting_macsec[] = { { .property_name = N_ (NM_SETTING_MACSEC_MODE), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_macsec_mode, + .set_fcn = _set_fcn_macsec_mode, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_macsec_get_mode, - .set_fcn = nmc_property_macsec_set_mode, - .values_fcn = nmc_property_macsec_allowed_mode, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_macsec_mode_get_type, ), }, { @@ -6364,14 +6082,12 @@ static const NmcPropertyInfo properties_setting_macsec[] = { { .property_name = N_ (NM_SETTING_MACSEC_VALIDATION), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_macsec_validation, + .set_fcn = _set_fcn_macsec_validation, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_macsec_get_validation, - .set_fcn = nmc_property_macsec_set_validation, - .values_fcn = nmc_property_macsec_allowed_validation, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_macsec_validation_get_type, ), }, }; @@ -6385,14 +6101,14 @@ static const NmcPropertyInfo properties_setting_macvlan[] = { { .property_name = N_ (NM_SETTING_MACVLAN_MODE), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_macvlan_mode, + .set_fcn = _set_fcn_macvlan_mode, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_macvlan_get_mode, - .set_fcn = nmc_property_macvlan_set_mode, - .values_fcn = nmc_property_macvlan_allowed_mode, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_macvlan_mode_get_type, + .min = NM_SETTING_MACVLAN_MODE_UNKNOWN + 1, + .max = G_MAXINT, ), }, { @@ -6409,20 +6125,16 @@ static const NmcPropertyInfo properties_setting_olpc_mesh[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_OLPC_MESH_SSID), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_olpc_get_ssid, - .set_fcn = nmc_property_set_ssid, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_olpc_mesh_ssid, + .set_fcn = _set_fcn_gobject_ssid, ), }, { .property_name = N_ (NM_SETTING_OLPC_MESH_CHANNEL), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_olpc_set_channel, + .set_fcn = _set_fcn_olpc_mesh_channel, ), }, { @@ -6536,14 +6248,14 @@ static const NmcPropertyInfo properties_setting_proxy[] = { { .property_name = N_ (NM_SETTING_PROXY_METHOD), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_proxy_method, + .set_fcn = _set_fcn_proxy_method, + .values_fcn = _values_fcn_gobject_enum, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_proxy_get_method, - .set_fcn = nmc_property_proxy_set_method, - .values_fcn = nmc_property_proxy_allowed_method, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_proxy_method_get_type, + .min = NM_SETTING_PROXY_METHOD_NONE, + .max = G_MAXINT, ), }, { @@ -6558,10 +6270,7 @@ static const NmcPropertyInfo properties_setting_proxy[] = { .property_name = N_ (NM_SETTING_PROXY_PAC_SCRIPT), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_proxy_set_pac_script, + .set_fcn = _set_fcn_proxy_pac_script, ), }, }; @@ -6573,10 +6282,7 @@ static const NmcPropertyInfo properties_setting_team[] = { .describe_message = N_ (TEAM_DESCRIBE_MESSAGE), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_team_set_config, + .set_fcn = _set_fcn_team_config, ), }, }; @@ -6588,10 +6294,7 @@ static const NmcPropertyInfo properties_setting_team_port[] = { .describe_message = N_ (TEAM_DESCRIBE_MESSAGE), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_team_set_config, + .set_fcn = _set_fcn_team_config, ), }, }; @@ -6601,14 +6304,11 @@ static const NmcPropertyInfo properties_setting_tun[] = { { .property_name = N_ (NM_SETTING_TUN_MODE), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .values_fcn = _values_fcn_nmc, + .get_fcn = _get_fcn_tun_mode, + .set_fcn = _set_fcn_tun_mode, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_tun_get_mode, - .set_fcn = nmc_property_tun_set_mode, - .values_fcn = nmc_property_tun_allowed_mode, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + .values_static = VALUES_STATIC ("tun", "tap", "unknown"), ), }, { @@ -6645,10 +6345,9 @@ static const NmcPropertyInfo properties_setting_serial[] = { }, { .property_name = N_ (NM_SETTING_SERIAL_PARITY), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_serial_get_parity, - .set_fcn = nmc_property_serial_set_parity, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_serial_parity, + .set_fcn = _set_fcn_serial_parity, ), }, { @@ -6673,36 +6372,25 @@ static const NmcPropertyInfo properties_setting_vlan[] = { }, { .property_name = N_ (NM_SETTING_VLAN_FLAGS), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_vlan_get_flags, - .set_fcn = nmc_property_set_flags, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_vlan_flags, + .set_fcn = _set_fcn_gobject_flags, ), }, { .property_name = N_ (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_vlan_get_ingress_priority_map, - .set_fcn = nmc_property_vlan_set_ingress_priority_map, - .remove_fcn = nmc_property_vlan_remove_ingress_priority_map, + .get_fcn = _get_fcn_vlan_ingress_priority_map, + .set_fcn = _set_fcn_vlan_ingress_priority_map, + .remove_fcn = _remove_fcn_vlan_ingress_priority_map, ), }, { .property_name = N_ (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_vlan_get_egress_priority_map, - .set_fcn = nmc_property_vlan_set_egress_priority_map, - .remove_fcn = nmc_property_vlan_remove_egress_priority_map, + .get_fcn = _get_fcn_vlan_egress_priority_map, + .set_fcn = _set_fcn_vlan_egress_priority_map, + .remove_fcn = _remove_fcn_vlan_egress_priority_map, ), }, }; @@ -6713,10 +6401,7 @@ static const NmcPropertyInfo properties_setting_vpn[] = { .property_name = N_ (NM_SETTING_VPN_SERVICE_TYPE), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_set_vpn_service, + .set_fcn = _set_fcn_vpn_service_type, ), }, { @@ -6726,28 +6411,18 @@ static const NmcPropertyInfo properties_setting_vpn[] = { { .property_name = N_ (NM_SETTING_VPN_DATA), .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_vpn_get_data, - .set_fcn = nmc_property_vpn_set_data, - .remove_fcn = nmc_property_vpn_remove_option_data, + .get_fcn = _get_fcn_vpn_data, + .set_fcn = _set_fcn_vpn_data, + .remove_fcn = _remove_fcn_vpn_data, ), }, { .property_name = N_ (NM_SETTING_VPN_SECRETS), .is_secret = TRUE, .property_type = DEFINE_PROPERTY_TYPE ( - .get_fcn = _get_fcn_nmc, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_vpn_get_secrets, - .set_fcn = nmc_property_vpn_set_secrets, - .remove_fcn = nmc_property_vpn_remove_option_secret, + .get_fcn = _get_fcn_vpn_secrets, + .set_fcn = _set_fcn_vpn_secrets, + .remove_fcn = _remove_fcn_vpn_secrets, ), }, { @@ -6884,12 +6559,8 @@ static const NmcPropertyInfo properties_setting_wired[] = { .property_name = N_ (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wired_set_mac_address_blacklist, - .remove_fcn = nmc_property_wired_remove_mac_address_blacklist, + .set_fcn = _set_fcn_wired_mac_address_blacklist, + .remove_fcn = _remove_fcn_wired_mac_address_blacklist, ), }, { @@ -6906,10 +6577,7 @@ static const NmcPropertyInfo properties_setting_wired[] = { "Example: 0.0.0e20 0.0.0e21 0.0.0e22\n"), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wired_set_s390_subchannels, + .set_fcn = _set_fcn_wired_s390_subchannels, ), }, { @@ -6924,14 +6592,9 @@ static const NmcPropertyInfo properties_setting_wired[] = { .property_type = DEFINE_PROPERTY_TYPE ( .describe_fcn = _describe_fcn_wired_s390_options, .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - .values_fcn = _values_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wired_set_s390_options, - .remove_fcn = nmc_property_wired_remove_option_s390_options, - .values_fcn = nmc_property_wired_allowed_s390_options, + .set_fcn = _set_fcn_wired_s390_options, + .remove_fcn = _remove_fcn_wired_s390_options, + .values_fcn = _values_fcn__wired_s390_options, ), }, { @@ -6951,10 +6614,9 @@ static const NmcPropertyInfo properties_setting_wireless[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIRELESS_SSID), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wireless_get_ssid, - .set_fcn = nmc_property_set_ssid, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_ssid, + .set_fcn = _set_fcn_gobject_ssid, ), }, { @@ -6977,10 +6639,7 @@ static const NmcPropertyInfo properties_setting_wireless[] = { .property_name = N_ (NM_SETTING_WIRELESS_CHANNEL), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wifi_set_channel, + .set_fcn = _set_fcn_wireless_channel, ), }, { @@ -7016,20 +6675,15 @@ static const NmcPropertyInfo properties_setting_wireless[] = { .property_name = N_ (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, - ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .set_fcn = nmc_property_wireless_set_mac_address_blacklist, - .remove_fcn = nmc_property_wireless_remove_mac_address_blacklist, + .set_fcn = _set_fcn_wireless_mac_address_blacklist, + .remove_fcn = _remove_fcn_wireless_mac_address_blacklist, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wireless_get_mac_address_randomization, - .set_fcn = nmc_property_wireless_set_mac_address_randomization, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_mac_address_randomization, + .set_fcn = _set_fcn_wireless_mac_address_randomization, ), }, { @@ -7049,10 +6703,9 @@ static const NmcPropertyInfo properties_setting_wireless[] = { }, { .property_name = N_ (NM_SETTING_WIRELESS_POWERSAVE), - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wireless_get_powersave, - .set_fcn = nmc_property_wireless_set_powersave, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_powersave, + .set_fcn = _set_fcn_wireless_powersave, ), }, }; @@ -7081,39 +6734,33 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PROTO), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, + .set_fcn = _set_fcn_wireless_security_proto, + .remove_fcn = _remove_fcn_wireless_security_proto, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( .values_static = wifi_sec_valid_protos, - .set_fcn = nmc_property_wifi_sec_set_proto, - .remove_fcn = nmc_property_wifi_sec_remove_proto, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_PAIRWISE), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, + .set_fcn = _set_fcn_wireless_security_pairwise, + .remove_fcn = _remove_fcn_wireless_security_pairwise, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( .values_static = wifi_sec_valid_pairwises, - .set_fcn = nmc_property_wifi_sec_set_pairwise, - .remove_fcn = nmc_property_wifi_sec_remove_pairwise, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_GROUP), .property_type = DEFINE_PROPERTY_TYPE ( .get_fcn = _get_fcn_gobject, - .set_fcn = _set_fcn_nmc, - .remove_fcn = _remove_fcn_nmc, + .set_fcn = _set_fcn_wireless_security_group, + .remove_fcn = _remove_fcn_wireless_security_group, ), - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_WITH_ARG1 (nmc, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( .values_static = wifi_sec_valid_groups, - .set_fcn = nmc_property_wifi_sec_set_group, - .remove_fcn = nmc_property_wifi_sec_remove_group, ), }, { @@ -7123,37 +6770,33 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), .is_secret = TRUE, - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wifi_sec_get_wep_key0, - .set_fcn = nmc_property_wifi_set_wep_key, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_security_wep_key0, + .set_fcn = _set_fcn_wireless_wep_key, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1), .is_secret = TRUE, - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wifi_sec_get_wep_key1, - .set_fcn = nmc_property_wifi_set_wep_key, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_security_wep_key1, + .set_fcn = _set_fcn_wireless_wep_key, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2), .is_secret = TRUE, - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wifi_sec_get_wep_key2, - .set_fcn = nmc_property_wifi_set_wep_key, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_security_wep_key2, + .set_fcn = _set_fcn_wireless_wep_key, ), }, { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3), .is_secret = TRUE, - .property_type = &_pt_nmc_getset, - .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (nmc, - .get_fcn = nmc_property_wifi_sec_get_wep_key3, - .set_fcn = nmc_property_wifi_set_wep_key, + .property_type = DEFINE_PROPERTY_TYPE ( + .get_fcn = _get_fcn_wireless_security_wep_key3, + .set_fcn = _set_fcn_wireless_wep_key, ), }, { diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 762fc69fbe..ae63ccf138 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -74,31 +74,20 @@ struct _NmcPropertyType { struct _NmcPropertyTypData { union { struct { - union { - char *(*get_fcn) (NMSetting *setting, NmcPropertyGetType get_type); - gboolean (*get_fcn_with_default) (NMSetting *setting); - }; - gboolean (*set_fcn) (NMSetting *setting, const char *property_name, const char *value, GError **error); - gboolean (*remove_fcn) (NMSetting *setting, const char *property_name, const char *option, guint32 idx, GError **error); - union { - union { - struct { - GType (*get_gtype) (void); - bool has_minmax:1; - int min; - int max; - } gobject_enum; - } values_data; - const char *const* (*values_fcn) (NMSetting *setting, const char *prop); - }; - } nmc; + gboolean (*fcn) (NMSetting *setting); + } get_with_default; + struct { + GType (*get_gtype) (void); + int min; + int max; + } gobject_enum; struct { guint32 (*get_fcn) (NMSetting *setting); } mtu; struct { NmcPropertyTypeMacMode mode; } mac; - }; + } subtype; const char *const*values_static; }; From 660fee1622d2a5977f2d7bb82b4e111474f457c9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Mar 2017 23:11:11 +0200 Subject: [PATCH 33/53] cli: allow dynamic results from values_fcn() and describe_fcn() property functions Mostly these strings are static. In same cases they are generated however. Instead of caching them in a static variable, return them to the caller. And belatedly fix invoking describe_fcn(). --- clients/cli/connections.c | 57 +++++++++++--------- clients/cli/settings.c | 110 ++++++++++++++++++-------------------- clients/cli/settings.h | 10 ++-- 3 files changed, 89 insertions(+), 88 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index b750ec97b2..6421f7fd07 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -5701,26 +5701,23 @@ should_complete_vpn_uuids (const char *prompt, const char *line) } static const char *const* -get_allowed_property_values (void) +get_allowed_property_values (char ***out_to_free) { - NMSetting *setting; - char *property; + gs_unref_object NMSetting *setting = NULL; + gs_free char *property = NULL; const char *const*avals = NULL; get_setting_and_property (rl_prompt, rl_line_buffer, &setting, &property); if (setting && property) - avals = nmc_setting_get_property_allowed_values (setting, property); - - if (setting) - g_object_unref (setting); - g_free (property); - + avals = nmc_setting_get_property_allowed_values (setting, property, out_to_free); return avals; } static gboolean should_complete_property_values (const char *prompt, const char *line, gboolean *multi) { + gs_strfreev char **to_free = NULL; + /* properties allowing multiple values */ const char *multi_props[] = { /* '802-1x' properties */ @@ -5736,10 +5733,9 @@ should_complete_property_values (const char *prompt, const char *line, gboolean NULL }; _get_and_check_property (prompt, line, NULL, multi_props, multi); - return get_allowed_property_values () != NULL; + return !!get_allowed_property_values (&to_free); } -//FIXME: this helper should go to libnm later static gboolean _setting_property_is_boolean (NMSetting *setting, const char *property_name) { @@ -5775,13 +5771,13 @@ should_complete_boolean (const char *prompt, const char *line) static char * gen_property_values (const char *text, int state) { - char *ret = NULL; + gs_strfreev char **to_free = NULL; const char *const*avals; - avals = get_allowed_property_values (); - if (avals) - ret = nmc_rl_gen_func_basic (text, state, avals); - return ret; + avals = get_allowed_property_values (&to_free); + if (!avals) + return NULL; + return nmc_rl_gen_func_basic (text, state, avals); } /* from readline */ @@ -6657,13 +6653,16 @@ property_edit_submenu (NmCli *nmc, * single values: : both SET and ADD sets the new value */ if (!cmd_property_arg) { - const char *const*avals = nmc_setting_get_property_allowed_values (curr_setting, prop_name); + gs_strfreev char **to_free = NULL; + const char *const*avals; + avals = nmc_setting_get_property_allowed_values (curr_setting, prop_name, &to_free); if (avals) { - char *avals_str = nmc_util_strv_for_display (avals, FALSE); + gs_free char *avals_str = NULL; + + avals_str = nmc_util_strv_for_display (avals, FALSE); g_print (_("Allowed values for '%s' property: %s\n"), prop_name, avals_str); - g_free (avals_str); } prop_val_user = nmc_readline (_("Enter '%s' value: "), prop_name); } else @@ -7068,8 +7067,9 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t /* Set property value */ if (!cmd_arg) { if (menu_ctx.level == 1) { + gs_strfreev char **avals_to_free = NULL; + gs_free char *prop_val_user = NULL; const char *prop_name; - char *prop_val_user = NULL; const char *const*avals; GError *tmp_err = NULL; @@ -7079,12 +7079,13 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t if (!prop_name) break; - avals = nmc_setting_get_property_allowed_values (menu_ctx.curr_setting, prop_name); + avals = nmc_setting_get_property_allowed_values (menu_ctx.curr_setting, prop_name, &avals_to_free); if (avals) { - char *avals_str = nmc_util_strv_for_display (avals, FALSE); + gs_free char *avals_str = NULL; + + avals_str = nmc_util_strv_for_display (avals, FALSE); g_print (_("Allowed values for '%s' property: %s\n"), prop_name, avals_str); - g_free (avals_str); } prop_val_user = nmc_readline (_("Enter '%s' value: "), prop_name); @@ -7137,12 +7138,16 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t /* Ask for value */ if (!cmd_arg_v) { - const char *const*avals = nmc_setting_get_property_allowed_values (ss, prop_name); + gs_strfreev char **avals_to_free = NULL; + const char *const*avals; + + avals = nmc_setting_get_property_allowed_values (ss, prop_name, &avals_to_free); if (avals) { - char *avals_str = nmc_util_strv_for_display (avals, FALSE); + gs_free char *avals_str = NULL; + + avals_str = nmc_util_strv_for_display (avals, FALSE); g_print (_("Allowed values for '%s' property: %s\n"), prop_name, avals_str); - g_free (avals_str); } cmd_arg_v = nmc_readline (_("Enter '%s' value: "), prop_name); } diff --git a/clients/cli/settings.c b/clients/cli/settings.c index d4f6efb498..5d1760adde 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -47,7 +47,7 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) /*****************************************************************************/ #define ARGS_DESCRIBE_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, char **out_to_free #define ARGS_GET_FCN \ const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type, gboolean show_secrets @@ -59,7 +59,7 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, guint32 idx, GError **error #define ARGS_VALUES_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info + const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, char ***out_to_free static char * _get_fcn_name (ARGS_GET_FCN) @@ -312,23 +312,16 @@ _set_fcn_gobject_secret_flags (ARGS_SET_FCN) static const char *const* _values_fcn_gobject_enum (ARGS_VALUES_FCN) { - static GHashTable *cache = NULL; - const char **v; + char **v, **w; + bool has_minmax = property_info->property_typ_data->subtype.gobject_enum.min + || property_info->property_typ_data->subtype.gobject_enum.max; - if (G_UNLIKELY (!cache)) - cache = g_hash_table_new (NULL, NULL); - - v = g_hash_table_lookup (cache, property_info); - if (!v) { - bool has_minmax = property_info->property_typ_data->subtype.gobject_enum.min - || property_info->property_typ_data->subtype.gobject_enum.max; - - v = nm_utils_enum_get_values ( property_info->property_typ_data->subtype.gobject_enum.get_gtype (), - has_minmax ? property_info->property_typ_data->subtype.gobject_enum.min : G_MININT, - has_minmax ? property_info->property_typ_data->subtype.gobject_enum.max : G_MAXINT); - g_hash_table_insert (cache, (gpointer) property_info, v); - } - return (const char *const*) v; + v = (char **) nm_utils_enum_get_values ( property_info->property_typ_data->subtype.gobject_enum.get_gtype (), + has_minmax ? property_info->property_typ_data->subtype.gobject_enum.min : G_MININT, + has_minmax ? property_info->property_typ_data->subtype.gobject_enum.max : G_MAXINT); + for (w = v; w && *w; w++) + *w = g_strdup (*w); + return (const char *const*) (*out_to_free = v); } /*****************************************************************************/ @@ -1480,29 +1473,26 @@ DEFINE_REMOVER_OPTION (_remove_fcn_bond_options, static const char * _describe_fcn_bond_options (ARGS_DESCRIBE_FCN) { - static char *desc = NULL; + gs_free char *options_str = NULL; const char **valid_options; - char *options_str; + char *s; - if (G_UNLIKELY (desc == NULL)) { - valid_options = nm_setting_bond_get_valid_options (NULL); - options_str = g_strjoinv (", ", (char **) valid_options); + valid_options = nm_setting_bond_get_valid_options (NULL); + options_str = g_strjoinv (", ", (char **) valid_options); - desc = g_strdup_printf (_("Enter a list of bonding options formatted as:\n" - " option = , option = ,... \n" - "Valid options are: %s\n" - "'mode' can be provided as a name or a number:\n" - "balance-rr = 0\n" - "active-backup = 1\n" - "balance-xor = 2\n" - "broadcast = 3\n" - "802.3ad = 4\n" - "balance-tlb = 5\n" - "balance-alb = 6\n\n" - "Example: mode=2,miimon=120\n"), options_str); - g_free (options_str); - } - return desc; + s = g_strdup_printf (_("Enter a list of bonding options formatted as:\n" + " option = , option = ,... \n" + "Valid options are: %s\n" + "'mode' can be provided as a name or a number:\n" + "balance-rr = 0\n" + "active-backup = 1\n" + "balance-xor = 2\n" + "broadcast = 3\n" + "802.3ad = 4\n" + "balance-tlb = 5\n" + "balance-alb = 6\n\n" + "Example: mode=2,miimon=120\n"), options_str); + return (*out_to_free = s); } static const char *const* @@ -3641,22 +3631,19 @@ _values_fcn__wired_s390_options (ARGS_VALUES_FCN) static const char * _describe_fcn_wired_s390_options (ARGS_DESCRIBE_FCN) { - static char *desc = NULL; + gs_free char *options_str = NULL; const char **valid_options; - char *options_str; + char *s; - if (G_UNLIKELY (desc == NULL)) { - valid_options = nm_setting_wired_get_valid_s390_options (NULL); + valid_options = nm_setting_wired_get_valid_s390_options (NULL); - options_str = g_strjoinv (", ", (char **) valid_options); + options_str = g_strjoinv (", ", (char **) valid_options); - desc = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n" - " option = , option = ,...\n" - "Valid options are: %s\n"), - options_str); - g_free (options_str); - } - return desc; + s = g_strdup_printf (_("Enter a list of S/390 options formatted as:\n" + " option = , option = ,...\n" + "Valid options are: %s\n"), + options_str); + return (*out_to_free = s); } @@ -4655,17 +4642,17 @@ nmc_setting_get_valid_properties (NMSetting *setting) return valid_props; } -/* - * Return allowed values for 'prop' as a string. - */ const char *const* -nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) +nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, char ***out_to_free) { const NmcSettingInfo *setting_info; const NmcPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); + g_return_val_if_fail (out_to_free, FALSE); + + *out_to_free = NULL; if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { if (property_info->is_name) { @@ -4673,7 +4660,8 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) * For the moment, skip it from get_property_val(). */ } else if (property_info->property_type->values_fcn) { return property_info->property_type->values_fcn (setting_info, - property_info); + property_info, + out_to_free); } else if (property_info->property_typ_data && property_info->property_typ_data->values_static) return property_info->property_typ_data->values_static; } @@ -4694,6 +4682,7 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop) char * nmc_setting_get_property_desc (NMSetting *setting, const char *prop) { + gs_free char *desc_to_free = NULL; const char *setting_desc = NULL; const char *setting_desc_title = ""; const char *nmcli_desc = NULL; @@ -4709,11 +4698,18 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) setting_desc_title = _("[NM property description]"); if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) { + const char *desc = NULL; + if (property_info->is_name) { /* Traditionally, the "name" property was not handled here. * For the moment, skip it from get_property_val(). */ - } else if (property_info->describe_message) { - nmcli_desc = _(property_info->describe_message); + } else if (property_info->property_type->describe_fcn) { + desc = property_info->property_type->describe_fcn (setting_info, property_info, &desc_to_free); + } else + desc = property_info->describe_message; + + if (desc) { + nmcli_desc = _(desc); nmcli_desc_title = _("[nmcli specific description]"); nmcli_nl = "\n"; } diff --git a/clients/cli/settings.h b/clients/cli/settings.h index ae63ccf138..76d2a3bbd9 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -45,9 +45,9 @@ typedef struct _NmcPropertyTypData NmcPropertyTypData; struct _NmcPropertyType { - /* FIXME: the function should return an allocated string. */ const char *(*describe_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info); + const NmcPropertyInfo *property_info, + char **out_to_free); char *(*get_fcn) (const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, @@ -66,9 +66,9 @@ struct _NmcPropertyType { guint32 idx, GError **error); - /* FIXME: the function should return an allocated string. */ const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info); + const NmcPropertyInfo *property_info, + char ***out_to_free); }; struct _NmcPropertyTypData { @@ -130,7 +130,7 @@ void nmc_setting_connection_connect_handlers (NMSettingConnection *setting, NMCo char **nmc_setting_get_valid_properties (NMSetting *setting); char *nmc_setting_get_property_desc (NMSetting *setting, const char *prop); -const char *const*nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop); +const char *const*nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, char ***out_to_free); char *nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error); From fcc19ea76016c8c3382dc6d70672ff0d7ec16cfe Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Mar 2017 11:14:14 +0200 Subject: [PATCH 34/53] nmcli: output property values in "parsable" mode when the "--terse" option is specified (again) Commit 623d888801f611be4e4d14570d6c2f84dcd92937 was reverted during refactoring nmcli to simplify merge conflicts. Restore the behavior of the patch. --- clients/cli/settings.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 5d1760adde..6cf35be6d4 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -4785,6 +4785,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean guint i; size_t tmpl_len; gs_free char *s_all = NULL; + NmcPropertyGetType type = NMC_PROPERTY_GET_PRETTY; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); @@ -4796,6 +4797,9 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE); + if (nmc->print_output == NMC_PRINT_TERSE) + type = NMC_PROPERTY_GET_PARSABLE; + tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1); tmpl = g_memdup (_get_nmc_output_fields (setting_info), tmpl_len); @@ -4812,7 +4816,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, property_info, setting, - NMC_PROPERTY_GET_PRETTY, + type, show_secrets)); } else set_val_str (arr, i, g_strdup (_(HIDDEN_TEXT))); From 2a71b5322fdffa2b64f757c4c8d83441c4a6a147 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Mar 2017 11:02:03 +0200 Subject: [PATCH 35/53] cli/trivial: rename metadata related names They will be moved out of nmcli as they are generally useful. Even if they happen to be used only inside nmcli, there should be a better separation between logic (nmcli) and setting decriptions. --- clients/cli/connections.c | 4 +- clients/cli/nmcli.c | 2 +- clients/cli/nmcli.h | 4 +- clients/cli/settings.c | 372 +++++++++++++++++++------------------- clients/cli/settings.h | 62 +++---- clients/cli/utils.c | 4 +- 6 files changed, 224 insertions(+), 224 deletions(-) diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 6421f7fd07..f381dfd73d 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -152,7 +152,7 @@ NmcOutputField nmc_fields_con_show[] = { { \ .name = setting, \ .name_l10n = N_ (setting), \ - .setting_info = &nmc_setting_infos[setting_type], \ + .setting_info = &nm_meta_setting_infos_editor[setting_type], \ } /* Available settings for 'connection show ' - profile part */ @@ -3185,7 +3185,7 @@ get_valid_properties_string (const NameItem *array, { const NameItem *iter = array; const NmcOutputField *field_iter; - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; const char *prop_name = NULL; GString *str; int i, j; diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index bbc848f7af..f7fc99899d 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -68,7 +68,7 @@ NM_CACHED_QUARK_FCN ("nmcli-error-quark", nmcli_error_quark) static void complete_field_new (GHashTable *h, const char *setting, NMMetaSettingType setting_type) { - const NmcSettingInfo *setting_info = &nmc_setting_infos[setting_type]; + const NMMetaSettingInfoEditor *setting_info = &nm_meta_setting_infos_editor[setting_type]; int i; for (i = 0; i < setting_info->properties_num; i++) { diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 8efb09289b..f150179d24 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -104,7 +104,7 @@ typedef enum { #define NMC_OF_FLAG_MAIN_HEADER_ADD 0x00000004 /* Print main header in addition to values/field names */ #define NMC_OF_FLAG_MAIN_HEADER_ONLY 0x00000008 /* Print main header only */ -struct _NmcSettingInfo; +struct _NMMetaSettingInfoEditor; typedef struct _NmcOutputField { const char *name; /* Field's name */ @@ -124,7 +124,7 @@ typedef struct _NmcOutputField { * * For now, hack around that by alternatively providing a @setting_info instead * of @group_list. */ - const struct _NmcSettingInfo *setting_info; + const struct _NMMetaSettingInfoEditor *setting_info; } NmcOutputField; typedef struct { diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 6cf35be6d4..962ee54de2 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -34,7 +34,7 @@ static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error); -static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type); +static char *secret_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type); #define ALL_SECRET_FLAGS \ (NM_SETTING_SECRET_FLAG_NONE | \ @@ -47,19 +47,19 @@ static char *secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) /*****************************************************************************/ #define ARGS_DESCRIBE_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, char **out_to_free + const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, char **out_to_free #define ARGS_GET_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, NmcPropertyGetType get_type, gboolean show_secrets + const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, NMMetaAccessorGetType get_type, gboolean show_secrets #define ARGS_SET_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error + const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error #define ARGS_REMOVE_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, NMSetting *setting, const char *value, guint32 idx, GError **error + const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *value, guint32 idx, GError **error #define ARGS_VALUES_FCN \ - const NmcSettingInfo *setting_info, const NmcPropertyInfo *property_info, char ***out_to_free + const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, char ***out_to_free static char * _get_fcn_name (ARGS_GET_FCN) @@ -76,7 +76,7 @@ _get_fcn_nmc_with_default (ARGS_GET_FCN) GValue val = G_VALUE_INIT; if (property_info->property_typ_data->subtype.get_with_default.fcn (setting)) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup (""); return g_strdup (_("(default)")); } @@ -84,7 +84,7 @@ _get_fcn_nmc_with_default (ARGS_GET_FCN) g_value_init (&val, G_TYPE_STRING); g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); s = g_value_get_string (&val); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) s_full = g_strdup (s && *s ? s : " "); else s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); @@ -116,7 +116,7 @@ _get_fcn_gobject_mtu (ARGS_GET_FCN) mtu = property_info->property_typ_data->subtype.mtu.get_fcn (setting); if (mtu == 0) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup ("auto"); else return g_strdup (_("auto")); @@ -251,20 +251,20 @@ _set_fcn_gobject_mtu (ARGS_SET_FCN) static gboolean _set_fcn_gobject_mac (ARGS_SET_FCN) { - NmcPropertyTypeMacMode mode; + NMMetaPropertyTypeMacMode mode; gboolean valid; if (property_info->property_typ_data) mode = property_info->property_typ_data->subtype.mac.mode; else - mode = NMC_PROPERTY_TYPE_MAC_MODE_DEFAULT; + mode = NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT; - if (mode == NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND) + if (mode == NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND) valid = nm_utils_hwaddr_valid (value, INFINIBAND_ALEN); else { valid = nm_utils_hwaddr_valid (value, ETH_ALEN) - || ( mode == NMC_PROPERTY_TYPE_MAC_MODE_CLONED + || ( mode == NM_META_PROPERTY_TYPE_MAC_MODE_CLONED && NM_CLONED_MAC_IS_SPECIAL (value)); } @@ -326,11 +326,11 @@ _values_fcn_gobject_enum (ARGS_VALUES_FCN) /*****************************************************************************/ -static const NmcSettingInfo * +static const NMMetaSettingInfoEditor * _meta_find_setting_info_by_name (const char *setting_name) { const NMMetaSettingInfo *meta_setting_info; - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; g_return_val_if_fail (setting_name, NULL); @@ -341,21 +341,21 @@ _meta_find_setting_info_by_name (const char *setting_name) g_return_val_if_fail (nm_streq0 (meta_setting_info->setting_name, setting_name), NULL); - if (meta_setting_info->meta_type >= G_N_ELEMENTS (nmc_setting_infos)) + if (meta_setting_info->meta_type >= G_N_ELEMENTS (nm_meta_setting_infos_editor)) return NULL; - setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + setting_info = &nm_meta_setting_infos_editor[meta_setting_info->meta_type]; g_return_val_if_fail (setting_info->general == meta_setting_info, NULL); return setting_info; } -static const NmcSettingInfo * +static const NMMetaSettingInfoEditor * _meta_find_setting_info_by_gtype (GType gtype) { const NMMetaSettingInfo *meta_setting_info; - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; meta_setting_info = nm_meta_setting_infos_by_gtype (gtype); @@ -365,20 +365,20 @@ _meta_find_setting_info_by_gtype (GType gtype) g_return_val_if_fail (meta_setting_info->get_setting_gtype, NULL); g_return_val_if_fail (meta_setting_info->get_setting_gtype () == gtype, NULL); - if (meta_setting_info->meta_type >= G_N_ELEMENTS (nmc_setting_infos)) + if (meta_setting_info->meta_type >= G_N_ELEMENTS (nm_meta_setting_infos_editor)) return NULL; - setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + setting_info = &nm_meta_setting_infos_editor[meta_setting_info->meta_type]; g_return_val_if_fail (setting_info->general == meta_setting_info, NULL); return setting_info; } -static const NmcSettingInfo * +static const NMMetaSettingInfoEditor * _meta_find_setting_info_by_setting (NMSetting *setting) { - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; g_return_val_if_fail (NM_IS_SETTING (setting), NULL); @@ -392,8 +392,8 @@ _meta_find_setting_info_by_setting (NMSetting *setting) return setting_info; } -static const NmcPropertyInfo * -_meta_setting_info_find_property_info (const NmcSettingInfo *setting_info, const char *property_name) +static const NMMetaPropertyInfo * +_meta_setting_info_find_property_info (const NMMetaSettingInfoEditor *setting_info, const char *property_name) { guint i; @@ -408,10 +408,10 @@ _meta_setting_info_find_property_info (const NmcSettingInfo *setting_info, const return NULL; } -static const NmcPropertyInfo * -_meta_find_property_info_by_name (const char *setting_name, const char *property_name, const NmcSettingInfo **out_setting_info) +static const NMMetaPropertyInfo * +_meta_find_property_info_by_name (const char *setting_name, const char *property_name, const NMMetaSettingInfoEditor **out_setting_info) { - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; setting_info = _meta_find_setting_info_by_name (setting_name); @@ -421,11 +421,11 @@ _meta_find_property_info_by_name (const char *setting_name, const char *property return _meta_setting_info_find_property_info (setting_info, property_name); } -static const NmcPropertyInfo * -_meta_find_property_info_by_setting (NMSetting *setting, const char *property_name, const NmcSettingInfo **out_setting_info) +static const NMMetaPropertyInfo * +_meta_find_property_info_by_setting (NMSetting *setting, const char *property_name, const NMMetaSettingInfoEditor **out_setting_info) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; setting_info = _meta_find_setting_info_by_setting (setting); @@ -442,7 +442,7 @@ _meta_find_property_info_by_setting (NMSetting *setting, const char *property_na /*****************************************************************************/ static const NmcOutputField * -_get_nmc_output_fields (const NmcSettingInfo *setting_info) +_get_nmc_output_fields (const NMMetaSettingInfoEditor *setting_info) { static NmcOutputField *fields[_NM_META_SETTING_TYPE_NUM + 1] = { }; NmcOutputField **field; @@ -502,11 +502,11 @@ bytes_to_string (GBytes *bytes) } static char * -vlan_flags_to_string (guint32 flags, NmcPropertyGetType get_type) +vlan_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type) { GString *flag_str; - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%u", flags); if (flags == 0) @@ -554,9 +554,9 @@ vlan_priorities_to_string (NMSettingVlan *s_vlan, NMVlanPriorityMap map) } static char * -ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NmcPropertyGetType get_type) +ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NMMetaAccessorGetType get_type) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%d", ip6_privacy); switch (ip6_privacy) { @@ -573,9 +573,9 @@ ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NmcPropertyGetType static char * autoconnect_slaves_to_string (NMSettingConnectionAutoconnectSlaves autoconnect_slaves, - NmcPropertyGetType get_type) + NMMetaAccessorGetType get_type) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%d", autoconnect_slaves); switch (autoconnect_slaves) { @@ -590,11 +590,11 @@ autoconnect_slaves_to_string (NMSettingConnectionAutoconnectSlaves autoconnect_s } static char * -secret_flags_to_string (guint32 flags, NmcPropertyGetType get_type) +secret_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type) { GString *flag_str; - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%u", flags); if (flags == 0) @@ -1345,7 +1345,7 @@ _get_fcn_802_1x_phase1_auth_flags (ARGS_GET_FCN) flags = nm_setting_802_1x_get_phase1_auth_flags (s_8021x); tmp = nm_utils_enum_to_str (nm_setting_802_1x_auth_flags_get_type (), flags); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "none"); else str = g_strdup_printf ("%d (%s)", flags, tmp && *tmp ? tmp : "none"); @@ -1508,7 +1508,7 @@ _get_fcn_connection_autoconnect_retires (ARGS_GET_FCN) gint retries; retries = nm_setting_connection_get_autoconnect_retries (s_con); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%d", retries); switch (retries) { @@ -1748,7 +1748,7 @@ _get_fcn_connection_metered (ARGS_GET_FCN) { NMSettingConnection *s_conn = NM_SETTING_CONNECTION (setting); - if (get_type == NMC_PROPERTY_GET_PARSABLE) { + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) { switch (nm_setting_connection_get_metered (s_conn)) { case NM_METERED_YES: return g_strdup ("yes"); @@ -1806,7 +1806,7 @@ _get_fcn_connection_lldp (ARGS_GET_FCN) lldp = nm_setting_connection_get_lldp (s_conn); tmp = nm_utils_enum_to_str (nm_setting_connection_lldp_get_type (), lldp); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "default"); else str = g_strdup_printf ("%d (%s)", lldp, tmp && *tmp ? tmp : "default"); @@ -2266,7 +2266,7 @@ _get_fcn_infiniband_p_key (ARGS_GET_FCN) p_key = nm_setting_infiniband_get_p_key (s_infiniband); if (p_key == -1) { - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup ("default"); else return g_strdup (_("default")); @@ -2374,7 +2374,7 @@ _get_fcn_ip_config_routes (ARGS_GET_FCN) attr_str = nm_utils_format_variant_attributes (hash, ' ', '='); - if (get_type == NMC_PROPERTY_GET_PARSABLE) { + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) { if (printable->len > 0) g_string_append (printable, ", "); @@ -2423,7 +2423,7 @@ _get_fcn_ip4_config_dad_timeout (ARGS_GET_FCN) gint dad_timeout; dad_timeout = nm_setting_ip_config_get_dad_timeout (s_ip); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) return g_strdup_printf ("%d", dad_timeout); switch (dad_timeout) { @@ -3103,7 +3103,7 @@ _get_fcn_macvlan_mode (ARGS_GET_FCN) mode = nm_setting_macvlan_get_mode (s_macvlan); tmp = nm_utils_enum_to_str (nm_setting_macvlan_mode_get_type (), mode); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) str = g_strdup (tmp ? tmp : ""); else str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : ""); @@ -3285,7 +3285,7 @@ _get_fcn_tun_mode (ARGS_GET_FCN) mode = nm_setting_tun_get_mode (s_tun); tmp = nm_utils_enum_to_str (nm_setting_tun_mode_get_type (), mode); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) str = g_strdup_printf ("%s", tmp ? tmp : ""); else str = g_strdup_printf ("%d (%s)", mode, tmp ? tmp : ""); @@ -3371,7 +3371,7 @@ _set_fcn_vlan_egress_priority_map (ARGS_SET_FCN) static gboolean _remove_vlan_xgress_priority_map (NMSetting *setting, - const NmcPropertyInfo *property_info, + const NMMetaPropertyInfo *property_info, const char *value, guint32 idx, NMVlanPriorityMap map_type, @@ -3504,7 +3504,7 @@ _get_fcn_wired_wake_on_lan (ARGS_GET_FCN) wol = nm_setting_wired_get_wake_on_lan (s_wired); tmp = nm_utils_enum_to_str (nm_setting_wired_wake_on_lan_get_type (), wol); - if (get_type == NMC_PROPERTY_GET_PARSABLE) + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) str = g_strdup_printf ("%s", tmp && *tmp ? tmp : "none"); else str = g_strdup_printf ("%d (%s)", wol, tmp && *tmp ? tmp : "none"); @@ -3674,7 +3674,7 @@ _get_fcn_wireless_powersave (ARGS_GET_FCN) powersave = nm_setting_wireless_get_powersave (s_wireless); str = nm_utils_enum_to_str (nm_setting_wireless_powersave_get_type (), powersave); - if (get_type == NMC_PROPERTY_GET_PARSABLE) { + if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) { ret = str; str = NULL; return ret; @@ -4437,10 +4437,10 @@ nmc_setting_custom_init (NMSetting *setting) /*****************************************************************************/ static char * -get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_type, gboolean show_secrets, GError **error) +get_property_val (NMSetting *setting, const char *prop, NMMetaAccessorGetType get_type, gboolean show_secrets, GError **error) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -4472,7 +4472,7 @@ get_property_val (NMSetting *setting, const char *prop, NmcPropertyGetType get_t char * nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error) { - return get_property_val (setting, prop, NMC_PROPERTY_GET_PRETTY, TRUE, error); + return get_property_val (setting, prop, NM_META_ACCESSOR_GET_TYPE_PRETTY, TRUE, error); } /* @@ -4482,7 +4482,7 @@ nmc_setting_get_property (NMSetting *setting, const char *prop, GError **error) char * nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError **error) { - return get_property_val (setting, prop, NMC_PROPERTY_GET_PARSABLE, TRUE, error); + return get_property_val (setting, prop, NM_META_ACCESSOR_GET_TYPE_PARSABLE, TRUE, error); } /* @@ -4496,8 +4496,8 @@ nmc_setting_get_property_parsable (NMSetting *setting, const char *prop, GError gboolean nmc_setting_set_property (NMSetting *setting, const char *prop, const char *value, GError **error) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -4552,8 +4552,8 @@ nmc_property_set_default_value (NMSetting *setting, const char *prop) gboolean nmc_setting_reset_property (NMSetting *setting, const char *prop, GError **error) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -4588,8 +4588,8 @@ nmc_setting_remove_property_option (NMSetting *setting, guint32 idx, GError **error) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -4646,8 +4646,8 @@ const char *const* nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, char ***out_to_free) { - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (out_to_free, FALSE); @@ -4688,8 +4688,8 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop) const char *nmcli_desc = NULL; const char *nmcli_desc_title = ""; const char *nmcli_nl = ""; - const NmcSettingInfo *setting_info; - const NmcPropertyInfo *property_info; + const NMMetaSettingInfoEditor *setting_info; + const NMMetaPropertyInfo *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); @@ -4761,7 +4761,7 @@ nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value) /*****************************************************************************/ static char * -_all_properties (const NmcSettingInfo *setting_info) +_all_properties (const NMMetaSettingInfoEditor *setting_info) { GString *str; guint i; @@ -4779,26 +4779,26 @@ gboolean setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean show_secrets) { const NMMetaSettingInfo *meta_setting_info; - const NmcSettingInfo *setting_info; + const NMMetaSettingInfoEditor *setting_info; gs_free NmcOutputField *tmpl = NULL; NmcOutputField *arr; guint i; size_t tmpl_len; gs_free char *s_all = NULL; - NmcPropertyGetType type = NMC_PROPERTY_GET_PRETTY; + NMMetaAccessorGetType type = NM_META_ACCESSOR_GET_TYPE_PRETTY; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); meta_setting_info = nm_meta_setting_infos_by_gtype (G_OBJECT_TYPE (setting)); g_return_val_if_fail (meta_setting_info, FALSE); - setting_info = &nmc_setting_infos[meta_setting_info->meta_type]; + setting_info = &nm_meta_setting_infos_editor[meta_setting_info->meta_type]; g_return_val_if_fail (setting_info, FALSE); g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE); if (nmc->print_output == NMC_PRINT_TERSE) - type = NMC_PROPERTY_GET_PARSABLE; + type = NM_META_ACCESSOR_GET_TYPE_PARSABLE; tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1); tmpl = g_memdup (_get_nmc_output_fields (setting_info), tmpl_len); @@ -4810,7 +4810,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX); for (i = 0; i < setting_info->properties_num; i++) { - const NmcPropertyInfo *property_info = &setting_info->properties[i]; + const NMMetaPropertyInfo *property_info = &setting_info->properties[i]; if (!property_info->is_secret || show_secrets) { set_val_str (arr, i, property_info->property_type->get_fcn (setting_info, @@ -4832,60 +4832,60 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean /*****************************************************************************/ #define DEFINE_PROPERTY_TYPE(...) \ - (&((NmcPropertyType) { __VA_ARGS__ } )) + (&((NMMetaPropertyType) { __VA_ARGS__ } )) #define DEFINE_PROPERTY_TYP_DATA(...) \ - (&((NmcPropertyTypData) { __VA_ARGS__ } )) + (&((NMMetaPropertyTypData) { __VA_ARGS__ } )) #define DEFINE_PROPERTY_TYP_DATA_SUBTYPE(type, ...) \ DEFINE_PROPERTY_TYP_DATA ( \ .subtype = { .type = { __VA_ARGS__ } } , \ ) -static const NmcPropertyType _pt_name = { +static const NMMetaPropertyType _pt_name = { .get_fcn = _get_fcn_name, }; -static const NmcPropertyType _pt_gobject_readonly = { +static const NMMetaPropertyType _pt_gobject_readonly = { .get_fcn = _get_fcn_gobject, }; -static const NmcPropertyType _pt_gobject_string = { +static const NMMetaPropertyType _pt_gobject_string = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_string, }; -static const NmcPropertyType _pt_gobject_bool = { +static const NMMetaPropertyType _pt_gobject_bool = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_bool, }; -static const NmcPropertyType _pt_gobject_int = { +static const NMMetaPropertyType _pt_gobject_int = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_int, }; -static const NmcPropertyType _pt_gobject_int64 = { +static const NMMetaPropertyType _pt_gobject_int64 = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_int64, }; -static const NmcPropertyType _pt_gobject_uint = { +static const NMMetaPropertyType _pt_gobject_uint = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_uint, }; -static const NmcPropertyType _pt_gobject_mtu = { +static const NMMetaPropertyType _pt_gobject_mtu = { .get_fcn = _get_fcn_gobject_mtu, .set_fcn = _set_fcn_gobject_mtu, }; -static const NmcPropertyType _pt_gobject_mac = { +static const NMMetaPropertyType _pt_gobject_mac = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_mac, }; -static const NmcPropertyType _pt_gobject_secret_flags = { +static const NMMetaPropertyType _pt_gobject_secret_flags = { .get_fcn = _get_fcn_gobject_secret_flags, .set_fcn = _set_fcn_gobject_secret_flags, }; @@ -4919,7 +4919,7 @@ static const NmcPropertyType _pt_gobject_secret_flags = { "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n" \ " set team.config /etc/my-team.conf\n" -static const NmcPropertyInfo properties_setting_802_1x[] = { +static const NMMetaPropertyInfo property_infos_802_1x[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_802_1X_EAP), @@ -5202,7 +5202,7 @@ static const NmcPropertyInfo properties_setting_802_1x[] = { }, }; -static const NmcPropertyInfo properties_setting_adsl[] = { +static const NMMetaPropertyInfo property_infos_adsl[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_ADSL_USERNAME), @@ -5244,7 +5244,7 @@ static const NmcPropertyInfo properties_setting_adsl[] = { }, }; -static const NmcPropertyInfo properties_setting_bluetooth[] = { +static const NMMetaPropertyInfo property_infos_bluetooth[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_BLUETOOTH_BDADDR), @@ -5260,7 +5260,7 @@ static const NmcPropertyInfo properties_setting_bluetooth[] = { }, }; -static const NmcPropertyInfo properties_setting_bond[] = { +static const NMMetaPropertyInfo property_infos_bond[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_BOND_OPTIONS), @@ -5274,7 +5274,7 @@ static const NmcPropertyInfo properties_setting_bond[] = { }, }; -static const NmcPropertyInfo properties_setting_bridge[] = { +static const NMMetaPropertyInfo property_infos_bridge[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_BRIDGE_MAC_ADDRESS), @@ -5310,7 +5310,7 @@ static const NmcPropertyInfo properties_setting_bridge[] = { }, }; -static const NmcPropertyInfo properties_setting_bridge_port[] = { +static const NMMetaPropertyInfo property_infos_bridge_port[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_BRIDGE_PORT_PRIORITY), @@ -5326,7 +5326,7 @@ static const NmcPropertyInfo properties_setting_bridge_port[] = { }, }; -static const NmcPropertyInfo properties_setting_cdma[] = { +static const NMMetaPropertyInfo property_infos_cdma[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_CDMA_NUMBER), @@ -5354,7 +5354,7 @@ static const NmcPropertyInfo properties_setting_cdma[] = { }, }; -static const NmcPropertyInfo properties_setting_connection[] = { +static const NMMetaPropertyInfo property_infos_connection[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_CONNECTION_ID), @@ -5492,7 +5492,7 @@ static const NmcPropertyInfo properties_setting_connection[] = { }, }; -static const NmcPropertyInfo properties_setting_dcb[] = { +static const NMMetaPropertyInfo property_infos_dcb[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_DCB_APP_FCOE_FLAGS), @@ -5602,11 +5602,11 @@ static const NmcPropertyInfo properties_setting_dcb[] = { }, }; -static const NmcPropertyInfo properties_setting_dummy[] = { +static const NMMetaPropertyInfo property_infos_dummy[] = { PROPERTY_INFO_NAME(), }; -static const NmcPropertyInfo properties_setting_gsm[] = { +static const NMMetaPropertyInfo property_infos_gsm[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_GSM_NUMBER), @@ -5670,13 +5670,13 @@ static const NmcPropertyInfo properties_setting_gsm[] = { }, }; -static const NmcPropertyInfo properties_setting_infiniband[] = { +static const NMMetaPropertyInfo property_infos_infiniband[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_INFINIBAND_MAC_ADDRESS), .property_type = &_pt_gobject_mac, .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, - .mode = NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND, + .mode = NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND, ), }, { @@ -5709,7 +5709,7 @@ static const NmcPropertyInfo properties_setting_infiniband[] = { }, }; -static const NmcPropertyInfo properties_setting_ip4_config[] = { +static const NMMetaPropertyInfo property_infos_ip4_config[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), @@ -5840,7 +5840,7 @@ static const NmcPropertyInfo properties_setting_ip4_config[] = { }, }; -static const NmcPropertyInfo properties_setting_ip6_config[] = { +static const NMMetaPropertyInfo property_infos_ip6_config[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_IP_CONFIG_METHOD), @@ -5980,7 +5980,7 @@ static const NmcPropertyInfo properties_setting_ip6_config[] = { }, }; -static const NmcPropertyInfo properties_setting_ip_tunnel[] = { +static const NMMetaPropertyInfo property_infos_ip_tunnel[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_IP_TUNNEL_MODE), @@ -6041,7 +6041,7 @@ static const NmcPropertyInfo properties_setting_ip_tunnel[] = { }, }; -static const NmcPropertyInfo properties_setting_macsec[] = { +static const NMMetaPropertyInfo property_infos_macsec[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_MACSEC_PARENT), @@ -6092,7 +6092,7 @@ static const NmcPropertyInfo properties_setting_macsec[] = { }, }; -static const NmcPropertyInfo properties_setting_macvlan[] = { +static const NMMetaPropertyInfo property_infos_macvlan[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_MACVLAN_PARENT), @@ -6121,7 +6121,7 @@ static const NmcPropertyInfo properties_setting_macvlan[] = { }, }; -static const NmcPropertyInfo properties_setting_olpc_mesh[] = { +static const NMMetaPropertyInfo property_infos_olpc_mesh[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_OLPC_MESH_SSID), @@ -6143,7 +6143,7 @@ static const NmcPropertyInfo properties_setting_olpc_mesh[] = { }, }; -static const NmcPropertyInfo properties_setting_pppoe[] = { +static const NMMetaPropertyInfo property_infos_pppoe[] = { PROPERTY_INFO_NAME (), { .property_name = N_ (NM_SETTING_PPPOE_SERVICE), @@ -6164,7 +6164,7 @@ static const NmcPropertyInfo properties_setting_pppoe[] = { }, }; -static const NmcPropertyInfo properties_setting_ppp[] = { +static const NMMetaPropertyInfo property_infos_ppp[] = { PROPERTY_INFO_NAME (), { .property_name = N_ (NM_SETTING_PPP_NOAUTH), @@ -6243,7 +6243,7 @@ static const NmcPropertyInfo properties_setting_ppp[] = { }, }; -static const NmcPropertyInfo properties_setting_proxy[] = { +static const NMMetaPropertyInfo property_infos_proxy[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_PROXY_METHOD), @@ -6275,7 +6275,7 @@ static const NmcPropertyInfo properties_setting_proxy[] = { }, }; -static const NmcPropertyInfo properties_setting_team[] = { +static const NMMetaPropertyInfo property_infos_team[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_TEAM_CONFIG), @@ -6287,7 +6287,7 @@ static const NmcPropertyInfo properties_setting_team[] = { }, }; -static const NmcPropertyInfo properties_setting_team_port[] = { +static const NMMetaPropertyInfo property_infos_team_port[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_TEAM_PORT_CONFIG), @@ -6299,7 +6299,7 @@ static const NmcPropertyInfo properties_setting_team_port[] = { }, }; -static const NmcPropertyInfo properties_setting_tun[] = { +static const NMMetaPropertyInfo property_infos_tun[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_TUN_MODE), @@ -6333,7 +6333,7 @@ static const NmcPropertyInfo properties_setting_tun[] = { }, }; -static const NmcPropertyInfo properties_setting_serial[] = { +static const NMMetaPropertyInfo property_infos_serial[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_SERIAL_BAUD), @@ -6360,7 +6360,7 @@ static const NmcPropertyInfo properties_setting_serial[] = { }, }; -static const NmcPropertyInfo properties_setting_vlan[] = { +static const NMMetaPropertyInfo property_infos_vlan[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_VLAN_PARENT), @@ -6395,7 +6395,7 @@ static const NmcPropertyInfo properties_setting_vlan[] = { }, }; -static const NmcPropertyInfo properties_setting_vpn[] = { +static const NMMetaPropertyInfo property_infos_vpn[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_VPN_SERVICE_TYPE), @@ -6435,7 +6435,7 @@ static const NmcPropertyInfo properties_setting_vpn[] = { }, }; -static const NmcPropertyInfo properties_setting_vxlan[] = { +static const NMMetaPropertyInfo property_infos_vxlan[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_VXLAN_PARENT), @@ -6503,7 +6503,7 @@ static const NmcPropertyInfo properties_setting_vxlan[] = { }, }; -static const NmcPropertyInfo properties_setting_wimax[] = { +static const NMMetaPropertyInfo property_infos_wimax[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIMAX_MAC_ADDRESS), @@ -6515,7 +6515,7 @@ static const NmcPropertyInfo properties_setting_wimax[] = { }, }; -static const NmcPropertyInfo properties_setting_wired[] = { +static const NMMetaPropertyInfo property_infos_wired[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIRED_PORT), @@ -6548,7 +6548,7 @@ static const NmcPropertyInfo properties_setting_wired[] = { .property_name = N_ (NM_SETTING_WIRED_CLONED_MAC_ADDRESS), .property_type = &_pt_gobject_mac, .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, - .mode = NMC_PROPERTY_TYPE_MAC_MODE_CLONED, + .mode = NM_META_PROPERTY_TYPE_MAC_MODE_CLONED, ), }, { @@ -6610,7 +6610,7 @@ static const NmcPropertyInfo properties_setting_wired[] = { }, }; -static const NmcPropertyInfo properties_setting_wireless[] = { +static const NMMetaPropertyInfo property_infos_wireless[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIRELESS_SSID), @@ -6664,7 +6664,7 @@ static const NmcPropertyInfo properties_setting_wireless[] = { .property_name = N_ (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS), .property_type = &_pt_gobject_mac, .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac, - .mode = NMC_PROPERTY_TYPE_MAC_MODE_CLONED, + .mode = NM_META_PROPERTY_TYPE_MAC_MODE_CLONED, ), }, { @@ -6710,7 +6710,7 @@ static const NmcPropertyInfo properties_setting_wireless[] = { }, }; -static const NmcPropertyInfo properties_setting_wireless_security[] = { +static const NMMetaPropertyInfo property_infos_wireless_security[] = { PROPERTY_INFO_NAME(), { .property_name = N_ (NM_SETTING_WIRELESS_SECURITY_KEY_MGMT), @@ -6836,165 +6836,165 @@ static const NmcPropertyInfo properties_setting_wireless_security[] = { }, }; -const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM] = { +const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTING_TYPE_NUM] = { [NM_META_SETTING_TYPE_802_1X] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_802_1X], - .properties = properties_setting_802_1x, - .properties_num = G_N_ELEMENTS (properties_setting_802_1x), + .properties = property_infos_802_1x, + .properties_num = G_N_ELEMENTS (property_infos_802_1x), }, [NM_META_SETTING_TYPE_ADSL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_ADSL], - .properties = properties_setting_adsl, - .properties_num = G_N_ELEMENTS (properties_setting_adsl), + .properties = property_infos_adsl, + .properties_num = G_N_ELEMENTS (property_infos_adsl), }, [NM_META_SETTING_TYPE_BLUETOOTH] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BLUETOOTH], - .properties = properties_setting_bluetooth, - .properties_num = G_N_ELEMENTS (properties_setting_bluetooth), + .properties = property_infos_bluetooth, + .properties_num = G_N_ELEMENTS (property_infos_bluetooth), }, [NM_META_SETTING_TYPE_BOND] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BOND], - .properties = properties_setting_bond, - .properties_num = G_N_ELEMENTS (properties_setting_bond), + .properties = property_infos_bond, + .properties_num = G_N_ELEMENTS (property_infos_bond), }, [NM_META_SETTING_TYPE_BRIDGE] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE], - .properties = properties_setting_bridge, - .properties_num = G_N_ELEMENTS (properties_setting_bridge), + .properties = property_infos_bridge, + .properties_num = G_N_ELEMENTS (property_infos_bridge), }, [NM_META_SETTING_TYPE_BRIDGE_PORT] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_BRIDGE_PORT], - .properties = properties_setting_bridge_port, - .properties_num = G_N_ELEMENTS (properties_setting_bridge_port), + .properties = property_infos_bridge_port, + .properties_num = G_N_ELEMENTS (property_infos_bridge_port), }, [NM_META_SETTING_TYPE_CDMA] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CDMA], - .properties = properties_setting_cdma, - .properties_num = G_N_ELEMENTS (properties_setting_cdma), + .properties = property_infos_cdma, + .properties_num = G_N_ELEMENTS (property_infos_cdma), }, [NM_META_SETTING_TYPE_CONNECTION] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_CONNECTION], - .properties = properties_setting_connection, - .properties_num = G_N_ELEMENTS (properties_setting_connection), + .properties = property_infos_connection, + .properties_num = G_N_ELEMENTS (property_infos_connection), }, [NM_META_SETTING_TYPE_DCB] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DCB], - .properties = properties_setting_dcb, - .properties_num = G_N_ELEMENTS (properties_setting_dcb), + .properties = property_infos_dcb, + .properties_num = G_N_ELEMENTS (property_infos_dcb), }, [NM_META_SETTING_TYPE_DUMMY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_DUMMY], - .properties = properties_setting_dummy, - .properties_num = G_N_ELEMENTS (properties_setting_dummy), + .properties = property_infos_dummy, + .properties_num = G_N_ELEMENTS (property_infos_dummy), }, [NM_META_SETTING_TYPE_GSM] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_GSM], - .properties = properties_setting_gsm, - .properties_num = G_N_ELEMENTS (properties_setting_gsm), + .properties = property_infos_gsm, + .properties_num = G_N_ELEMENTS (property_infos_gsm), }, [NM_META_SETTING_TYPE_INFINIBAND] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_INFINIBAND], - .properties = properties_setting_infiniband, - .properties_num = G_N_ELEMENTS (properties_setting_infiniband), + .properties = property_infos_infiniband, + .properties_num = G_N_ELEMENTS (property_infos_infiniband), }, [NM_META_SETTING_TYPE_IP4_CONFIG] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP4_CONFIG], - .properties = properties_setting_ip4_config, - .properties_num = G_N_ELEMENTS (properties_setting_ip4_config), + .properties = property_infos_ip4_config, + .properties_num = G_N_ELEMENTS (property_infos_ip4_config), }, [NM_META_SETTING_TYPE_IP6_CONFIG] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP6_CONFIG], - .properties = properties_setting_ip6_config, - .properties_num = G_N_ELEMENTS (properties_setting_ip6_config), + .properties = property_infos_ip6_config, + .properties_num = G_N_ELEMENTS (property_infos_ip6_config), }, [NM_META_SETTING_TYPE_IP_TUNNEL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_IP_TUNNEL], - .properties = properties_setting_ip_tunnel, - .properties_num = G_N_ELEMENTS (properties_setting_ip_tunnel), + .properties = property_infos_ip_tunnel, + .properties_num = G_N_ELEMENTS (property_infos_ip_tunnel), }, [NM_META_SETTING_TYPE_MACSEC] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACSEC], - .properties = properties_setting_macsec, - .properties_num = G_N_ELEMENTS (properties_setting_macsec), + .properties = property_infos_macsec, + .properties_num = G_N_ELEMENTS (property_infos_macsec), }, [NM_META_SETTING_TYPE_MACVLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_MACVLAN], - .properties = properties_setting_macvlan, - .properties_num = G_N_ELEMENTS (properties_setting_macvlan), + .properties = property_infos_macvlan, + .properties_num = G_N_ELEMENTS (property_infos_macvlan), }, [NM_META_SETTING_TYPE_OLPC_MESH] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_OLPC_MESH], - .properties = properties_setting_olpc_mesh, - .properties_num = G_N_ELEMENTS (properties_setting_olpc_mesh), + .properties = property_infos_olpc_mesh, + .properties_num = G_N_ELEMENTS (property_infos_olpc_mesh), }, [NM_META_SETTING_TYPE_PPPOE] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPPOE], - .properties = properties_setting_pppoe, - .properties_num = G_N_ELEMENTS (properties_setting_pppoe), + .properties = property_infos_pppoe, + .properties_num = G_N_ELEMENTS (property_infos_pppoe), }, [NM_META_SETTING_TYPE_PPP] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PPP], - .properties = properties_setting_ppp, - .properties_num = G_N_ELEMENTS (properties_setting_ppp), + .properties = property_infos_ppp, + .properties_num = G_N_ELEMENTS (property_infos_ppp), }, [NM_META_SETTING_TYPE_PROXY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_PROXY], - .properties = properties_setting_proxy, - .properties_num = G_N_ELEMENTS (properties_setting_proxy), + .properties = property_infos_proxy, + .properties_num = G_N_ELEMENTS (property_infos_proxy), }, [NM_META_SETTING_TYPE_SERIAL] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_SERIAL], - .properties = properties_setting_serial, - .properties_num = G_N_ELEMENTS (properties_setting_serial), + .properties = property_infos_serial, + .properties_num = G_N_ELEMENTS (property_infos_serial), }, [NM_META_SETTING_TYPE_TEAM] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM], - .properties = properties_setting_team, - .properties_num = G_N_ELEMENTS (properties_setting_team), + .properties = property_infos_team, + .properties_num = G_N_ELEMENTS (property_infos_team), }, [NM_META_SETTING_TYPE_TEAM_PORT] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TEAM_PORT], - .properties = properties_setting_team_port, - .properties_num = G_N_ELEMENTS (properties_setting_team_port), + .properties = property_infos_team_port, + .properties_num = G_N_ELEMENTS (property_infos_team_port), }, [NM_META_SETTING_TYPE_TUN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_TUN], - .properties = properties_setting_tun, - .properties_num = G_N_ELEMENTS (properties_setting_tun), + .properties = property_infos_tun, + .properties_num = G_N_ELEMENTS (property_infos_tun), }, [NM_META_SETTING_TYPE_VLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VLAN], - .properties = properties_setting_vlan, - .properties_num = G_N_ELEMENTS (properties_setting_vlan), + .properties = property_infos_vlan, + .properties_num = G_N_ELEMENTS (property_infos_vlan), }, [NM_META_SETTING_TYPE_VPN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VPN], - .properties = properties_setting_vpn, - .properties_num = G_N_ELEMENTS (properties_setting_vpn), + .properties = property_infos_vpn, + .properties_num = G_N_ELEMENTS (property_infos_vpn), }, [NM_META_SETTING_TYPE_VXLAN] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_VXLAN], - .properties = properties_setting_vxlan, - .properties_num = G_N_ELEMENTS (properties_setting_vxlan), + .properties = property_infos_vxlan, + .properties_num = G_N_ELEMENTS (property_infos_vxlan), }, [NM_META_SETTING_TYPE_WIMAX] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIMAX], - .properties = properties_setting_wimax, - .properties_num = G_N_ELEMENTS (properties_setting_wimax), + .properties = property_infos_wimax, + .properties_num = G_N_ELEMENTS (property_infos_wimax), }, [NM_META_SETTING_TYPE_WIRED] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRED], - .properties = properties_setting_wired, - .properties_num = G_N_ELEMENTS (properties_setting_wired), + .properties = property_infos_wired, + .properties_num = G_N_ELEMENTS (property_infos_wired), }, [NM_META_SETTING_TYPE_WIRELESS] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS], - .properties = properties_setting_wireless, - .properties_num = G_N_ELEMENTS (properties_setting_wireless), + .properties = property_infos_wireless, + .properties_num = G_N_ELEMENTS (property_infos_wireless), }, [NM_META_SETTING_TYPE_WIRELESS_SECURITY] = { .general = &nm_meta_setting_infos[NM_META_SETTING_TYPE_WIRELESS_SECURITY], - .properties = properties_setting_wireless_security, - .properties_num = G_N_ELEMENTS (properties_setting_wireless_security), + .properties = property_infos_wireless_security, + .properties_num = G_N_ELEMENTS (property_infos_wireless_security), }, }; diff --git a/clients/cli/settings.h b/clients/cli/settings.h index 76d2a3bbd9..485a961e92 100644 --- a/clients/cli/settings.h +++ b/clients/cli/settings.h @@ -28,50 +28,50 @@ /*****************************************************************************/ typedef enum { - NMC_PROPERTY_GET_PRETTY, - NMC_PROPERTY_GET_PARSABLE, -} NmcPropertyGetType; + NM_META_ACCESSOR_GET_TYPE_PRETTY, + NM_META_ACCESSOR_GET_TYPE_PARSABLE, +} NMMetaAccessorGetType; typedef enum { - NMC_PROPERTY_TYPE_MAC_MODE_DEFAULT, - NMC_PROPERTY_TYPE_MAC_MODE_CLONED, - NMC_PROPERTY_TYPE_MAC_MODE_INFINIBAND, -} NmcPropertyTypeMacMode; + NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT, + NM_META_PROPERTY_TYPE_MAC_MODE_CLONED, + NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND, +} NMMetaPropertyTypeMacMode; -typedef struct _NmcSettingInfo NmcSettingInfo; -typedef struct _NmcPropertyInfo NmcPropertyInfo; -typedef struct _NmcPropertyType NmcPropertyType; -typedef struct _NmcPropertyTypData NmcPropertyTypData; +typedef struct _NMMetaSettingInfoEditor NMMetaSettingInfoEditor; +typedef struct _NMMetaPropertyInfo NMMetaPropertyInfo; +typedef struct _NMMetaPropertyType NMMetaPropertyType; +typedef struct _NMMetaPropertyTypData NMMetaPropertyTypData; -struct _NmcPropertyType { +struct _NMMetaPropertyType { - const char *(*describe_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, + const char *(*describe_fcn) (const NMMetaSettingInfoEditor *setting_info, + const NMMetaPropertyInfo *property_info, char **out_to_free); - char *(*get_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, + char *(*get_fcn) (const NMMetaSettingInfoEditor *setting_info, + const NMMetaPropertyInfo *property_info, NMSetting *setting, - NmcPropertyGetType get_type, + NMMetaAccessorGetType get_type, gboolean show_secrets); - gboolean (*set_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, + gboolean (*set_fcn) (const NMMetaSettingInfoEditor *setting_info, + const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error); - gboolean (*remove_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, + gboolean (*remove_fcn) (const NMMetaSettingInfoEditor *setting_info, + const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *option, guint32 idx, GError **error); - const char *const*(*values_fcn) (const NmcSettingInfo *setting_info, - const NmcPropertyInfo *property_info, + const char *const*(*values_fcn) (const NMMetaSettingInfoEditor *setting_info, + const NMMetaPropertyInfo *property_info, char ***out_to_free); }; -struct _NmcPropertyTypData { +struct _NMMetaPropertyTypData { union { struct { gboolean (*fcn) (NMSetting *setting); @@ -85,13 +85,13 @@ struct _NmcPropertyTypData { guint32 (*get_fcn) (NMSetting *setting); } mtu; struct { - NmcPropertyTypeMacMode mode; + NMMetaPropertyTypeMacMode mode; } mac; } subtype; const char *const*values_static; }; -struct _NmcPropertyInfo { +struct _NMMetaPropertyInfo { const char *property_name; /* the property list for now must contain as first field the @@ -104,19 +104,19 @@ struct _NmcPropertyInfo { const char *describe_message; - const NmcPropertyType *property_type; - const NmcPropertyTypData *property_typ_data; + const NMMetaPropertyType *property_type; + const NMMetaPropertyTypData *property_typ_data; }; -struct _NmcSettingInfo { +struct _NMMetaSettingInfoEditor { const NMMetaSettingInfo *general; /* the order of the properties matter. The first *must* be the * "name", and then the order is as they are listed by default. */ - const NmcPropertyInfo *properties; + const NMMetaPropertyInfo *properties; guint properties_num; }; -extern const NmcSettingInfo nmc_setting_infos[_NM_META_SETTING_TYPE_NUM]; +extern const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[_NM_META_SETTING_TYPE_NUM]; /*****************************************************************************/ diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 4252cd2cb4..93fe651047 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -871,7 +871,7 @@ parse_output_fields (const char *fields_str, for (i = 0; fields_array[i].name; i++) { if (strcasecmp (left, fields_array[i].name) == 0) { const NmcOutputField *valid_names = fields_array[i].group_list; - const NmcSettingInfo *setting_info = fields_array[i].setting_info; + const NMMetaSettingInfoEditor *setting_info = fields_array[i].setting_info; idx = i; if (!right && !valid_names && !setting_info) { @@ -966,7 +966,7 @@ nmc_get_allowed_fields (const NmcOutputField fields_array[], int group_idx) fields_array[group_idx].name, second_level[i].name); } } else if (group_idx != -1 && fields_array[group_idx].setting_info) { - const NmcSettingInfo *second_level = fields_array[group_idx].setting_info; + const NMMetaSettingInfoEditor *second_level = fields_array[group_idx].setting_info; for (i = 1; i < second_level->properties_num; i++) { g_string_append_printf (allowed_fields, "%s.%s,", From b5c8622ad3e8eb34143e5023cdf784da741f338c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Mar 2017 11:38:00 +0200 Subject: [PATCH 36/53] cli: split nm-meta-setting-desc out of settings This part contains static functions and variables to describe settings. It is distinct from the mechanism to use them, or access them. Split it out. It still uses clients/cli/common.h and clients/cli/utils.h which shall be fixed next. --- Makefile.am | 11 +- clients/cli/settings.c | 6080 +--------------- clients/cli/settings.h | 96 +- clients/common/nm-meta-setting-desc.c | 6108 +++++++++++++++++ clients/common/nm-meta-setting-desc.h | 118 + libnm-core/nm-keyfile-internal.h | 2 +- po/POTFILES.in | 1 + ...m-setting-metadata.c => nm-meta-setting.c} | 2 +- ...m-setting-metadata.h => nm-meta-setting.h} | 6 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 2 +- .../ifnet/nms-ifnet-connection-parser.c | 2 +- 11 files changed, 6244 insertions(+), 6184 deletions(-) create mode 100644 clients/common/nm-meta-setting-desc.c create mode 100644 clients/common/nm-meta-setting-desc.h rename shared/{nm-setting-metadata.c => nm-meta-setting.c} (99%) rename shared/{nm-setting-metadata.h => nm-meta-setting.h} (97%) diff --git a/Makefile.am b/Makefile.am index fb18977464..6fdbe186f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -416,7 +416,7 @@ libnm_core_lib_h_pub_mkenums = \ libnm_core_lib_h_priv = \ shared/nm-utils/nm-shared-utils.h \ shared/nm-utils/nm-udev-utils.h \ - shared/nm-setting-metadata.h \ + shared/nm-meta-setting.h \ libnm-core/crypto.h \ libnm-core/nm-connection-private.h \ libnm-core/nm-core-internal.h \ @@ -429,7 +429,7 @@ libnm_core_lib_h_priv = \ libnm_core_lib_c_real = \ shared/nm-utils/nm-shared-utils.c \ shared/nm-utils/nm-udev-utils.c \ - shared/nm-setting-metadata.c \ + shared/nm-meta-setting.c \ libnm-core/crypto.c \ libnm-core/nm-connection.c \ libnm-core/nm-dbus-utils.c \ @@ -3118,8 +3118,11 @@ bin_PROGRAMS += clients/cli/nmcli clients_cli_nmcli_SOURCES = \ \ - shared/nm-setting-metadata.c \ - shared/nm-setting-metadata.h \ + shared/nm-meta-setting.c \ + shared/nm-meta-setting.h \ + \ + clients/common/nm-meta-setting-desc.c \ + clients/common/nm-meta-setting-desc.h \ \ clients/cli/agent.c \ clients/cli/agent.h \ diff --git a/clients/cli/settings.c b/clients/cli/settings.c index 962ee54de2..28f7ebfcd9 100644 --- a/clients/cli/settings.c +++ b/clients/cli/settings.c @@ -31,301 +31,6 @@ /*****************************************************************************/ -static gboolean validate_int (NMSetting *setting, const char* prop, gint val, GError **error); -static gboolean validate_uint (NMSetting *setting, const char* prop, guint val, GError **error); -static gboolean validate_int64 (NMSetting *setting, const char* prop, gint64 val, GError **error); -static char *secret_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type); - -#define ALL_SECRET_FLAGS \ - (NM_SETTING_SECRET_FLAG_NONE | \ - NM_SETTING_SECRET_FLAG_AGENT_OWNED | \ - NM_SETTING_SECRET_FLAG_NOT_SAVED | \ - NM_SETTING_SECRET_FLAG_NOT_REQUIRED) - -#define HIDDEN_TEXT "" - -/*****************************************************************************/ - -#define ARGS_DESCRIBE_FCN \ - const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, char **out_to_free - -#define ARGS_GET_FCN \ - const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, NMMetaAccessorGetType get_type, gboolean show_secrets - -#define ARGS_SET_FCN \ - const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *value, GError **error - -#define ARGS_REMOVE_FCN \ - const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, NMSetting *setting, const char *value, guint32 idx, GError **error - -#define ARGS_VALUES_FCN \ - const NMMetaSettingInfoEditor *setting_info, const NMMetaPropertyInfo *property_info, char ***out_to_free - -static char * -_get_fcn_name (ARGS_GET_FCN) -{ - nm_assert (nm_streq0 (nm_setting_get_name (setting), setting_info->general->setting_name)); - return g_strdup (setting_info->general->setting_name); -} - -static char * -_get_fcn_nmc_with_default (ARGS_GET_FCN) -{ - const char *s; - char *s_full; - GValue val = G_VALUE_INIT; - - if (property_info->property_typ_data->subtype.get_with_default.fcn (setting)) { - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup (""); - return g_strdup (_("(default)")); - } - - g_value_init (&val, G_TYPE_STRING); - g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); - s = g_value_get_string (&val); - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - s_full = g_strdup (s && *s ? s : " "); - else - s_full = s ? g_strdup_printf ("\"%s\"", s) : g_strdup (""); - g_value_unset (&val); - return s_full; -} - -static char * -_get_fcn_gobject (ARGS_GET_FCN) -{ - char *s; - GValue val = G_VALUE_INIT; - - g_value_init (&val, G_TYPE_STRING); - g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); - s = g_value_dup_string (&val); - g_value_unset (&val); - return s; -} - -static char * -_get_fcn_gobject_mtu (ARGS_GET_FCN) -{ - guint32 mtu; - - if ( !property_info->property_typ_data - || !property_info->property_typ_data->subtype.mtu.get_fcn) - return _get_fcn_gobject (setting_info, property_info, setting, get_type, show_secrets); - - mtu = property_info->property_typ_data->subtype.mtu.get_fcn (setting); - if (mtu == 0) { - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup ("auto"); - else - return g_strdup (_("auto")); - } - return g_strdup_printf ("%u", (unsigned) mtu); -} - -static char * -_get_fcn_gobject_secret_flags (ARGS_GET_FCN) -{ - guint v; - GValue val = G_VALUE_INIT; - - g_value_init (&val, G_TYPE_UINT); - g_object_get_property (G_OBJECT (setting), property_info->property_name, &val); - v = g_value_get_uint (&val); - g_value_unset (&val); - return secret_flags_to_string (v, get_type); -} - -/*****************************************************************************/ - -static gboolean -_set_fcn_gobject_string (ARGS_SET_FCN) -{ - if ( property_info->property_typ_data - && property_info->property_typ_data->values_static) { - value = nmc_string_is_valid (value, - (const char **) property_info->property_typ_data->values_static, - error); - if (!value) - return FALSE; - } - g_object_set (setting, property_info->property_name, value, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_bool (ARGS_SET_FCN) -{ - gboolean val_bool; - - if (!nmc_string_to_bool (value, &val_bool, error)) - return FALSE; - - g_object_set (setting, property_info->property_name, val_bool, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_trilean (ARGS_SET_FCN) -{ - long int val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_int (value, TRUE, -1, 1, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid value; use -1, 0 or 1"), value); - return FALSE; - } - - g_object_set (setting, property_info->property_name, val_int, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_int (ARGS_SET_FCN) -{ - long int val_int; - - if (!nmc_string_to_int (value, TRUE, G_MININT, G_MAXINT, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_int (setting, property_info->property_name, (gint) val_int, error)) - return FALSE; - - g_object_set (setting, property_info->property_name, (gint) val_int, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_int64 (ARGS_SET_FCN) -{ - long val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_int (value, FALSE, 0, 0, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_int64 (setting, property_info->property_name, (gint64) val_int, error)) - return FALSE; - - g_object_set (setting, property_info->property_name, (gint64) val_int, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_uint (ARGS_SET_FCN) -{ - unsigned long val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - if (!nmc_string_to_uint (value, TRUE, 0, G_MAXUINT, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid number (or out of range)"), value); - return FALSE; - } - - /* Validate the number according to the property spec */ - if (!validate_uint (setting, property_info->property_name, (guint) val_int, error)) - return FALSE; - - g_object_set (setting, property_info->property_name, (guint) val_int, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_mtu (ARGS_SET_FCN) -{ - if (nm_streq0 (value, "auto")) - value = "0"; - return _set_fcn_gobject_uint (setting_info, property_info, setting, value, error); -} - -static gboolean -_set_fcn_gobject_mac (ARGS_SET_FCN) -{ - NMMetaPropertyTypeMacMode mode; - gboolean valid; - - if (property_info->property_typ_data) - mode = property_info->property_typ_data->subtype.mac.mode; - else - mode = NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT; - - - if (mode == NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND) - valid = nm_utils_hwaddr_valid (value, INFINIBAND_ALEN); - else { - valid = nm_utils_hwaddr_valid (value, ETH_ALEN) - || ( mode == NM_META_PROPERTY_TYPE_MAC_MODE_CLONED - && NM_CLONED_MAC_IS_SPECIAL (value)); - } - - if (!valid) { - g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), value); - return FALSE; - } - - g_object_set (setting, property_info->property_name, value, NULL); - return TRUE; -} - -static gboolean -_set_fcn_gobject_secret_flags (ARGS_SET_FCN) -{ - char **strv = NULL, **iter; - unsigned long flags = 0, val_int; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - strv = nmc_strsplit_set (value, " \t,", 0); - for (iter = strv; iter && *iter; iter++) { - if (!nmc_string_to_uint (*iter, TRUE, 0, ALL_SECRET_FLAGS, &val_int)) { - g_set_error (error, 1, 0, _("'%s' is not a valid flag number; use <0-%d>"), - *iter, ALL_SECRET_FLAGS); - g_strfreev (strv); - return FALSE; - } - flags += val_int; - } - g_strfreev (strv); - - /* Validate the flags number */ - if (flags > ALL_SECRET_FLAGS) { - flags = ALL_SECRET_FLAGS; - g_print (_("Warning: '%s' sum is higher than all flags => all flags set\n"), value); - } - - g_object_set (setting, property_info->property_name, (guint) flags, NULL); - return TRUE; -} - -/*****************************************************************************/ - -static const char *const* -_values_fcn_gobject_enum (ARGS_VALUES_FCN) -{ - char **v, **w; - bool has_minmax = property_info->property_typ_data->subtype.gobject_enum.min - || property_info->property_typ_data->subtype.gobject_enum.max; - - v = (char **) nm_utils_enum_get_values ( property_info->property_typ_data->subtype.gobject_enum.get_gtype (), - has_minmax ? property_info->property_typ_data->subtype.gobject_enum.min : G_MININT, - has_minmax ? property_info->property_typ_data->subtype.gobject_enum.max : G_MAXINT); - for (w = v; w && *w; w++) - *w = g_strdup (*w); - return (const char *const*) (*out_to_free = v); -} - -/*****************************************************************************/ - static const NMMetaSettingInfoEditor * _meta_find_setting_info_by_name (const char *setting_name) { @@ -468,3619 +173,6 @@ _get_nmc_output_fields (const NMMetaSettingInfoEditor *setting_info) /*****************************************************************************/ -static char * -wep_key_type_to_string (NMWepKeyType type) -{ - switch (type) { - case NM_WEP_KEY_TYPE_KEY: - return g_strdup_printf (_("%d (key)"), type); - case NM_WEP_KEY_TYPE_PASSPHRASE: - return g_strdup_printf (_("%d (passphrase)"), type); - case NM_WEP_KEY_TYPE_UNKNOWN: - default: - return g_strdup_printf (_("%d (unknown)"), type); - } -} - -static char * -bytes_to_string (GBytes *bytes) -{ - const guint8 *data; - gsize len; - GString *cert = NULL; - int i; - - if (!bytes) - return NULL; - data = g_bytes_get_data (bytes, &len); - - cert = g_string_new (NULL); - for (i = 0; i < len; i++) - g_string_append_printf (cert, "%02X", data[i]); - - return g_string_free (cert, FALSE); -} - -static char * -vlan_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type) -{ - GString *flag_str; - - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup_printf ("%u", flags); - - if (flags == 0) - return g_strdup (_("0 (NONE)")); - - flag_str = g_string_new (NULL); - g_string_printf (flag_str, "%d (", flags); - - if (flags & NM_VLAN_FLAG_REORDER_HEADERS) - g_string_append (flag_str, _("REORDER_HEADERS, ")); - if (flags & NM_VLAN_FLAG_GVRP) - g_string_append (flag_str, _("GVRP, ")); - if (flags & NM_VLAN_FLAG_LOOSE_BINDING) - g_string_append (flag_str, _("LOOSE_BINDING, ")); - if (flags & NM_VLAN_FLAG_MVRP) - g_string_append (flag_str, _("MVRP, ")); - - if (flag_str->str[flag_str->len-1] == '(') - g_string_append (flag_str, _("unknown")); - else - g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */ - - g_string_append_c (flag_str, ')'); - - return g_string_free (flag_str, FALSE); -} - -static char * -vlan_priorities_to_string (NMSettingVlan *s_vlan, NMVlanPriorityMap map) -{ - GString *priorities; - int i; - - priorities = g_string_new (NULL); - for (i = 0; i < nm_setting_vlan_get_num_priorities (s_vlan, map); i++) { - guint32 from, to; - - if (nm_setting_vlan_get_priority (s_vlan, map, i, &from, &to)) - g_string_append_printf (priorities, "%d:%d,", from, to); - } - if (priorities->len) - g_string_truncate (priorities, priorities->len-1); /* chop off trailing ',' */ - - return g_string_free (priorities, FALSE); -} - -static char * -ip6_privacy_to_string (NMSettingIP6ConfigPrivacy ip6_privacy, NMMetaAccessorGetType get_type) -{ - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup_printf ("%d", ip6_privacy); - - switch (ip6_privacy) { - case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: - return g_strdup_printf (_("%d (disabled)"), ip6_privacy); - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: - return g_strdup_printf (_("%d (enabled, prefer public IP)"), ip6_privacy); - case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: - return g_strdup_printf (_("%d (enabled, prefer temporary IP)"), ip6_privacy); - default: - return g_strdup_printf (_("%d (unknown)"), ip6_privacy); - } -} - -static char * -autoconnect_slaves_to_string (NMSettingConnectionAutoconnectSlaves autoconnect_slaves, - NMMetaAccessorGetType get_type) -{ - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup_printf ("%d", autoconnect_slaves); - - switch (autoconnect_slaves) { - case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO: - return g_strdup_printf (_("%d (no)"), autoconnect_slaves); - case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES: - return g_strdup_printf (_("%d (yes)"), autoconnect_slaves); - case NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: - default: - return g_strdup_printf (_("%d (default)"), autoconnect_slaves); - } -} - -static char * -secret_flags_to_string (guint32 flags, NMMetaAccessorGetType get_type) -{ - GString *flag_str; - - if (get_type == NM_META_ACCESSOR_GET_TYPE_PARSABLE) - return g_strdup_printf ("%u", flags); - - if (flags == 0) - return g_strdup (_("0 (none)")); - - flag_str = g_string_new (NULL); - g_string_printf (flag_str, "%u (", flags); - - if (flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED) - g_string_append (flag_str, _("agent-owned, ")); - if (flags & NM_SETTING_SECRET_FLAG_NOT_SAVED) - g_string_append (flag_str, _("not saved, ")); - if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) - g_string_append (flag_str, _("not required, ")); - - if (flag_str->str[flag_str->len-1] == '(') - g_string_append (flag_str, _("unknown")); - else - g_string_truncate (flag_str, flag_str->len-2); /* chop off trailing ', ' */ - - g_string_append_c (flag_str, ')'); - - return g_string_free (flag_str, FALSE); -} - -static void -vpn_data_item (const char *key, const char *value, gpointer user_data) -{ - GString *ret_str = (GString *) user_data; - - if (ret_str->len != 0) - g_string_append (ret_str, ", "); - - g_string_append_printf (ret_str, "%s = %s", key, value); -} - -#define DEFINE_SETTER_STR_LIST_MULTI(def_func, s_macro, set_func) \ - static gboolean \ - def_func (NMSetting *setting, \ - const char *prop, \ - const char *value, \ - const char **valid_strv, \ - GError **error) \ - { \ - char **strv = NULL, **iter; \ - const char *item; \ - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ - strv = nmc_strsplit_set (value, " \t,", 0); \ - for (iter = strv; iter && *iter; iter++) { \ - if (!(item = nmc_string_is_valid (g_strstrip (*iter), valid_strv, error))) { \ - g_strfreev (strv); \ - return FALSE; \ - } \ - set_func (s_macro (setting), item); \ - } \ - g_strfreev (strv); \ - return TRUE; \ - } - -#define DEFINE_SETTER_OPTIONS(def_func, s_macro, s_type, add_func, valid_func1, valid_func2) \ - static gboolean \ - def_func (ARGS_SET_FCN) \ - { \ - char **strv = NULL, **iter; \ - const char **(*valid_func1_p) (s_type *) = valid_func1; \ - const char * (*valid_func2_p) (const char *, const char *, GError **) = valid_func2; \ - const char *opt_name, *opt_val; \ - \ - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); \ - \ - strv = nmc_strsplit_set (value, ",", 0); \ - for (iter = strv; iter && *iter; iter++) { \ - char *left = g_strstrip (*iter); \ - char *right = strchr (left, '='); \ - if (!right) { \ - g_set_error (error, 1, 0, _("'%s' is not valid; use