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"
|
2022-09-27 13:04:47 +02:00
|
|
|
#include "nm-simple-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
|
|
|
|
2023-10-26 13:27:07 +02:00
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-26 13:39:23 +02:00
|
|
|
struct _NMRefString;
|
|
|
|
|
|
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 */
|
2022-09-26 13:39:23 +02:00
|
|
|
struct _NMRefString *path;
|
2021-06-14 19:29:18 +02:00
|
|
|
} NMConnectionPrivate;
|
|
|
|
|
|
|
|
|
|
extern GTypeClass *_nm_simple_connection_class_instance;
|
|
|
|
|
extern int _nm_simple_connection_private_offset;
|
|
|
|
|
|
2022-09-27 13:04:47 +02:00
|
|
|
#undef NM_IS_SIMPLE_CONNECTION
|
|
|
|
|
#define NM_IS_SIMPLE_CONNECTION(self) \
|
|
|
|
|
({ \
|
|
|
|
|
gconstpointer _self1 = (self); \
|
|
|
|
|
gboolean _result; \
|
|
|
|
|
\
|
|
|
|
|
_result = \
|
|
|
|
|
(_self1 \
|
|
|
|
|
&& (((GTypeInstance *) _self1)->g_class == _nm_simple_connection_class_instance)); \
|
|
|
|
|
\
|
|
|
|
|
nm_assert(_result == G_TYPE_CHECK_INSTANCE_TYPE(_self1, NM_TYPE_SIMPLE_CONNECTION)); \
|
|
|
|
|
\
|
|
|
|
|
_result; \
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
#undef NM_IS_CONNECTION
|
|
|
|
|
#define NM_IS_CONNECTION(self) \
|
|
|
|
|
({ \
|
|
|
|
|
gconstpointer _self0 = (self); \
|
|
|
|
|
\
|
|
|
|
|
(_self0 \
|
|
|
|
|
&& (NM_IS_SIMPLE_CONNECTION(_self0) \
|
|
|
|
|
|| G_TYPE_CHECK_INSTANCE_TYPE(_self0, NM_TYPE_CONNECTION))); \
|
|
|
|
|
})
|
|
|
|
|
|
2022-09-27 12:45:18 +02:00
|
|
|
#define _NM_SIMPLE_CONNECTION_GET_CONNECTION_PRIVATE(connection) \
|
|
|
|
|
({ \
|
|
|
|
|
gpointer _connection_1 = (connection); \
|
|
|
|
|
NMConnectionPrivate *_priv_1; \
|
|
|
|
|
\
|
|
|
|
|
nm_assert(NM_IS_SIMPLE_CONNECTION(_connection_1)); \
|
|
|
|
|
\
|
|
|
|
|
_priv_1 = (void *) (&(((char *) _connection_1)[_nm_simple_connection_private_offset])); \
|
|
|
|
|
\
|
|
|
|
|
nm_assert(_priv_1 \
|
|
|
|
|
== G_TYPE_INSTANCE_GET_PRIVATE(_connection_1, \
|
|
|
|
|
NM_TYPE_SIMPLE_CONNECTION, \
|
|
|
|
|
NMConnectionPrivate)); \
|
|
|
|
|
\
|
|
|
|
|
_priv_1; \
|
|
|
|
|
})
|
|
|
|
|
|
2021-06-14 19:29:18 +02:00
|
|
|
void _nm_connection_private_clear(NMConnectionPrivate *priv);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm: embed private structure in NMSetting and avoid g_type_class_add_private()
Historically, the NMSetting types were in public headers. Theoretically,
that allowed users to subtype our classes. However in practice that was
impossible because they lacked required access to internal functions to
fully create an NMSetting class outside of libnm. And it also was not
useful, because you simply cannot extend libnm by subtyping a libnm
class. And supporting such a use case would be hard and limit what we can
do in libnm.
Having GObject structs in public headers also require that we don't
change it's layout. The ABI of those structs must not change, if anybody
out there was actually subclassing our GObjects.
In libnm 1.34 (commit e46d484fae9e ('libnm: hide NMSetting types from
public headers')) we moved the structs from headers to internal.
This would have caused a compiler error if anybody was using those
struct definitions. However, we still didn't change the ABI/layout so
that we didn't break users who relied on it (for whatever reason).
It doesn't seem there were any affected user. We waited long enough.
Change internal ABI.
No longer use g_type_class_add_private(). Instead, embed the private
structs directly (_NM_GET_PRIVATE()) or indirectly
(_NM_GET_PRIVATE_PTR()) in the object.
The main benefit is for debugging in the debugger, where we can now
easily find the private data. Previously that was so cumbersome to be
effectively impossible.
It's also the fastest possible way, since NM_SETTING_*_GET_PRIVATE()
literally resolves to "&self->_priv" (plus static asserts and
nm_assert() for type checking).
_NM_GET_PRIVATE() also propagates constness and requires that the
argument is a compatible pointer type (at compile time).
Note that g_type_class_add_private() is also deprecated in glib 2.58 and
replaced by G_ADD_PRIVATE(). For one, we still don't rely on 2.58. Also,
G_ADD_PRIVATE() is a worse solution as it supports a usecase that we
don't care for (public structs in headers). _NM_GET_PRIVATE() is still
faster, works with older glib and most importantly: is better for
debugging as you can find the private data from an object pointer.
For NMSettingIPConfig this is rather awkward, because all direct
properties require a common "klass->private_offset". This was however
the case before this change. Nothing new here. And if you ever touch
this and do something wrong, many unit tests will fail. It's almost
impossible to get wrong, albeit it can be confusing to understand.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1773
2023-10-24 19:05:50 +02:00
|
|
|
struct _NMSettingPrivate;
|
|
|
|
|
|
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 {
|
libnm: embed private structure in NMSetting and avoid g_type_class_add_private()
Historically, the NMSetting types were in public headers. Theoretically,
that allowed users to subtype our classes. However in practice that was
impossible because they lacked required access to internal functions to
fully create an NMSetting class outside of libnm. And it also was not
useful, because you simply cannot extend libnm by subtyping a libnm
class. And supporting such a use case would be hard and limit what we can
do in libnm.
Having GObject structs in public headers also require that we don't
change it's layout. The ABI of those structs must not change, if anybody
out there was actually subclassing our GObjects.
In libnm 1.34 (commit e46d484fae9e ('libnm: hide NMSetting types from
public headers')) we moved the structs from headers to internal.
This would have caused a compiler error if anybody was using those
struct definitions. However, we still didn't change the ABI/layout so
that we didn't break users who relied on it (for whatever reason).
It doesn't seem there were any affected user. We waited long enough.
Change internal ABI.
No longer use g_type_class_add_private(). Instead, embed the private
structs directly (_NM_GET_PRIVATE()) or indirectly
(_NM_GET_PRIVATE_PTR()) in the object.
The main benefit is for debugging in the debugger, where we can now
easily find the private data. Previously that was so cumbersome to be
effectively impossible.
It's also the fastest possible way, since NM_SETTING_*_GET_PRIVATE()
literally resolves to "&self->_priv" (plus static asserts and
nm_assert() for type checking).
_NM_GET_PRIVATE() also propagates constness and requires that the
argument is a compatible pointer type (at compile time).
Note that g_type_class_add_private() is also deprecated in glib 2.58 and
replaced by G_ADD_PRIVATE(). For one, we still don't rely on 2.58. Also,
G_ADD_PRIVATE() is a worse solution as it supports a usecase that we
don't care for (public structs in headers). _NM_GET_PRIVATE() is still
faster, works with older glib and most importantly: is better for
debugging as you can find the private data from an object pointer.
For NMSettingIPConfig this is rather awkward, because all direct
properties require a common "klass->private_offset". This was however
the case before this change. Nothing new here. And if you ever touch
this and do something wrong, many unit tests will fail. It's almost
impossible to get wrong, albeit it can be confusing to understand.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1773
2023-10-24 19:05:50 +02:00
|
|
|
GObject parent;
|
|
|
|
|
struct _NMSettingPrivate *_priv;
|
2021-06-11 00:27:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMSettingClass {
|
|
|
|
|
GObjectClass parent;
|
|
|
|
|
|
|
|
|
|
int (*verify)(NMSetting *setting, NMConnection *connection, GError **error);
|
|
|
|
|
|
|
|
|
|
gboolean (*verify_secrets)(NMSetting *setting, NMConnection *connection, GError **error);
|
|
|
|
|
|
2022-10-07 10:59:02 +02:00
|
|
|
GPtrArray *(*need_secrets)(NMSetting *setting, gboolean check_rerequest);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
int (*update_one_secret)(NMSetting *setting, const char *key, GVariant *value, GError **error);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean (*get_secret_flags)(NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
2021-06-11 00:27:31 +02:00
|
|
|
NMSettingSecretFlags *out_flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean (*set_secret_flags)(NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
2021-06-11 00:27:31 +02:00
|
|
|
NMSettingSecretFlags flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info,
|
2021-11-09 13:28:54 +01:00
|
|
|
const NMSettInfoProperty *property_info,
|
|
|
|
|
NMSetting *setting,
|
2021-06-11 00:27:31 +02:00
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info,
|
2021-11-09 13:28:54 +01:00
|
|
|
NMSetting *src,
|
|
|
|
|
NMSetting *dst);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
void (*enumerate_values)(const struct _NMSettInfoProperty *property_info,
|
2021-11-09 13:28:54 +01:00
|
|
|
NMSetting *setting,
|
2021-06-11 00:27:31 +02:00
|
|
|
NMSettingValueIterFn func,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
gboolean (*aggregate)(NMSetting *setting, int type_i, gpointer arg);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void (*for_each_secret)(NMSetting *setting,
|
|
|
|
|
const char *secret_name,
|
|
|
|
|
GVariant *val,
|
2021-06-11 00:27:31 +02:00
|
|
|
gboolean remove_non_secrets,
|
|
|
|
|
_NMConnectionForEachSecretFunc callback,
|
|
|
|
|
gpointer callback_data,
|
2021-11-09 13:28:54 +01:00
|
|
|
GVariantBuilder *setting_builder);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean (*init_from_dbus)(NMSetting *setting,
|
|
|
|
|
GHashTable *keys,
|
|
|
|
|
GVariant *setting_dict,
|
|
|
|
|
GVariant *connection_dict,
|
2021-06-11 00:27:31 +02:00
|
|
|
guint /* NMSettingParseFlags */ parse_flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2021-06-11 00:27:31 +02:00
|
|
|
|
|
|
|
|
const struct _NMMetaSettingInfo *setting_info;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingIPConfig:
|
|
|
|
|
*/
|
|
|
|
|
struct _NMSettingIPConfig {
|
|
|
|
|
NMSetting parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMSettingIPConfigClass {
|
|
|
|
|
NMSettingClass parent;
|
libnm: embed private structure in NMSetting and avoid g_type_class_add_private()
Historically, the NMSetting types were in public headers. Theoretically,
that allowed users to subtype our classes. However in practice that was
impossible because they lacked required access to internal functions to
fully create an NMSetting class outside of libnm. And it also was not
useful, because you simply cannot extend libnm by subtyping a libnm
class. And supporting such a use case would be hard and limit what we can
do in libnm.
Having GObject structs in public headers also require that we don't
change it's layout. The ABI of those structs must not change, if anybody
out there was actually subclassing our GObjects.
In libnm 1.34 (commit e46d484fae9e ('libnm: hide NMSetting types from
public headers')) we moved the structs from headers to internal.
This would have caused a compiler error if anybody was using those
struct definitions. However, we still didn't change the ABI/layout so
that we didn't break users who relied on it (for whatever reason).
It doesn't seem there were any affected user. We waited long enough.
Change internal ABI.
No longer use g_type_class_add_private(). Instead, embed the private
structs directly (_NM_GET_PRIVATE()) or indirectly
(_NM_GET_PRIVATE_PTR()) in the object.
The main benefit is for debugging in the debugger, where we can now
easily find the private data. Previously that was so cumbersome to be
effectively impossible.
It's also the fastest possible way, since NM_SETTING_*_GET_PRIVATE()
literally resolves to "&self->_priv" (plus static asserts and
nm_assert() for type checking).
_NM_GET_PRIVATE() also propagates constness and requires that the
argument is a compatible pointer type (at compile time).
Note that g_type_class_add_private() is also deprecated in glib 2.58 and
replaced by G_ADD_PRIVATE(). For one, we still don't rely on 2.58. Also,
G_ADD_PRIVATE() is a worse solution as it supports a usecase that we
don't care for (public structs in headers). _NM_GET_PRIVATE() is still
faster, works with older glib and most importantly: is better for
debugging as you can find the private data from an object pointer.
For NMSettingIPConfig this is rather awkward, because all direct
properties require a common "klass->private_offset". This was however
the case before this change. Nothing new here. And if you ever touch
this and do something wrong, many unit tests will fail. It's almost
impossible to get wrong, albeit it can be confusing to understand.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1773
2023-10-24 19:05:50 +02:00
|
|
|
int private_offset;
|
|
|
|
|
gint8 addr_family;
|
|
|
|
|
bool is_ipv4;
|
2021-06-11 00:27:31 +02:00
|
|
|
};
|
|
|
|
|
|
2021-06-28 18:14:04 +02:00
|
|
|
typedef struct {
|
2023-10-26 13:27:36 +02:00
|
|
|
NMValueStrv dns_search; /* array of domain name strings */
|
|
|
|
|
NMValueStrv dhcp_reject_servers;
|
2023-11-15 20:16:18 +01:00
|
|
|
NMValueStrv dns_options; /* array of DNS options */
|
2023-10-26 13:27:36 +02:00
|
|
|
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;
|
libnm,nmcli: add ipvx.dhcp-dscp property
Currently the internal DHCP client sets traffic class "CS6" in the DS
field of the IP header for outgoing packets.
dhclient sets the field according to the definition of TOS (RFC 1349),
which was was deprecated in 1998 by RFC 2474 in favor of DSCP.
Introduce a new property IPvX.dhcp-dscp (currently valid only for
IPv4) to specify a custom DSCP value for DHCP backends that support it
(currently, only the internal one).
Define the default value to CS0, because:
- section 4.9 of RFC 4594 specifies that DHCP should use the standard
(CS0 = 0) service class;
- section 3.2 says that class CS6 is for "transmitting packets
between network devices (routers) that require control (routing)
information to be exchanged between nodes", listing "OSPF, BGP,
ISIS, RIP" as examples of such traffic. Furthermore, it says that:
User traffic is not allowed to use this service class. By user
traffic, we mean packet flows that originate from user-controlled
end points that are connected to the network.
- we got reports of some Cisco switches dropping DHCP packets because
of the CS6 marking.
(cherry picked from commit fcd907e062c72205ee2505ca6c175c6d1396f166)
2023-12-20 11:40:02 +01:00
|
|
|
char *dhcp_dscp;
|
2023-10-26 13:27:36 +02:00
|
|
|
gint64 route_metric;
|
|
|
|
|
int auto_route_ext_gw;
|
|
|
|
|
int replace_local_rule;
|
2024-01-26 14:04:51 +01:00
|
|
|
int dhcp_send_release;
|
2023-10-26 13:27:36 +02:00
|
|
|
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;
|
2021-06-28 18:14:04 +02:00
|
|
|
} NMSettingIPConfigPrivate;
|
|
|
|
|
|
|
|
|
|
void _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv);
|
|
|
|
|
|
2022-09-26 21:50:42 +02:00
|
|
|
#define NM_SETTING_IP_CONFIG_GET_ADDR_FAMILY(setting) \
|
|
|
|
|
(NM_SETTING_IP_CONFIG_GET_CLASS(setting)->addr_family)
|
|
|
|
|
|
|
|
|
|
#define NM_SETTING_IP_CONFIG_IS_IPv4(setting) (NM_SETTING_IP_CONFIG_GET_CLASS(setting)->is_ipv4)
|
|
|
|
|
|
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-09-07 11:21:08 +02:00
|
|
|
int _nm_setting_sort_for_nm_assert(NMSetting *a, NMSetting *b);
|
2021-06-11 15:28:42 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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);
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_setting_clear_secrets(NMSetting *setting,
|
2019-01-13 20:47:05 +01:00
|
|
|
NMSettingClearSecretsWithFlagsFn func,
|
|
|
|
|
gpointer user_data);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2021-06-18 00:01:30 +02:00
|
|
|
/*****************************************************************************/
|
2022-01-24 17:10:34 +01:00
|
|
|
|
2022-11-18 17:07:23 +01:00
|
|
|
struct _NMRange {
|
libnm: make ref counting of immutable types thread safe
The types NMBridgeVlan, NMIPRoutingRule, NMRange, NMWireGuardPeer
are immutable (or immutable, after the seal() function is called).
Immutable types are great, as it means a reference to them can be shared
without doing a full clone. Hence the G_DEFINE_BOXED_TYPE() for these
types prefers to take a reference instead of cloning the objects. Except
for sealable types, where it will prefer to clone unsealed values.
Likewise, nm_simple_connection_new_clone() probably will just take
another reference to the value, instead of doing a deep clone.
libnm is not a thread-safe library in the sense that you could pass a
NMConnection or NMClient instance to multiple threads and access them
without your own synchronization. However, it should be possible that
multiple threads access (seemingly) distinct objects.
As the copy function of these boxed types (and nm_simple_connection_new_clone()
and similar) prefers to share the references to immutable types, it is important
that the ref function is thread-safe too. Otherwise you cannot just clone a
NMConnection on thread1, hand the clone to thread2 and operate on the
clone and the original independently. If you do before this patch, you would
hit a subtle race condition.
Avoid that. While atomic operations have a runtime overhead, being safe
is more important. Also, we already save a full malloc()/free() by
having immutable, ref-counted types. We just need to make it safe to use
in order to fully benefit from it.
2022-11-30 16:55:09 +01:00
|
|
|
int refcount;
|
2022-11-18 17:07:23 +01:00
|
|
|
guint64 start;
|
|
|
|
|
guint64 end;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
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
|
2021-12-29 14:29:09 -03:00
|
|
|
* this flag, are ignored when doing an inferrable comparison. This flag should
|
2014-07-24 08:53:33 -04:00
|
|
|
* 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))
|
|
|
|
|
|
libnm: refactor to-dbus on the client skipping to serialize legacy properties
We have 4 legacy properties ("ipv[46].addresses", "ipv[46].routes") that
got replaced by newer variants ("ipv[46].address-data", "ipv[46].route-data").
When the client side of libnm (_nm_utils_is_manager_process) serializes
those properties, it must only serialize the newer version. That is so
that the forward/backward compatibility works as intended.
Previously, there was the NM_SETTING_PARAM_LEGACY GObject property flag.
That was fine, but not very clear.
For one, the legacy part of those properties is only about D-Bus. In
particular, they are not deprecated in libnm, keyfile, or nmcli. Thus
the name wasn't very clear.
Also, in the meantime we have more elaborate property meta data, that
goes beyond the meta data of the GObject property.
Move NM_SETTING_PARAM_LEGACY to NMSettInfoProperty.to_dbus_only_in_manager_process.
I think, this is a better name. It's also right at
```
_nm_properties_override_gobj(
properties_override,
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_to_dbus,
.compare_fcn = _nm_setting_ip_config_compare_fcn_routes,
.from_dbus_fcn = ip6_routes_from_dbus, ),
.to_dbus_only_in_manager_process = TRUE,
.dbus_deprecated = TRUE, );
```
that is, directly at the place where we describe how the D-Bus property behaves.
2022-10-24 13:22:40 +02:00
|
|
|
/* This flag has no meaning (anymore). It's only kept, because we used it
|
|
|
|
|
* on some older versions of libnm. */
|
|
|
|
|
#define NM_SETTING_PARAM_UNUSED1 (1 << (5 + G_PARAM_USER_SHIFT))
|
2014-11-14 11:46:19 -05:00
|
|
|
|
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;
|
2023-10-25 11:58:29 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_gprop_strv_oldstyle;
|
2019-09-22 10:57:57 +02:00
|
|
|
|
2021-06-28 17:04:37 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean;
|
2021-07-13 22:56:05 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32;
|
2021-06-29 07:57:41 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32;
|
2022-01-05 15:29:50 +01:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64;
|
2021-10-20 10:53:39 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64;
|
2021-06-28 19:17:19 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string;
|
2021-10-27 20:24:17 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes;
|
2022-01-24 17:10:34 +01:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_strv;
|
2021-10-20 10:53:39 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_enum;
|
2021-10-20 10:53:39 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_flags;
|
2021-07-13 18:09:13 +02:00
|
|
|
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_mac_address;
|
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,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
2015-11-10 14:36:20 +01:00
|
|
|
|
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-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_setting_compare_flags_check(const GParamSpec *param_spec,
|
2021-06-29 18:12:56 +02:00
|
|
|
NMSettingCompareFlags flags,
|
2021-11-09 13:28:54 +01:00
|
|
|
NMSetting *set_a,
|
|
|
|
|
NMSetting *set_b);
|
2021-06-29 18:12:56 +02:00
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
NMTernary _nm_setting_property_compare_fcn_ignore(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
2021-06-29 14:23:16 +02:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void _nm_setting_property_get_property_direct(GObject *object,
|
2021-06-28 20:48:40 +02:00
|
|
|
guint prop_id,
|
2021-11-09 13:28:54 +01:00
|
|
|
GValue *value,
|
2021-06-28 20:48:40 +02:00
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
void _nm_setting_property_set_property_direct(GObject *object,
|
2021-06-28 20:48:40 +02:00
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
2021-11-09 13:28:54 +01:00
|
|
|
GParamSpec *pspec);
|
2021-06-28 20:48:40 +02:00
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_ignore(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *
|
|
|
|
|
_nm_setting_property_to_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway(
|
|
|
|
|
_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_direct_mac_address(
|
|
|
|
|
_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
2021-06-30 00:05:49 +02:00
|
|
|
|
2023-11-29 14:43:43 +01:00
|
|
|
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);
|
|
|
|
|
|
2024-01-16 13:58:11 +01:00
|
|
|
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);
|
|
|
|
|
|
2024-01-22 14:58:56 +01:00
|
|
|
gboolean
|
|
|
|
|
_nm_setting_connection_autoconnect_ports_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *
|
|
|
|
|
_nm_setting_connection_autoconnect_ports_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_connection_autoconnect_slaves_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2024-02-19 14:51:36 +01:00
|
|
|
gboolean _nm_setting_wireless_mac_denylist_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_setting_wireless_mac_denylist_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_wireless_mac_blacklist_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2024-03-13 12:44:59 +01:00
|
|
|
gboolean _nm_setting_wired_mac_denylist_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_setting_wired_mac_denylist_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
gboolean _nm_setting_wired_mac_blacklist_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
GVariant *_nm_setting_to_dbus(NMSetting *setting,
|
|
|
|
|
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,
|
2021-11-09 13:28:54 +01: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,
|
2021-11-09 13:28:54 +01:00
|
|
|
GError **error);
|
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
|
|
|
|
2019-01-06 13:49:46 +01:00
|
|
|
gboolean _nm_setting_property_is_regular_secret(NMSetting *setting, const char *secret_name);
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_setting_property_is_regular_secret_flags(NMSetting *setting,
|
2019-01-06 13:49:46 +01:00
|
|
|
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,
|
2021-11-09 13:28:54 +01:00
|
|
|
const GParamSpec *param_spec);
|
2021-06-28 23:00:21 +02:00
|
|
|
|
2023-10-25 11:26:13 +02:00
|
|
|
GArray *_nm_sett_info_property_override_create_array_sized(guint reserved_size);
|
2021-06-21 14:52:47 +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
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2021-07-14 07:40:35 +02:00
|
|
|
GArray *_nm_sett_info_property_override_create_array_ip_config(int addr_family);
|
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-11-09 13:28:54 +01:00
|
|
|
void _nm_setting_class_commit(NMSettingClass *setting_class,
|
2021-06-28 14:53:16 +02:00
|
|
|
NMMetaSettingType meta_type,
|
|
|
|
|
const NMSettInfoSettDetail *detail,
|
2021-11-09 13:28:54 +01:00
|
|
|
GArray *properties_override,
|
2021-06-28 14:53:16 +02:00
|
|
|
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
|
|
|
|
2023-12-11 11:59:25 +01:00
|
|
|
static inline guint
|
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);
|
2023-12-11 11:59:25 +01:00
|
|
|
return properties_override->len - 1u;
|
2019-09-22 15:23:41 +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
|
|
|
|
2023-10-25 17:25:26 +02:00
|
|
|
#define _nm_properties_override_gobj(properties_override, \
|
|
|
|
|
p_param_spec, \
|
|
|
|
|
p_property_type, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
2023-12-11 11:59:25 +01:00
|
|
|
({ \
|
2023-10-25 17:25:26 +02:00
|
|
|
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__)); \
|
2023-12-11 11:59:25 +01:00
|
|
|
})
|
2019-09-22 15:32:04 +02:00
|
|
|
|
2022-10-24 11:16:42 +02:00
|
|
|
#define _nm_properties_override_dbus(properties_override, \
|
|
|
|
|
p_name, \
|
|
|
|
|
p_property_type, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
_nm_properties_override((properties_override), \
|
|
|
|
|
NM_SETT_INFO_PROPERTY(.name = ("" p_name ""), \
|
|
|
|
|
.property_type = (p_property_type), \
|
|
|
|
|
__VA_ARGS__))
|
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); \
|
2021-11-09 13:28:54 +01:00
|
|
|
GParamSpec *_param_spec; \
|
2021-06-28 17:04:37 +02:00
|
|
|
\
|
|
|
|
|
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)); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_param_spec = g_param_spec_boolean("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
_default_value, \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
2021-06-28 17:04:37 +02:00
|
|
|
\
|
|
|
|
|
(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))); \
|
2021-07-13 22:56:05 +02:00
|
|
|
G_STATIC_ASSERT((min_value) <= (guint64) (default_value)); \
|
|
|
|
|
G_STATIC_ASSERT((default_value) <= (guint64) (max_value)); \
|
2021-06-29 07:57:41 +02:00
|
|
|
G_STATIC_ASSERT((max_value) <= (guint64) G_MAXUINT32); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_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)); \
|
2021-06-29 07:57:41 +02:00
|
|
|
\
|
|
|
|
|
(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-07-13 22:56:05 +02:00
|
|
|
#define _nm_setting_property_define_direct_int32(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) >= (gint64) (G_MININT32)); \
|
|
|
|
|
G_STATIC_ASSERT((min_value) <= (gint64) (default_value)); \
|
|
|
|
|
G_STATIC_ASSERT((default_value) <= (gint64) (max_value)); \
|
|
|
|
|
G_STATIC_ASSERT((max_value) <= (gint64) G_MAXUINT32); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_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)); \
|
2021-07-13 22:56:05 +02:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_int32, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
2021-10-20 10:53:39 +02:00
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-01-05 15:29:50 +01:00
|
|
|
#define _nm_setting_property_define_direct_int64(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) >= G_MININT64); \
|
|
|
|
|
G_STATIC_ASSERT((min_value) <= (default_value)); \
|
|
|
|
|
G_STATIC_ASSERT((default_value) <= (max_value)); \
|
|
|
|
|
G_STATIC_ASSERT((max_value) <= G_MAXINT64); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_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)); \
|
2022-01-05 15:29:50 +01:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_int64, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-20 10:53:39 +02:00
|
|
|
#define _nm_setting_property_define_direct_uint64(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) <= (default_value)); \
|
2024-04-05 08:20:02 +02:00
|
|
|
G_STATIC_ASSERT((default_value) == 0 || (default_value) - 1u < (max_value)); \
|
2021-10-20 10:53:39 +02:00
|
|
|
G_STATIC_ASSERT((max_value) <= G_MAXUINT64); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_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)); \
|
2021-10-20 10:53:39 +02:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_uint64, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(guint64, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
2021-07-13 22:56:05 +02:00
|
|
|
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 */) \
|
2023-12-11 11:59:25 +01:00
|
|
|
({ \
|
2021-11-09 13:28:54 +01:00
|
|
|
GParamSpec *_param_spec; \
|
2021-06-28 23:51:42 +02:00
|
|
|
const NMSettInfoPropertType *_property_type = (property_type); \
|
|
|
|
|
\
|
|
|
|
|
G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \
|
|
|
|
|
~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \
|
2021-12-28 10:50:05 +01:00
|
|
|
| NM_SETTING_PARAM_INFERRABLE | NM_SETTING_PARAM_REQUIRED \
|
2021-06-28 23:51:42 +02:00
|
|
|
| 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); \
|
2023-11-29 14:43:43 +01:00
|
|
|
nm_assert(NM_IN_SET(_property_type->to_dbus_fcn, \
|
|
|
|
|
_nm_setting_property_to_dbus_fcn_direct, \
|
2024-01-16 13:58:11 +01:00
|
|
|
_nm_setting_connection_controller_to_dbus, \
|
|
|
|
|
_nm_setting_connection_port_type_to_dbus)); \
|
2021-06-28 23:51:42 +02:00
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_param_spec = g_param_spec_string("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
NULL, \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
2021-06-28 23:51:42 +02:00
|
|
|
\
|
|
|
|
|
(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__); \
|
2023-12-11 11:59:25 +01:00
|
|
|
})
|
2021-06-28 19:17:19 +02:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-20 10:53:39 +02:00
|
|
|
|
2021-10-27 20:24:17 +02:00
|
|
|
#define _nm_setting_property_define_direct_bytes(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
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_SECRET | NM_SETTING_PARAM_INFERRABLE \
|
|
|
|
|
| NM_SETTING_PARAM_FUZZY_IGNORE))); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_param_spec = g_param_spec_boxed("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
G_TYPE_BYTES, \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
2021-10-27 20:24:17 +02:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_bytes, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(GBytes *, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-02-19 14:39:25 +01:00
|
|
|
#define _nm_setting_property_define_direct_strv(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
property_type, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
({ \
|
|
|
|
|
GParamSpec *_param_spec; \
|
|
|
|
|
const NMSettInfoPropertType *_property_type; \
|
|
|
|
|
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_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
|
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
_property_type = (property_type) ?: &nm_sett_info_propert_type_direct_strv; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj((properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
_property_type, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(NMValueStrv, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
2024-02-15 13:51:40 +01:00
|
|
|
})
|
2022-01-24 17:10:34 +01:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-02-20 14:50:15 +00:00
|
|
|
/* Define a direct property of type enum, but using `int` as type in the underlying
|
|
|
|
|
* GObject property. This is the preferred way to define enum properties because using
|
|
|
|
|
* real enums it is not possible to maintain backwards compatibility with clients
|
|
|
|
|
* using an old libnm (glib asserts against new values of the enum not being valid).
|
|
|
|
|
* The main difference from define_direct_real_enum is that this will accept any
|
|
|
|
|
* integer value, and we'll check that it's valid in #NMSetting::verify, as doing
|
|
|
|
|
* 'verify' is optional for clients. */
|
2024-01-22 14:58:56 +01:00
|
|
|
#define _nm_setting_property_define_direct_enum(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
gtype_enum, \
|
|
|
|
|
default_value, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
property_type, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
({ \
|
|
|
|
|
GParamSpec *_param_spec; \
|
|
|
|
|
const NMSettInfoPropertType *_property_type; \
|
|
|
|
|
\
|
|
|
|
|
G_STATIC_ASSERT( \
|
|
|
|
|
!NM_FLAGS_ANY((param_flags), \
|
|
|
|
|
~(NM_SETTING_PARAM_REAPPLY_IMMEDIATELY | NM_SETTING_PARAM_FUZZY_IGNORE \
|
|
|
|
|
| NM_SETTING_PARAM_INFERRABLE))); \
|
|
|
|
|
\
|
2024-02-20 14:50:15 +00:00
|
|
|
nm_assert(G_TYPE_IS_ENUM(gtype_enum)); \
|
|
|
|
|
\
|
|
|
|
|
_param_spec = g_param_spec_int("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
G_MININT32, \
|
|
|
|
|
G_MAXINT32, \
|
|
|
|
|
(default_value), \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
|
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
_property_type = (property_type) ?: &nm_sett_info_propert_type_direct_enum; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
_property_type, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(int, private_struct_type, private_struct_field), \
|
|
|
|
|
.direct_data.enum_gtype = (gtype_enum), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* Define an enum property using real enums in the GObject, not integers. Note that
|
|
|
|
|
* this is not backwards compatible because clients with old libnm will reject
|
|
|
|
|
* newer values of the enum. Generally you want to use define_direct_enum and use this
|
|
|
|
|
* one only for properties that already existed as real enums */
|
|
|
|
|
#define _nm_setting_property_define_direct_real_enum(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
gtype_enum, \
|
|
|
|
|
default_value, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
property_type, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
({ \
|
|
|
|
|
GParamSpec *_param_spec; \
|
|
|
|
|
const NMSettInfoPropertType *_property_type; \
|
|
|
|
|
\
|
|
|
|
|
G_STATIC_ASSERT( \
|
|
|
|
|
!NM_FLAGS_ANY((param_flags), \
|
|
|
|
|
~(NM_SETTING_PARAM_REAPPLY_IMMEDIATELY | NM_SETTING_PARAM_FUZZY_IGNORE \
|
|
|
|
|
| NM_SETTING_PARAM_INFERRABLE))); \
|
|
|
|
|
\
|
|
|
|
|
nm_assert(G_TYPE_IS_ENUM(gtype_enum)); \
|
|
|
|
|
\
|
2024-01-22 14:58:56 +01:00
|
|
|
_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; \
|
|
|
|
|
_property_type = (property_type) ?: &nm_sett_info_propert_type_direct_enum; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
_property_type, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(int, private_struct_type, private_struct_field), \
|
2024-02-20 14:50:15 +00:00
|
|
|
.direct_data.enum_gtype = (gtype_enum), \
|
2024-01-22 14:58:56 +01:00
|
|
|
__VA_ARGS__); \
|
2024-01-22 14:50:13 +01:00
|
|
|
})
|
2021-10-20 10:53:39 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-02-20 14:50:15 +00:00
|
|
|
#define _nm_setting_property_is_valid_direct_enum(property_info) \
|
|
|
|
|
({ \
|
|
|
|
|
const NMSettInfoProperty *_property_info = (property_info); \
|
|
|
|
|
NMValueType direct_nmtype = _property_info->property_type->direct_type; \
|
|
|
|
|
GType direct_gtype = _property_info->direct_data.enum_gtype; \
|
|
|
|
|
GParamSpec *spec = _property_info->param_spec; \
|
|
|
|
|
GType spec_gtype = spec ? spec->value_type : G_TYPE_INVALID; \
|
|
|
|
|
\
|
|
|
|
|
direct_nmtype == NM_VALUE_TYPE_ENUM &&direct_gtype &&G_TYPE_IS_ENUM(direct_gtype) \
|
|
|
|
|
&& NM_IN_SET(spec_gtype, G_TYPE_INT, direct_gtype); \
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-20 16:13:14 +02:00
|
|
|
#define _nm_setting_property_define_direct_ternary_enum(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
param_flags, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
...) \
|
2024-02-20 14:50:15 +00:00
|
|
|
_nm_setting_property_define_direct_real_enum((properties_override), \
|
|
|
|
|
(obj_properties), \
|
|
|
|
|
prop_name, \
|
|
|
|
|
(prop_id), \
|
|
|
|
|
NM_TYPE_TERNARY, \
|
|
|
|
|
NM_TERNARY_DEFAULT, \
|
|
|
|
|
(param_flags), \
|
|
|
|
|
NULL, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
__VA_ARGS__)
|
2021-10-20 16:13:14 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-20 10:53:39 +02:00
|
|
|
#define _nm_setting_property_define_direct_flags(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
gtype_flags, \
|
|
|
|
|
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))); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_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)); \
|
2021-10-20 10:53:39 +02:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_flags, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(guint, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define _nm_setting_property_define_direct_secret_flags(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
... /* extra NMSettInfoProperty fields */) \
|
|
|
|
|
_nm_setting_property_define_direct_flags((properties_override), \
|
|
|
|
|
(obj_properties), \
|
|
|
|
|
prop_name, \
|
|
|
|
|
(prop_id), \
|
|
|
|
|
NM_TYPE_SETTING_SECRET_FLAGS, \
|
|
|
|
|
NM_SETTING_SECRET_FLAG_NONE, \
|
|
|
|
|
NM_SETTING_PARAM_NONE, \
|
|
|
|
|
private_struct_type, \
|
|
|
|
|
private_struct_field, \
|
|
|
|
|
##__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-06-17 22:10:48 +02:00
|
|
|
|
2021-07-13 18:09:13 +02:00
|
|
|
#define _nm_setting_property_define_direct_mac_address(properties_override, \
|
|
|
|
|
obj_properties, \
|
|
|
|
|
prop_name, \
|
|
|
|
|
prop_id, \
|
|
|
|
|
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_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \
|
|
|
|
|
| NM_SETTING_PARAM_INFERRABLE \
|
|
|
|
|
| NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \
|
|
|
|
|
\
|
2023-12-11 12:09:13 +01:00
|
|
|
_param_spec = g_param_spec_string("" prop_name "", \
|
|
|
|
|
"", \
|
|
|
|
|
"", \
|
|
|
|
|
NULL, \
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY \
|
|
|
|
|
| G_PARAM_STATIC_STRINGS | (param_flags)); \
|
2021-07-13 18:09:13 +02:00
|
|
|
\
|
|
|
|
|
(obj_properties)[(prop_id)] = _param_spec; \
|
|
|
|
|
\
|
|
|
|
|
_nm_properties_override_gobj( \
|
|
|
|
|
(properties_override), \
|
|
|
|
|
_param_spec, \
|
|
|
|
|
&nm_sett_info_propert_type_direct_mac_address, \
|
|
|
|
|
.direct_offset = \
|
|
|
|
|
NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \
|
|
|
|
|
__VA_ARGS__); \
|
|
|
|
|
} \
|
|
|
|
|
G_STMT_END
|
|
|
|
|
|
2023-10-25 13:15:58 +02:00
|
|
|
/* 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
|
|
|
|
|
|
2021-07-13 18:09:13 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_setting_use_legacy_property(NMSetting *setting,
|
|
|
|
|
GVariant *connection_dict,
|
2014-11-14 11:46:19 -05:00
|
|
|
const char *legacy_property,
|
|
|
|
|
const char *new_property);
|
|
|
|
|
|
2022-10-07 10:59:02 +02:00
|
|
|
GPtrArray *_nm_setting_need_secrets(NMSetting *setting, gboolean check_rerequest);
|
2014-10-07 08:46:36 +02:00
|
|
|
|
2021-11-09 13:28:54 +01:00
|
|
|
gboolean _nm_setting_should_compare_secret_property(NMSetting *setting,
|
|
|
|
|
NMSetting *other,
|
|
|
|
|
const char *secret_name,
|
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
|
|
|
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);
|
|
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
gboolean _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2022-11-18 17:43:57 +01:00
|
|
|
gboolean _nm_utils_ranges_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_utils_ranges_cmp(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
GVariant *_nm_utils_ranges_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
|
|
|
|
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
NMTernary _nm_setting_ip_config_compare_fcn_addresses(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
|
|
|
|
NMTernary _nm_setting_ip_config_compare_fcn_routes(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2022-10-27 21:10:45 +02:00
|
|
|
NMTernary _nm_setting_ip_config_compare_fcn_dns(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil);
|
|
|
|
|
|
2022-10-21 14:50:27 +02:00
|
|
|
gboolean _nm_sett_info_prop_missing_from_dbus_fcn_cloned_mac_address(
|
|
|
|
|
_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil);
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
|
2022-10-21 14:50:27 +02:00
|
|
|
GVariant *
|
|
|
|
|
_nm_sett_info_prop_to_dbus_fcn_cloned_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
|
libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som
boilerplate to implement the hundereds of properties we have, while
we want that properties have common behaviors and similarities.
Instead of repeatedly spelling out the function arguments, use a macro.
Advantages:
- the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this
is an implementation of a property. You can now grep for these macros
to find all implementation. That was previously rather imprecise, you
could only `git grep '\.to_dbus_fcn'` to find the uses, but not the
implementations.
As the goal is to keep properties "similar", there is a desire to
reduce the number of similar implementations and to find them.
- changing the arguments now no longer will require you to go through
all implementations. At least not, if you merely add an argument that
has a reasonable default behavior and does not require explicit
handling by most implementation.
- it's convenient to be able to patch the argument list to let the
compiler help to reason about something. For example, the
"connection_dict" argument to from_dbus_fcn() is usually unused.
If you'd like to find who uses it, rename the parameter, and
review the (few) compiler errors.
- it does save 573 LOC of boilerplate with no actual logic or useful
information. I argue, that this simplifies the code and review, by
increasing the relative amount of actually meaningful code.
Disadvantages:
- the user no longer directly sees the argument list. They would need
cscope/ctags or an IDE to jump to the macro definition and conveniently
see all arguments.
Also use _nm_nil, so that clang-format interprets this as a function
parameter list. Otherwise, it formats the function differently.
2021-07-26 23:45:31 +02:00
|
|
|
|
2022-10-21 14:50:27 +02:00
|
|
|
gboolean
|
|
|
|
|
_nm_sett_info_prop_from_dbus_fcn_cloned_mac_address(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
|
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
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-12-12 19:36:35 +01:00
|
|
|
void _nm_setting_wireless_normalize_mac_address_randomization(
|
|
|
|
|
NMSettingWireless *s_wifi,
|
|
|
|
|
const char **out_cloned_mac_address,
|
|
|
|
|
NMSettingMacRandomization *out_mac_address_randomization);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#endif /* NM_SETTING_PRIVATE_H */
|