mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 11:58:12 +02:00
libnm: merge branch 'th/connection-get-setting-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1618 (cherry picked from commit20cf4ff31a) (cherry picked from commit4f6ba7f601)
This commit is contained in:
commit
cf5d8a41e3
5 changed files with 113 additions and 85 deletions
|
|
@ -361,6 +361,20 @@ nm_settings_connection_get_connection(NMSettingsConnection *self)
|
||||||
return NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->connection;
|
return NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
nm_settings_connection_get_setting(NMSettingsConnection *self, NMMetaSettingType meta_type)
|
||||||
|
{
|
||||||
|
NMConnection *connection;
|
||||||
|
|
||||||
|
nm_assert(NM_IS_SETTINGS_CONNECTION(self));
|
||||||
|
|
||||||
|
connection = NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->connection;
|
||||||
|
|
||||||
|
nm_assert(NM_IS_SIMPLE_CONNECTION(connection));
|
||||||
|
|
||||||
|
return _nm_connection_get_setting_by_metatype_unsafe(connection, meta_type);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_nm_settings_connection_set_connection(NMSettingsConnection *self,
|
_nm_settings_connection_set_connection(NMSettingsConnection *self,
|
||||||
NMConnection *new_connection,
|
NMConnection *new_connection,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#ifndef __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
#ifndef __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
||||||
#define __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
#define __NETWORKMANAGER_SETTINGS_CONNECTION_H__
|
||||||
|
|
||||||
|
#include "libnm-core-intern/nm-meta-setting-base.h"
|
||||||
|
|
||||||
#include "nm-dbus-object.h"
|
#include "nm-dbus-object.h"
|
||||||
#include "nm-connection.h"
|
#include "nm-connection.h"
|
||||||
|
|
||||||
|
|
@ -218,6 +220,8 @@ GType nm_settings_connection_get_type(void);
|
||||||
NMSettingsConnection *nm_settings_connection_new(void);
|
NMSettingsConnection *nm_settings_connection_new(void);
|
||||||
|
|
||||||
NMConnection *nm_settings_connection_get_connection(NMSettingsConnection *self);
|
NMConnection *nm_settings_connection_get_connection(NMSettingsConnection *self);
|
||||||
|
gpointer nm_settings_connection_get_setting(NMSettingsConnection *self,
|
||||||
|
NMMetaSettingType meta_type);
|
||||||
|
|
||||||
void _nm_settings_connection_set_connection(NMSettingsConnection *self,
|
void _nm_settings_connection_set_connection(NMSettingsConnection *self,
|
||||||
NMConnection *new_connection,
|
NMConnection *new_connection,
|
||||||
|
|
|
||||||
|
|
@ -302,26 +302,7 @@ nm_connection_remove_setting(NMConnection *connection, GType setting_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
_connection_get_setting(NMConnection *connection, GType setting_type)
|
_get_setting_by_metatype(NMConnectionPrivate *priv, NMMetaSettingType meta_type)
|
||||||
{
|
|
||||||
NMSetting *setting;
|
|
||||||
const NMMetaSettingInfo *setting_info;
|
|
||||||
|
|
||||||
nm_assert(NM_IS_CONNECTION(connection));
|
|
||||||
nm_assert(g_type_is_a(setting_type, NM_TYPE_SETTING));
|
|
||||||
|
|
||||||
setting_info = _nm_meta_setting_info_from_gtype(setting_type);
|
|
||||||
if (!setting_info)
|
|
||||||
g_return_val_if_reached(NULL);
|
|
||||||
|
|
||||||
setting = NM_CONNECTION_GET_PRIVATE(connection)->settings[setting_info->meta_type];
|
|
||||||
|
|
||||||
nm_assert(!setting || G_TYPE_CHECK_INSTANCE_TYPE(setting, setting_type));
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpointer
|
|
||||||
_connection_get_setting_by_meta_type(NMConnectionPrivate *priv, NMMetaSettingType meta_type)
|
|
||||||
{
|
{
|
||||||
nm_assert(priv);
|
nm_assert(priv);
|
||||||
nm_assert(_NM_INT_NOT_NEGATIVE(meta_type));
|
nm_assert(_NM_INT_NOT_NEGATIVE(meta_type));
|
||||||
|
|
@ -330,20 +311,15 @@ _connection_get_setting_by_meta_type(NMConnectionPrivate *priv, NMMetaSettingTyp
|
||||||
return priv->settings[meta_type];
|
return priv->settings[meta_type];
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
/* The "unsafe" part here is that _nm_connection_get_setting_by_metatype() has a compile
|
||||||
_connection_get_setting_check(NMConnection *connection, GType setting_type)
|
* time check that meta_type is valid. With the unsafe variant, the caller must ensure that,
|
||||||
|
* and we only get an nm_assert() check -- which is basically nothing. */
|
||||||
|
gpointer
|
||||||
|
_nm_connection_get_setting_by_metatype_unsafe(NMConnection *connection, NMMetaSettingType meta_type)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||||
|
|
||||||
return _connection_get_setting(connection, setting_type);
|
return _get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection), meta_type);
|
||||||
}
|
|
||||||
|
|
||||||
static gpointer
|
|
||||||
_connection_get_setting_by_meta_type_check(NMConnection *connection, NMMetaSettingType meta_type)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
|
||||||
|
|
||||||
return _connection_get_setting_by_meta_type(NM_CONNECTION_GET_PRIVATE(connection), meta_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -360,19 +336,34 @@ _connection_get_setting_by_meta_type_check(NMConnection *connection, NMMetaSetti
|
||||||
NMSetting *
|
NMSetting *
|
||||||
nm_connection_get_setting(NMConnection *connection, GType setting_type)
|
nm_connection_get_setting(NMConnection *connection, GType setting_type)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(g_type_is_a(setting_type, NM_TYPE_SETTING), NULL);
|
NMSetting *setting;
|
||||||
|
const NMMetaSettingInfo *setting_info;
|
||||||
|
|
||||||
return _connection_get_setting_check(connection, setting_type);
|
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||||
|
|
||||||
|
setting_info = _nm_meta_setting_info_from_gtype(setting_type);
|
||||||
|
|
||||||
|
if (!setting_info)
|
||||||
|
g_return_val_if_reached(NULL);
|
||||||
|
|
||||||
|
setting = NM_CONNECTION_GET_PRIVATE(connection)->settings[setting_info->meta_type];
|
||||||
|
|
||||||
|
nm_assert(!setting || G_TYPE_CHECK_INSTANCE_TYPE(setting, setting_type));
|
||||||
|
|
||||||
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
NMSettingIPConfig *
|
NMSettingIPConfig *
|
||||||
nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
|
nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||||
|
|
||||||
nm_assert_addr_family(addr_family);
|
nm_assert_addr_family(addr_family);
|
||||||
|
|
||||||
return NM_SETTING_IP_CONFIG(_connection_get_setting(
|
return NM_SETTING_IP_CONFIG(_get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection),
|
||||||
connection,
|
(addr_family == AF_INET)
|
||||||
(addr_family == AF_INET) ? NM_TYPE_SETTING_IP4_CONFIG : NM_TYPE_SETTING_IP6_CONFIG));
|
? NM_META_SETTING_TYPE_IP4_CONFIG
|
||||||
|
: NM_META_SETTING_TYPE_IP6_CONFIG));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -389,12 +380,14 @@ nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
|
||||||
NMSetting *
|
NMSetting *
|
||||||
nm_connection_get_setting_by_name(NMConnection *connection, const char *name)
|
nm_connection_get_setting_by_name(NMConnection *connection, const char *name)
|
||||||
{
|
{
|
||||||
GType type;
|
const NMMetaSettingInfo *setting_info;
|
||||||
|
|
||||||
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
|
||||||
|
|
||||||
type = nm_setting_lookup_type(name);
|
setting_info = nm_meta_setting_infos_by_name(name);
|
||||||
return type ? _connection_get_setting(connection, type) : NULL;
|
return setting_info ? _get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection),
|
||||||
|
setting_info->meta_type)
|
||||||
|
: NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -1672,8 +1665,8 @@ _normalize_802_1x_empty_strings(NMConnection *self)
|
||||||
NMSetting8021x *s_8021x;
|
NMSetting8021x *s_8021x;
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
s_8021x = _connection_get_setting_by_meta_type(NM_CONNECTION_GET_PRIVATE(self),
|
s_8021x =
|
||||||
NM_META_SETTING_TYPE_802_1X);
|
_get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(self), NM_META_SETTING_TYPE_802_1X);
|
||||||
if (!s_8021x)
|
if (!s_8021x)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
@ -1823,7 +1816,7 @@ _nm_connection_verify(NMConnection *connection, GError **error)
|
||||||
|
|
||||||
priv = NM_CONNECTION_GET_PRIVATE(connection);
|
priv = NM_CONNECTION_GET_PRIVATE(connection);
|
||||||
|
|
||||||
if (!_connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_CONNECTION)) {
|
if (!_get_setting_by_metatype(priv, NM_META_SETTING_TYPE_CONNECTION)) {
|
||||||
g_set_error_literal(error,
|
g_set_error_literal(error,
|
||||||
NM_CONNECTION_ERROR,
|
NM_CONNECTION_ERROR,
|
||||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||||
|
|
@ -1868,9 +1861,9 @@ _nm_connection_verify(NMConnection *connection, GError **error)
|
||||||
g_clear_error(&verify_error);
|
g_clear_error(&verify_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_ip4 = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_IP4_CONFIG);
|
s_ip4 = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_IP4_CONFIG);
|
||||||
s_ip6 = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_IP6_CONFIG);
|
s_ip6 = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_IP6_CONFIG);
|
||||||
s_proxy = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_PROXY);
|
s_proxy = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_PROXY);
|
||||||
|
|
||||||
nm_assert(normalizable_error_type != NM_SETTING_VERIFY_ERROR);
|
nm_assert(normalizable_error_type != NM_SETTING_VERIFY_ERROR);
|
||||||
if (NM_IN_SET(normalizable_error_type,
|
if (NM_IN_SET(normalizable_error_type,
|
||||||
|
|
@ -3231,7 +3224,7 @@ nm_connection_get_virtual_device_description(NMConnection *connection)
|
||||||
NMSetting8021x *
|
NMSetting8021x *
|
||||||
nm_connection_get_setting_802_1x(NMConnection *connection)
|
nm_connection_get_setting_802_1x(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_802_1X);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_802_1X);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3245,7 +3238,7 @@ nm_connection_get_setting_802_1x(NMConnection *connection)
|
||||||
NMSettingBluetooth *
|
NMSettingBluetooth *
|
||||||
nm_connection_get_setting_bluetooth(NMConnection *connection)
|
nm_connection_get_setting_bluetooth(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BLUETOOTH);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BLUETOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3259,7 +3252,7 @@ nm_connection_get_setting_bluetooth(NMConnection *connection)
|
||||||
NMSettingBond *
|
NMSettingBond *
|
||||||
nm_connection_get_setting_bond(NMConnection *connection)
|
nm_connection_get_setting_bond(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BOND);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3273,7 +3266,7 @@ nm_connection_get_setting_bond(NMConnection *connection)
|
||||||
NMSettingTeam *
|
NMSettingTeam *
|
||||||
nm_connection_get_setting_team(NMConnection *connection)
|
nm_connection_get_setting_team(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TEAM);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3287,7 +3280,7 @@ nm_connection_get_setting_team(NMConnection *connection)
|
||||||
NMSettingTeamPort *
|
NMSettingTeamPort *
|
||||||
nm_connection_get_setting_team_port(NMConnection *connection)
|
nm_connection_get_setting_team_port(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TEAM_PORT);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TEAM_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3301,7 +3294,7 @@ nm_connection_get_setting_team_port(NMConnection *connection)
|
||||||
NMSettingBridge *
|
NMSettingBridge *
|
||||||
nm_connection_get_setting_bridge(NMConnection *connection)
|
nm_connection_get_setting_bridge(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BRIDGE);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BRIDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3315,7 +3308,7 @@ nm_connection_get_setting_bridge(NMConnection *connection)
|
||||||
NMSettingCdma *
|
NMSettingCdma *
|
||||||
nm_connection_get_setting_cdma(NMConnection *connection)
|
nm_connection_get_setting_cdma(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_CDMA);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_CDMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3329,7 +3322,7 @@ nm_connection_get_setting_cdma(NMConnection *connection)
|
||||||
NMSettingConnection *
|
NMSettingConnection *
|
||||||
nm_connection_get_setting_connection(NMConnection *connection)
|
nm_connection_get_setting_connection(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_CONNECTION);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3343,7 +3336,7 @@ nm_connection_get_setting_connection(NMConnection *connection)
|
||||||
NMSettingDcb *
|
NMSettingDcb *
|
||||||
nm_connection_get_setting_dcb(NMConnection *connection)
|
nm_connection_get_setting_dcb(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_DCB);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_DCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3359,7 +3352,7 @@ nm_connection_get_setting_dcb(NMConnection *connection)
|
||||||
NMSettingDummy *
|
NMSettingDummy *
|
||||||
nm_connection_get_setting_dummy(NMConnection *connection)
|
nm_connection_get_setting_dummy(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_DUMMY);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_DUMMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3373,7 +3366,7 @@ nm_connection_get_setting_dummy(NMConnection *connection)
|
||||||
NMSettingGeneric *
|
NMSettingGeneric *
|
||||||
nm_connection_get_setting_generic(NMConnection *connection)
|
nm_connection_get_setting_generic(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_GENERIC);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GENERIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3387,7 +3380,7 @@ nm_connection_get_setting_generic(NMConnection *connection)
|
||||||
NMSettingGsm *
|
NMSettingGsm *
|
||||||
nm_connection_get_setting_gsm(NMConnection *connection)
|
nm_connection_get_setting_gsm(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_GSM);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GSM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3401,7 +3394,7 @@ nm_connection_get_setting_gsm(NMConnection *connection)
|
||||||
NMSettingInfiniband *
|
NMSettingInfiniband *
|
||||||
nm_connection_get_setting_infiniband(NMConnection *connection)
|
nm_connection_get_setting_infiniband(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_INFINIBAND);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_INFINIBAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3420,7 +3413,7 @@ nm_connection_get_setting_infiniband(NMConnection *connection)
|
||||||
NMSettingIPConfig *
|
NMSettingIPConfig *
|
||||||
nm_connection_get_setting_ip4_config(NMConnection *connection)
|
nm_connection_get_setting_ip4_config(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP4_CONFIG);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP4_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3436,7 +3429,7 @@ nm_connection_get_setting_ip4_config(NMConnection *connection)
|
||||||
NMSettingIPTunnel *
|
NMSettingIPTunnel *
|
||||||
nm_connection_get_setting_ip_tunnel(NMConnection *connection)
|
nm_connection_get_setting_ip_tunnel(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP_TUNNEL);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP_TUNNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3455,7 +3448,7 @@ nm_connection_get_setting_ip_tunnel(NMConnection *connection)
|
||||||
NMSettingIPConfig *
|
NMSettingIPConfig *
|
||||||
nm_connection_get_setting_ip6_config(NMConnection *connection)
|
nm_connection_get_setting_ip6_config(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP6_CONFIG);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP6_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3471,7 +3464,7 @@ nm_connection_get_setting_ip6_config(NMConnection *connection)
|
||||||
NMSettingMacsec *
|
NMSettingMacsec *
|
||||||
nm_connection_get_setting_macsec(NMConnection *connection)
|
nm_connection_get_setting_macsec(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_MACSEC);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_MACSEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3487,7 +3480,7 @@ nm_connection_get_setting_macsec(NMConnection *connection)
|
||||||
NMSettingMacvlan *
|
NMSettingMacvlan *
|
||||||
nm_connection_get_setting_macvlan(NMConnection *connection)
|
nm_connection_get_setting_macvlan(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_MACVLAN);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_MACVLAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3501,7 +3494,7 @@ nm_connection_get_setting_macvlan(NMConnection *connection)
|
||||||
NMSettingOlpcMesh *
|
NMSettingOlpcMesh *
|
||||||
nm_connection_get_setting_olpc_mesh(NMConnection *connection)
|
nm_connection_get_setting_olpc_mesh(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OLPC_MESH);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OLPC_MESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3517,7 +3510,7 @@ nm_connection_get_setting_olpc_mesh(NMConnection *connection)
|
||||||
NMSettingOvsBridge *
|
NMSettingOvsBridge *
|
||||||
nm_connection_get_setting_ovs_bridge(NMConnection *connection)
|
nm_connection_get_setting_ovs_bridge(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_BRIDGE);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_BRIDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3533,8 +3526,7 @@ nm_connection_get_setting_ovs_bridge(NMConnection *connection)
|
||||||
NMSettingOvsInterface *
|
NMSettingOvsInterface *
|
||||||
nm_connection_get_setting_ovs_interface(NMConnection *connection)
|
nm_connection_get_setting_ovs_interface(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection,
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_INTERFACE);
|
||||||
NM_META_SETTING_TYPE_OVS_INTERFACE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3550,7 +3542,7 @@ nm_connection_get_setting_ovs_interface(NMConnection *connection)
|
||||||
NMSettingOvsPatch *
|
NMSettingOvsPatch *
|
||||||
nm_connection_get_setting_ovs_patch(NMConnection *connection)
|
nm_connection_get_setting_ovs_patch(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_PATCH);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_PATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3566,7 +3558,7 @@ nm_connection_get_setting_ovs_patch(NMConnection *connection)
|
||||||
NMSettingOvsPort *
|
NMSettingOvsPort *
|
||||||
nm_connection_get_setting_ovs_port(NMConnection *connection)
|
nm_connection_get_setting_ovs_port(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_PORT);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3580,7 +3572,7 @@ nm_connection_get_setting_ovs_port(NMConnection *connection)
|
||||||
NMSettingPpp *
|
NMSettingPpp *
|
||||||
nm_connection_get_setting_ppp(NMConnection *connection)
|
nm_connection_get_setting_ppp(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PPP);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3594,7 +3586,7 @@ nm_connection_get_setting_ppp(NMConnection *connection)
|
||||||
NMSettingPppoe *
|
NMSettingPppoe *
|
||||||
nm_connection_get_setting_pppoe(NMConnection *connection)
|
nm_connection_get_setting_pppoe(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PPPOE);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PPPOE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3610,7 +3602,7 @@ nm_connection_get_setting_pppoe(NMConnection *connection)
|
||||||
NMSettingProxy *
|
NMSettingProxy *
|
||||||
nm_connection_get_setting_proxy(NMConnection *connection)
|
nm_connection_get_setting_proxy(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PROXY);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PROXY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3624,7 +3616,7 @@ nm_connection_get_setting_proxy(NMConnection *connection)
|
||||||
NMSettingSerial *
|
NMSettingSerial *
|
||||||
nm_connection_get_setting_serial(NMConnection *connection)
|
nm_connection_get_setting_serial(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_SERIAL);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_SERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3640,7 +3632,7 @@ nm_connection_get_setting_serial(NMConnection *connection)
|
||||||
NMSettingTCConfig *
|
NMSettingTCConfig *
|
||||||
nm_connection_get_setting_tc_config(NMConnection *connection)
|
nm_connection_get_setting_tc_config(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TC_CONFIG);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TC_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3656,7 +3648,7 @@ nm_connection_get_setting_tc_config(NMConnection *connection)
|
||||||
NMSettingTun *
|
NMSettingTun *
|
||||||
nm_connection_get_setting_tun(NMConnection *connection)
|
nm_connection_get_setting_tun(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TUN);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TUN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3670,7 +3662,7 @@ nm_connection_get_setting_tun(NMConnection *connection)
|
||||||
NMSettingVpn *
|
NMSettingVpn *
|
||||||
nm_connection_get_setting_vpn(NMConnection *connection)
|
nm_connection_get_setting_vpn(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VPN);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VPN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3686,7 +3678,7 @@ nm_connection_get_setting_vpn(NMConnection *connection)
|
||||||
NMSettingVxlan *
|
NMSettingVxlan *
|
||||||
nm_connection_get_setting_vxlan(NMConnection *connection)
|
nm_connection_get_setting_vxlan(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VXLAN);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VXLAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3700,7 +3692,7 @@ nm_connection_get_setting_vxlan(NMConnection *connection)
|
||||||
NMSettingWimax *
|
NMSettingWimax *
|
||||||
nm_connection_get_setting_wimax(NMConnection *connection)
|
nm_connection_get_setting_wimax(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIMAX);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIMAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3714,7 +3706,7 @@ nm_connection_get_setting_wimax(NMConnection *connection)
|
||||||
NMSettingWired *
|
NMSettingWired *
|
||||||
nm_connection_get_setting_wired(NMConnection *connection)
|
nm_connection_get_setting_wired(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIRED);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3728,7 +3720,7 @@ nm_connection_get_setting_wired(NMConnection *connection)
|
||||||
NMSettingAdsl *
|
NMSettingAdsl *
|
||||||
nm_connection_get_setting_adsl(NMConnection *connection)
|
nm_connection_get_setting_adsl(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_ADSL);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_ADSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3742,7 +3734,7 @@ nm_connection_get_setting_adsl(NMConnection *connection)
|
||||||
NMSettingWireless *
|
NMSettingWireless *
|
||||||
nm_connection_get_setting_wireless(NMConnection *connection)
|
nm_connection_get_setting_wireless(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIRELESS);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIRELESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3756,8 +3748,8 @@ nm_connection_get_setting_wireless(NMConnection *connection)
|
||||||
NMSettingWirelessSecurity *
|
NMSettingWirelessSecurity *
|
||||||
nm_connection_get_setting_wireless_security(NMConnection *connection)
|
nm_connection_get_setting_wireless_security(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection,
|
return _nm_connection_get_setting_by_metatype(connection,
|
||||||
NM_META_SETTING_TYPE_WIRELESS_SECURITY);
|
NM_META_SETTING_TYPE_WIRELESS_SECURITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3771,7 +3763,7 @@ nm_connection_get_setting_wireless_security(NMConnection *connection)
|
||||||
NMSettingBridgePort *
|
NMSettingBridgePort *
|
||||||
nm_connection_get_setting_bridge_port(NMConnection *connection)
|
nm_connection_get_setting_bridge_port(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BRIDGE_PORT);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BRIDGE_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -3785,7 +3777,7 @@ nm_connection_get_setting_bridge_port(NMConnection *connection)
|
||||||
NMSettingVlan *
|
NMSettingVlan *
|
||||||
nm_connection_get_setting_vlan(NMConnection *connection)
|
nm_connection_get_setting_vlan(NMConnection *connection)
|
||||||
{
|
{
|
||||||
return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VLAN);
|
return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VLAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
NMSettingBluetooth *
|
NMSettingBluetooth *
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,10 @@ nm_setting_lookup_type(const char *name)
|
||||||
{
|
{
|
||||||
const NMMetaSettingInfo *setting_info;
|
const NMMetaSettingInfo *setting_info;
|
||||||
|
|
||||||
|
/* various callers check whether the result is valid with plain `if (gtype)`.
|
||||||
|
* Assert that G_TYPE_INVALID is zero. */
|
||||||
|
G_STATIC_ASSERT(G_TYPE_INVALID == 0);
|
||||||
|
|
||||||
g_return_val_if_fail(name, G_TYPE_INVALID);
|
g_return_val_if_fail(name, G_TYPE_INVALID);
|
||||||
|
|
||||||
setting_info = nm_meta_setting_infos_by_name(name);
|
setting_info = nm_meta_setting_infos_by_name(name);
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,20 @@ _nm_connection_get_setting(NMConnection *connection, GType type)
|
||||||
return (gpointer) nm_connection_get_setting(connection, type);
|
return (gpointer) nm_connection_get_setting(connection, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpointer _nm_connection_get_setting_by_metatype_unsafe(NMConnection *connection,
|
||||||
|
NMMetaSettingType meta_type);
|
||||||
|
|
||||||
|
/* This variant is the most efficient one, because it does not require resolving a
|
||||||
|
* name/GType first. The NMMetaSettingType enum allows for a direct lookup. */
|
||||||
|
#define _nm_connection_get_setting_by_metatype(connection, meta_type) \
|
||||||
|
({ \
|
||||||
|
/* Static assert that meta_type is in the valid range. If you don't want that,
|
||||||
|
* because the argument is no a compile time constant, use _nm_connection_get_setting_by_metatype_unsafe(). */ \
|
||||||
|
G_STATIC_ASSERT((meta_type) < _NM_META_SETTING_TYPE_NUM && ((int) meta_type) >= 0); \
|
||||||
|
\
|
||||||
|
_nm_connection_get_setting_by_metatype_unsafe((connection), (meta_type)); \
|
||||||
|
})
|
||||||
|
|
||||||
NMSettingIPConfig *nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family);
|
NMSettingIPConfig *nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue