man nm-settings-nmcli: autogenerate the "Format" field

Instead of deducing the type from the GLib's types, use the properties'
metadata available in nm-meta-setting-desc.c which is the most accurate
representation of what the expected input from the user is.
This commit is contained in:
Íñigo Huguet
2023-09-04 15:04:59 +02:00
parent 33cc96b137
commit af5c1c8019
4 changed files with 1394 additions and 546 deletions

View File

@@ -4661,44 +4661,52 @@ static const NMMetaPropertyType _pt_gobject_readonly = {
static const NMMetaPropertyType _pt_gobject_string = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_string,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
};
static const NMMetaPropertyType _pt_gobject_bool = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_bool,
.complete_fcn = _complete_fcn_gobject_bool,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_BOOL,
};
static const NMMetaPropertyType _pt_gobject_ternary = {
.get_fcn = _get_fcn_gobject_enum,
.set_fcn = _set_fcn_gobject_ternary,
.complete_fcn = _complete_fcn_gobject_ternary,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_TERNARY,
};
static const NMMetaPropertyType _pt_gobject_int = {
.get_fcn = _get_fcn_gobject_int,
.set_fcn = _set_fcn_gobject_int,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_INT,
};
static const NMMetaPropertyType _pt_gobject_mtu = {
.get_fcn = _get_fcn_gobject_mtu,
.set_fcn = _set_fcn_gobject_mtu,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_MTU,
};
static const NMMetaPropertyType _pt_gobject_bytes = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_bytes,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_BYTES,
};
static const NMMetaPropertyType _pt_gobject_mac = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_mac,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_MAC,
};
static const NMMetaPropertyType _pt_gobject_secret_flags = {
.get_fcn = _get_fcn_gobject_secret_flags,
.set_fcn = _set_fcn_gobject_enum,
.values_fcn = _values_fcn_gobject_enum,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_SECRET_FLAGS,
.set_supports_remove = TRUE,
};
@@ -4706,6 +4714,7 @@ static const NMMetaPropertyType _pt_gobject_enum = {
.get_fcn = _get_fcn_gobject_enum,
.set_fcn = _set_fcn_gobject_enum,
.values_fcn = _values_fcn_gobject_enum,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_ENUM,
.set_supports_remove = TRUE,
};
@@ -4713,45 +4722,53 @@ static const NMMetaPropertyType _pt_gobject_devices = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_string,
.complete_fcn = _complete_fcn_gobject_devices,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
};
static const NMMetaPropertyType _pt_dcb_flags = {
.get_fcn = _get_fcn_dcb_flags,
.set_fcn = _set_fcn_dcb_flags,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_DCB_FLAGS,
};
static const NMMetaPropertyType _pt_dcb_bool = {
.get_fcn = _get_fcn_dcb_bool,
.set_fcn = _set_fcn_dcb_bool,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_DCB_BOOL,
};
static const NMMetaPropertyType _pt_dcb = {
.get_fcn = _get_fcn_dcb,
.set_fcn = _set_fcn_dcb,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_DCB,
};
static const NMMetaPropertyType _pt_cert_8021x = {
.get_fcn = _get_fcn_cert_8021x,
.set_fcn = _set_fcn_cert_8021x,
.complete_fcn = _complete_fcn_cert_8021x,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_PATH,
};
static const NMMetaPropertyType _pt_ethtool = {
.get_fcn = _get_fcn_ethtool,
.set_fcn = _set_fcn_ethtool,
.complete_fcn = _complete_fcn_ethtool,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_ETHTOOL,
};
static const NMMetaPropertyType _pt_multilist = {
.get_fcn = _get_fcn_multilist,
.set_fcn = _set_fcn_multilist,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_MULTILIST,
};
static const NMMetaPropertyType _pt_objlist = {
.get_fcn = _get_fcn_objlist,
.set_fcn = _set_fcn_objlist,
.set_supports_remove = TRUE,
.get_fcn = _get_fcn_objlist,
.set_fcn = _set_fcn_objlist,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OBJLIST,
};
#define MULTILIST_GET_NUM_FCN_U32(type, func) (((func) == ((guint32 (*) (type * )) (func))) ? ((guint32 (*) (NMSetting * )) (func)) : NULL)
@@ -4879,6 +4896,7 @@ static const NMMetaPropertyInfo *const property_infos_802_1X[] = {
.strsplit_plain = TRUE,
),
.values_static = NM_MAKE_STRV ("leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd"),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_IDENTITY,
@@ -4924,6 +4942,7 @@ static const NMMetaPropertyInfo *const property_infos_802_1X[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSetting8021x, nm_setting_802_1x_remove_altsubject_match_by_value),
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH,
@@ -5009,7 +5028,11 @@ static const NMMetaPropertyInfo *const property_infos_802_1X[] = {
.property_type = &_pt_gobject_secret_flags,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_PHASE2_CA_PATH,
.property_type = &_pt_gobject_string,
.property_type = DEFINE_PROPERTY_TYPE(
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_string,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_PATH,
)
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH,
.property_type = &_pt_gobject_string,
@@ -5024,6 +5047,7 @@ static const NMMetaPropertyInfo *const property_infos_802_1X[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSetting8021x, nm_setting_802_1x_remove_phase2_altsubject_match_by_value),
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH,
@@ -5215,6 +5239,7 @@ static const NMMetaPropertyInfo property_info_BOND_OPTIONS =
.set_fcn = _set_fcn_optionlist,
.set_supports_remove = TRUE,
.values_fcn = _values_fcn_bond_options,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
PROPERTY_TYP_DATA_SUBTYPE (optionlist,
@@ -5469,10 +5494,11 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.property_type = &_pt_gobject_string,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_UUID,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_connection_uuid,
),
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_connection_uuid,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_STABLE_ID,
.property_type = &_pt_gobject_string,
@@ -5487,6 +5513,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_connection_type,
.complete_fcn = _complete_fcn_connection_type,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_INTERFACE_NAME,
@@ -5497,6 +5524,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_ifname,
.complete_fcn = _complete_fcn_gobject_devices,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_AUTOCONNECT,
@@ -5547,6 +5575,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.get_fcn = _get_fcn_connection_permissions,
.set_fcn = _set_fcn_multilist,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_MULTILIST,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
PROPERTY_TYP_DATA_SUBTYPE (multilist,
@@ -5557,6 +5586,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.validate2_fcn = _multilist_validate2_fcn_connection_permissions,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_ZONE,
@@ -5571,6 +5601,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_string,
.complete_fcn = _complete_fcn_connection_master,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_SLAVE_TYPE,
@@ -5608,6 +5639,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.validate2_fcn = _multilist_validate2_fcn_uuid,
.strsplit_with_spaces = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT,
@@ -5623,6 +5655,7 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_connection_metered,
.set_fcn = _set_fcn_connection_metered,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_TERNARY,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
.values_static = NM_MAKE_STRV ("yes", "no", "unknown"),
@@ -5916,6 +5949,7 @@ static const NMMetaPropertyInfo *const property_infos_GSM[] = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gsm_auto_config,
.complete_fcn = _complete_fcn_gobject_bool,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_BOOL,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_NUMBER,
@@ -5969,6 +6003,7 @@ static const NMMetaPropertyInfo *const property_infos_GSM[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gsm_sim_operator_id,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_MTU,
@@ -6042,7 +6077,16 @@ static const NMMetaPropertyInfo *const property_infos_INFINIBAND[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_infiniband_p_key,
.set_fcn = _set_fcn_infiniband_p_key,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_INT,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE(gobject_int,
.value_infos = INT_VALUE_INFOS (
{
.value.i64 = -1,
.nick = "default",
},
),
)
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_INFINIBAND_PARENT,
.is_cli_option = TRUE,
@@ -6051,6 +6095,7 @@ static const NMMetaPropertyInfo *const property_infos_INFINIBAND[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_ifname,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
NULL
@@ -6063,6 +6108,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip_config_method,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
.values_static = NM_MAKE_STRV (NM_SETTING_IP4_CONFIG_METHOD_AUTO,
@@ -6085,6 +6131,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_by_value),
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_IPV4,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_SEARCH, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_SEARCH,
@@ -6098,6 +6145,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.validate_fcn = _multilist_validate_fcn_is_domain,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_OPTIONS, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_OPTIONS,
@@ -6112,6 +6160,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.strsplit_plain = TRUE,
),
.is_default_fcn = _is_default_func_ip_config_dns_options,
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_PRIORITY, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_PRIORITY,
@@ -6146,6 +6195,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip_config_gateway,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_IPV4,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_ROUTES, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTES,
@@ -6298,6 +6348,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
.validate_fcn = _multilist_validate_fcn_is_ipv4_addr_or_subnet,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_IPV4,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_AUTO_ROUTE_EXT_GW, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_AUTO_ROUTE_EXT_GW,
@@ -6313,6 +6364,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip_config_method,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
.values_static = NM_MAKE_STRV (NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
@@ -6343,6 +6395,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingIPConfig, nm_setting_ip_config_remove_dns_by_value),
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_IPV6,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_SEARCH, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_SEARCH,
@@ -6356,6 +6409,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.validate_fcn = _multilist_validate_fcn_is_domain,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_OPTIONS, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_OPTIONS,
@@ -6370,6 +6424,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.strsplit_plain = TRUE,
),
.is_default_fcn = _is_default_func_ip_config_dns_options,
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_PRIORITY, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_PRIORITY,
@@ -6404,6 +6459,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip_config_gateway,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_IPV6,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_ROUTES, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTES,
@@ -6823,6 +6879,7 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_interface_name_by_value),
.strsplit_with_spaces = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_KERNEL_COMMAND_LINE,
@@ -6835,6 +6892,7 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_kernel_command_line_by_value),
.strsplit_with_spaces = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_DRIVER,
@@ -6847,6 +6905,7 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_driver_by_value),
.strsplit_with_spaces = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_MATCH_PATH,
@@ -6859,6 +6918,7 @@ static const NMMetaPropertyInfo *const property_infos_MATCH[] = {
.remove_by_value_fcn = MULTILIST_REMOVE_BY_VALUE_FCN (NMSettingMatch, nm_setting_match_remove_path_by_value),
.strsplit_with_spaces = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
NULL
@@ -6875,6 +6935,7 @@ static const NMMetaPropertyInfo *const property_infos_OLPC_MESH[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_olpc_mesh_ssid,
.set_fcn = _set_fcn_gobject_ssid,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OLPC_MESH_CHANNEL,
@@ -6884,6 +6945,7 @@ static const NMMetaPropertyInfo *const property_infos_OLPC_MESH[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_olpc_mesh_channel,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_INT,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS,
@@ -7360,6 +7422,7 @@ static const NMMetaPropertyInfo *const property_infos_TEAM[] = {
),
.values_static = NM_MAKE_STRV ("eth", "vlan", "ipv4", "ipv6", "ip",
"l3", "tcp", "udp", "sctp", "l4"),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_TEAM_RUNNER_TX_BALANCER,
@@ -7620,6 +7683,7 @@ static const NMMetaPropertyInfo *const property_infos_VLAN[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_vlan_flags,
.set_fcn = _set_fcn_gobject_flags,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_ENUM,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_VLAN_PROTOCOL,
@@ -7636,6 +7700,7 @@ static const NMMetaPropertyInfo *const property_infos_VLAN[] = {
.get_fcn = _get_fcn_vlan_xgress_priority_map,
.set_fcn = _set_fcn_vlan_xgress_priority_map,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OBJLIST,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP,
@@ -7646,6 +7711,7 @@ static const NMMetaPropertyInfo *const property_infos_VLAN[] = {
.get_fcn = _get_fcn_vlan_xgress_priority_map,
.set_fcn = _set_fcn_vlan_xgress_priority_map,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OBJLIST,
),
),
NULL
@@ -7664,6 +7730,7 @@ static const NMMetaPropertyInfo *const property_infos_VPN[] = {
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_vpn_service_type,
.complete_fcn = _complete_fcn_vpn_service_type,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_VPN_USER_NAME,
@@ -7677,6 +7744,7 @@ static const NMMetaPropertyInfo *const property_infos_VPN[] = {
.get_fcn = _get_fcn_vpn_options,
.set_fcn = _set_fcn_optionlist,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (optionlist,
.set_fcn = _optionlist_set_fcn_vpn_data,
@@ -7688,6 +7756,7 @@ static const NMMetaPropertyInfo *const property_infos_VPN[] = {
.get_fcn = _get_fcn_vpn_options,
.set_fcn = _set_fcn_optionlist,
.set_supports_remove = TRUE,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (optionlist,
.set_fcn = _optionlist_set_fcn_vpn_secrets,
@@ -7886,6 +7955,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRED[] = {
.validate2_fcn = _multilist_validate2_fcn_mac_addr,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_MAC,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRED_MTU,
@@ -7904,6 +7974,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRED[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_wired_s390_subchannels,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OBJLIST,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRED_S390_NETTYPE,
@@ -7919,6 +7990,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRED[] = {
.set_fcn = _set_fcn_optionlist,
.set_supports_remove = TRUE,
.values_fcn = _values_fcn_wired_s390_options,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (optionlist,
.set_fcn = _optionlist_set_fcn_wired_s390_options,
@@ -8003,6 +8075,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_wireless_ssid,
.set_fcn = _set_fcn_gobject_ssid,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_MODE,
@@ -8028,6 +8101,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_wireless_channel,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_INT,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_BSSID,
@@ -8062,6 +8136,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
.validate2_fcn = _multilist_validate2_fcn_mac_addr,
.strsplit_plain = TRUE,
),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_MAC,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION,
@@ -8147,6 +8222,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.strsplit_plain = TRUE,
),
.values_static = NM_MAKE_STRV ("wpa", "rsn"),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PAIRWISE,
@@ -8160,6 +8236,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.strsplit_plain = TRUE,
),
.values_static = NM_MAKE_STRV ("tkip", "ccmp"),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_GROUP,
@@ -8173,6 +8250,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.strsplit_plain = TRUE,
),
.values_static = NM_MAKE_STRV ("wep40", "wep104", "tkip", "ccmp"),
.list_items_doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_PMF,
@@ -8191,6 +8269,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_wireless_security_wep_key,
.set_fcn = _set_fcn_wireless_wep_key,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_WEP_KEY1,
@@ -8198,6 +8277,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_wireless_security_wep_key,
.set_fcn = _set_fcn_wireless_wep_key,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_WEP_KEY2,
@@ -8205,6 +8285,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_wireless_security_wep_key,
.set_fcn = _set_fcn_wireless_wep_key,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_WEP_KEY3,
@@ -8212,6 +8293,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_wireless_security_wep_key,
.set_fcn = _set_fcn_wireless_wep_key,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS,

View File

@@ -183,6 +183,29 @@ typedef enum {
NM_META_PROPERTY_TYPE_MAC_MODE_WPAN,
} NMMetaPropertyTypeMacMode;
typedef enum _nm_packed {
NM_META_PROPERTY_TYPE_FORMAT_UNDEF = 0,
NM_META_PROPERTY_TYPE_FORMAT_INT,
NM_META_PROPERTY_TYPE_FORMAT_STRING,
NM_META_PROPERTY_TYPE_FORMAT_ENUM,
NM_META_PROPERTY_TYPE_FORMAT_SECRET_FLAGS,
NM_META_PROPERTY_TYPE_FORMAT_BOOL,
NM_META_PROPERTY_TYPE_FORMAT_TERNARY,
NM_META_PROPERTY_TYPE_FORMAT_MAC,
NM_META_PROPERTY_TYPE_FORMAT_IPV4,
NM_META_PROPERTY_TYPE_FORMAT_IPV6,
NM_META_PROPERTY_TYPE_FORMAT_MTU,
NM_META_PROPERTY_TYPE_FORMAT_BYTES,
NM_META_PROPERTY_TYPE_FORMAT_PATH,
NM_META_PROPERTY_TYPE_FORMAT_ETHTOOL,
NM_META_PROPERTY_TYPE_FORMAT_MULTILIST,
NM_META_PROPERTY_TYPE_FORMAT_OBJLIST,
NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST,
NM_META_PROPERTY_TYPE_FORMAT_DCB,
NM_META_PROPERTY_TYPE_FORMAT_DCB_BOOL,
NM_META_PROPERTY_TYPE_FORMAT_DCB_FLAGS,
} NMMetaPropertyTypeFormat;
typedef struct _NMMetaEnvironment NMMetaEnvironment;
typedef struct _NMMetaType NMMetaType;
typedef struct _NMMetaAbstractInfo NMMetaAbstractInfo;
@@ -232,6 +255,8 @@ struct _NMMetaPropertyType {
gboolean *out_complete_filename,
char ***out_to_free);
NMMetaPropertyTypeFormat doc_format;
/* Whether set_fcn() supports the '-' modifier. That is, whether the property
* is a list type. */
bool set_supports_remove : 1;
@@ -350,6 +375,7 @@ struct _NMMetaPropertyTypData {
const char *const *values_static;
const NMMetaPropertyTypDataNested *nested;
NMMetaPropertyTypFlags typ_flags;
NMMetaPropertyTypeFormat list_items_doc_format;
};
typedef enum {

View File

@@ -3,9 +3,41 @@
#include "libnm-client-aux-extern/nm-default-client.h"
#include "libnmc-setting/nm-meta-setting-desc.h"
#include "libnmc-setting/nm-meta-setting-base.h"
#include "nm-core-enum-types.h"
#include <stdarg.h>
#include <stdlib.h>
#define INDENT 4
#define prop_assert(cond, ...) \
G_STMT_START \
if (!(cond)) \
_prop_log(TRUE, __VA_ARGS__); \
G_STMT_END
#define prop_abort(...) _prop_log(TRUE, __VA_ARGS__)
#define prop_warn(...) _prop_log(FALSE, __VA_ARGS__)
static void G_GNUC_PRINTF(3, 4)
_prop_log(gboolean fatal, const NMMetaPropertyInfo *prop_info, const char *fmt, ...)
{
va_list vaargs;
gs_free char *msg = NULL;
gs_free char *msg_full = NULL;
va_start(vaargs, fmt);
msg = g_strdup_vprintf(fmt, vaargs);
msg_full = g_strdup_printf("gen-metadata-nm-settings-nmcli: %s.%s (type %d): %s\n",
prop_info->setting_info->general->setting_name,
prop_info->property_name,
prop_info->property_type->doc_format,
msg);
if (fatal)
g_error("%s", msg_full);
else
g_warning("%s", msg_full);
}
static char *
_xml_escape_attribute(const char *value)
{
@@ -24,6 +56,174 @@ _indent_level(guint num_spaces)
return &spaces[G_N_ELEMENTS(spaces) - num_spaces - 1];
}
static GType
_property_get_gtype(const NMMetaPropertyInfo *prop_info)
{
nm_auto_unref_gtypeclass NMSettingClass *setting_class =
g_type_class_ref(prop_info->setting_info->general->get_setting_gtype());
GParamSpec *param_spec =
g_object_class_find_property(G_OBJECT_CLASS(setting_class), prop_info->property_name);
if (param_spec)
return param_spec->value_type;
g_return_val_if_reached(G_TYPE_INVALID);
}
static char *
_get_enum_format(GType g_type)
{
if (G_TYPE_IS_FLAGS(g_type))
return g_strdup_printf("flags (%s)", g_type_name(g_type));
else
return g_strdup_printf("choice (%s)", g_type_name(g_type));
}
static char *
get_enum_format(const NMMetaPropertyInfo *prop_info)
{
GType gtype = G_TYPE_INVALID;
const NMMetaPropertyTypData *prop_typ_data = prop_info->property_typ_data;
if (prop_typ_data && prop_typ_data->subtype.gobject_enum.get_gtype)
gtype = prop_typ_data->subtype.gobject_enum.get_gtype();
else
gtype = _property_get_gtype(prop_info);
prop_assert(gtype != G_TYPE_INVALID, prop_info, "unknown property's enum type");
return _get_enum_format(gtype);
}
static char *
get_mac_format(const NMMetaPropertyInfo *prop_info)
{
const NMMetaPropertyTypData *prop_typ_data = prop_info->property_typ_data;
if (prop_typ_data) {
switch (prop_typ_data->subtype.mac.mode) {
case NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT:
case NM_META_PROPERTY_TYPE_MAC_MODE_CLONED:
break;
case NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND:
return g_strdup("Infiniband MAC address");
case NM_META_PROPERTY_TYPE_MAC_MODE_WPAN:
return g_strdup("WPAN MAC address");
default:
prop_abort(prop_info, "unknown mode (%d)", prop_typ_data->subtype.mac.mode);
break;
}
}
return g_strdup("MAC address");
}
static char *
get_ethtool_format(const NMMetaPropertyInfo *prop_info)
{
NMEthtoolID ethtool_id;
prop_assert(prop_info->property_typ_data, prop_info, "missing .property_typ_data");
ethtool_id = prop_info->property_typ_data->subtype.ethtool.ethtool_id;
if (nm_ethtool_id_is_coalesce(ethtool_id) || nm_ethtool_id_is_ring(ethtool_id))
return g_strdup("integer");
else if (nm_ethtool_id_is_feature(ethtool_id) || nm_ethtool_id_is_pause(ethtool_id))
return g_strdup("ternary");
return NULL;
}
static char *
get_multilist_format(const NMMetaPropertyInfo *prop_info)
{
NMMetaPropertyTypeFormat item_fmt;
if (prop_info->property_typ_data) {
item_fmt = prop_info->property_typ_data->list_items_doc_format;
switch (item_fmt) {
case NM_META_PROPERTY_TYPE_FORMAT_UNDEF:
prop_abort(prop_info, "undefined item format for multilist");
break;
case NM_META_PROPERTY_TYPE_FORMAT_INT:
case NM_META_PROPERTY_TYPE_FORMAT_MTU:
return g_strdup("list of integers");
case NM_META_PROPERTY_TYPE_FORMAT_STRING:
return g_strdup("list of strings");
case NM_META_PROPERTY_TYPE_FORMAT_BOOL:
return g_strdup("list of booleans");
case NM_META_PROPERTY_TYPE_FORMAT_TERNARY:
return g_strdup("list of ternaries");
case NM_META_PROPERTY_TYPE_FORMAT_MAC:
return g_strdup("list of MAC addresses");
case NM_META_PROPERTY_TYPE_FORMAT_IPV4:
return g_strdup("list of IPv4 addresses");
case NM_META_PROPERTY_TYPE_FORMAT_IPV6:
return g_strdup("list of IPv6 addresses");
default:
prop_abort(prop_info, "unsupported item format (%d)", item_fmt);
break;
}
}
return NULL;
}
static char *
get_property_format(const NMMetaPropertyInfo *prop_info)
{
const NMMetaPropertyType *prop_type = prop_info->property_type;
NMMetaPropertyTypeFormat fmt = prop_type->doc_format;
if (!prop_type->set_fcn)
return g_strdup("read only");
switch (fmt) {
case NM_META_PROPERTY_TYPE_FORMAT_INT:
case NM_META_PROPERTY_TYPE_FORMAT_MTU:
return g_strdup("integer");
case NM_META_PROPERTY_TYPE_FORMAT_STRING:
return g_strdup("string");
case NM_META_PROPERTY_TYPE_FORMAT_ENUM:
return get_enum_format(prop_info);
case NM_META_PROPERTY_TYPE_FORMAT_SECRET_FLAGS:
return _get_enum_format(NM_TYPE_SETTING_SECRET_FLAGS);
case NM_META_PROPERTY_TYPE_FORMAT_DCB_FLAGS:
return _get_enum_format(NM_TYPE_SETTING_DCB_FLAGS);
case NM_META_PROPERTY_TYPE_FORMAT_BOOL:
return g_strdup("boolean");
case NM_META_PROPERTY_TYPE_FORMAT_TERNARY:
return g_strdup("ternary");
case NM_META_PROPERTY_TYPE_FORMAT_MAC:
return get_mac_format(prop_info);
case NM_META_PROPERTY_TYPE_FORMAT_IPV4:
return g_strdup("IPv4 address");
case NM_META_PROPERTY_TYPE_FORMAT_IPV6:
return g_strdup("IPv6 address");
case NM_META_PROPERTY_TYPE_FORMAT_BYTES:
return g_strdup("bytes");
case NM_META_PROPERTY_TYPE_FORMAT_PATH:
return g_strdup("filesystem path");
case NM_META_PROPERTY_TYPE_FORMAT_ETHTOOL:
return get_ethtool_format(prop_info);
case NM_META_PROPERTY_TYPE_FORMAT_MULTILIST:
return get_multilist_format(prop_info);
case NM_META_PROPERTY_TYPE_FORMAT_OBJLIST:
return g_strdup_printf("list of %s.%s objects",
prop_info->setting_info->general->setting_name,
prop_info->property_name);
case NM_META_PROPERTY_TYPE_FORMAT_OPTIONLIST:
return g_strdup("list of key/value options");
case NM_META_PROPERTY_TYPE_FORMAT_DCB:
return g_strdup("list of integers");
case NM_META_PROPERTY_TYPE_FORMAT_DCB_BOOL:
return g_strdup("list of booleans");
default:
prop_abort(prop_info, "missing .format");
return NULL;
}
}
int
main(int argc, char *argv[])
{
@@ -47,16 +247,17 @@ main(int argc, char *argv[])
for (i_property = 0; i_property < sett_info->properties_num; i_property++) {
const NMMetaPropertyInfo *prop_info = sett_info->properties[i_property];
gs_free char *tmp2 = NULL;
gs_free char *tmp3 = NULL;
gs_free char *tmp4 = NULL;
gs_free char *name = NULL;
gs_free char *alias = NULL;
gs_free char *descr = NULL;
gs_free char *fmt = NULL;
g_print("%s<property", _indent_level(2 * INDENT));
g_print(" name=%s", tmp2 = _xml_escape_attribute(prop_info->property_name));
g_print(" name=%s", name = _xml_escape_attribute(prop_info->property_name));
if (prop_info->property_alias)
g_print("\n%salias=%s",
_indent_level(2 * INDENT + 10),
tmp3 = _xml_escape_attribute(prop_info->property_alias));
alias = _xml_escape_attribute(prop_info->property_alias));
if (prop_info->describe_doc) {
/* These descriptions are used by interactive nmcli modes. For the most part,
* they are themselves generated (see "settings-docs.h"). Some of them are instead
@@ -71,8 +272,15 @@ main(int argc, char *argv[])
* Name them something else ("<nmcli-description>") which isn't actually used. */
g_print("\n%snmcli-description=%s",
_indent_level(2 * INDENT + 10),
tmp4 = _xml_escape_attribute(prop_info->describe_doc));
descr = _xml_escape_attribute(prop_info->describe_doc));
}
fmt = get_property_format(prop_info);
if (fmt)
g_print("\n%sformat=%s",
_indent_level(2 * INDENT + 10),
_xml_escape_attribute(fmt));
g_print(" />\n");
}

File diff suppressed because it is too large Load Diff