diff options
Diffstat (limited to 'src/libnm-core-impl/nm-setting-private.h')
| -rw-r--r-- | src/libnm-core-impl/nm-setting-private.h | 349 |
1 files changed, 193 insertions, 156 deletions
diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index fff6c1cc..9fe49de4 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -6,7 +6,7 @@ #ifndef __NM_SETTING_PRIVATE_H__ #define __NM_SETTING_PRIVATE_H__ -#if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) +#if !((NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) #error Cannot use this header. #endif @@ -20,6 +20,14 @@ /*****************************************************************************/ +/* This holds a property of type NM_VALUE_TYPE_STRV. You probably want + * to use nm_strvarray_*() API with this. */ +typedef struct { + GArray *arr; +} NMValueStrv; + +/*****************************************************************************/ + struct _NMRefString; typedef struct { @@ -80,6 +88,8 @@ void _nm_connection_private_clear(NMConnectionPrivate *priv); /*****************************************************************************/ +struct _NMSettingPrivate; + /** * NMSetting: * @@ -87,15 +97,13 @@ void _nm_connection_private_clear(NMConnectionPrivate *priv); * It should only be accessed through the functions described below. */ struct _NMSetting { - GObject parent; - /* In the past, this struct was public API. Preserve ABI! */ + GObject parent; + struct _NMSettingPrivate *_priv; }; struct _NMSettingClass { GObjectClass parent; - /* In the past, this struct was public API. Preserve ABI! */ - int (*verify)(NMSetting *setting, NMConnection *connection, GError **error); gboolean (*verify_secrets)(NMSetting *setting, NMConnection *connection, GError **error); @@ -120,8 +128,6 @@ struct _NMSettingClass { NMSettingClearSecretsWithFlagsFn func, gpointer user_data); - void (*padding_1)(void); - void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info, NMSetting *src, NMSetting *dst); @@ -158,58 +164,41 @@ struct _NMSettingClass { */ struct _NMSettingIPConfig { NMSetting parent; - /* In the past, this struct was public API. Preserve ABI! */ }; struct _NMSettingIPConfigClass { NMSettingClass parent; - - /* In the past, this struct was public API. Preserve ABI! */ - - union { - gpointer _dummy1; - int private_offset; - }; - - union { - gpointer _dummy2; - gint8 addr_family; - }; - - union { - gpointer _dummy3; - bool is_ipv4; - }; - - gpointer padding[5]; + int private_offset; + gint8 addr_family; + bool is_ipv4; }; typedef struct { - GPtrArray *dns; /* array of IP address strings */ - GPtrArray *dns_search; /* array of domain name strings */ - GPtrArray *dns_options; /* array of DNS options */ - GPtrArray *addresses; /* array of NMIPAddress */ - GPtrArray *routes; /* array of NMIPRoute */ - GPtrArray *routing_rules; - GArray *dhcp_reject_servers; - char *method; - char *gateway; - char *dhcp_hostname; - char *dhcp_iaid; - gint64 route_metric; - int auto_route_ext_gw; - int replace_local_rule; - gint32 required_timeout; - gint32 dad_timeout; - gint32 dhcp_timeout; - gint32 dns_priority; - guint32 route_table; - guint32 dhcp_hostname_flags; - bool ignore_auto_routes; - bool ignore_auto_dns; - bool dhcp_send_hostname; - bool never_default; - bool may_fail; + NMValueStrv dns_search; /* array of domain name strings */ + NMValueStrv dhcp_reject_servers; + NMValueStrv dns_options; /* array of DNS options */ + GPtrArray *dns; /* array of IP address strings */ + GPtrArray *addresses; /* array of NMIPAddress */ + GPtrArray *routes; /* array of NMIPRoute */ + GPtrArray *routing_rules; + char *method; + char *gateway; + char *dhcp_hostname; + char *dhcp_iaid; + gint64 route_metric; + int auto_route_ext_gw; + int replace_local_rule; + gint32 required_timeout; + gint32 dad_timeout; + gint32 dhcp_timeout; + gint32 dns_priority; + guint32 route_table; + guint32 dhcp_hostname_flags; + bool ignore_auto_routes; + bool ignore_auto_dns; + bool dhcp_send_hostname; + bool never_default; + bool may_fail; } NMSettingIPConfigPrivate; void _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv); @@ -296,14 +285,6 @@ gboolean _nm_setting_clear_secrets(NMSetting *setting, /*****************************************************************************/ -/* This holds a property of type NM_VALUE_TYPE_STRV. You probably want - * to use nm_strvarray_*() API with this. */ -typedef struct { - GArray *arr; -} NMValueStrv; - -/*****************************************************************************/ - struct _NMRange { int refcount; guint64 start; @@ -350,6 +331,7 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_setting_name; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u; +extern const NMSettInfoPropertType nm_sett_info_propert_type_gprop_strv_oldstyle; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32; @@ -417,6 +399,18 @@ gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_ gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); +gboolean _nm_setting_connection_controller_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_setting_connection_controller_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_connection_master_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_connection_port_type_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_setting_connection_port_type_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_connection_slave_type_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + GVariant *_nm_setting_to_dbus(NMSetting *setting, NMConnection *connection, NMConnectionSerializationFlags flags, @@ -438,11 +432,7 @@ const NMSettInfoProperty * _nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, const GParamSpec *param_spec); -static inline GArray * -_nm_sett_info_property_override_create_array_sized(guint reserved_size) -{ - return g_array_sized_new(FALSE, FALSE, sizeof(NMSettInfoProperty), reserved_size); -} +GArray *_nm_sett_info_property_override_create_array_sized(guint reserved_size); static inline GArray * _nm_sett_info_property_override_create_array(void) @@ -497,23 +487,30 @@ void _nm_setting_class_commit(NMSettingClass *setting_class, gboolean _nm_properties_override_assert(const NMSettInfoProperty *prop_info); -static inline void +static inline guint _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *prop_info) { nm_assert(properties_override); nm_assert(_nm_properties_override_assert(prop_info)); g_array_append_vals(properties_override, prop_info, 1); + return properties_override->len - 1u; } -#define _nm_properties_override_gobj(properties_override, \ - p_param_spec, \ - p_property_type, \ - ... /* extra NMSettInfoProperty fields */) \ - _nm_properties_override((properties_override), \ - NM_SETT_INFO_PROPERTY(.name = NULL, \ - .param_spec = (p_param_spec), \ - .property_type = (p_property_type), \ - __VA_ARGS__)) +#define _nm_properties_override_gobj(properties_override, \ + p_param_spec, \ + p_property_type, \ + ... /* extra NMSettInfoProperty fields */) \ + ({ \ + GParamSpec *const _p_param_spec_2 = (p_param_spec); \ + \ + nm_assert(_p_param_spec_2); \ + \ + _nm_properties_override((properties_override), \ + NM_SETT_INFO_PROPERTY(.name = _p_param_spec_2->name, \ + .param_spec = _p_param_spec_2, \ + .property_type = (p_property_type), \ + __VA_ARGS__)); \ + }) #define _nm_properties_override_dbus(properties_override, \ p_name, \ @@ -557,12 +554,12 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p \ nm_assert(NM_IN_SET(_default_value, 0, 1)); \ \ - _param_spec = \ - g_param_spec_boolean("" prop_name "", \ - "", \ - "", \ - _default_value, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_boolean("" prop_name "", \ + "", \ + "", \ + _default_value, \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -600,14 +597,14 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STATIC_ASSERT((default_value) <= (guint64) (max_value)); \ G_STATIC_ASSERT((max_value) <= (guint64) G_MAXUINT32); \ \ - _param_spec = \ - g_param_spec_uint("" prop_name "", \ - "", \ - "", \ - (min_value), \ - (max_value), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_uint("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -646,14 +643,14 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STATIC_ASSERT((default_value) <= (gint64) (max_value)); \ G_STATIC_ASSERT((max_value) <= (gint64) G_MAXUINT32); \ \ - _param_spec = \ - g_param_spec_int("" prop_name "", \ - "", \ - "", \ - (min_value), \ - (max_value), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_int("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -692,14 +689,14 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STATIC_ASSERT((default_value) <= (max_value)); \ G_STATIC_ASSERT((max_value) <= G_MAXINT64); \ \ - _param_spec = \ - g_param_spec_int64("" prop_name "", \ - "", \ - "", \ - (min_value), \ - (max_value), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_int64("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -737,14 +734,14 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STATIC_ASSERT((default_value) == 0 || (default_value) -1u < (max_value)); \ G_STATIC_ASSERT((max_value) <= G_MAXUINT64); \ \ - _param_spec = \ - g_param_spec_uint64("" prop_name "", \ - "", \ - "", \ - (min_value), \ - (max_value), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_uint64("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -769,8 +766,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p private_struct_type, \ private_struct_field, \ ... /* extra NMSettInfoProperty fields */) \ - G_STMT_START \ - { \ + ({ \ GParamSpec *_param_spec; \ const NMSettInfoPropertType *_property_type = (property_type); \ \ @@ -782,14 +778,17 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p nm_assert(_property_type); \ nm_assert(g_variant_type_equal(_property_type->dbus_type, "s")); \ nm_assert(_property_type->direct_type == NM_VALUE_TYPE_STRING); \ - nm_assert(_property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_direct); \ + nm_assert(NM_IN_SET(_property_type->to_dbus_fcn, \ + _nm_setting_property_to_dbus_fcn_direct, \ + _nm_setting_connection_controller_to_dbus, \ + _nm_setting_connection_port_type_to_dbus)); \ \ - _param_spec = \ - g_param_spec_string("" prop_name "", \ - "", \ - "", \ - NULL, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_string("" prop_name "", \ + "", \ + "", \ + NULL, \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -800,8 +799,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p .direct_offset = \ NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \ __VA_ARGS__); \ - } \ - G_STMT_END + }) #define _nm_setting_property_define_direct_string(properties_override, \ obj_properties, \ @@ -839,12 +837,12 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_INFERRABLE \ | NM_SETTING_PARAM_FUZZY_IGNORE))); \ \ - _param_spec = \ - g_param_spec_boxed("" prop_name "", \ - "", \ - "", \ - G_TYPE_BYTES, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_boxed("" prop_name "", \ + "", \ + "", \ + G_TYPE_BYTES, \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -874,12 +872,12 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p \ G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), ~(NM_SETTING_PARAM_FUZZY_IGNORE))); \ \ - _param_spec = \ - g_param_spec_boxed("" prop_name "", \ - "", \ - "", \ - G_TYPE_STRV, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_boxed("" prop_name "", \ + "", \ + "", \ + G_TYPE_STRV, \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -915,13 +913,13 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p ~(NM_SETTING_PARAM_REAPPLY_IMMEDIATELY | NM_SETTING_PARAM_FUZZY_IGNORE \ | NM_SETTING_PARAM_INFERRABLE))); \ \ - _param_spec = \ - g_param_spec_enum("" prop_name "", \ - "", \ - "", \ - (gtype_enum), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_enum("" prop_name "", \ + "", \ + "", \ + (gtype_enum), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -976,13 +974,13 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p !NM_FLAGS_ANY((param_flags), \ ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ \ - _param_spec = \ - g_param_spec_flags("" prop_name "", \ - "", \ - "", \ - (gtype_flags), \ - (default_value), \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_flags("" prop_name "", \ + "", \ + "", \ + (gtype_flags), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -1035,12 +1033,12 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p | NM_SETTING_PARAM_INFERRABLE \ | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ \ - _param_spec = \ - g_param_spec_string("" prop_name "", \ - "", \ - "", \ - NULL, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + _param_spec = g_param_spec_string("" prop_name "", \ + "", \ + "", \ + NULL, \ + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \ + | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ @@ -1054,6 +1052,38 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p } \ G_STMT_END +/* This should not be used for new strv properties. Use _nm_setting_property_define_direct_strv(). + * + * FIXME: existing properties should migrate to _nm_setting_property_define_direct_strv(). */ +#define _nm_setting_property_define_gprop_strv_oldstyle(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \ + | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ + \ + _param_spec = \ + g_param_spec_boxed("" prop_name "", \ + "", \ + "", \ + G_TYPE_STRV, \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj((properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_gprop_strv_oldstyle); \ + } \ + G_STMT_END + /*****************************************************************************/ gboolean _nm_setting_use_legacy_property(NMSetting *setting, @@ -1098,4 +1128,11 @@ _nm_sett_info_prop_from_dbus_fcn_cloned_mac_address(_NM_SETT_INFO_PROP_FROM_DBUS /*****************************************************************************/ +void _nm_setting_wireless_normalize_mac_address_randomization( + NMSettingWireless *s_wifi, + const char **out_cloned_mac_address, + NMSettingMacRandomization *out_mac_address_randomization); + +/*****************************************************************************/ + #endif /* NM_SETTING_PRIVATE_H */ |