libnm: add compare_fcn() to property meta data

So far, we only have NMSettingClass.compare_property() hook.
The ugliness is that this hook is per-setting, when basically
all implementations only compare one property.

It feels cleaner to have a per-property hook and call that consistently.

In step one, we give all properties (the same) compare_fcn() implementation,
which delegates to the existing NMSettingClass.compare_property().
In a second step, this will be untangled.

There is one problem with this approach: NMSettInfoPropertType grows by
one pointer size, and we have potentially many such types. That should
be addressed by unifying types in the future.
This commit is contained in:
Thomas Haller
2021-06-29 14:23:16 +02:00
parent d8292d462b
commit 7e7d2d173a
18 changed files with 154 additions and 55 deletions

View File

@@ -1996,6 +1996,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
NM_SETTING_PARAM_INFERRABLE,
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING,
.direct_type = NM_VALUE_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
.missing_from_dbus_fcn =
nm_setting_connection_no_interface_name),
@@ -2196,6 +2197,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
properties_override,
obj_properties[PROP_TIMESTAMP],
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT64,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _to_dbus_fcn_timestamp, ));
/**

View File

@@ -758,7 +758,8 @@ static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(
NM_G_VARIANT_TYPE("au"),
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT,
.gprop_from_dbus_fcn = _nm_setting_dcb_uint_array_from_dbus, );
.gprop_from_dbus_fcn = _nm_setting_dcb_uint_array_from_dbus,
.compare_fcn = _nm_setting_property_compare_fcn_default);
/*****************************************************************************/

View File

@@ -5783,6 +5783,7 @@ _nm_sett_info_property_override_create_array_ip_config(void)
obj_properties[PROP_GATEWAY],
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING,
.direct_type = NM_VALUE_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
.from_dbus_fcn = ip_gateway_set),
.direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, gateway),
@@ -5813,6 +5814,7 @@ _nm_sett_info_property_override_create_array_ip_config(void)
NM_SETTING_IP_CONFIG_ROUTING_RULES,
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = _routing_rules_dbus_only_synth,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = _routing_rules_dbus_only_set, ));
_nm_properties_override_gobj(

View File

@@ -956,6 +956,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
properties_override,
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS),
NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("au"),
.compare_fcn = _nm_setting_property_compare_fcn_default,
.gprop_from_dbus_fcn = ip4_dns_from_dbus, ),
.to_dbus_data.gprop_to_dbus_fcn = ip4_dns_to_dbus);
@@ -986,12 +987,14 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ADDRESSES),
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aau"),
.to_dbus_fcn = ip4_addresses_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip4_addresses_set, ));
_nm_properties_override_dbus(
properties_override,
"address-labels",
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING_ARRAY,
.to_dbus_fcn = ip4_address_labels_get, ));
.to_dbus_fcn = ip4_address_labels_get,
.compare_fcn = _nm_setting_property_compare_fcn_default, ));
/* ---dbus---
* property: address-data
@@ -1007,6 +1010,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
"address-data",
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = ip4_address_data_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip4_address_data_set, ));
/* ---dbus---
@@ -1040,6 +1044,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ROUTES),
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aau"),
.to_dbus_fcn = ip4_routes_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip4_routes_set, ));
/* ---dbus---
@@ -1060,6 +1065,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
"route-data",
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = ip4_route_data_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip4_route_data_set, ));
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);

View File

@@ -1022,6 +1022,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
properties_override,
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS),
NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("aay"),
.compare_fcn = _nm_setting_property_compare_fcn_default,
.gprop_from_dbus_fcn = ip6_dns_from_dbus, ),
.to_dbus_data.gprop_to_dbus_fcn = ip6_dns_to_dbus);
@@ -1044,6 +1045,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ADDRESSES),
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a(ayuay)"),
.to_dbus_fcn = ip6_addresses_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip6_addresses_set, ));
/* ---dbus---
@@ -1060,6 +1062,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
"address-data",
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = ip6_address_data_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip6_address_data_set, ));
/* ---dbus---
@@ -1081,6 +1084,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ROUTES),
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a(ayuayu)"),
.to_dbus_fcn = ip6_routes_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip6_routes_set, ));
/* ---dbus---
@@ -1101,6 +1105,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
"route-data",
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = ip6_route_data_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = ip6_route_data_set, ));
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);

View File

@@ -315,6 +315,14 @@ gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType typ
gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type);
NMTernary _nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info,
const NMSettInfoProperty *property_info,
NMConnection * con_a,
NMSetting * set_a,
NMConnection * con_b,
NMSetting * set_b,
NMSettingCompareFlags flags);
void _nm_setting_property_get_property_direct(GObject * object,
guint prop_id,
GValue * value,
@@ -397,11 +405,10 @@ void _nm_setting_class_commit(NMSettingClass * setting_class,
.dbus_type = _dbus_type, __VA_ARGS__ \
}
#define NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, ...) \
{ \
.dbus_type = _dbus_type, .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \
__VA_ARGS__ \
}
#define NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, ...) \
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, \
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \
__VA_ARGS__)
#define NM_SETT_INFO_PROPERT_TYPE(init) \
({ \

View File

@@ -312,6 +312,7 @@ nm_setting_serial_class_init(NMSettingSerialClass *klass)
properties_override,
obj_properties[PROP_PARITY],
NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BYTE,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.gprop_from_dbus_fcn = parity_from_dbus, ),
.to_dbus_data.gprop_to_dbus_fcn = parity_to_dbus, );

View File

@@ -1323,11 +1323,13 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass)
G_TYPE_PTR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
| G_PARAM_STATIC_STRINGS);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_VFS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = vfs_to_dbus,
.from_dbus_fcn = vfs_from_dbus, ));
_nm_properties_override_gobj(
properties_override,
obj_properties[PROP_VFS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = vfs_to_dbus,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = vfs_from_dbus, ));
/**
* NMSettingSriov:autoprobe-drivers

View File

@@ -2112,11 +2112,13 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass)
G_TYPE_PTR_ARRAY,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
| G_PARAM_STATIC_STRINGS);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_QDISCS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_qdiscs_get,
.from_dbus_fcn = tc_qdiscs_set, ));
_nm_properties_override_gobj(
properties_override,
obj_properties[PROP_QDISCS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_qdiscs_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = tc_qdiscs_set, ));
/**
* NMSettingTCConfig:tfilters: (type GPtrArray(NMTCTfilter))
@@ -2254,6 +2256,7 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass)
obj_properties[PROP_TFILTERS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = tc_tfilters_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = tc_tfilters_set, ));
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);

View File

@@ -927,7 +927,8 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass)
properties_override,
obj_properties[PROP_FLAGS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT32,
.to_dbus_fcn = _override_flags_get,
.to_dbus_fcn = _override_flags_get,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.missing_from_dbus_fcn = _override_flags_not_set, ));
/**

View File

@@ -1231,6 +1231,7 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass)
obj_properties[PROP_SECRETS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a{ss}"),
.to_dbus_fcn = vpn_secrets_to_dbus,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = vpn_secrets_from_dbus, ));
/**

View File

@@ -2597,6 +2597,7 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
NM_SETTING_WIREGUARD_PEERS,
NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"),
.to_dbus_fcn = _peers_dbus_only_synth,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = _peers_dbus_only_set, ));
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);

View File

@@ -1785,7 +1785,8 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
obj_properties[PROP_SEEN_BSSIDS],
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING_ARRAY,
.to_dbus_fcn = _to_dbus_fcn_seen_bssids,
.from_dbus_fcn = _from_dbus_fcn_seen_bssids, ));
.from_dbus_fcn = _from_dbus_fcn_seen_bssids,
.compare_fcn = _nm_setting_property_compare_fcn_default, ));
/**
* NMSettingWireless:mtu:
@@ -1916,7 +1917,8 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
properties_override,
"security",
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING,
.to_dbus_fcn = nm_setting_wireless_get_security, ));
.to_dbus_fcn = nm_setting_wireless_get_security,
.compare_fcn = _nm_setting_property_compare_fcn_default, ));
/**
* NMSettingWireless:wake-on-wlan:

View File

@@ -370,35 +370,52 @@ _nm_setting_class_commit(NMSettingClass * setting_class,
vtype = p->param_spec->value_type;
if (vtype == G_TYPE_BOOLEAN)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BOOLEAN);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_BOOLEAN,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_UCHAR)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BYTE);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_BYTE,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_INT)
p->property_type = &nm_sett_info_propert_type_plain_i;
else if (vtype == G_TYPE_UINT)
p->property_type = &nm_sett_info_propert_type_plain_u;
else if (vtype == G_TYPE_INT64)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_INT64);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_INT64,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_UINT64)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_UINT64);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_UINT64,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_STRING)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_STRING);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_DOUBLE)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_DOUBLE);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_DOUBLE,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_STRV)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_STRING_ARRAY);
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING_ARRAY,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_BYTES) {
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_BYTESTRING,
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES);
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES,
.compare_fcn = _nm_setting_property_compare_fcn_default);
} else if (g_type_is_a(vtype, G_TYPE_ENUM)) {
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_INT32,
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM);
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM,
.compare_fcn = _nm_setting_property_compare_fcn_default);
} else if (g_type_is_a(vtype, G_TYPE_FLAGS)) {
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_UINT32,
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS);
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS,
.compare_fcn = _nm_setting_property_compare_fcn_default);
} else
nm_assert_not_reached();
@@ -1695,6 +1712,23 @@ _nm_setting_should_compare_secret_property(NMSetting * setting,
return TRUE;
}
/*****************************************************************************/
NMTernary
_nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info,
const NMSettInfoProperty *property_info,
NMConnection * con_a,
NMSetting * set_a,
NMConnection * con_b,
NMSetting * set_b,
NMSettingCompareFlags flags)
{
/* For the moment, the default implementation delegates to NMSettingClass.compare_property().
* That will change. */
return NM_SETTING_GET_CLASS(set_a)
->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags);
}
static NMTernary
compare_property(const NMSettInfoSetting * sett_info,
const NMSettInfoProperty *property_info,
@@ -1774,11 +1808,10 @@ _compare_property(const NMSettInfoSetting * sett_info,
nm_assert(NM_SETTING_GET_CLASS(set_a) == sett_info->setting_class);
nm_assert(!set_b || NM_SETTING_GET_CLASS(set_b) == sett_info->setting_class);
compare_result =
NM_SETTING_GET_CLASS(set_a)
->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags);
compare_result = property_info->property_type
->compare_fcn(sett_info, property_info, con_a, set_a, con_b, set_b, flags);
nm_assert(NM_IN_SET(compare_result, NM_TERNARY_DEFAULT, NM_TERNARY_FALSE, NM_TERNARY_TRUE));
nm_assert_is_ternary(compare_result);
/* check that the inferable flag and the GObject property flag corresponds. */
nm_assert(!NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) || !property_info->param_spec
@@ -1786,16 +1819,12 @@ _compare_property(const NMSettInfoSetting * sett_info,
|| compare_result == NM_TERNARY_DEFAULT);
#if NM_MORE_ASSERTS > 10
/* assert that compare_property() is symeric. */
nm_assert(!set_b
|| compare_result
== NM_SETTING_GET_CLASS(set_a)->compare_property(sett_info,
property_info,
con_b,
set_b,
con_a,
set_a,
flags));
/* assert that compare_fcn() is symeric. */
nm_assert(
!set_b
|| compare_result
== property_info->property_type
->compare_fcn(sett_info, property_info, con_b, set_b, con_a, set_a, flags));
#endif
return compare_result;
@@ -2716,6 +2745,7 @@ _nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting *
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn =
_nm_setting_get_deprecated_virtual_interface_name, );
@@ -2723,33 +2753,38 @@ const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(
G_VARIANT_TYPE_INT32,
/* No functions set. This property type is to silently ignore the value on D-Bus. */
);
.compare_fcn = _nm_setting_property_compare_fcn_default, );
const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(
G_VARIANT_TYPE_UINT32,
/* No functions set. This property type is to silently ignore the value on D-Bus. */
);
.compare_fcn = _nm_setting_property_compare_fcn_default, );
const NMSettInfoPropertType nm_sett_info_propert_type_plain_i =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32);
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32,
.compare_fcn = _nm_setting_property_compare_fcn_default);
const NMSettInfoPropertType nm_sett_info_propert_type_plain_u =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32);
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32,
.compare_fcn = _nm_setting_property_compare_fcn_default);
const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN,
.direct_type = NM_VALUE_TYPE_BOOL,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct);
const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32 =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT32,
.direct_type = NM_VALUE_TYPE_UINT32,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct);
const NMSettInfoPropertType nm_sett_info_propert_type_direct_string =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
.direct_type = NM_VALUE_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct);
/*****************************************************************************/

View File

@@ -2787,22 +2787,27 @@ _nm_team_settings_property_from_dbus_link_watchers(GVariant *dbus_value, GValue
const NMSettInfoPropertType nm_sett_info_propert_type_team_b =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
const NMSettInfoPropertType nm_sett_info_propert_type_team_i =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
const NMSettInfoPropertType nm_sett_info_propert_type_team_s =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
const NMSettInfoPropertType nm_sett_info_propert_type_team_as =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("as"),
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_team_settings_property_to_dbus, );
const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"),
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_team_settings_property_to_dbus,
.gprop_from_dbus_fcn =
_nm_team_settings_property_from_dbus_link_watchers, );

View File

@@ -777,7 +777,8 @@ const NMSettInfoPropertType nm_sett_info_propert_type_strdict =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(NM_G_VARIANT_TYPE("a{ss}"),
.gprop_from_dbus_fcn = _nm_utils_strdict_from_dbus,
.typdata_to_dbus.gprop_type =
NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT);
NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT,
.compare_fcn = _nm_setting_property_compare_fcn_default);
GHashTable *
_nm_utils_copy_strdict(GHashTable *strdict)
@@ -4063,8 +4064,9 @@ _nm_utils_hwaddr_cloned_not_set(NMSetting * setting,
const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BYTESTRING,
.to_dbus_fcn = _nm_utils_hwaddr_cloned_get,
.from_dbus_fcn = _nm_utils_hwaddr_cloned_set,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_utils_hwaddr_cloned_get,
.from_dbus_fcn = _nm_utils_hwaddr_cloned_set,
.missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, );
static GVariant *
@@ -4126,6 +4128,7 @@ _nm_utils_hwaddr_cloned_data_set(NMSetting * setting,
const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth,
.from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set, );
@@ -4141,10 +4144,11 @@ _nm_utils_hwaddr_from_dbus(GVariant *dbus_value, GValue *prop_value)
}
const NMSettInfoPropertType nm_sett_info_propert_type_mac_address =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(
G_VARIANT_TYPE_BYTESTRING,
.gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus,
.typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS);
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_BYTESTRING,
.gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus,
.typdata_to_dbus.gprop_type =
NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS,
.compare_fcn = _nm_setting_property_compare_fcn_default);
/*****************************************************************************/
@@ -5546,6 +5550,7 @@ _nm_utils_bridge_vlans_from_dbus(NMSetting * setting,
const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"),
.compare_fcn = _nm_setting_property_compare_fcn_default,
.to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus,
.from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, );

View File

@@ -4524,6 +4524,11 @@ check_done:;
if (!g_hash_table_insert(h_properties, (char *) sip->name, sip->param_spec))
g_assert_not_reached();
if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_default) {
/* for the moment, all types have this implementation. This will change. */
} else
g_assert_not_reached();
property_types_data = g_hash_table_lookup(h_property_types, sip->property_type);
if (!property_types_data) {
property_types_data = g_array_new(FALSE, FALSE, sizeof(guint));
@@ -4675,6 +4680,7 @@ check_done:;
if (!g_variant_type_equal(pt->dbus_type, pt_2->dbus_type)
|| pt->direct_type != pt_2->direct_type || pt->to_dbus_fcn != pt_2->to_dbus_fcn
|| pt->from_dbus_fcn != pt_2->from_dbus_fcn
|| pt->compare_fcn != pt_2->compare_fcn
|| pt->missing_from_dbus_fcn != pt_2->missing_from_dbus_fcn
|| pt->gprop_from_dbus_fcn != pt_2->gprop_from_dbus_fcn
|| memcmp(&pt->typdata_to_dbus,

View File

@@ -693,6 +693,20 @@ typedef struct {
* to the property value. */
NMValueType direct_type;
/* compare_fcn() returns a ternary, where DEFAULT means that the property should not
* be compared due to the compare @flags. A TRUE/FALSE result means that the property is
* equal/not-equal.
*
* The "b" setting may be %NULL, in which case the function only determines whether
* the setting should be compared (TRUE) or not (DEFAULT). */
NMTernary (*compare_fcn)(const NMSettInfoSetting * sett_info,
const NMSettInfoProperty *property_info,
NMConnection * con_a,
NMSetting * set_a,
NMConnection * con_b,
NMSetting * set_b,
NMSettingCompareFlags flags);
NMSettInfoPropToDBusFcn to_dbus_fcn;
NMSettInfoPropFromDBusFcn from_dbus_fcn;
NMSettInfoPropMissingFromDBusFcn missing_from_dbus_fcn;