libnm: add nm_sett_info_propert_type_direct_mac_address

A MAC address is a relatively common "type". The GObject property is of type string,
but the D-Bus type is a bytestring ("ay"). We will need a special NMSettInfoPropertType.

Note that like most implementations, the from-dbus implementation still is based
on GObject setters. This will change in the future.

Also note that the previous compare function was
_nm_setting_property_compare_fcn_default(). That is, it used to convert
the property to GVariant and compare those. The conversion to GVariant
in that case normalizes the string (e.g. it is case insensitive). Also,
only properties could be compared which were also convertible to D-Bus
(which is probably fine, because there is no guarantee the profiles that
don't verify can be compared).

The code now uses the direct comparison of the strings. That mostly
preserves the case-insensitivity of the previous comparison, because
the property setters for mac addresses all use
_nm_utils_hwaddr_canonical_or_invalid() to normalize the strings.
This is subtle, but still correct. Note that this will improve later,
by ensuring that the property setters for mac addresses automatically
perform the right normalization.
This commit is contained in:
Thomas Haller
2021-07-13 18:09:13 +02:00
parent dc2e4d04f1
commit 82e9f43289
13 changed files with 190 additions and 109 deletions

View File

@@ -1627,15 +1627,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
* BRIDGE_MACADDR for bridges is an NM extension.
* ---end---
*/
obj_properties[PROP_MAC_ADDRESS] = g_param_spec_string(
_nm_setting_property_define_direct_mac_address(
properties_override,
obj_properties,
NM_SETTING_BRIDGE_MAC_ADDRESS,
"",
"",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_MAC_ADDRESS],
&nm_sett_info_propert_type_mac_address);
PROP_MAC_ADDRESS,
NM_SETTING_PARAM_INFERRABLE,
NMSettingBridgePrivate,
mac_address,
/* it's special, because it uses _nm_utils_hwaddr_canonical_or_invalid(). */
.direct_has_special_setter = TRUE);
/**
* NMSettingBridge:stp:
@@ -1935,15 +1936,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
* example: BRIDGING_OPTS="group_address=01:80:C2:00:00:0A"
* ---end---
*/
obj_properties[PROP_GROUP_ADDRESS] = g_param_spec_string(
_nm_setting_property_define_direct_mac_address(
properties_override,
obj_properties,
NM_SETTING_BRIDGE_GROUP_ADDRESS,
"",
"",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_GROUP_ADDRESS],
&nm_sett_info_propert_type_mac_address);
PROP_GROUP_ADDRESS,
NM_SETTING_PARAM_INFERRABLE,
NMSettingBridgePrivate,
group_address,
/* it's special, because it uses _nm_utils_hwaddr_canonical_or_invalid(). */
.direct_has_special_setter = TRUE);
/**
* NMSettingBridge:vlan-protocol: