clients: unify IPv4 and IPv6 accessors for dns-search, dns-options

This commit is contained in:
Beniamino Galvani 2019-01-12 10:17:54 +01:00
parent a9ab50efb1
commit 1f32e417a8

View file

@ -3350,7 +3350,7 @@ DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns,
_validate_and_remove_ipv4_dns)
static gboolean
_set_fcn_ip4_config_dns_search (ARGS_SET_FCN)
_set_fcn_ip_config_dns_search (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
gsize i;
@ -3369,9 +3369,9 @@ _set_fcn_ip4_config_dns_search (ARGS_SET_FCN)
}
static gboolean
_validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
const char *dns_search,
GError **error)
_validate_and_remove_ip_dns_search (NMSettingIPConfig *setting,
const char *dns_search,
GError **error)
{
gboolean ret;
@ -3382,14 +3382,14 @@ _validate_and_remove_ipv4_dns_search (NMSettingIPConfig *setting,
dns_search);
return ret;
}
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns_search,
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ip_config_dns_search,
NM_SETTING_IP_CONFIG,
nm_setting_ip_config_get_num_dns_searches,
nm_setting_ip_config_remove_dns_search,
_validate_and_remove_ipv4_dns_search)
_validate_and_remove_ip_dns_search)
static gboolean
_set_fcn_ip4_config_dns_options (ARGS_SET_FCN)
_set_fcn_ip_config_dns_options (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
gsize i;
@ -3406,9 +3406,9 @@ _set_fcn_ip4_config_dns_options (ARGS_SET_FCN)
}
static gboolean
_validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
const char *dns_option,
GError **error)
_validate_and_remove_ip_dns_option (NMSettingIPConfig *setting,
const char *dns_option,
GError **error)
{
gboolean ret;
@ -3419,11 +3419,11 @@ _validate_and_remove_ipv4_dns_option (NMSettingIPConfig *setting,
dns_option);
return ret;
}
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv4_config_dns_options,
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ip_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_ipv4_dns_option)
_validate_and_remove_ip_dns_option)
static gboolean
_set_fcn_ip4_config_addresses (ARGS_SET_FCN)
@ -3593,82 +3593,6 @@ DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_ipv6_config_dns,
nm_setting_ip_config_remove_dns,
_validate_and_remove_ipv6_dns)
static gboolean
_set_fcn_ip6_config_dns_search (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
gsize i;
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (!verify_string_list (strv, property_info->property_name, nmc_util_is_domain, error))
return FALSE;
if (strv) {
for (i = 0; strv[i]; i++)
nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (setting), strv[i]);
}
return TRUE;
}
static gboolean
_validate_and_remove_ipv6_dns_search (NMSettingIPConfig *setting,
const char *dns_search,
GError **error)
{
gboolean ret;
ret = nm_setting_ip_config_remove_dns_search_by_value (setting, dns_search);
if (!ret)
g_set_error (error, 1, 0,
_("the property doesn't contain DNS search domain '%s'"),
dns_search);
return ret;
}
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,
_validate_and_remove_ipv6_dns_search)
static gboolean
_set_fcn_ip6_config_dns_options (ARGS_SET_FCN)
{
gs_free const char **strv = NULL;
gsize i;
nm_assert (!error || !*error);
nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (strv) {
for (i = 0; strv[i]; i++)
nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i]);
}
return TRUE;
}
static gboolean
_validate_and_remove_ipv6_dns_option (NMSettingIPConfig *setting,
const char *dns_option,
GError **error)
{
gboolean ret;
ret = nm_setting_ip_config_remove_dns_option_by_value (setting, dns_option);
if (!ret)
g_set_error (error, 1, 0,
_("the property doesn't contain DNS option '%s'"),
dns_option);
return ret;
}
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)
static gboolean
_dns_options_is_default (NMSettingIPConfig *setting)
{
@ -6182,15 +6106,15 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_SEARCH, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_SEARCH,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip4_config_dns_search,
.remove_fcn = _remove_fcn_ipv4_config_dns_search,
.set_fcn = _set_fcn_ip_config_dns_search,
.remove_fcn = _remove_fcn_ip_config_dns_search,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_OPTIONS, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_OPTIONS,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_nmc_with_default,
.set_fcn = _set_fcn_ip4_config_dns_options,
.remove_fcn = _remove_fcn_ipv4_config_dns_options,
.set_fcn = _set_fcn_ip_config_dns_options,
.remove_fcn = _remove_fcn_ip_config_dns_options,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (get_with_default,
.fcn = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, _dns_options_is_default),
@ -6345,15 +6269,15 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_SEARCH, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_SEARCH,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_ip6_config_dns_search,
.remove_fcn = _remove_fcn_ipv6_config_dns_search,
.set_fcn = _set_fcn_ip_config_dns_search,
.remove_fcn = _remove_fcn_ip_config_dns_search,
),
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DNS_OPTIONS, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_OPTIONS,
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_nmc_with_default,
.set_fcn = _set_fcn_ip6_config_dns_options,
.remove_fcn = _remove_fcn_ipv6_config_dns_options,
.set_fcn = _set_fcn_ip_config_dns_options,
.remove_fcn = _remove_fcn_ip_config_dns_options,
),
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (get_with_default,
.fcn = GET_FCN_WITH_DEFAULT (NMSettingIPConfig, _dns_options_is_default),