mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 04:58:01 +02:00
cli: merge IPv4 and IPv6 implementation for NMSettingIPConfig (pt4)
This commit is contained in:
parent
574f1cf1a4
commit
46eb783fcd
1 changed files with 9 additions and 28 deletions
|
|
@ -3331,24 +3331,25 @@ _set_fcn_ip4_config_addresses (ARGS_SET_FCN)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_validate_and_remove_ipv4_address (NMSettingIPConfig *setting,
|
_validate_and_remove_ip_address (NMSettingIPConfig *setting,
|
||||||
const char *address,
|
const char *value,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
nm_auto_unref_ip_address NMIPAddress *addr = NULL;
|
nm_auto_unref_ip_address NMIPAddress *addr = NULL;
|
||||||
|
int addr_family = nm_setting_ip_config_get_addr_family (NM_SETTING_IP_CONFIG (setting));
|
||||||
|
|
||||||
addr = _parse_ip_address (AF_INET, address, error);
|
addr = _parse_ip_address (addr_family, value, error);
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nm_setting_ip_config_remove_address_by_value (setting, addr);
|
nm_setting_ip_config_remove_address_by_value (setting, addr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
DEFINE_REMOVER_INDEX_OR_VALUE_COMPLEX (_remove_fcn_ipv4_config_addresses,
|
DEFINE_REMOVER_INDEX_OR_VALUE_COMPLEX (_remove_fcn_ip_config_addresses,
|
||||||
NM_SETTING_IP_CONFIG,
|
NM_SETTING_IP_CONFIG,
|
||||||
nm_setting_ip_config_get_num_addresses,
|
nm_setting_ip_config_get_num_addresses,
|
||||||
nm_setting_ip_config_remove_address,
|
nm_setting_ip_config_remove_address,
|
||||||
_validate_and_remove_ipv4_address)
|
_validate_and_remove_ip_address)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_set_fcn_ip4_config_gateway (ARGS_SET_FCN)
|
_set_fcn_ip4_config_gateway (ARGS_SET_FCN)
|
||||||
|
|
@ -3441,26 +3442,6 @@ _set_fcn_ip6_config_addresses (ARGS_SET_FCN)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_validate_and_remove_ipv6_address (NMSettingIPConfig *setting,
|
|
||||||
const char *value,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
nm_auto_unref_ip_address NMIPAddress *addr = NULL;
|
|
||||||
|
|
||||||
addr = _parse_ip_address (AF_INET6, value, error);
|
|
||||||
if (!addr)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
nm_setting_ip_config_remove_address_by_value (setting, addr);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
DEFINE_REMOVER_INDEX_OR_VALUE_COMPLEX (_remove_fcn_ipv6_config_addresses,
|
|
||||||
NM_SETTING_IP_CONFIG,
|
|
||||||
nm_setting_ip_config_get_num_addresses,
|
|
||||||
nm_setting_ip_config_remove_address,
|
|
||||||
_validate_and_remove_ipv6_address)
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_set_fcn_ip6_config_gateway (ARGS_SET_FCN)
|
_set_fcn_ip6_config_gateway (ARGS_SET_FCN)
|
||||||
{
|
{
|
||||||
|
|
@ -5818,7 +5799,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
|
||||||
.property_type = DEFINE_PROPERTY_TYPE (
|
.property_type = DEFINE_PROPERTY_TYPE (
|
||||||
.get_fcn = _get_fcn_ip_config_addresses,
|
.get_fcn = _get_fcn_ip_config_addresses,
|
||||||
.set_fcn = _set_fcn_ip4_config_addresses,
|
.set_fcn = _set_fcn_ip4_config_addresses,
|
||||||
.remove_fcn = _remove_fcn_ipv4_config_addresses,
|
.remove_fcn = _remove_fcn_ip_config_addresses,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_GATEWAY, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_GATEWAY,
|
PROPERTY_INFO (NM_SETTING_IP_CONFIG_GATEWAY, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_GATEWAY,
|
||||||
|
|
@ -5986,7 +5967,7 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
|
||||||
.property_type = DEFINE_PROPERTY_TYPE (
|
.property_type = DEFINE_PROPERTY_TYPE (
|
||||||
.get_fcn = _get_fcn_ip_config_addresses,
|
.get_fcn = _get_fcn_ip_config_addresses,
|
||||||
.set_fcn = _set_fcn_ip6_config_addresses,
|
.set_fcn = _set_fcn_ip6_config_addresses,
|
||||||
.remove_fcn = _remove_fcn_ipv6_config_addresses,
|
.remove_fcn = _remove_fcn_ip_config_addresses,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_GATEWAY, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_GATEWAY,
|
PROPERTY_INFO (NM_SETTING_IP_CONFIG_GATEWAY, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_GATEWAY,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue