diff --git a/src/libnm-client-impl/nm-device-hsr.c b/src/libnm-client-impl/nm-device-hsr.c index 7160bf6d9..fd4da41bf 100644 --- a/src/libnm-client-impl/nm-device-hsr.c +++ b/src/libnm-client-impl/nm-device-hsr.c @@ -20,10 +20,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PORT1, PROP_MULTICAST_SPEC, PROP_PRP, ); +enum { + PROPERTY_O_IDX_PORT1, + PROPERTY_O_IDX_PORT2, + _PROPERTY_O_IDX_NUM, +}; + typedef struct { char *supervision_address; - NMLDBusPropertyO port1; - NMLDBusPropertyO port2; + NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; guint8 multicast_spec; bool prp; } NMDeviceHsrPrivate; @@ -57,7 +62,8 @@ nm_device_hsr_get_port1(NMDeviceHsr *device) { g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL); - return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port1); + return nml_dbus_property_o_get_obj( + &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT1]); } /** @@ -73,7 +79,8 @@ nm_device_hsr_get_port2(NMDeviceHsr *device) { g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL); - return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port2); + return nml_dbus_property_o_get_obj( + &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT2]); } /** @@ -179,12 +186,12 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_hsr = NML_DBUS_META_IFACE_ NML_DBUS_META_PROPERTY_INIT_O_PROP("Port1", PROP_PORT1, NMDeviceHsr, - _priv.port1, + _priv.property_o[PROPERTY_O_IDX_PORT1], nm_device_get_type), NML_DBUS_META_PROPERTY_INIT_O_PROP("Port2", PROP_PORT2, NMDeviceHsr, - _priv.port2, + _priv.property_o[PROPERTY_O_IDX_PORT2], nm_device_get_type), NML_DBUS_META_PROPERTY_INIT_B("Prp", PROP_PRP, NMDeviceHsr, _priv.prp), NML_DBUS_META_PROPERTY_INIT_S("SupervisionAddress", @@ -203,8 +210,7 @@ nm_device_hsr_class_init(NMDeviceHsrClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceHsr); - _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port1); - _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port2); + _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_N(nm_object_class, NMDeviceHsrPrivate, property_o); /** * NMDeviceHsr:port1: diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index f677ad8e6..4a59f6eca 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -2690,8 +2690,10 @@ test_types(void) G(nm_device_ethernet_get_type), G(nm_device_generic_get_type), G(nm_device_get_type), + G(nm_device_hsr_get_type), G(nm_device_infiniband_get_type), G(nm_device_ip_tunnel_get_type), + G(nm_device_ipvlan_get_type), G(nm_device_macsec_get_type), G(nm_device_macvlan_get_type), G(nm_device_modem_capabilities_get_type), @@ -2762,6 +2764,7 @@ test_types(void) G(nm_setting_generic_get_type), G(nm_setting_get_type), G(nm_setting_gsm_get_type), + G(nm_setting_hsr_get_type), G(nm_setting_infiniband_get_type), G(nm_setting_ip4_config_get_type), G(nm_setting_ip6_config_addr_gen_mode_get_type), @@ -2769,6 +2772,8 @@ test_types(void) G(nm_setting_ip6_config_privacy_get_type), G(nm_setting_ip_config_get_type), G(nm_setting_ip_tunnel_get_type), + G(nm_setting_ipvlan_get_type), + G(nm_setting_ipvlan_mode_get_type), G(nm_setting_mac_randomization_get_type), G(nm_setting_macsec_get_type), G(nm_setting_macsec_mode_get_type), @@ -2999,8 +3004,13 @@ test_nml_dbus_meta(void) g_assert(NM_IS_OBJECT_CLASS(p->klass)); g_assert(g_type_is_a(gtype, G_TYPE_FROM_CLASS(p->klass))); if (ii == 0) + /* If there is more than one NMLDBusPropertyO needed in the struct + * associated to the DBus object, they must be all in the same struct field + * as an array. This is later used on nm-object.c to perform operations on + * all the object properties at once. */ g_assert(p->klass->property_o_info == p); else + /* Same check than above if branch but for NMLDBusPropertyAO. */ g_assert(p->klass->property_ao_info == p); g_assert_cmpint(p->klass->priv_ptr_offset, >, 0); if (p_prev) { @@ -3383,6 +3393,11 @@ test_dbus_meta_types(void) NM_TYPE_DEVICE_GENERIC, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, }, + { + NM_DBUS_INTERFACE_DEVICE_HSR, + NM_TYPE_DEVICE_HSR, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + }, { NM_DBUS_INTERFACE_DEVICE_INFINIBAND, NM_TYPE_DEVICE_INFINIBAND, @@ -3393,6 +3408,11 @@ test_dbus_meta_types(void) NM_TYPE_DEVICE_IP_TUNNEL, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, }, + { + NM_DBUS_INTERFACE_DEVICE_IPVLAN, + NM_TYPE_DEVICE_IPVLAN, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + }, { NM_DBUS_INTERFACE_DEVICE_MACSEC, NM_TYPE_DEVICE_MACSEC,