mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 20:20:09 +01:00
all: merge branch 'th/connection-track-setting-rework'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/890
(cherry picked from commit 8f3892ba3e)
This commit is contained in:
commit
2fe9d99fc0
48 changed files with 1166 additions and 457 deletions
|
|
@ -1999,16 +1999,16 @@ nm_manager_remove_device(NMManager *self, const char *ifname, NMDeviceType devic
|
|||
static NMDevice *
|
||||
system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMDeviceFactory * factory;
|
||||
gs_free NMSettingsConnection **connections = NULL;
|
||||
guint i;
|
||||
gs_free char * iface = NULL;
|
||||
const char * parent_spec;
|
||||
NMDevice * device = NULL, *parent = NULL;
|
||||
NMDevice * dev_candidate;
|
||||
GError * error = NULL;
|
||||
NMLogLevel log_level;
|
||||
NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMDeviceFactory * factory;
|
||||
NMSettingsConnection *const *connections;
|
||||
guint i;
|
||||
gs_free char * iface = NULL;
|
||||
const char * parent_spec;
|
||||
NMDevice * device = NULL, *parent = NULL;
|
||||
NMDevice * dev_candidate;
|
||||
GError * error = NULL;
|
||||
NMLogLevel log_level;
|
||||
|
||||
g_return_val_if_fail(NM_IS_MANAGER(self), NULL);
|
||||
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||
|
|
@ -2091,13 +2091,7 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
|||
}
|
||||
|
||||
/* Create backing resources if the device has any autoconnect connections */
|
||||
connections = nm_settings_get_connections_clone(
|
||||
priv->settings,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data,
|
||||
NULL);
|
||||
connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL);
|
||||
for (i = 0; connections[i]; i++) {
|
||||
NMConnection * candidate = nm_settings_connection_get_connection(connections[i]);
|
||||
NMSettingConnection *s_con;
|
||||
|
|
@ -2136,19 +2130,13 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
|||
static void
|
||||
retry_connections_for_parent_device(NMManager *self, NMDevice *device)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
gs_free NMSettingsConnection **connections = NULL;
|
||||
guint i;
|
||||
NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMSettingsConnection *const *connections;
|
||||
guint i;
|
||||
|
||||
g_return_if_fail(device);
|
||||
|
||||
connections = nm_settings_get_connections_clone(
|
||||
priv->settings,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data,
|
||||
NULL);
|
||||
connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL);
|
||||
for (i = 0; connections[i]; i++) {
|
||||
NMSettingsConnection *sett_conn = connections[i];
|
||||
NMConnection * connection = nm_settings_connection_get_connection(sett_conn);
|
||||
|
|
@ -4425,13 +4413,13 @@ find_slaves(NMManager * manager,
|
|||
guint * out_n_slaves,
|
||||
gboolean for_user_request)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(manager);
|
||||
gs_free NMSettingsConnection **all_connections = NULL;
|
||||
guint n_all_connections;
|
||||
guint i;
|
||||
SlaveConnectionInfo * slaves = NULL;
|
||||
guint n_slaves = 0;
|
||||
NMSettingConnection * s_con;
|
||||
NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(manager);
|
||||
NMSettingsConnection *const *all_connections = NULL;
|
||||
guint n_all_connections;
|
||||
guint i;
|
||||
SlaveConnectionInfo * slaves = NULL;
|
||||
guint n_slaves = 0;
|
||||
NMSettingConnection * s_con;
|
||||
gs_unref_hashtable GHashTable *devices = NULL;
|
||||
|
||||
nm_assert(out_n_slaves);
|
||||
|
|
@ -4445,13 +4433,9 @@ find_slaves(NMManager * manager,
|
|||
* even if a slave was already active, it might be deactivated during
|
||||
* master reactivation.
|
||||
*/
|
||||
all_connections = nm_settings_get_connections_clone(
|
||||
priv->settings,
|
||||
&n_all_connections,
|
||||
NULL,
|
||||
NULL,
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data,
|
||||
NULL);
|
||||
all_connections =
|
||||
nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings,
|
||||
&n_all_connections);
|
||||
for (i = 0; i < n_all_connections; i++) {
|
||||
NMSettingsConnection *master_connection = NULL;
|
||||
NMDevice * master_device = NULL, *slave_device;
|
||||
|
|
@ -6918,9 +6902,9 @@ devices_inited_cb(gpointer user_data)
|
|||
gboolean
|
||||
nm_manager_start(NMManager *self, GError **error)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
gs_free NMSettingsConnection **connections = NULL;
|
||||
guint i;
|
||||
NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
NMSettingsConnection *const *connections;
|
||||
guint i;
|
||||
|
||||
nm_device_factory_manager_load_factories(_register_device_factory, self);
|
||||
|
||||
|
|
@ -6978,13 +6962,7 @@ nm_manager_start(NMManager *self, GError **error)
|
|||
NM_SETTINGS_SIGNAL_CONNECTION_UPDATED,
|
||||
G_CALLBACK(connection_updated_cb),
|
||||
self);
|
||||
connections = nm_settings_get_connections_clone(
|
||||
priv->settings,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data,
|
||||
NULL);
|
||||
connections = nm_settings_get_connections_sorted_by_autoconnect_priority(priv->settings, NULL);
|
||||
for (i = 0; connections[i]; i++)
|
||||
connection_changed(self, connections[i]);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@ typedef struct _NMSettingsConnectionPrivate {
|
|||
|
||||
NMConnection *connection;
|
||||
|
||||
struct {
|
||||
NMConnectionSerializationOptions options;
|
||||
GVariant * variant;
|
||||
} getsettings_cached;
|
||||
|
||||
NMSettingsStorage *storage;
|
||||
|
||||
char *filename;
|
||||
|
|
@ -249,6 +254,57 @@ _seen_bssids_hash_new(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_getsettings_cached_clear(NMSettingsConnectionPrivate *priv)
|
||||
{
|
||||
if (nm_clear_pointer(&priv->getsettings_cached.variant, g_variant_unref)) {
|
||||
priv->getsettings_cached.options.timestamp.has = FALSE;
|
||||
priv->getsettings_cached.options.timestamp.val = 0;
|
||||
nm_clear_g_free((gpointer *) &priv->getsettings_cached.options.seen_bssids);
|
||||
}
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
_getsettings_cached_get(NMSettingsConnection *self, const NMConnectionSerializationOptions *options)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE(self);
|
||||
GVariant * variant;
|
||||
|
||||
if (priv->getsettings_cached.variant) {
|
||||
if (nm_connection_serialization_options_equal(&priv->getsettings_cached.options, options)) {
|
||||
#if NM_MORE_ASSERTS > 10
|
||||
gs_unref_variant GVariant *variant2 = NULL;
|
||||
|
||||
variant = nm_connection_to_dbus_full(priv->connection,
|
||||
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET,
|
||||
options);
|
||||
nm_assert(variant);
|
||||
variant2 = g_variant_new("(@a{sa{sv}})", variant);
|
||||
nm_assert(g_variant_equal(priv->getsettings_cached.variant, variant2));
|
||||
#endif
|
||||
return priv->getsettings_cached.variant;
|
||||
}
|
||||
_getsettings_cached_clear(priv);
|
||||
}
|
||||
|
||||
nm_assert(!priv->getsettings_cached.options.seen_bssids);
|
||||
|
||||
variant = nm_connection_to_dbus_full(priv->connection,
|
||||
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET,
|
||||
options);
|
||||
nm_assert(variant);
|
||||
|
||||
priv->getsettings_cached.variant = g_variant_ref_sink(g_variant_new("(@a{sa{sv}})", variant));
|
||||
|
||||
priv->getsettings_cached.options = *options;
|
||||
priv->getsettings_cached.options.seen_bssids =
|
||||
nm_utils_strv_dup_packed(priv->getsettings_cached.options.seen_bssids, -1);
|
||||
|
||||
return priv->getsettings_cached.variant;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMConnection *
|
||||
nm_settings_connection_get_connection(NMSettingsConnection *self)
|
||||
{
|
||||
|
|
@ -280,6 +336,9 @@ _nm_settings_connection_set_connection(NMSettingsConnection * self,
|
|||
priv->connection = g_object_ref(new_connection);
|
||||
nmtst_connection_assert_unchanging(priv->connection);
|
||||
|
||||
_getsettings_cached_clear(priv);
|
||||
_nm_settings_notify_sorted_by_autoconnect_priority_maybe_changed(priv->settings);
|
||||
|
||||
/* note that we only return @connection_old if the new connection actually differs from
|
||||
* before.
|
||||
*
|
||||
|
|
@ -1243,7 +1302,6 @@ get_settings_auth_cb(NMSettingsConnection * self,
|
|||
{
|
||||
gs_free const char ** seen_bssids = NULL;
|
||||
NMConnectionSerializationOptions options = {};
|
||||
GVariant * settings;
|
||||
|
||||
if (error) {
|
||||
g_dbus_method_invocation_return_gerror(context, error);
|
||||
|
|
@ -1270,10 +1328,8 @@ get_settings_auth_cb(NMSettingsConnection * self,
|
|||
* get returned by the GetSecrets method which can be better
|
||||
* protected against leakage of secrets to unprivileged callers.
|
||||
*/
|
||||
settings = nm_connection_to_dbus_full(nm_settings_connection_get_connection(self),
|
||||
NM_CONNECTION_SERIALIZE_WITH_NON_SECRET,
|
||||
&options);
|
||||
g_dbus_method_invocation_return_value(context, g_variant_new("(@a{sa{sv}})", settings));
|
||||
|
||||
g_dbus_method_invocation_return_value(context, _getsettings_cached_get(self, &options));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2084,7 +2140,9 @@ _cmp_last_resort(NMSettingsConnection *a, NMSettingsConnection *b)
|
|||
|
||||
/* hm, same UUID. Use their pointer value to give them a stable
|
||||
* order. */
|
||||
return (a > b) ? -1 : 1;
|
||||
NM_CMP_DIRECT_PTR(a, b);
|
||||
|
||||
return nm_assert_unreachable_val(0);
|
||||
}
|
||||
|
||||
/* sorting for "best" connections.
|
||||
|
|
@ -2125,6 +2183,15 @@ nm_settings_connection_cmp_autoconnect_priority(NMSettingsConnection *a, NMSetti
|
|||
return _cmp_last_resort(a, b);
|
||||
}
|
||||
|
||||
int
|
||||
nm_settings_connection_cmp_autoconnect_priority_with_data(gconstpointer pa,
|
||||
gconstpointer pb,
|
||||
gpointer user_data)
|
||||
{
|
||||
return nm_settings_connection_cmp_autoconnect_priority((NMSettingsConnection *) pa,
|
||||
(NMSettingsConnection *) pb);
|
||||
}
|
||||
|
||||
int
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data(gconstpointer pa,
|
||||
gconstpointer pb,
|
||||
|
|
@ -2185,6 +2252,8 @@ nm_settings_connection_update_timestamp(NMSettingsConnection *self, guint64 time
|
|||
|
||||
_LOGT("timestamp: set timestamp %" G_GUINT64_FORMAT, timestamp);
|
||||
|
||||
_nm_settings_notify_sorted_by_autoconnect_priority_maybe_changed(priv->settings);
|
||||
|
||||
if (!priv->kf_db_timestamps)
|
||||
return;
|
||||
|
||||
|
|
@ -2609,6 +2678,8 @@ dispose(GObject *object)
|
|||
|
||||
g_clear_object(&priv->connection);
|
||||
|
||||
_getsettings_cached_clear(priv);
|
||||
|
||||
nm_clear_pointer(&priv->kf_db_timestamps, nm_key_file_db_unref);
|
||||
nm_clear_pointer(&priv->kf_db_seen_bssids, nm_key_file_db_unref);
|
||||
|
||||
|
|
|
|||
|
|
@ -323,6 +323,9 @@ int nm_settings_connection_cmp_timestamp_p_with_data(gconstpointer pa,
|
|||
gpointer user_data);
|
||||
int nm_settings_connection_cmp_autoconnect_priority(NMSettingsConnection *a,
|
||||
NMSettingsConnection *b);
|
||||
int nm_settings_connection_cmp_autoconnect_priority_with_data(gconstpointer pa,
|
||||
gconstpointer pb,
|
||||
gpointer user_data);
|
||||
int nm_settings_connection_cmp_autoconnect_priority_p_with_data(gconstpointer pa,
|
||||
gconstpointer pb,
|
||||
gpointer user_data);
|
||||
|
|
|
|||
|
|
@ -371,6 +371,7 @@ typedef struct {
|
|||
CList connections_lst_head;
|
||||
|
||||
NMSettingsConnection **connections_cached_list;
|
||||
NMSettingsConnection **connections_cached_list_sorted_by_autoconnect_priority;
|
||||
|
||||
GSList *unmanaged_specs;
|
||||
GSList *unrecognized_specs;
|
||||
|
|
@ -389,6 +390,12 @@ typedef struct {
|
|||
|
||||
bool started : 1;
|
||||
|
||||
/* Whether NMSettingsConnections changed in a way that affects the comparison
|
||||
* with nm_settings_connection_cmp_autoconnect_priority_with_data(). In that case,
|
||||
* we may need to re-sort the connections_cached_list_sorted_by_autoconnect_priority
|
||||
* list. */
|
||||
bool sorted_by_autoconnect_priority_maybe_changed : 1;
|
||||
|
||||
} NMSettingsPrivate;
|
||||
|
||||
struct _NMSettings {
|
||||
|
|
@ -2870,25 +2877,48 @@ impl_settings_reload_connections(NMDBusObject * obj,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
_nm_settings_notify_sorted_by_autoconnect_priority_maybe_changed(NMSettings *self)
|
||||
{
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE(self);
|
||||
|
||||
priv->sorted_by_autoconnect_priority_maybe_changed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_clear_connections_cached_list(NMSettingsPrivate *priv)
|
||||
{
|
||||
if (!priv->connections_cached_list)
|
||||
return;
|
||||
|
||||
nm_assert(priv->connections_len == NM_PTRARRAY_LEN(priv->connections_cached_list));
|
||||
if (priv->connections_cached_list) {
|
||||
nm_assert(priv->connections_len == NM_PTRARRAY_LEN(priv->connections_cached_list));
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
/* set the pointer to a bogus value. This makes it more apparent
|
||||
* if somebody has a reference to the cached list and still uses
|
||||
* it. That is a bug, this code just tries to make it blow up
|
||||
* more eagerly. */
|
||||
memset(priv->connections_cached_list,
|
||||
0x43,
|
||||
sizeof(NMSettingsConnection *) * (priv->connections_len + 1));
|
||||
/* set the pointer to a bogus value. This makes it more apparent
|
||||
* if somebody has a reference to the cached list and still uses
|
||||
* it. That is a bug, this code just tries to make it blow up
|
||||
* more eagerly. */
|
||||
memset(priv->connections_cached_list,
|
||||
0x43,
|
||||
sizeof(NMSettingsConnection *) * (priv->connections_len + 1));
|
||||
#endif
|
||||
|
||||
nm_clear_g_free(&priv->connections_cached_list);
|
||||
nm_clear_g_free(&priv->connections_cached_list);
|
||||
}
|
||||
if (priv->connections_cached_list_sorted_by_autoconnect_priority) {
|
||||
nm_assert(priv->connections_len
|
||||
== NM_PTRARRAY_LEN(priv->connections_cached_list_sorted_by_autoconnect_priority));
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
/* set the pointer to a bogus value. This makes it more apparent
|
||||
* if somebody has a reference to the cached list and still uses
|
||||
* it. That is a bug, this code just tries to make it blow up
|
||||
* more eagerly. */
|
||||
memset(priv->connections_cached_list_sorted_by_autoconnect_priority,
|
||||
0x42,
|
||||
sizeof(NMSettingsConnection *) * (priv->connections_len + 1));
|
||||
#endif
|
||||
|
||||
nm_clear_g_free(&priv->connections_cached_list_sorted_by_autoconnect_priority);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3027,6 +3057,65 @@ nm_settings_get_connections(NMSettings *self, guint *out_len)
|
|||
return priv->connections_cached_list;
|
||||
}
|
||||
|
||||
NMSettingsConnection *const *
|
||||
nm_settings_get_connections_sorted_by_autoconnect_priority(NMSettings *self, guint *out_len)
|
||||
{
|
||||
NMSettingsPrivate *priv;
|
||||
gboolean needs_sort = FALSE;
|
||||
|
||||
g_return_val_if_fail(NM_IS_SETTINGS(self), NULL);
|
||||
|
||||
priv = NM_SETTINGS_GET_PRIVATE(self);
|
||||
|
||||
nm_assert(priv->connections_len == c_list_length(&priv->connections_lst_head));
|
||||
nm_assert(
|
||||
!priv->connections_cached_list_sorted_by_autoconnect_priority
|
||||
|| (priv->connections_len
|
||||
== NM_PTRARRAY_LEN(priv->connections_cached_list_sorted_by_autoconnect_priority)));
|
||||
|
||||
if (!priv->connections_cached_list_sorted_by_autoconnect_priority) {
|
||||
NMSettingsConnection *const *list_cached;
|
||||
guint len;
|
||||
|
||||
list_cached = nm_settings_get_connections(self, &len);
|
||||
priv->connections_cached_list_sorted_by_autoconnect_priority =
|
||||
nm_memdup(list_cached, sizeof(NMSettingsConnection *) * (len + 1));
|
||||
needs_sort = (len > 1);
|
||||
} else if (priv->sorted_by_autoconnect_priority_maybe_changed) {
|
||||
if (!nm_utils_ptrarray_is_sorted(
|
||||
(gconstpointer *) priv->connections_cached_list_sorted_by_autoconnect_priority,
|
||||
priv->connections_len,
|
||||
FALSE,
|
||||
nm_settings_connection_cmp_autoconnect_priority_with_data,
|
||||
NULL)) {
|
||||
/* We cache the sorted list, but we don't monitor all entries whether they
|
||||
* get modified to invalidate the sort order. So every time we have to check
|
||||
* whether the sort order is still correct. The vast majority of the time it
|
||||
* is, and this check is faster than sorting anew. */
|
||||
needs_sort = TRUE;
|
||||
}
|
||||
} else {
|
||||
nm_assert(nm_utils_ptrarray_is_sorted(
|
||||
(gconstpointer *) priv->connections_cached_list_sorted_by_autoconnect_priority,
|
||||
priv->connections_len,
|
||||
TRUE,
|
||||
nm_settings_connection_cmp_autoconnect_priority_with_data,
|
||||
NULL));
|
||||
}
|
||||
|
||||
priv->sorted_by_autoconnect_priority_maybe_changed = FALSE;
|
||||
if (needs_sort) {
|
||||
g_qsort_with_data(priv->connections_cached_list_sorted_by_autoconnect_priority,
|
||||
priv->connections_len,
|
||||
sizeof(NMSettingsConnection *),
|
||||
nm_settings_connection_cmp_autoconnect_priority_p_with_data,
|
||||
NULL);
|
||||
}
|
||||
|
||||
NM_SET_OUT(out_len, priv->connections_len);
|
||||
return priv->connections_cached_list_sorted_by_autoconnect_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_settings_get_connections_clone:
|
||||
* @self: the #NMSetting
|
||||
|
|
@ -3058,9 +3147,13 @@ nm_settings_get_connections_clone(NMSettings * self,
|
|||
|
||||
g_return_val_if_fail(NM_IS_SETTINGS(self), NULL);
|
||||
|
||||
list_cached = nm_settings_get_connections(self, &len);
|
||||
if (sort_compare_func == nm_settings_connection_cmp_autoconnect_priority_p_with_data) {
|
||||
list_cached = nm_settings_get_connections_sorted_by_autoconnect_priority(self, &len);
|
||||
sort_compare_func = NULL;
|
||||
} else
|
||||
list_cached = nm_settings_get_connections(self, &len);
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
#if NM_MORE_ASSERTS > 10
|
||||
nm_assert(list_cached);
|
||||
for (i = 0; i < len; i++)
|
||||
nm_assert(NM_IS_SETTINGS_CONNECTION(list_cached[i]));
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ void nm_settings_add_connection_dbus(NMSettings * self,
|
|||
|
||||
NMSettingsConnection *const *nm_settings_get_connections(NMSettings *settings, guint *out_len);
|
||||
|
||||
NMSettingsConnection *const *
|
||||
nm_settings_get_connections_sorted_by_autoconnect_priority(NMSettings *self, guint *out_len);
|
||||
|
||||
NMSettingsConnection **nm_settings_get_connections_clone(NMSettings * self,
|
||||
guint * out_len,
|
||||
NMSettingsConnectionFilterFunc func,
|
||||
|
|
@ -127,4 +130,6 @@ const char *nm_settings_get_startup_complete_blocked_reason(NMSettings *self,
|
|||
|
||||
void nm_settings_kf_db_write(NMSettings *settings);
|
||||
|
||||
void _nm_settings_notify_sorted_by_autoconnect_priority_maybe_changed(NMSettings *self);
|
||||
|
||||
#endif /* __NM_SETTINGS_H__ */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -4083,10 +4083,9 @@ nm_keyfile_write(NMConnection * connection,
|
|||
nm_auto_unref_keyfile GKeyFile *keyfile = NULL;
|
||||
GError * local = NULL;
|
||||
KeyfileWriterInfo info;
|
||||
gs_free NMSetting **settings = NULL;
|
||||
guint n_settings = 0;
|
||||
guint i;
|
||||
guint j;
|
||||
NMSetting ** settings;
|
||||
int i;
|
||||
guint j;
|
||||
|
||||
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||
g_return_val_if_fail(!error || !*error, NULL);
|
||||
|
|
@ -4124,13 +4123,16 @@ nm_keyfile_write(NMConnection * connection,
|
|||
.user_data = user_data,
|
||||
};
|
||||
|
||||
settings = nm_connection_get_settings(connection, &n_settings);
|
||||
for (i = 0; i < n_settings; i++) {
|
||||
settings = _nm_connection_get_settings_arr(connection);
|
||||
for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) {
|
||||
NMSetting * setting = settings[nm_meta_setting_types_by_priority[i]];
|
||||
const NMSettInfoSetting *sett_info;
|
||||
NMSetting * setting = settings[i];
|
||||
const char * setting_name;
|
||||
const char * setting_alias;
|
||||
|
||||
if (!setting)
|
||||
continue;
|
||||
|
||||
sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting));
|
||||
|
||||
setting_name = sett_info->setting_class->setting_info->setting_name;
|
||||
|
|
|
|||
|
|
@ -519,6 +519,74 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = {
|
|||
},
|
||||
};
|
||||
|
||||
const NMMetaSettingType nm_meta_setting_types_by_priority[] = {
|
||||
|
||||
/* NM_SETTING_PRIORITY_CONNECTION */
|
||||
NM_META_SETTING_TYPE_CONNECTION,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_BASE */
|
||||
NM_META_SETTING_TYPE_6LOWPAN,
|
||||
NM_META_SETTING_TYPE_OLPC_MESH,
|
||||
NM_META_SETTING_TYPE_WIRELESS,
|
||||
NM_META_SETTING_TYPE_WIRED,
|
||||
NM_META_SETTING_TYPE_ADSL,
|
||||
NM_META_SETTING_TYPE_BOND,
|
||||
NM_META_SETTING_TYPE_BRIDGE,
|
||||
NM_META_SETTING_TYPE_CDMA,
|
||||
NM_META_SETTING_TYPE_DUMMY,
|
||||
NM_META_SETTING_TYPE_GENERIC,
|
||||
NM_META_SETTING_TYPE_GSM,
|
||||
NM_META_SETTING_TYPE_INFINIBAND,
|
||||
NM_META_SETTING_TYPE_IP_TUNNEL,
|
||||
NM_META_SETTING_TYPE_MACSEC,
|
||||
NM_META_SETTING_TYPE_MACVLAN,
|
||||
NM_META_SETTING_TYPE_OVS_BRIDGE,
|
||||
NM_META_SETTING_TYPE_OVS_DPDK,
|
||||
NM_META_SETTING_TYPE_OVS_INTERFACE,
|
||||
NM_META_SETTING_TYPE_OVS_PATCH,
|
||||
NM_META_SETTING_TYPE_OVS_PORT,
|
||||
NM_META_SETTING_TYPE_TEAM,
|
||||
NM_META_SETTING_TYPE_TUN,
|
||||
NM_META_SETTING_TYPE_VETH,
|
||||
NM_META_SETTING_TYPE_VLAN,
|
||||
NM_META_SETTING_TYPE_VPN,
|
||||
NM_META_SETTING_TYPE_VRF,
|
||||
NM_META_SETTING_TYPE_VXLAN,
|
||||
NM_META_SETTING_TYPE_WIFI_P2P,
|
||||
NM_META_SETTING_TYPE_WIMAX,
|
||||
NM_META_SETTING_TYPE_WIREGUARD,
|
||||
NM_META_SETTING_TYPE_WPAN,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_NON_BASE */
|
||||
NM_META_SETTING_TYPE_BLUETOOTH,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_AUX */
|
||||
NM_META_SETTING_TYPE_WIRELESS_SECURITY,
|
||||
NM_META_SETTING_TYPE_802_1X,
|
||||
NM_META_SETTING_TYPE_DCB,
|
||||
NM_META_SETTING_TYPE_SERIAL,
|
||||
NM_META_SETTING_TYPE_SRIOV,
|
||||
|
||||
/* NM_SETTING_PRIORITY_AUX */
|
||||
NM_META_SETTING_TYPE_BRIDGE_PORT,
|
||||
NM_META_SETTING_TYPE_ETHTOOL,
|
||||
NM_META_SETTING_TYPE_MATCH,
|
||||
NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS,
|
||||
NM_META_SETTING_TYPE_PPP,
|
||||
NM_META_SETTING_TYPE_PPPOE,
|
||||
NM_META_SETTING_TYPE_TEAM_PORT,
|
||||
|
||||
/* NM_SETTING_PRIORITY_IP */
|
||||
NM_META_SETTING_TYPE_HOSTNAME,
|
||||
NM_META_SETTING_TYPE_IP4_CONFIG,
|
||||
NM_META_SETTING_TYPE_IP6_CONFIG,
|
||||
NM_META_SETTING_TYPE_PROXY,
|
||||
NM_META_SETTING_TYPE_TC_CONFIG,
|
||||
|
||||
/* NM_SETTING_PRIORITY_USER */
|
||||
NM_META_SETTING_TYPE_USER,
|
||||
};
|
||||
|
||||
const NMMetaSettingInfo *
|
||||
nm_meta_setting_infos_by_name(const char *name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -187,11 +187,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSetting8021x {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSetting8021xClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingAdsl {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingAdslClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingBluetooth {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingBluetoothClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingBond {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingBondClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingBridgePort {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingBridgePortClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingCdma {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingCdmaClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingConnection {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingConnectionClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingDcb {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingDcbClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@
|
|||
*/
|
||||
struct _NMSettingDummy {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingDummyClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingGeneric {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingGenericClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingGsm {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingGsmClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingInfiniband {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingInfinibandClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingIPTunnel {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingIPTunnelClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingIP4Config {
|
||||
NMSettingIPConfig parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingIP4ConfigClass {
|
||||
NMSettingIPConfigClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingIP6Config {
|
||||
NMSettingIPConfig parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingIP6ConfigClass {
|
||||
NMSettingIPConfigClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingMacsec {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingMacsecClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingMacvlan {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingMacvlanClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingOlpcMesh {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingOlpcMeshClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingPpp {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingPppClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingPppoe {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingPppoeClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,22 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
NMConnection *self;
|
||||
|
||||
NMSetting *settings[_NM_META_SETTING_TYPE_NUM];
|
||||
|
||||
/* D-Bus path of the connection, if any */
|
||||
char *path;
|
||||
} NMConnectionPrivate;
|
||||
|
||||
extern GTypeClass *_nm_simple_connection_class_instance;
|
||||
extern int _nm_simple_connection_private_offset;
|
||||
|
||||
void _nm_connection_private_clear(NMConnectionPrivate *priv);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* NMSetting:
|
||||
*
|
||||
|
|
@ -27,12 +43,14 @@
|
|||
*/
|
||||
struct _NMSetting {
|
||||
GObject parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingClass {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Virtual functions */
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
|
||||
int (*verify)(NMSetting *setting, NMConnection *connection, GError **error);
|
||||
|
||||
gboolean (*verify_secrets)(NMSetting *setting, NMConnection *connection, GError **error);
|
||||
|
|
@ -51,7 +69,6 @@ struct _NMSettingClass {
|
|||
NMSettingSecretFlags flags,
|
||||
GError ** error);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info,
|
||||
guint property_idx,
|
||||
NMSetting * setting,
|
||||
|
|
@ -64,7 +81,6 @@ struct _NMSettingClass {
|
|||
*
|
||||
* @other may be %NULL, in which case the function only determines whether
|
||||
* the setting should be compared (TRUE) or not (DEFAULT). */
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
NMTernary (*compare_property)(const struct _NMSettInfoSetting *sett_info,
|
||||
guint property_idx,
|
||||
NMConnection * con_a,
|
||||
|
|
@ -73,21 +89,17 @@ struct _NMSettingClass {
|
|||
NMSetting * set_b,
|
||||
NMSettingCompareFlags flags);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info,
|
||||
NMSetting * src,
|
||||
NMSetting * dst);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
void (*enumerate_values)(const struct _NMSettInfoProperty *property_info,
|
||||
NMSetting * setting,
|
||||
NMSettingValueIterFn func,
|
||||
gpointer user_data);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gboolean (*aggregate)(NMSetting *setting, int type_i, gpointer arg);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
void (*for_each_secret)(NMSetting * setting,
|
||||
const char * secret_name,
|
||||
GVariant * val,
|
||||
|
|
@ -96,7 +108,6 @@ struct _NMSettingClass {
|
|||
gpointer callback_data,
|
||||
GVariantBuilder * setting_builder);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gboolean (*init_from_dbus)(NMSetting * setting,
|
||||
GHashTable * keys,
|
||||
GVariant * setting_dict,
|
||||
|
|
@ -104,10 +115,8 @@ struct _NMSettingClass {
|
|||
guint /* NMSettingParseFlags */ parse_flags,
|
||||
GError ** error);
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[1];
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
const struct _NMMetaSettingInfo *setting_info;
|
||||
};
|
||||
|
||||
|
|
@ -132,6 +141,60 @@ struct _NMSettingIPConfigClass {
|
|||
NMSettingPriority _nm_setting_get_base_type_priority(NMSetting *setting);
|
||||
int _nm_setting_compare_priority(gconstpointer a, gconstpointer b);
|
||||
|
||||
int _nmtst_nm_setting_sort(NMSetting *a, NMSetting *b);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _nm_assert_setting_info(setting_info, gtype) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
const NMMetaSettingInfo *_setting_info = (setting_info); \
|
||||
\
|
||||
if (NM_MORE_ASSERTS > 0) { \
|
||||
GType _gtype = (gtype); \
|
||||
\
|
||||
nm_assert(_setting_info); \
|
||||
nm_assert(_NM_INT_NOT_NEGATIVE(_setting_info->meta_type)); \
|
||||
nm_assert(_setting_info->meta_type < _NM_META_SETTING_TYPE_NUM); \
|
||||
nm_assert(_setting_info->get_setting_gtype); \
|
||||
if (_gtype != 0) \
|
||||
nm_assert(_setting_info->get_setting_gtype() == _gtype); \
|
||||
else \
|
||||
_gtype = _setting_info->get_setting_gtype(); \
|
||||
nm_assert(g_type_is_a(_gtype, NM_TYPE_SETTING)); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
static inline const NMMetaSettingInfo *
|
||||
_nm_meta_setting_info_from_class(NMSettingClass *klass)
|
||||
{
|
||||
const NMMetaSettingInfo *setting_info;
|
||||
|
||||
if (!NM_IS_SETTING_CLASS(klass))
|
||||
return NULL;
|
||||
|
||||
setting_info = klass->setting_info;
|
||||
if (!setting_info)
|
||||
return NULL;
|
||||
|
||||
_nm_assert_setting_info(setting_info, G_OBJECT_CLASS_TYPE(klass));
|
||||
return setting_info;
|
||||
}
|
||||
|
||||
static inline const NMMetaSettingInfo *
|
||||
_nm_meta_setting_info_from_gtype(GType gtype)
|
||||
{
|
||||
const NMMetaSettingInfo *setting_info;
|
||||
|
||||
setting_info = nm_meta_setting_infos_by_gtype(gtype);
|
||||
if (!setting_info)
|
||||
return NULL;
|
||||
|
||||
_nm_assert_setting_info(setting_info, gtype);
|
||||
return setting_info;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void _nm_setting_emit_property_changed(NMSetting *setting);
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingSerial {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingSerialClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingTeamPort {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingTeamPortClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -742,11 +742,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingTeam {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingTeamClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingTun {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingTunClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingVlan {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingVlanClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,11 +81,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingVpn {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingVpnClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,11 +67,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingVxlan {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingVxlanClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingWimax {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingWimaxClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -76,11 +76,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingWired {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingWiredClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingWirelessSecurity {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingWirelessSecurityClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -73,11 +73,11 @@ typedef struct {
|
|||
*/
|
||||
struct _NMSettingWireless {
|
||||
NMSetting parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSettingWirelessClass {
|
||||
NMSettingClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,16 +20,21 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
GTypeClass *_nm_simple_connection_class_instance = NULL;
|
||||
int _nm_simple_connection_private_offset;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* NMSimpleConnection:
|
||||
*/
|
||||
struct _NMSimpleConnection {
|
||||
GObject parent;
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
};
|
||||
|
||||
struct _NMSimpleConnectionClass {
|
||||
GObjectClass parent;
|
||||
|
||||
/* In the past, this struct was public API. Preserve ABI! */
|
||||
gpointer padding[4];
|
||||
};
|
||||
|
|
@ -42,11 +47,20 @@ G_DEFINE_TYPE_WITH_CODE(NMSimpleConnection,
|
|||
G_IMPLEMENT_INTERFACE(NM_TYPE_CONNECTION,
|
||||
nm_simple_connection_interface_init);)
|
||||
|
||||
#define _GET_PRIVATE(self) \
|
||||
G_TYPE_INSTANCE_GET_PRIVATE(self, NM_TYPE_SIMPLE_CONNECTION, NMConnectionPrivate)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_simple_connection_init(NMSimpleConnection *self)
|
||||
{}
|
||||
{
|
||||
NMConnectionPrivate *priv;
|
||||
|
||||
priv = _GET_PRIVATE(self);
|
||||
|
||||
priv->self = (NMConnection *) self;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_simple_connection_new:
|
||||
|
|
@ -143,22 +157,31 @@ nm_simple_connection_new_clone(NMConnection *connection)
|
|||
static void
|
||||
dispose(GObject *object)
|
||||
{
|
||||
NMConnection *connection = NM_CONNECTION(object);
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
g_signal_handlers_disconnect_by_data(object,
|
||||
(gpointer) &_nmtst_connection_unchanging_user_data);
|
||||
#endif
|
||||
|
||||
nm_connection_clear_secrets(NM_CONNECTION(object));
|
||||
nm_connection_clear_secrets(connection);
|
||||
|
||||
_nm_connection_private_clear(_GET_PRIVATE(connection));
|
||||
|
||||
G_OBJECT_CLASS(nm_simple_connection_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_simple_connection_class_init(NMSimpleConnectionClass *simple_class)
|
||||
nm_simple_connection_class_init(NMSimpleConnectionClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(simple_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
g_type_class_add_private(klass, sizeof(NMConnectionPrivate));
|
||||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
_nm_simple_connection_private_offset = g_type_class_get_instance_private_offset(klass);
|
||||
_nm_simple_connection_class_instance = (GTypeClass *) klass;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -109,6 +109,61 @@ _connection_new_from_dbus_strict(GVariant *dict, gboolean normalize)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_nm_meta_setting_types_by_priority(void)
|
||||
{
|
||||
gs_unref_ptrarray GPtrArray *arr = NULL;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
G_STATIC_ASSERT_EXPR(_NM_META_SETTING_TYPE_NUM
|
||||
== G_N_ELEMENTS(nm_meta_setting_types_by_priority));
|
||||
|
||||
G_STATIC_ASSERT_EXPR(_NM_META_SETTING_TYPE_NUM == 51);
|
||||
|
||||
arr = g_ptr_array_new_with_free_func(g_object_unref);
|
||||
|
||||
for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) {
|
||||
const NMMetaSettingType meta_type = nm_meta_setting_types_by_priority[i];
|
||||
const NMMetaSettingInfo *setting_info;
|
||||
NMSetting * setting;
|
||||
|
||||
g_assert(_NM_INT_NOT_NEGATIVE(meta_type));
|
||||
g_assert(meta_type < _NM_META_SETTING_TYPE_NUM);
|
||||
|
||||
setting_info = &nm_meta_setting_infos[meta_type];
|
||||
g_assert(setting_info);
|
||||
_nm_assert_setting_info(setting_info, 0);
|
||||
|
||||
for (j = 0; j < i; j++)
|
||||
g_assert_cmpint(nm_meta_setting_types_by_priority[j], !=, meta_type);
|
||||
|
||||
setting = g_object_new(setting_info->get_setting_gtype(), NULL);
|
||||
g_assert(NM_IS_SETTING(setting));
|
||||
|
||||
g_ptr_array_add(arr, setting);
|
||||
}
|
||||
|
||||
for (i = 1; i < _NM_META_SETTING_TYPE_NUM; i++) {
|
||||
NMSetting *setting = arr->pdata[i];
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
NMSetting *other = arr->pdata[j];
|
||||
|
||||
if (_nmtst_nm_setting_sort(other, setting) >= 0) {
|
||||
g_error("sort order for nm_meta_setting_types_by_priority[%d vs %d] is wrong: %s "
|
||||
"should be before %s",
|
||||
j,
|
||||
i,
|
||||
nm_setting_get_name(setting),
|
||||
nm_setting_get_name(other));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static char *
|
||||
_create_random_ipaddr(int addr_family, gboolean as_service)
|
||||
{
|
||||
|
|
@ -4593,6 +4648,9 @@ main(int argc, char **argv)
|
|||
|
||||
g_test_add_func("/libnm/test_connection_uuid", test_connection_uuid);
|
||||
|
||||
g_test_add_func("/libnm/settings/test_nm_meta_setting_types_by_priority",
|
||||
test_nm_meta_setting_types_by_priority);
|
||||
|
||||
g_test_add_data_func("/libnm/setting-8021x/key-and-cert",
|
||||
"test_key_and_cert.pem, test",
|
||||
test_8021x);
|
||||
|
|
|
|||
|
|
@ -180,6 +180,8 @@ NM_TERNARY_TO_OPTION_BOOL(NMTernary v)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMSetting **_nm_connection_get_settings_arr(NMConnection *connection);
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PARSE_FLAGS_NONE = 0,
|
||||
NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
|
||||
|
|
@ -205,10 +207,13 @@ typedef struct {
|
|||
bool has;
|
||||
} timestamp;
|
||||
|
||||
const char **seen_bssids;
|
||||
const char *const *seen_bssids;
|
||||
|
||||
} NMConnectionSerializationOptions;
|
||||
|
||||
gboolean nm_connection_serialization_options_equal(const NMConnectionSerializationOptions *a,
|
||||
const NMConnectionSerializationOptions *b);
|
||||
|
||||
GVariant *nm_connection_to_dbus_full(NMConnection * connection,
|
||||
NMConnectionSerializationFlags flags,
|
||||
const NMConnectionSerializationOptions *options);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ extern const NMSetting8021xSchemeVtable
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
typedef enum _nm_packed {
|
||||
/* the enum (and their numeric values) are internal API. Do not assign
|
||||
* any meaning the numeric values, because they already have one:
|
||||
*
|
||||
|
|
@ -175,6 +175,8 @@ typedef struct _NMMetaSettingInfo_Alias NMMetaSettingInfo;
|
|||
|
||||
extern const NMMetaSettingInfo nm_meta_setting_infos[_NM_META_SETTING_TYPE_NUM + 1];
|
||||
|
||||
extern const NMMetaSettingType nm_meta_setting_types_by_priority[_NM_META_SETTING_TYPE_NUM];
|
||||
|
||||
const NMMetaSettingInfo *nm_meta_setting_infos_by_name(const char *name);
|
||||
const NMMetaSettingInfo *nm_meta_setting_infos_by_gtype(GType gtype);
|
||||
|
||||
|
|
|
|||
|
|
@ -3948,6 +3948,28 @@ nm_utils_ptrarray_find_first(gconstpointer *list, gssize len, gconstpointer need
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_utils_ptrarray_is_sorted(gconstpointer * list,
|
||||
gsize len,
|
||||
gboolean require_strict,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
for (i = 1; i < len; i++) {
|
||||
int c;
|
||||
|
||||
c = cmpfcn(list[i - 1], list[i], user_data);
|
||||
if (G_LIKELY(c < 0))
|
||||
continue;
|
||||
|
||||
if (c > 0 || require_strict)
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gssize
|
||||
nm_utils_ptrarray_find_binary_search(gconstpointer * list,
|
||||
gsize len,
|
||||
|
|
|
|||
|
|
@ -556,6 +556,7 @@ extern const void *const _NM_PTRARRAY_EMPTY[1];
|
|||
|
||||
#define NM_PTRARRAY_EMPTY(type) ((type const *) _NM_PTRARRAY_EMPTY)
|
||||
#define NM_STRV_EMPTY() ((char **) _NM_PTRARRAY_EMPTY)
|
||||
#define NM_STRV_EMPTY_CC() NM_PTRARRAY_EMPTY(const char *)
|
||||
|
||||
static inline void
|
||||
_nm_utils_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
|
||||
|
|
@ -2133,6 +2134,12 @@ nm_g_hash_table_remove(GHashTable *hash, gconstpointer key)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_utils_ptrarray_is_sorted(gconstpointer * list,
|
||||
gsize len,
|
||||
gboolean require_strict,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
|
||||
gssize nm_utils_ptrarray_find_binary_search(gconstpointer * list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
|
|
|
|||
|
|
@ -519,6 +519,74 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = {
|
|||
},
|
||||
};
|
||||
|
||||
const NMMetaSettingType nm_meta_setting_types_by_priority[] = {
|
||||
|
||||
/* NM_SETTING_PRIORITY_CONNECTION */
|
||||
NM_META_SETTING_TYPE_CONNECTION,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_BASE */
|
||||
NM_META_SETTING_TYPE_6LOWPAN,
|
||||
NM_META_SETTING_TYPE_OLPC_MESH,
|
||||
NM_META_SETTING_TYPE_WIRELESS,
|
||||
NM_META_SETTING_TYPE_WIRED,
|
||||
NM_META_SETTING_TYPE_ADSL,
|
||||
NM_META_SETTING_TYPE_BOND,
|
||||
NM_META_SETTING_TYPE_BRIDGE,
|
||||
NM_META_SETTING_TYPE_CDMA,
|
||||
NM_META_SETTING_TYPE_DUMMY,
|
||||
NM_META_SETTING_TYPE_GENERIC,
|
||||
NM_META_SETTING_TYPE_GSM,
|
||||
NM_META_SETTING_TYPE_INFINIBAND,
|
||||
NM_META_SETTING_TYPE_IP_TUNNEL,
|
||||
NM_META_SETTING_TYPE_MACSEC,
|
||||
NM_META_SETTING_TYPE_MACVLAN,
|
||||
NM_META_SETTING_TYPE_OVS_BRIDGE,
|
||||
NM_META_SETTING_TYPE_OVS_DPDK,
|
||||
NM_META_SETTING_TYPE_OVS_INTERFACE,
|
||||
NM_META_SETTING_TYPE_OVS_PATCH,
|
||||
NM_META_SETTING_TYPE_OVS_PORT,
|
||||
NM_META_SETTING_TYPE_TEAM,
|
||||
NM_META_SETTING_TYPE_TUN,
|
||||
NM_META_SETTING_TYPE_VETH,
|
||||
NM_META_SETTING_TYPE_VLAN,
|
||||
NM_META_SETTING_TYPE_VPN,
|
||||
NM_META_SETTING_TYPE_VRF,
|
||||
NM_META_SETTING_TYPE_VXLAN,
|
||||
NM_META_SETTING_TYPE_WIFI_P2P,
|
||||
NM_META_SETTING_TYPE_WIMAX,
|
||||
NM_META_SETTING_TYPE_WIREGUARD,
|
||||
NM_META_SETTING_TYPE_WPAN,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_NON_BASE */
|
||||
NM_META_SETTING_TYPE_BLUETOOTH,
|
||||
|
||||
/* NM_SETTING_PRIORITY_HW_AUX */
|
||||
NM_META_SETTING_TYPE_WIRELESS_SECURITY,
|
||||
NM_META_SETTING_TYPE_802_1X,
|
||||
NM_META_SETTING_TYPE_DCB,
|
||||
NM_META_SETTING_TYPE_SERIAL,
|
||||
NM_META_SETTING_TYPE_SRIOV,
|
||||
|
||||
/* NM_SETTING_PRIORITY_AUX */
|
||||
NM_META_SETTING_TYPE_BRIDGE_PORT,
|
||||
NM_META_SETTING_TYPE_ETHTOOL,
|
||||
NM_META_SETTING_TYPE_MATCH,
|
||||
NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS,
|
||||
NM_META_SETTING_TYPE_PPP,
|
||||
NM_META_SETTING_TYPE_PPPOE,
|
||||
NM_META_SETTING_TYPE_TEAM_PORT,
|
||||
|
||||
/* NM_SETTING_PRIORITY_IP */
|
||||
NM_META_SETTING_TYPE_HOSTNAME,
|
||||
NM_META_SETTING_TYPE_IP4_CONFIG,
|
||||
NM_META_SETTING_TYPE_IP6_CONFIG,
|
||||
NM_META_SETTING_TYPE_PROXY,
|
||||
NM_META_SETTING_TYPE_TC_CONFIG,
|
||||
|
||||
/* NM_SETTING_PRIORITY_USER */
|
||||
NM_META_SETTING_TYPE_USER,
|
||||
};
|
||||
|
||||
const NMMetaSettingInfo *
|
||||
nm_meta_setting_infos_by_name(const char *name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ extern const NMSetting8021xSchemeVtable
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
typedef enum _nm_packed {
|
||||
/* the enum (and their numeric values) are internal API. Do not assign
|
||||
* any meaning the numeric values, because they already have one:
|
||||
*
|
||||
|
|
@ -175,6 +175,8 @@ typedef struct _NMMetaSettingInfo_Alias NMMetaSettingInfo;
|
|||
|
||||
extern const NMMetaSettingInfo nm_meta_setting_infos[_NM_META_SETTING_TYPE_NUM + 1];
|
||||
|
||||
extern const NMMetaSettingType nm_meta_setting_types_by_priority[_NM_META_SETTING_TYPE_NUM];
|
||||
|
||||
const NMMetaSettingInfo *nm_meta_setting_infos_by_name(const char *name);
|
||||
const NMMetaSettingInfo *nm_meta_setting_infos_by_gtype(GType gtype);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue