2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-07-24 08:53:33 -04:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2011 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NM_SETTING_PRIVATE_H__
|
|
|
|
|
#define __NM_SETTING_PRIVATE_H__
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2018-01-02 13:37:06 +01:00
|
|
|
#if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE)
|
2021-07-09 08:48:48 +02:00
|
|
|
#error Cannot use this header.
|
2018-01-02 13:37:06 +01:00
|
|
|
#endif
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-setting.h"
|
2019-03-16 17:21:35 +01:00
|
|
|
#include "nm-setting-bridge.h"
|
2014-08-06 19:35:31 -04:00
|
|
|
#include "nm-connection.h"
|
2014-08-07 17:19:40 -04:00
|
|
|
#include "nm-core-enum-types.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-02-12 15:01:09 +01:00
|
|
|
#include "libnm-core-intern/nm-core-internal.h"
|
2014-08-11 18:10:43 +02:00
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-06-14 19:29:18 +02:00
|
|
|
typedef struct {
|
|
|
|
|
NMConnection *self;
|
|
|
|
|
|
|
|
|
|
NMSetting *settings[_NM_META_SETTING_TYPE_NUM];
|
|
|
|
|
|
|
|
|
|
/* D-Bus path of the connection, if any */
|
|
|
|
|
char *path;
|
|
|
|
|
} NMConnectionPrivate;
|
|
|
|
|
|
|
|
|
|
extern GTypeClass *_nm_simple_connection_class_instance;
|
|
|
|
|
extern int _nm_simple_connection_private_offset;
|
|
|
|
|
|
|
|
|
|
void _nm_connection_private_clear(NMConnectionPrivate *priv);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-11 00:27:31 +02:00
|
|
|
/**
|
|
|
|
|
* NMSetting:
|
|
|
|
|
*
|
|
|
|
|
* The NMSetting struct contains only private data.
|
|
|
|
|
* It should only be accessed through the functions described below.
|
|
|
|
|
*/
|
|
|
|
|
struct _NMSetting {
|
|
|
|
|
GObject parent;
|
2021-06-14 09:26:25 +02:00
|
|
|
/* In the past, this struct was public API. Preserve ABI! */
|
2021-06-11 00:27:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMSettingClass {
|
|
|
|
|
GObjectClass parent;
|
|
|
|
|
|
2021-06-14 09:26:25 +02:00
|
|
|
/* In the past, this struct was public API. Preserve ABI! */
|
|
|
|
|
|
2021-06-11 00:27:31 +02:00
|
|
|
int (*verify)(NMSetting *setting, NMConnection *connection, GError **error);
|
|
|
|
|
|
|
|
|
|
gboolean (*verify_secrets)(NMSetting *setting, NMConnection *connection, GError **error);
|
|
|
|
|
|
|
|
|
|
GPtrArray *(*need_secrets)(NMSetting *setting);
|
|
|
|
|
|
|
|
|
|
int (*update_one_secret)(NMSetting *setting, const char *key, GVariant *value, GError **error);
|
|
|
|
|
|
|
|
|
|
gboolean (*get_secret_flags)(NMSetting * setting,
|
|
|
|
|
const char * secret_name,
|
|
|
|
|
NMSettingSecretFlags *out_flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
gboolean (*set_secret_flags)(NMSetting * setting,
|
|
|
|
|
const char * secret_name,
|
|
|
|
|
NMSettingSecretFlags flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info,
|
2021-06-29 12:04:00 +02:00
|
|
|
const NMSettInfoProperty * property_info,
|
2021-06-11 00:27:31 +02:00
|
|
|
NMSetting * setting,
|
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2021-06-29 16:58:21 +02:00
|
|
|
void (*padding_1)(void);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info,
|
|
|
|
|
NMSetting * src,
|
|
|
|
|
NMSetting * dst);
|
|
|
|
|
|
|
|
|
|
void (*enumerate_values)(const struct _NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMSettingValueIterFn func,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
gboolean (*aggregate)(NMSetting *setting, int type_i, gpointer arg);
|
|
|
|
|
|
|
|
|
|
void (*for_each_secret)(NMSetting * setting,
|
|
|
|
|
const char * secret_name,
|
|
|
|
|
GVariant * val,
|
|
|
|
|
gboolean remove_non_secrets,
|
|
|
|
|
_NMConnectionForEachSecretFunc callback,
|
|
|
|
|
gpointer callback_data,
|
|
|
|
|
GVariantBuilder * setting_builder);
|
|
|
|
|
|
|
|
|
|
gboolean (*init_from_dbus)(NMSetting * setting,
|
|
|
|
|
GHashTable * keys,
|
|
|
|
|
GVariant * setting_dict,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
guint /* NMSettingParseFlags */ parse_flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
2021-06-28 23:51:42 +02:00
|
|
|
union {
|
|
|
|
|
gpointer padding[1];
|
|
|
|
|
struct {
|
|
|
|
|
/* Whether NMSetting.finalize() calls _nm_setting_property_finalize_direct(). Subclasses
|
|
|
|
|
* need to be aware of that, and currently this is opt-in.
|
|
|
|
|
*
|
|
|
|
|
* The only reason because subclasses need to be aware of this, is that they
|
|
|
|
|
* otherwise might clear the properties already and leave dangling pointers.
|
|
|
|
|
*
|
|
|
|
|
* Eventually all setting classes should stop touching their direct properties
|
|
|
|
|
* during finalize, and always let NMSetting.finalize() handle them. */
|
|
|
|
|
bool finalize_direct : 1;
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
const struct _NMMetaSettingInfo *setting_info;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingIPConfig:
|
|
|
|
|
*/
|
|
|
|
|
struct _NMSettingIPConfig {
|
|
|
|
|
NMSetting parent;
|
2021-06-28 18:14:04 +02:00
|
|
|
/* In the past, this struct was public API. Preserve ABI! */
|
2021-06-11 00:27:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMSettingIPConfigClass {
|
|
|
|
|
NMSettingClass parent;
|
|
|
|
|
|
2021-06-28 18:14:04 +02:00
|
|
|
/* In the past, this struct was public API. Preserve ABI! */
|
|
|
|
|
union {
|
|
|
|
|
gpointer _dummy;
|
|
|
|
|
int private_offset;
|
|
|
|
|
};
|
|
|
|
|
gpointer padding[7];
|
2021-06-11 00:27:31 +02:00
|
|
|
};
|
|
|
|
|
|
2021-06-28 18:14:04 +02:00
|
|
|
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;
|
|
|
|
|
guint dhcp_hostname_flags;
|
|
|
|
|
int dns_priority;
|
|
|
|
|
int dad_timeout;
|
|
|
|
|
int dhcp_timeout;
|
|
|
|
|
int required_timeout;
|
|
|
|
|
guint32 route_table;
|
2021-06-28 17:28:21 +02:00
|
|
|
bool ignore_auto_routes;
|
|
|
|
|
bool ignore_auto_dns;
|
|
|
|
|
bool dhcp_send_hostname;
|
|
|
|
|
bool never_default;
|
|
|
|
|
bool may_fail;
|
2021-06-28 18:14:04 +02:00
|
|
|
} NMSettingIPConfigPrivate;
|
|
|
|
|
|
|
|
|
|
void _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv);
|
|
|
|
|
|
2021-06-11 00:27:31 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-06-01 13:43:52 +02:00
|
|
|
NMSettingPriority _nm_setting_get_base_type_priority(NMSetting *setting);
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
int _nm_setting_compare_priority(gconstpointer a, gconstpointer b);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-06-11 15:28:42 +02:00
|
|
|
int _nmtst_nm_setting_sort(NMSetting *a, NMSetting *b);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define _nm_assert_setting_info(setting_info, gtype) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
const NMMetaSettingInfo *_setting_info = (setting_info); \
|
|
|
|
|
\
|
|
|
|
|
if (NM_MORE_ASSERTS > 0) { \
|
|
|
|
|
GType _gtype = (gtype); \
|
|
|
|
|
\
|
|
|
|
|
nm_assert(_setting_info); \
|
|
|
|
|
nm_assert(_NM_INT_NOT_NEGATIVE(_setting_info->meta_type)); \
|
|
|
|
|
nm_assert(_setting_info->meta_type < _NM_META_SETTING_TYPE_NUM); \
|
|
|
|
|
nm_assert(_setting_info->get_setting_gtype); \
|
|
|
|
|
if (_gtype != 0) \
|
|
|
|
|
nm_assert(_setting_info->get_setting_gtype() == _gtype); \
|
|
|
|
|
else \
|
|
|
|
|
_gtype = _setting_info->get_setting_gtype(); \
|
|
|
|
|
nm_assert(g_type_is_a(_gtype, NM_TYPE_SETTING)); \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
static inline const NMMetaSettingInfo *
|
|
|
|
|
_nm_meta_setting_info_from_class(NMSettingClass *klass)
|
|
|
|
|
{
|
|
|
|
|
const NMMetaSettingInfo *setting_info;
|
|
|
|
|
|
|
|
|
|
if (!NM_IS_SETTING_CLASS(klass))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
setting_info = klass->setting_info;
|
|
|
|
|
if (!setting_info)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
_nm_assert_setting_info(setting_info, G_OBJECT_CLASS_TYPE(klass));
|
|
|
|
|
return setting_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline const NMMetaSettingInfo *
|
|
|
|
|
_nm_meta_setting_info_from_gtype(GType gtype)
|
|
|
|
|
{
|
|
|
|
|
const NMMetaSettingInfo *setting_info;
|
|
|
|
|
|
|
|
|
|
setting_info = nm_meta_setting_infos_by_gtype(gtype);
|
|
|
|
|
if (!setting_info)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
_nm_assert_setting_info(setting_info, gtype);
|
|
|
|
|
return setting_info;
|
|
|
|
|
}
|
|
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-01-20 13:49:08 +01:00
|
|
|
void _nm_setting_emit_property_changed(NMSetting *setting);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
typedef enum NMSettingUpdateSecretResult {
|
|
|
|
|
NM_SETTING_UPDATE_SECRET_ERROR = FALSE,
|
|
|
|
|
NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED = TRUE,
|
|
|
|
|
NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED = 2,
|
|
|
|
|
} NMSettingUpdateSecretResult;
|
|
|
|
|
|
|
|
|
|
NMSettingUpdateSecretResult
|
|
|
|
|
_nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error);
|
2019-01-13 20:47:05 +01:00
|
|
|
gboolean _nm_setting_clear_secrets(NMSetting * setting,
|
|
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-06-18 00:01:30 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define NM_SETTING_PARAM_NONE 0
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/* The property of the #NMSetting should be considered during comparisons that
|
|
|
|
|
* use the %NM_SETTING_COMPARE_FLAG_INFERRABLE flag. Properties that don't have
|
|
|
|
|
* this flag, are ignored when doing an infrerrable comparison. This flag should
|
|
|
|
|
* be set on all properties that are read from the kernel or the system when a
|
|
|
|
|
* connection is generated. eg, IP addresses/routes can be read from the
|
|
|
|
|
* kernel, but the 'autoconnect' property cannot, so
|
|
|
|
|
* %NM_SETTING_IP4_CONFIG_ADDRESSES gets the INFERRABLE flag, but
|
|
|
|
|
* %NM_SETTING_CONNECTION_AUTOCONNECT would not.
|
|
|
|
|
*
|
|
|
|
|
* This flag should not be used with properties where the default cannot be
|
|
|
|
|
* read separately from the current value, like MTU or wired duplex mode.
|
|
|
|
|
*/
|
|
|
|
|
#define NM_SETTING_PARAM_INFERRABLE (1 << (4 + G_PARAM_USER_SHIFT))
|
|
|
|
|
|
2014-11-14 11:46:19 -05:00
|
|
|
/* This is a legacy property, which clients should not send to the daemon. */
|
|
|
|
|
#define NM_SETTING_PARAM_LEGACY (1 << (5 + G_PARAM_USER_SHIFT))
|
|
|
|
|
|
2015-09-18 17:21:34 +02:00
|
|
|
/* When a connection is active and gets modified, usually the change
|
|
|
|
|
* to the settings-connection does not propagate automatically to the
|
|
|
|
|
* applied-connection of the device. For certain properties like the
|
|
|
|
|
* firewall zone and the metered property, this is different.
|
|
|
|
|
*
|
|
|
|
|
* Such fields can be ignored during nm_connection_compare() with the
|
|
|
|
|
* NMSettingCompareFlag NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY.
|
|
|
|
|
*/
|
|
|
|
|
#define NM_SETTING_PARAM_REAPPLY_IMMEDIATELY (1 << (6 + G_PARAM_USER_SHIFT))
|
|
|
|
|
|
2019-09-24 18:25:00 +02:00
|
|
|
/* property_to_dbus() should ignore the property flags, and instead always calls to_dbus_fcn()
|
|
|
|
|
*/
|
|
|
|
|
#define NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS (1 << (7 + G_PARAM_USER_SHIFT))
|
|
|
|
|
|
2021-06-29 22:28:07 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_setting_name;
|
2019-09-22 10:57:57 +02:00
|
|
|
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_plain_i;
|
|
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-06-28 17:04:37 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean;
|
2021-06-29 07:57:41 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32;
|
2021-06-28 19:17:19 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string;
|
2021-06-28 17:04:37 +02:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
NMSettingVerifyResult
|
|
|
|
|
_nm_setting_verify(NMSetting *setting, NMConnection *connection, GError **error);
|
|
|
|
|
|
2015-11-10 14:36:20 +01:00
|
|
|
gboolean _nm_setting_verify_secret_string(const char *str,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
const char *property,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
2019-01-04 11:28:27 +01:00
|
|
|
gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpointer arg);
|
|
|
|
|
|
2014-07-07 17:05:10 +02:00
|
|
|
gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type);
|
|
|
|
|
|
2021-06-29 18:12:56 +02:00
|
|
|
gboolean _nm_setting_compare_flags_check(const GParamSpec * param_spec,
|
|
|
|
|
NMSettingCompareFlags flags,
|
|
|
|
|
NMSetting * set_a,
|
|
|
|
|
NMSetting * set_b);
|
|
|
|
|
|
2021-06-29 17:03:37 +02:00
|
|
|
NMTernary _nm_setting_property_compare_fcn_ignore(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
2021-06-29 18:18:06 +02:00
|
|
|
NMConnection * con_a,
|
|
|
|
|
NMSetting * set_a,
|
|
|
|
|
NMConnection * con_b,
|
|
|
|
|
NMSetting * set_b,
|
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_property_compare_fcn_direct(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
2021-06-29 17:03:37 +02:00
|
|
|
NMConnection * con_a,
|
|
|
|
|
NMSetting * set_a,
|
|
|
|
|
NMConnection * con_b,
|
|
|
|
|
NMSetting * set_b,
|
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
2021-06-29 14:23:16 +02:00
|
|
|
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);
|
|
|
|
|
|
2021-06-28 20:48:40 +02:00
|
|
|
void _nm_setting_property_get_property_direct(GObject * object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue * value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
|
void _nm_setting_property_set_property_direct(GObject * object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec * pspec);
|
|
|
|
|
|
2021-06-29 22:28:07 +02:00
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_ignore(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty * property_info,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
|
|
|
|
|
2021-06-18 08:59:12 +02:00
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * sett_info,
|
2021-06-29 12:04:00 +02:00
|
|
|
const NMSettInfoProperty * property_info,
|
2021-06-18 08:59:12 +02:00
|
|
|
NMConnection * connection,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
|
|
|
|
|
2021-06-28 17:04:37 +02:00
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting * sett_info,
|
2021-06-29 12:04:00 +02:00
|
|
|
const NMSettInfoProperty * property_info,
|
2021-06-28 17:04:37 +02:00
|
|
|
NMConnection * connection,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
|
|
|
|
|
2021-06-30 00:05:49 +02:00
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_ignore(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
GVariant * value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_gprop(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
GVariant * value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant *_nm_setting_to_dbus(NMSetting * setting,
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
NMConnection * connection,
|
2019-06-27 09:07:16 +02:00
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
2014-08-04 11:23:11 -04:00
|
|
|
|
2014-08-06 19:35:31 -04:00
|
|
|
NMSetting *_nm_setting_new_from_dbus(GType setting_type,
|
2014-08-16 10:09:48 -04:00
|
|
|
GVariant * setting_dict,
|
|
|
|
|
GVariant * connection_dict,
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
NMSettingParseFlags parse_flags,
|
libnm-core: add dbus-only properties to NMSettingClass
Add _nm_setting_class_add_dbus_only_property(), for declaring
properties that appear in the D-Bus serialization, but which don't
correspond to GObject properties.
Since some property overrides will require examining settings other
than the setting that they are on (eg, the value of
802-11-wireless.security depends on whether an
NMSettingWirelessSecurity setting is present, and
NMSettingConnection:interface-name might sometimes be set from, eg,
bond.interface-name), we also update _nm_setting_to_dbus() to take the
full NMConnection as an argument, and _nm_setting_new_from_dbus() to
take the full connection hash.
Additionally, with some deprecated properties, we'll want to validate
them on construction, but we don't need to keep the value around after
that. So allow _nm_setting_new_from_dbus() to return a verification
error directly, so we don't need to store the value until the verify()
call.
2014-07-29 18:25:10 -04:00
|
|
|
GError ** error);
|
|
|
|
|
|
2019-01-06 13:49:46 +01:00
|
|
|
gboolean _nm_setting_property_is_regular_secret(NMSetting *setting, const char *secret_name);
|
|
|
|
|
gboolean _nm_setting_property_is_regular_secret_flags(NMSetting * setting,
|
|
|
|
|
const char *secret_flags_name);
|
|
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-28 23:00:21 +02:00
|
|
|
const NMSettInfoProperty *
|
|
|
|
|
_nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info,
|
|
|
|
|
const GParamSpec * param_spec);
|
|
|
|
|
|
2021-06-21 14:52:47 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
static inline GArray *
|
|
|
|
|
_nm_sett_info_property_override_create_array(void)
|
|
|
|
|
{
|
2021-06-21 14:52:47 +02:00
|
|
|
/* pre-allocate a relatively large buffer to avoid frequent re-allocations.
|
|
|
|
|
* Note that the buffer is only short-lived and will be destroyed by
|
2021-06-28 14:53:16 +02:00
|
|
|
* _nm_setting_class_commit(). */
|
2021-06-21 14:52:47 +02:00
|
|
|
return _nm_sett_info_property_override_create_array_sized(20);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GArray *_nm_sett_info_property_override_create_array_ip_config(void);
|
|
|
|
|
|
2021-06-28 14:53:16 +02:00
|
|
|
void _nm_setting_class_commit(NMSettingClass * setting_class,
|
|
|
|
|
NMMetaSettingType meta_type,
|
|
|
|
|
const NMSettInfoSettDetail *detail,
|
|
|
|
|
GArray * properties_override,
|
|
|
|
|
gint16 private_offset);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
libnm: add generic-data for implementing NMSetting
Add a new way how NMSetting subclasses can be implemented.
Currently, most NMSetting implementations realize all their properties
via GObject properties. That has some downsides:
- the biggest one, is the large effort to add new properties.
Most of them are implemented on a one-by-one basis and they come
with additional API (like native getter functions).
It makes it cumbersome to add more properties.
- for certain properties, it's hard to encode them entirely in
a GObject property. That results in unusable API like
NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_BOND_OPTIONS,
NM_SETTING_USER_DATA. These complex valued properties only
exist, because we currently always need GObject properties
to even implement simple functionality. For example,
nm_setting_duplicate() is entirely implemented via
nm_setting_enumerate_values(), which can only iterate
GObject properies. There is no reason why this is necessary.
Note also how nmcli badly handles bond options and VPN
data. That is only a shortcoming of nmcli and wouldn't
need to be that way. But it happend, because we didn't
keep an open mind that settings might be more than just
accessing GObject properties.
- a major point of NMSetting is to convert to/from a GVariant
from the D-Bus API. As NMSetting needs to squeeze all values
into the static GObject structure, there is no place to
encode invalid or unknown properties. Optimally,
_nm_setting_new_from_dbus() does not loose any information
and a subsequent _nm_setting_to_dbus() can restore the original
variant. That is interesting, because we want that an older
libnm client can talk to a newer NetworkManager version. The
client needs to handle unknown properties gracefully to stay
forward compatible. However, it also should not just drop the
properties on the floor.
Note however, optimally we want that nm_setting_verify() still
can reject settings that have such unknown/invalid values. So,
it should be possible to create an NMSetting instance without
error or loosing information. But verify() should be usable to
identify such settings as invalid.
They also have a few upsides.
- libnm is heavily oriented around GObject. So, we generate
our nm-settings manual based on the gtk-doc. Note however,
how we fail to generate a useful manual for bond.options.
Also note, that there is no reason we couldn't generate
great documentation, even if the properties are not GObject
properties.
- GObject properties do give some functionality like meta-data,
data binding and notification. However, the meta-data is not
sufficient on its own. Note how keyfile and nmcli need extensive
descriptor tables on top of GObject properties, to make this
useful. Note how GObject notifications for NMSetting instances
are usually not useful, aside for data binding like nmtui does.
Also note how NMSettingBond already follows a different paradigm
than using GObject properties. Nowdays, NMSettingBond is considered
a mistake (related bug rh#1032808). Many ideas of NMSettingBond
are flawed, like exposing an inferiour API that reduces everything
to a string hash. Also, it only implemented the options hash inside
NMSettingBond. That means, if we would consider this a good style,
we would have to duplicate this approach in each new setting
implementation.
Add a new style to track data for NMSetting subclasses. It keeps
an internal hash table with all GVariant properies. Also, the
functionality is hooked into NMSetting base class, so all future
subclasses that follow this way, can benefit from this. This approach
has a few similiarties with NMSettingBond, but avoids its flaws.
With this, we also no longer need GObject properties (if we would
also implement generating useful documentation based on non-gkt-doc).
They may be added as accessors if they are useful, but there is no
need for them.
Also, handling the properties as a hash of variants invites for a
more generic approach when handling them. While we still could add
accessors that operate on a one-by-one bases, this leads to a more
generic usage where we apply common functionality to a set of properties.
Also, this is for the moment entirely internal and an implementation
detail. It's entirely up to the NMSetting subclass to make use of this
new style. Also, there are little hooks for the subclass available.
If they turn out to be necessary, they might be added. However, for
the moment, the functionality is restricted to what is useful and
necessary.
2018-07-27 10:05:40 +02:00
|
|
|
#define NM_SETT_INFO_SETT_GENDATA(...) \
|
|
|
|
|
({ \
|
|
|
|
|
static const NMSettInfoSettGendata _g = {__VA_ARGS__}; \
|
|
|
|
|
\
|
|
|
|
|
&_g; \
|
|
|
|
|
})
|
2020-09-28 16:03:33 +02:00
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
#define NM_SETT_INFO_SETT_DETAIL(...) (&((const NMSettInfoSettDetail){__VA_ARGS__}))
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2021-06-18 09:59:40 +02:00
|
|
|
#define NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, ...) \
|
|
|
|
|
{ \
|
|
|
|
|
.dbus_type = _dbus_type, __VA_ARGS__ \
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 14:23:16 +02:00
|
|
|
#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__)
|
2021-06-18 09:59:40 +02:00
|
|
|
|
|
|
|
|
#define NM_SETT_INFO_PROPERT_TYPE(init) \
|
|
|
|
|
({ \
|
|
|
|
|
static const NMSettInfoPropertType _g = init; \
|
|
|
|
|
\
|
|
|
|
|
&_g; \
|
libnm: refactor NMSettInfoProperty to save memory for simple properties
In total, we register 447 property informations. Out of these,
326 are plain, GObject property based without special implementations.
The NMSettInfoProperty had all function pointers directly embedded,
currently this amounts to 5 function pointers and the "dbus_type" field.
That means, at runtime we have 326 times trivial implementations with
waste 326*6*8 bytes of NULL pointers. We can compact these by moving
them to a separate structure.
Before:
447 * 5 function pointers
447 * "dbus_type" pointer
= 2682 pointers
After:
447 * 1 pointers (for NMSettInfoProperty.property_type)
89 * 6 pointers (for the distinct NMSettInfoPropertType data)
= 981 pointers
So, in total this saves 13608 byes of runtime memory (on 64 bit arch).
The 89 NMSettInfoPropertType instances are the remaining distinct instances.
Note that every NMSettInfoProperty has a "property_type" pointer, but most of them are
shared. That is because the underlying type and the operations are the same.
Also nice is that the NMSettInfoPropertType are actually constant,
static fields and initialized very early.
This change also makes sense form a design point of view. Previously,
NMSettInfoProperty contained both per-property data (the "name") but
also the behavior. Now, the "behavioral" part is moved to a separate
structure (where it is also shared). That means, the parts that are
concerned with the type of the property (the behavior) are separate
from the actual data of the property.
2019-09-22 08:53:06 +02:00
|
|
|
})
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2021-06-18 09:44:46 +02:00
|
|
|
#define NM_SETT_INFO_PROPERT_TYPE_DBUS(_dbus_type, ...) \
|
2021-06-18 09:59:40 +02:00
|
|
|
NM_SETT_INFO_PROPERT_TYPE(NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, __VA_ARGS__))
|
2021-06-18 09:44:46 +02:00
|
|
|
|
2021-06-18 09:59:40 +02:00
|
|
|
#define NM_SETT_INFO_PROPERT_TYPE_GPROP(_dbus_type, ...) \
|
|
|
|
|
NM_SETT_INFO_PROPERT_TYPE(NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, __VA_ARGS__))
|
2021-06-18 08:59:12 +02:00
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
#define NM_SETT_INFO_PROPERTY(...) (&((const NMSettInfoProperty){__VA_ARGS__}))
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2019-09-22 15:32:04 +02:00
|
|
|
gboolean _nm_properties_override_assert(const NMSettInfoProperty *prop_info);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
2019-09-22 15:23:41 +02:00
|
|
|
static inline void
|
2019-09-22 15:32:04 +02:00
|
|
|
_nm_properties_override(GArray *properties_override, const NMSettInfoProperty *prop_info)
|
2019-09-22 15:23:41 +02:00
|
|
|
{
|
|
|
|
|
nm_assert(properties_override);
|
2019-09-22 15:32:04 +02:00
|
|
|
nm_assert(_nm_properties_override_assert(prop_info));
|
2019-09-22 15:23:41 +02:00
|
|
|
g_array_append_vals(properties_override, prop_info, 1);
|
|
|
|
|
}
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
2021-06-28 17:04:37 +02:00
|
|
|
#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), \
|
2021-06-18 10:36:17 +02:00
|
|
|
__VA_ARGS__))
|
2019-09-22 15:32:04 +02:00
|
|
|
|
|
|
|
|
#define _nm_properties_override_dbus(properties_override, p_name, p_property_type) \
|
|
|
|
|
_nm_properties_override( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
NM_SETT_INFO_PROPERTY(.name = ("" p_name ""), .property_type = (p_property_type), ))
|
2019-09-22 10:57:57 +02:00
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
/*****************************************************************************/
|
2021-06-28 17:04:37 +02:00
|
|
|
|
|
|
|
|
/* Define "direct" properties. These are properties that have a GParamSpec and
|
|
|
|
|
* NMSettInfoPropertType.direct_type != NM_VALUE_TYPE_NONE.
|
|
|
|
|
*
|
|
|
|
|
* With this, the location of the data is known at
|
|
|
|
|
*
|
|
|
|
|
* _nm_setting_get_private(setting, sett_info, property_info->direct_offset)
|
|
|
|
|
*
|
|
|
|
|
* which allows to generically handle the property operations (like get, set, compare).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define _nm_setting_property_define_direct_boolean(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
default_value, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
const gboolean _default_value = (default_value); \
|
|
|
|
|
GParamSpec * _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
G_STATIC_ASSERT( \
|
|
|
|
|
!NM_FLAGS_ANY((param_flags), \
|
|
|
|
|
~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE \
|
|
|
|
|
| NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \
|
|
|
|
|
\
|
|
|
|
|
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)); \
|
|
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_boolean, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(bool, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2014-07-30 10:46:24 -04:00
|
|
|
|
2021-06-29 07:57:41 +02:00
|
|
|
#define _nm_setting_property_define_direct_uint32(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
min_value, \
|
|
|
|
|
max_value, \
|
|
|
|
|
default_value, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
GParamSpec *_param_spec; \
|
|
|
|
|
\
|
|
|
|
|
G_STATIC_ASSERT( \
|
|
|
|
|
!NM_FLAGS_ANY((param_flags), \
|
|
|
|
|
~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \
|
|
|
|
|
G_STATIC_ASSERT((min_value) <= (guint64) G_MAXUINT32); \
|
|
|
|
|
G_STATIC_ASSERT((max_value) <= (guint64) G_MAXUINT32); \
|
|
|
|
|
G_STATIC_ASSERT((default_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)); \
|
|
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_uint32, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-28 23:51:42 +02:00
|
|
|
#define _nm_setting_property_define_direct_string_full(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
property_type, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
G_STMT_START \
|
|
|
|
|
{ \
|
|
|
|
|
GParamSpec * _param_spec; \
|
|
|
|
|
const NMSettInfoPropertType *_property_type = (property_type); \
|
|
|
|
|
\
|
|
|
|
|
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))); \
|
|
|
|
|
\
|
|
|
|
|
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); \
|
|
|
|
|
\
|
|
|
|
|
_param_spec = \
|
|
|
|
|
g_param_spec_string("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
NULL, \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \
|
|
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
_property_type, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
2021-06-28 19:17:19 +02:00
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
#define _nm_setting_property_define_direct_string(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
2021-06-28 23:51:42 +02:00
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
2021-06-28 19:17:19 +02:00
|
|
|
_nm_setting_property_define_direct_string_full((properties_override), \
|
|
|
|
|
(obj_properties), \
|
|
|
|
|
prop_name, \
|
|
|
|
|
(prop_id), \
|
|
|
|
|
(param_flags), \
|
|
|
|
|
&nm_sett_info_propert_type_direct_string, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
__VA_ARGS__)
|
2021-06-17 22:10:48 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-11-14 11:46:19 -05:00
|
|
|
gboolean _nm_setting_use_legacy_property(NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
const char *legacy_property,
|
|
|
|
|
const char *new_property);
|
|
|
|
|
|
2014-10-07 08:46:36 +02:00
|
|
|
GPtrArray *_nm_setting_need_secrets(NMSetting *setting);
|
|
|
|
|
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
gboolean _nm_setting_should_compare_secret_property(NMSetting * setting,
|
|
|
|
|
NMSetting * other,
|
|
|
|
|
const char * secret_name,
|
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
2019-03-16 17:21:35 +01:00
|
|
|
NMBridgeVlan *_nm_bridge_vlan_dup(const NMBridgeVlan *vlan);
|
|
|
|
|
NMBridgeVlan *_nm_bridge_vlan_dup_and_seal(const NMBridgeVlan *vlan);
|
|
|
|
|
|
2021-06-29 23:51:46 +02:00
|
|
|
gboolean _nm_utils_bridge_vlans_from_dbus(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
GVariant * value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError ** error);
|
2021-06-29 14:37:16 +02:00
|
|
|
|
|
|
|
|
GVariant *_nm_utils_bridge_vlans_to_dbus(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty * property_info,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_ip_config_compare_fcn_addresses(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMConnection * con_a,
|
|
|
|
|
NMSetting * set_a,
|
|
|
|
|
NMConnection * con_b,
|
|
|
|
|
NMSetting * set_b,
|
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_ip_config_compare_fcn_routes(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMConnection * con_a,
|
|
|
|
|
NMSetting * set_a,
|
|
|
|
|
NMConnection * con_b,
|
|
|
|
|
NMSetting * set_b,
|
|
|
|
|
NMSettingCompareFlags flags);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_utils_hwaddr_cloned_not_set(NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
const char * property,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError ** error);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_utils_hwaddr_cloned_get(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty * property_info,
|
|
|
|
|
NMConnection * connection,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options);
|
|
|
|
|
|
2021-06-29 23:51:46 +02:00
|
|
|
gboolean _nm_utils_hwaddr_cloned_set(const NMSettInfoSetting * sett_info,
|
|
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting * setting,
|
|
|
|
|
GVariant * connection_dict,
|
|
|
|
|
GVariant * value,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError ** error);
|
2021-06-29 14:37:16 +02:00
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#endif /* NM_SETTING_PRIVATE_H */
|