mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-21 14:10:25 +01:00
bluetooth: merge branch 'th/bluetooth-nap-bgo783326'
https://bugzilla.gnome.org/show_bug.cgi?id=783326
This commit is contained in:
commit
4649ac1a9c
50 changed files with 400 additions and 466 deletions
|
|
@ -543,23 +543,30 @@ request_secrets_from_ui (NMSecretAgentSimpleRequest *request)
|
|||
TRUE);
|
||||
g_ptr_array_add (secrets, secret);
|
||||
} else if (nm_connection_is_type (request->connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
|
||||
NMSetting *setting;
|
||||
NMSetting *setting = NULL;
|
||||
|
||||
setting = nm_connection_get_setting_by_name (request->connection, NM_SETTING_GSM_SETTING_NAME);
|
||||
if (!setting)
|
||||
setting = nm_connection_get_setting_by_name (request->connection, NM_SETTING_CDMA_SETTING_NAME);
|
||||
setting = nm_connection_get_setting_by_name (request->connection, NM_SETTING_BLUETOOTH_SETTING_NAME);
|
||||
if ( setting
|
||||
&& !nm_streq0 (nm_setting_bluetooth_get_connection_type (NM_SETTING_BLUETOOTH (setting)), NM_SETTING_BLUETOOTH_TYPE_NAP)) {
|
||||
setting = nm_connection_get_setting_by_name (request->connection, NM_SETTING_GSM_SETTING_NAME);
|
||||
if (!setting)
|
||||
setting = nm_connection_get_setting_by_name (request->connection, NM_SETTING_CDMA_SETTING_NAME);
|
||||
}
|
||||
|
||||
title = _("Mobile broadband network password");
|
||||
msg = g_strdup_printf (_("A password is required to connect to '%s'."),
|
||||
nm_connection_get_id (request->connection));
|
||||
if (setting) {
|
||||
title = _("Mobile broadband network password");
|
||||
msg = g_strdup_printf (_("A password is required to connect to '%s'."),
|
||||
nm_connection_get_id (request->connection));
|
||||
|
||||
secret = nm_secret_agent_simple_secret_new (_("Password"),
|
||||
setting,
|
||||
"password",
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE);
|
||||
g_ptr_array_add (secrets, secret);
|
||||
secret = nm_secret_agent_simple_secret_new (_("Password"),
|
||||
setting,
|
||||
"password",
|
||||
NULL,
|
||||
NULL,
|
||||
TRUE);
|
||||
g_ptr_array_add (secrets, secret);
|
||||
} else
|
||||
ok = FALSE;
|
||||
} else if (nm_connection_is_type (request->connection, NM_SETTING_VPN_SETTING_NAME)) {
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
|
|
|
|||
|
|
@ -93,10 +93,16 @@ _setting_release (gpointer key, gpointer value, gpointer user_data)
|
|||
static void
|
||||
_nm_connection_add_setting (NMConnection *connection, NMSetting *setting)
|
||||
{
|
||||
NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
const char *name = G_OBJECT_TYPE_NAME (setting);
|
||||
NMConnectionPrivate *priv;
|
||||
const char *name;
|
||||
NMSetting *s_old;
|
||||
|
||||
nm_assert (NM_IS_CONNECTION (connection));
|
||||
nm_assert (NM_IS_SETTING (setting));
|
||||
|
||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
name = G_OBJECT_TYPE_NAME (setting);
|
||||
|
||||
if ((s_old = g_hash_table_lookup (priv->settings, (gpointer) name)))
|
||||
g_signal_handlers_disconnect_by_func (s_old, setting_changed_cb, connection);
|
||||
g_hash_table_insert (priv->settings, (gpointer) name, setting);
|
||||
|
|
@ -160,6 +166,24 @@ nm_connection_remove_setting (NMConnection *connection, GType setting_type)
|
|||
_nm_connection_remove_setting (connection, setting_type);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
_connection_get_setting (NMConnection *connection, GType setting_type)
|
||||
{
|
||||
nm_assert (NM_IS_CONNECTION (connection));
|
||||
nm_assert (g_type_is_a (setting_type, NM_TYPE_SETTING));
|
||||
|
||||
return g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
|
||||
g_type_name (setting_type));
|
||||
}
|
||||
|
||||
static gpointer
|
||||
_connection_get_setting_check (NMConnection *connection, GType setting_type)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return _connection_get_setting (connection, setting_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting:
|
||||
* @connection: a #NMConnection
|
||||
|
|
@ -174,11 +198,9 @@ nm_connection_remove_setting (NMConnection *connection, GType setting_type)
|
|||
NMSetting *
|
||||
nm_connection_get_setting (NMConnection *connection, GType setting_type)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
g_return_val_if_fail (g_type_is_a (setting_type, NM_TYPE_SETTING), NULL);
|
||||
|
||||
return (NMSetting *) g_hash_table_lookup (NM_CONNECTION_GET_PRIVATE (connection)->settings,
|
||||
g_type_name (setting_type));
|
||||
return _connection_get_setting_check (connection, setting_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,11 +220,9 @@ nm_connection_get_setting_by_name (NMConnection *connection, const char *name)
|
|||
GType type;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
type = nm_setting_lookup_type (name);
|
||||
|
||||
return type ? nm_connection_get_setting (connection, type) : NULL;
|
||||
return type ? _connection_get_setting (connection, type) : NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -585,12 +605,12 @@ _nm_connection_find_base_type_setting (NMConnection *connection)
|
|||
NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
GHashTableIter iter;
|
||||
NMSetting *setting = NULL, *s_iter;
|
||||
guint32 setting_prio, s_iter_prio;
|
||||
NMSettingPriority setting_prio, s_iter_prio;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->settings);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
|
||||
s_iter_prio = _nm_setting_get_base_type_priority (s_iter);
|
||||
if (!s_iter_prio)
|
||||
if (s_iter_prio == NM_SETTING_PRIORITY_INVALID)
|
||||
continue;
|
||||
|
||||
if (setting) {
|
||||
|
|
@ -598,11 +618,14 @@ _nm_connection_find_base_type_setting (NMConnection *connection)
|
|||
continue;
|
||||
} else if (s_iter_prio == setting_prio) {
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
|
||||
const char *type;
|
||||
|
||||
if (!s_con)
|
||||
return NULL;
|
||||
return nm_connection_get_setting_by_name (connection,
|
||||
nm_setting_connection_get_connection_type (s_con));
|
||||
if (s_con) {
|
||||
type = nm_setting_connection_get_connection_type (s_con);
|
||||
if (type)
|
||||
return nm_connection_get_setting_by_name (connection, type);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
setting = s_iter;
|
||||
|
|
@ -1661,16 +1684,9 @@ nm_connection_to_dbus (NMConnection *connection,
|
|||
gboolean
|
||||
nm_connection_is_type (NMConnection *connection, const char *type)
|
||||
{
|
||||
NMSetting *setting;
|
||||
g_return_val_if_fail (type, FALSE);
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
g_return_val_if_fail (type != NULL, FALSE);
|
||||
|
||||
setting = nm_connection_get_setting_by_name (connection, type);
|
||||
if (!setting)
|
||||
return FALSE;
|
||||
|
||||
return !!_nm_setting_get_base_type_priority (setting);
|
||||
return nm_streq0 (type, nm_connection_get_connection_type (connection));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1708,7 +1724,7 @@ nm_connection_for_each_setting_value (NMConnection *connection,
|
|||
guint i, size;
|
||||
|
||||
g_return_if_fail (NM_IS_CONNECTION (connection));
|
||||
g_return_if_fail (func != NULL);
|
||||
g_return_if_fail (func);
|
||||
|
||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
|
|
@ -1782,10 +1798,7 @@ nm_connection_set_path (NMConnection *connection, const char *path)
|
|||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
g_free (priv->path);
|
||||
priv->path = NULL;
|
||||
|
||||
if (path)
|
||||
priv->path = g_strdup (path);
|
||||
priv->path = g_strdup (path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1823,10 +1836,7 @@ nm_connection_get_interface_name (NMConnection *connection)
|
|||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
|
||||
return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1864,13 +1874,8 @@ nm_connection_get_uuid (NMConnection *connection)
|
|||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con)
|
||||
return NULL;
|
||||
|
||||
return nm_setting_connection_get_uuid (s_con);
|
||||
return s_con ? nm_setting_connection_get_uuid (s_con) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1886,32 +1891,25 @@ nm_connection_get_id (NMConnection *connection)
|
|||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con)
|
||||
return NULL;
|
||||
|
||||
return nm_setting_connection_get_id (s_con);
|
||||
return s_con ? nm_setting_connection_get_id (s_con) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_connection_type:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* Returns: the connection's base type.
|
||||
* A shortcut to return the type from the connection's #NMSettingConnection.
|
||||
*
|
||||
* Returns: the type from the connection's 'connection' setting
|
||||
**/
|
||||
const char *
|
||||
nm_connection_get_connection_type (NMConnection *connection)
|
||||
{
|
||||
NMSetting *setting;
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
setting = _nm_connection_find_base_type_setting (connection);
|
||||
if (!setting)
|
||||
return NULL;
|
||||
return nm_setting_get_name (setting);
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
return s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1926,9 +1924,11 @@ nm_connection_get_connection_type (NMConnection *connection)
|
|||
gboolean
|
||||
nm_connection_is_virtual (NMConnection *connection)
|
||||
{
|
||||
const char *type = nm_connection_get_connection_type (connection);
|
||||
const char *type;
|
||||
|
||||
g_return_val_if_fail (type != NULL, FALSE);
|
||||
type = nm_connection_get_connection_type (connection);
|
||||
if (!type)
|
||||
return FALSE;
|
||||
|
||||
if ( !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_DUMMY_SETTING_NAME)
|
||||
|
|
@ -1946,10 +1946,12 @@ nm_connection_is_virtual (NMConnection *connection)
|
|||
NMSettingInfiniband *s_ib;
|
||||
|
||||
s_ib = nm_connection_get_setting_infiniband (connection);
|
||||
g_return_val_if_fail (s_ib != NULL, FALSE);
|
||||
return nm_setting_infiniband_get_virtual_interface_name (s_ib) != NULL;
|
||||
return s_ib && nm_setting_infiniband_get_virtual_interface_name (s_ib);
|
||||
}
|
||||
|
||||
if (nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME))
|
||||
return !!_nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1970,10 +1972,11 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
|
|||
const char *type;
|
||||
const char *iface = NULL, *display_type = NULL;
|
||||
|
||||
iface = nm_connection_get_interface_name (connection);
|
||||
|
||||
type = nm_connection_get_connection_type (connection);
|
||||
g_return_val_if_fail (type != NULL, FALSE);
|
||||
if (!type)
|
||||
return NULL;
|
||||
|
||||
iface = nm_connection_get_interface_name (connection);
|
||||
|
||||
if (!strcmp (type, NM_SETTING_BOND_SETTING_NAME))
|
||||
display_type = _("Bond");
|
||||
|
|
@ -2008,9 +2011,7 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
|
|||
NMSetting8021x *
|
||||
nm_connection_get_setting_802_1x (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_802_1X);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2024,9 +2025,7 @@ nm_connection_get_setting_802_1x (NMConnection *connection)
|
|||
NMSettingBluetooth *
|
||||
nm_connection_get_setting_bluetooth (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_BLUETOOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2040,9 +2039,7 @@ nm_connection_get_setting_bluetooth (NMConnection *connection)
|
|||
NMSettingBond *
|
||||
nm_connection_get_setting_bond (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingBond *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BOND);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_BOND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2056,9 +2053,7 @@ nm_connection_get_setting_bond (NMConnection *connection)
|
|||
NMSettingTeam *
|
||||
nm_connection_get_setting_team (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingTeam *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_TEAM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2072,9 +2067,7 @@ nm_connection_get_setting_team (NMConnection *connection)
|
|||
NMSettingTeamPort *
|
||||
nm_connection_get_setting_team_port (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_TEAM_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2088,9 +2081,7 @@ nm_connection_get_setting_team_port (NMConnection *connection)
|
|||
NMSettingBridge *
|
||||
nm_connection_get_setting_bridge (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingBridge *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_BRIDGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2104,9 +2095,7 @@ nm_connection_get_setting_bridge (NMConnection *connection)
|
|||
NMSettingCdma *
|
||||
nm_connection_get_setting_cdma (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_CDMA);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2120,9 +2109,7 @@ nm_connection_get_setting_cdma (NMConnection *connection)
|
|||
NMSettingConnection *
|
||||
nm_connection_get_setting_connection (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_CONNECTION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2136,9 +2123,7 @@ nm_connection_get_setting_connection (NMConnection *connection)
|
|||
NMSettingDcb *
|
||||
nm_connection_get_setting_dcb (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingDcb *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DCB);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_DCB);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2154,9 +2139,7 @@ nm_connection_get_setting_dcb (NMConnection *connection)
|
|||
NMSettingDummy *
|
||||
nm_connection_get_setting_dummy (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingDummy *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DUMMY);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_DUMMY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2170,9 +2153,7 @@ nm_connection_get_setting_dummy (NMConnection *connection)
|
|||
NMSettingGeneric *
|
||||
nm_connection_get_setting_generic (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingGeneric *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GENERIC);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_GENERIC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2186,9 +2167,7 @@ nm_connection_get_setting_generic (NMConnection *connection)
|
|||
NMSettingGsm *
|
||||
nm_connection_get_setting_gsm (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_GSM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2202,9 +2181,7 @@ nm_connection_get_setting_gsm (NMConnection *connection)
|
|||
NMSettingInfiniband *
|
||||
nm_connection_get_setting_infiniband (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingInfiniband *) nm_connection_get_setting (connection, NM_TYPE_SETTING_INFINIBAND);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_INFINIBAND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2223,9 +2200,7 @@ nm_connection_get_setting_infiniband (NMConnection *connection)
|
|||
NMSettingIPConfig *
|
||||
nm_connection_get_setting_ip4_config (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingIPConfig *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2241,9 +2216,7 @@ nm_connection_get_setting_ip4_config (NMConnection *connection)
|
|||
NMSettingIPTunnel *
|
||||
nm_connection_get_setting_ip_tunnel (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingIPTunnel *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP_TUNNEL);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP_TUNNEL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2262,9 +2235,7 @@ nm_connection_get_setting_ip_tunnel (NMConnection *connection)
|
|||
NMSettingIPConfig *
|
||||
nm_connection_get_setting_ip6_config (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingIPConfig *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2280,9 +2251,7 @@ nm_connection_get_setting_ip6_config (NMConnection *connection)
|
|||
NMSettingMacsec *
|
||||
nm_connection_get_setting_macsec (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingMacsec *) nm_connection_get_setting (connection, NM_TYPE_SETTING_MACSEC);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_MACSEC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2298,9 +2267,7 @@ nm_connection_get_setting_macsec (NMConnection *connection)
|
|||
NMSettingMacvlan *
|
||||
nm_connection_get_setting_macvlan (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingMacvlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_MACVLAN);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_MACVLAN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2314,9 +2281,7 @@ nm_connection_get_setting_macvlan (NMConnection *connection)
|
|||
NMSettingOlpcMesh *
|
||||
nm_connection_get_setting_olpc_mesh (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingOlpcMesh *) nm_connection_get_setting (connection, NM_TYPE_SETTING_OLPC_MESH);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_OLPC_MESH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2330,9 +2295,7 @@ nm_connection_get_setting_olpc_mesh (NMConnection *connection)
|
|||
NMSettingPpp *
|
||||
nm_connection_get_setting_ppp (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingPpp *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_PPP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2346,9 +2309,7 @@ nm_connection_get_setting_ppp (NMConnection *connection)
|
|||
NMSettingPppoe *
|
||||
nm_connection_get_setting_pppoe (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingPppoe *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_PPPOE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2364,9 +2325,7 @@ nm_connection_get_setting_pppoe (NMConnection *connection)
|
|||
NMSettingProxy *
|
||||
nm_connection_get_setting_proxy (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingProxy *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PROXY);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_PROXY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2380,9 +2339,7 @@ nm_connection_get_setting_proxy (NMConnection *connection)
|
|||
NMSettingSerial *
|
||||
nm_connection_get_setting_serial (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_SERIAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2398,9 +2355,7 @@ nm_connection_get_setting_serial (NMConnection *connection)
|
|||
NMSettingTun *
|
||||
nm_connection_get_setting_tun (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingTun *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TUN);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_TUN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2414,9 +2369,7 @@ nm_connection_get_setting_tun (NMConnection *connection)
|
|||
NMSettingVpn *
|
||||
nm_connection_get_setting_vpn (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingVpn *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_VPN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2432,9 +2385,7 @@ nm_connection_get_setting_vpn (NMConnection *connection)
|
|||
NMSettingVxlan *
|
||||
nm_connection_get_setting_vxlan (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingVxlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VXLAN);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_VXLAN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2448,9 +2399,7 @@ nm_connection_get_setting_vxlan (NMConnection *connection)
|
|||
NMSettingWimax *
|
||||
nm_connection_get_setting_wimax (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingWimax *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIMAX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2464,9 +2413,7 @@ nm_connection_get_setting_wimax (NMConnection *connection)
|
|||
NMSettingWired *
|
||||
nm_connection_get_setting_wired (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2480,9 +2427,7 @@ nm_connection_get_setting_wired (NMConnection *connection)
|
|||
NMSettingAdsl *
|
||||
nm_connection_get_setting_adsl (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_ADSL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2496,9 +2441,7 @@ nm_connection_get_setting_adsl (NMConnection *connection)
|
|||
NMSettingWireless *
|
||||
nm_connection_get_setting_wireless (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2512,9 +2455,7 @@ nm_connection_get_setting_wireless (NMConnection *connection)
|
|||
NMSettingWirelessSecurity *
|
||||
nm_connection_get_setting_wireless_security (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2528,9 +2469,7 @@ nm_connection_get_setting_wireless_security (NMConnection *connection)
|
|||
NMSettingBridgePort *
|
||||
nm_connection_get_setting_bridge_port (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingBridgePort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BRIDGE_PORT);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_BRIDGE_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2544,9 +2483,7 @@ nm_connection_get_setting_bridge_port (NMConnection *connection)
|
|||
NMSettingVlan *
|
||||
nm_connection_get_setting_vlan (NMConnection *connection)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
return (NMSettingVlan *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VLAN);
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_VLAN);
|
||||
}
|
||||
|
||||
NMSettingBluetooth *
|
||||
|
|
@ -2585,7 +2522,7 @@ nm_connection_get_private (NMConnection *connection)
|
|||
key = NM_CACHED_QUARK ("NMConnectionPrivate");
|
||||
|
||||
priv = g_object_get_qdata ((GObject *) connection, key);
|
||||
if (!priv) {
|
||||
if (G_UNLIKELY (!priv)) {
|
||||
priv = g_slice_new0 (NMConnectionPrivate);
|
||||
g_object_set_qdata_full ((GObject *) connection, key,
|
||||
priv, (GDestroyNotify) nm_connection_private_free);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,46 @@ NMConnection *_nm_simple_connection_new_from_dbus (GVariant *dict,
|
|||
NMSettingParseFlags parse_flags,
|
||||
GError **error);
|
||||
|
||||
guint32 _nm_setting_get_setting_priority (NMSetting *setting);
|
||||
/*
|
||||
* A setting's priority should roughly follow the OSI layer model, but it also
|
||||
* controls which settings get asked for secrets first. Thus settings which
|
||||
* relate to things that must be working first, like hardware, should get a
|
||||
* higher priority than things which layer on top of the hardware. For example,
|
||||
* the GSM/CDMA settings should provide secrets before the PPP setting does,
|
||||
* because a PIN is required to unlock the device before PPP can even start.
|
||||
* Even settings without secrets should be assigned the right priority.
|
||||
*
|
||||
* 0: reserved for invalid
|
||||
*
|
||||
* 1: reserved for the Connection setting
|
||||
*
|
||||
* 2,3: hardware-related settings like Ethernet, Wi-Fi, InfiniBand, Bridge, etc.
|
||||
* These priority 1 settings are also "base types", which means that at least
|
||||
* one of them is required for the connection to be valid, and their name is
|
||||
* valid in the 'type' property of the Connection setting.
|
||||
*
|
||||
* 4: hardware-related auxiliary settings that require a base setting to be
|
||||
* successful first, like Wi-Fi security, 802.1x, etc.
|
||||
*
|
||||
* 5: hardware-independent settings that are required before IP connectivity
|
||||
* can be established, like PPP, PPPoE, etc.
|
||||
*
|
||||
* 6: IP-level stuff
|
||||
*
|
||||
* 10: NMSettingUser
|
||||
*/
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PRIORITY_INVALID = 0,
|
||||
NM_SETTING_PRIORITY_CONNECTION = 1,
|
||||
NM_SETTING_PRIORITY_HW_BASE = 2,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE = 3,
|
||||
NM_SETTING_PRIORITY_HW_AUX = 4,
|
||||
NM_SETTING_PRIORITY_AUX = 5,
|
||||
NM_SETTING_PRIORITY_IP = 6,
|
||||
NM_SETTING_PRIORITY_USER = 10,
|
||||
} NMSettingPriority;
|
||||
|
||||
NMSettingPriority _nm_setting_get_setting_priority (NMSetting *setting);
|
||||
|
||||
gboolean _nm_setting_get_property (NMSetting *setting, const char *name, GValue *value);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING,
|
||||
_nm_register_setting (802_1X, 3))
|
||||
_nm_register_setting (802_1X, NM_SETTING_PRIORITY_HW_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_802_1X)
|
||||
|
||||
#define NM_SETTING_802_1X_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_802_1X, NMSetting8021xPrivate))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING,
|
||||
_nm_register_setting (ADSL, 1))
|
||||
_nm_register_setting (ADSL, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_ADSL)
|
||||
|
||||
#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate))
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBluetooth, nm_setting_bluetooth, NM_TYPE_SETTING,
|
||||
_nm_register_setting (BLUETOOTH, 2))
|
||||
_nm_register_setting (BLUETOOTH, NM_SETTING_PRIORITY_HW_NON_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BLUETOOTH)
|
||||
|
||||
#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING,
|
||||
_nm_register_setting (BOND, 1))
|
||||
_nm_register_setting (BOND, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BOND)
|
||||
|
||||
#define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBridgePort, nm_setting_bridge_port, NM_TYPE_SETTING,
|
||||
_nm_register_setting (BRIDGE_PORT, 4))
|
||||
_nm_register_setting (BRIDGE_PORT, NM_SETTING_PRIORITY_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE_PORT)
|
||||
|
||||
#define NM_SETTING_BRIDGE_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE_PORT, NMSettingBridgePortPrivate))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING,
|
||||
_nm_register_setting (BRIDGE, 1))
|
||||
_nm_register_setting (BRIDGE, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE)
|
||||
|
||||
#define NM_SETTING_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE, NMSettingBridgePrivate))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingCdma, nm_setting_cdma, NM_TYPE_SETTING,
|
||||
_nm_register_setting (CDMA, 1))
|
||||
_nm_register_setting (CDMA, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CDMA)
|
||||
|
||||
#define NM_SETTING_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CDMA, NMSettingCdmaPrivate))
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING,
|
||||
_nm_register_setting (CONNECTION, 0))
|
||||
_nm_register_setting (CONNECTION, NM_SETTING_PRIORITY_CONNECTION))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_CONNECTION)
|
||||
|
||||
#define NM_SETTING_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_CONNECTION, NMSettingConnectionPrivate))
|
||||
|
|
@ -926,7 +926,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
|
||||
base_type = nm_setting_lookup_type (priv->type);
|
||||
if (base_type == G_TYPE_INVALID || !_nm_setting_type_get_base_type_priority (base_type)) {
|
||||
if ( base_type == G_TYPE_INVALID
|
||||
|| _nm_setting_type_get_base_type_priority (base_type) == NM_SETTING_PRIORITY_INVALID) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingDcb, nm_setting_dcb, NM_TYPE_SETTING,
|
||||
_nm_register_setting (DCB, 3))
|
||||
_nm_register_setting (DCB, NM_SETTING_PRIORITY_HW_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB)
|
||||
|
||||
#define NM_SETTING_DCB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_DCB, NMSettingDcbPrivate))
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingDummy, nm_setting_dummy, NM_TYPE_SETTING,
|
||||
_nm_register_setting (DUMMY, 1))
|
||||
_nm_register_setting (DUMMY, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DUMMY)
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingGeneric, nm_setting_generic, NM_TYPE_SETTING,
|
||||
_nm_register_setting (GENERIC, 1))
|
||||
_nm_register_setting (GENERIC, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GENERIC)
|
||||
|
||||
#define NM_SETTING_GENERIC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GENERIC, NMSettingGenericPrivate))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
*/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING,
|
||||
_nm_register_setting (GSM, 1))
|
||||
_nm_register_setting (GSM, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GSM)
|
||||
|
||||
#define NM_SETTING_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GSM, NMSettingGsmPrivate))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingInfiniband, nm_setting_infiniband, NM_TYPE_SETTING,
|
||||
_nm_register_setting (INFINIBAND, 1))
|
||||
_nm_register_setting (INFINIBAND, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_INFINIBAND)
|
||||
|
||||
#define NM_SETTING_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandPrivate))
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingIPTunnel, nm_setting_ip_tunnel, NM_TYPE_SETTING,
|
||||
_nm_register_setting (IP_TUNNEL, 1))
|
||||
_nm_register_setting (IP_TUNNEL, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP_TUNNEL)
|
||||
|
||||
#define NM_SETTING_IP_TUNNEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP_TUNNEL, NMSettingIPTunnelPrivate))
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingIP4Config, nm_setting_ip4_config, NM_TYPE_SETTING_IP_CONFIG,
|
||||
_nm_register_setting (IP4_CONFIG, 5))
|
||||
_nm_register_setting (IP4_CONFIG, NM_SETTING_PRIORITY_IP))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG)
|
||||
|
||||
#define NM_SETTING_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigPrivate))
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingIP6Config, nm_setting_ip6_config, NM_TYPE_SETTING_IP_CONFIG,
|
||||
_nm_register_setting (IP6_CONFIG, 5))
|
||||
_nm_register_setting (IP6_CONFIG, NM_SETTING_PRIORITY_IP))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP6_CONFIG)
|
||||
|
||||
#define NM_SETTING_IP6_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_IP6_CONFIG, NMSettingIP6ConfigPrivate))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingMacsec, nm_setting_macsec, NM_TYPE_SETTING,
|
||||
_nm_register_setting (MACSEC, 1))
|
||||
_nm_register_setting (MACSEC, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_MACSEC)
|
||||
|
||||
#define NM_SETTING_MACSEC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_MACSEC, NMSettingMacsecPrivate))
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingMacvlan, nm_setting_macvlan, NM_TYPE_SETTING,
|
||||
_nm_register_setting (MACVLAN, 1))
|
||||
_nm_register_setting (MACVLAN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_MACVLAN)
|
||||
|
||||
#define NM_SETTING_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_MACVLAN, NMSettingMacvlanPrivate))
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
static void nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingOlpcMesh, nm_setting_olpc_mesh, NM_TYPE_SETTING,
|
||||
_nm_register_setting (OLPC_MESH, 1))
|
||||
_nm_register_setting (OLPC_MESH, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_OLPC_MESH)
|
||||
|
||||
#define NM_SETTING_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshPrivate))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingPpp, nm_setting_ppp, NM_TYPE_SETTING,
|
||||
_nm_register_setting (PPP, 4))
|
||||
_nm_register_setting (PPP, NM_SETTING_PRIORITY_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPP)
|
||||
|
||||
#define NM_SETTING_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPP, NMSettingPppPrivate))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingPppoe, nm_setting_pppoe, NM_TYPE_SETTING,
|
||||
_nm_register_setting (PPPOE, 4))
|
||||
_nm_register_setting (PPPOE, NM_SETTING_PRIORITY_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPPOE)
|
||||
|
||||
#define NM_SETTING_PPPOE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPPOE, NMSettingPppoePrivate))
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@
|
|||
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
void _nm_register_setting (const char *name,
|
||||
const GType type,
|
||||
const guint32 priority);
|
||||
void _nm_register_setting_impl (const char *name,
|
||||
GType type,
|
||||
NMSettingPriority priority);
|
||||
|
||||
#define _nm_register_setting(name, priority) \
|
||||
G_STMT_START { \
|
||||
_nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \
|
||||
_nm_register_setting_impl ("" NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \
|
||||
} G_STMT_END
|
||||
|
||||
guint32 _nm_setting_get_base_type_priority (NMSetting *setting);
|
||||
guint32 _nm_setting_type_get_base_type_priority (GType type);
|
||||
NMSettingPriority _nm_setting_get_base_type_priority (NMSetting *setting);
|
||||
NMSettingPriority _nm_setting_type_get_base_type_priority (GType type);
|
||||
gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
|
||||
|
||||
typedef enum NMSettingUpdateSecretResult {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingProxy, nm_setting_proxy, NM_TYPE_SETTING,
|
||||
_nm_register_setting (PROXY, 5))
|
||||
_nm_register_setting (PROXY, NM_SETTING_PRIORITY_IP))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PROXY)
|
||||
|
||||
#define NM_SETTING_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PROXY, NMSettingProxyPrivate))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingSerial, nm_setting_serial, NM_TYPE_SETTING,
|
||||
_nm_register_setting (SERIAL, 3))
|
||||
_nm_register_setting (SERIAL, NM_SETTING_PRIORITY_HW_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_SERIAL)
|
||||
|
||||
#define NM_SETTING_SERIAL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_SERIAL, NMSettingSerialPrivate))
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING,
|
||||
_nm_register_setting (TEAM_PORT, 4))
|
||||
_nm_register_setting (TEAM_PORT, NM_SETTING_PRIORITY_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT)
|
||||
|
||||
#define NM_SETTING_TEAM_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortPrivate))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingTeam, nm_setting_team, NM_TYPE_SETTING,
|
||||
_nm_register_setting (TEAM, 1))
|
||||
_nm_register_setting (TEAM, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM)
|
||||
|
||||
#define NM_SETTING_TEAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM, NMSettingTeamPrivate))
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingTun, nm_setting_tun, NM_TYPE_SETTING,
|
||||
_nm_register_setting (TUN, 1))
|
||||
_nm_register_setting (TUN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TUN)
|
||||
|
||||
#define NM_SETTING_TUN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TUN, NMSettingTunPrivate))
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ struct _NMSettingUserClass {
|
|||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingUser, nm_setting_user, NM_TYPE_SETTING,
|
||||
_nm_register_setting (USER, 10))
|
||||
_nm_register_setting (USER, NM_SETTING_PRIORITY_USER))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_USER)
|
||||
|
||||
#define NM_SETTING_USER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMSettingUser, NM_IS_SETTING_USER)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING,
|
||||
_nm_register_setting (VLAN, 1))
|
||||
_nm_register_setting (VLAN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VLAN)
|
||||
|
||||
#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate))
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingVpn, nm_setting_vpn, NM_TYPE_SETTING,
|
||||
_nm_register_setting (VPN, 1))
|
||||
_nm_register_setting (VPN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VPN)
|
||||
|
||||
#define NM_SETTING_VPN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VPN, NMSettingVpnPrivate))
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingVxlan, nm_setting_vxlan, NM_TYPE_SETTING,
|
||||
_nm_register_setting (VXLAN, 1))
|
||||
_nm_register_setting (VXLAN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_VXLAN)
|
||||
|
||||
#define NM_SETTING_VXLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VXLAN, NMSettingVxlanPrivate))
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING,
|
||||
_nm_register_setting (WIMAX, 1))
|
||||
_nm_register_setting (WIMAX, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX)
|
||||
|
||||
#define NM_SETTING_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIMAX, NMSettingWimaxPrivate))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING,
|
||||
_nm_register_setting (WIRED, 1))
|
||||
_nm_register_setting (WIRED, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRED)
|
||||
|
||||
#define NM_SETTING_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate))
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING,
|
||||
_nm_register_setting (WIRELESS_SECURITY, 3))
|
||||
_nm_register_setting (WIRELESS_SECURITY, NM_SETTING_PRIORITY_HW_AUX))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS_SECURITY)
|
||||
|
||||
#define NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS_SECURITY, NMSettingWirelessSecurityPrivate))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING,
|
||||
_nm_register_setting (WIRELESS, 1))
|
||||
_nm_register_setting (WIRELESS, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS)
|
||||
|
||||
#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ G_DEFINE_ABSTRACT_TYPE (NMSetting, nm_setting, G_TYPE_OBJECT)
|
|||
typedef struct {
|
||||
const char *name;
|
||||
GType type;
|
||||
guint32 priority;
|
||||
NMSettingPriority priority;
|
||||
} SettingInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -118,61 +118,31 @@ _ensure_registered_constructor (void)
|
|||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* _nm_register_setting:
|
||||
* _nm_register_setting_impl:
|
||||
* @name: the name of the #NMSetting object to register
|
||||
* @type: the #GType of the #NMSetting
|
||||
* @priority: the sort priority of the setting, see below
|
||||
* @priority: the sort priority of the setting, see #NMSettingPriority
|
||||
*
|
||||
* INTERNAL ONLY: registers a setting's internal properties with libnm.
|
||||
*
|
||||
* A setting's priority should roughly follow the OSI layer model, but it also
|
||||
* controls which settings get asked for secrets first. Thus settings which
|
||||
* relate to things that must be working first, like hardware, should get a
|
||||
* higher priority than things which layer on top of the hardware. For example,
|
||||
* the GSM/CDMA settings should provide secrets before the PPP setting does,
|
||||
* because a PIN is required to unlock the device before PPP can even start.
|
||||
* Even settings without secrets should be assigned the right priority.
|
||||
*
|
||||
* 0: reserved for the Connection setting
|
||||
*
|
||||
* 1,2: hardware-related settings like Ethernet, Wi-Fi, InfiniBand, Bridge, etc.
|
||||
* These priority 1 settings are also "base types", which means that at least
|
||||
* one of them is required for the connection to be valid, and their name is
|
||||
* valid in the 'type' property of the Connection setting.
|
||||
*
|
||||
* 3: hardware-related auxiliary settings that require a base setting to be
|
||||
* successful first, like Wi-Fi security, 802.1x, etc.
|
||||
*
|
||||
* 4: hardware-independent settings that are required before IP connectivity
|
||||
* can be established, like PPP, PPPoE, etc.
|
||||
*
|
||||
* 5: IP-level stuff
|
||||
*
|
||||
* 10: NMSettingUser
|
||||
*/
|
||||
void
|
||||
(_nm_register_setting) (const char *name,
|
||||
const GType type,
|
||||
const guint32 priority)
|
||||
_nm_register_setting_impl (const char *name,
|
||||
GType type,
|
||||
NMSettingPriority priority)
|
||||
{
|
||||
SettingInfo *info;
|
||||
|
||||
g_return_if_fail (name != NULL && *name);
|
||||
g_return_if_fail (type != G_TYPE_INVALID);
|
||||
g_return_if_fail (type != G_TYPE_NONE);
|
||||
nm_assert (name && *name);
|
||||
nm_assert (!NM_IN_SET (type, G_TYPE_INVALID, G_TYPE_NONE));
|
||||
nm_assert (priority != NM_SETTING_PRIORITY_INVALID);
|
||||
|
||||
_ensure_registered ();
|
||||
|
||||
if (G_LIKELY ((info = g_hash_table_lookup (registered_settings, name)))) {
|
||||
g_return_if_fail (info->type == type);
|
||||
g_return_if_fail (info->priority == priority);
|
||||
g_return_if_fail (g_strcmp0 (info->name, name) == 0);
|
||||
return;
|
||||
}
|
||||
g_return_if_fail (g_hash_table_lookup (registered_settings_by_type, &type) == NULL);
|
||||
nm_assert (!g_hash_table_lookup (registered_settings, name));
|
||||
nm_assert (!g_hash_table_lookup (registered_settings_by_type, &type));
|
||||
|
||||
if (priority == 0)
|
||||
g_assert_cmpstr (name, ==, NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
nm_assert ( priority != NM_SETTING_PRIORITY_CONNECTION
|
||||
|| nm_streq (name, NM_SETTING_CONNECTION_SETTING_NAME));
|
||||
|
||||
info = g_slice_new0 (SettingInfo);
|
||||
info->type = type;
|
||||
|
|
@ -189,7 +159,7 @@ _nm_setting_lookup_setting_by_type (GType type)
|
|||
return g_hash_table_lookup (registered_settings_by_type, &type);
|
||||
}
|
||||
|
||||
static guint32
|
||||
static NMSettingPriority
|
||||
_get_setting_type_priority (GType type)
|
||||
{
|
||||
const SettingInfo *info;
|
||||
|
|
@ -200,7 +170,7 @@ _get_setting_type_priority (GType type)
|
|||
return info->priority;
|
||||
}
|
||||
|
||||
guint32
|
||||
NMSettingPriority
|
||||
_nm_setting_get_setting_priority (NMSetting *setting)
|
||||
{
|
||||
NMSettingPrivate *priv;
|
||||
|
|
@ -211,10 +181,10 @@ _nm_setting_get_setting_priority (NMSetting *setting)
|
|||
return priv->info->priority;
|
||||
}
|
||||
|
||||
guint32
|
||||
NMSettingPriority
|
||||
_nm_setting_type_get_base_type_priority (GType type)
|
||||
{
|
||||
guint32 priority;
|
||||
NMSettingPriority priority;
|
||||
|
||||
/* Historical oddity: PPPoE is a base-type even though it's not
|
||||
* priority 1. It needs to be sorted *after* lower-level stuff like
|
||||
|
|
@ -222,13 +192,16 @@ _nm_setting_type_get_base_type_priority (GType type)
|
|||
* base type.
|
||||
*/
|
||||
priority = _get_setting_type_priority (type);
|
||||
if (priority == 1 || priority == 2 || (type == NM_TYPE_SETTING_PPPOE))
|
||||
if ( NM_IN_SET (priority,
|
||||
NM_SETTING_PRIORITY_HW_BASE,
|
||||
NM_SETTING_PRIORITY_HW_NON_BASE)
|
||||
|| type == NM_TYPE_SETTING_PPPOE)
|
||||
return priority;
|
||||
else
|
||||
return 0;
|
||||
return NM_SETTING_PRIORITY_INVALID;
|
||||
}
|
||||
|
||||
guint32
|
||||
NMSettingPriority
|
||||
_nm_setting_get_base_type_priority (NMSetting *setting)
|
||||
{
|
||||
return _nm_setting_type_get_base_type_priority (G_OBJECT_TYPE (setting));
|
||||
|
|
@ -248,7 +221,7 @@ nm_setting_lookup_type (const char *name)
|
|||
{
|
||||
SettingInfo *info;
|
||||
|
||||
g_return_val_if_fail (name != NULL, G_TYPE_INVALID);
|
||||
g_return_val_if_fail (name, G_TYPE_INVALID);
|
||||
|
||||
_ensure_registered ();
|
||||
|
||||
|
|
@ -259,7 +232,7 @@ nm_setting_lookup_type (const char *name)
|
|||
gint
|
||||
_nm_setting_compare_priority (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
guint32 prio_a, prio_b;
|
||||
NMSettingPriority prio_a, prio_b;
|
||||
|
||||
prio_a = _nm_setting_get_setting_priority ((NMSetting *) a);
|
||||
prio_b = _nm_setting_get_setting_priority ((NMSetting *) b);
|
||||
|
|
|
|||
|
|
@ -3896,8 +3896,8 @@ _nm_utils_inet6_is_token (const struct in6_addr *in6addr)
|
|||
gboolean
|
||||
nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_type)
|
||||
{
|
||||
g_return_val_if_fail (_nm_setting_type_get_base_type_priority (virtual_type), FALSE);
|
||||
g_return_val_if_fail (_nm_setting_type_get_base_type_priority (other_type), FALSE);
|
||||
g_return_val_if_fail (_nm_setting_type_get_base_type_priority (virtual_type) != NM_SETTING_PRIORITY_INVALID, FALSE);
|
||||
g_return_val_if_fail (_nm_setting_type_get_base_type_priority (other_type) != NM_SETTING_PRIORITY_INVALID, FALSE);
|
||||
|
||||
if (virtual_type == NM_TYPE_SETTING_BOND) {
|
||||
return ( other_type == NM_TYPE_SETTING_INFINIBAND
|
||||
|
|
|
|||
|
|
@ -3492,7 +3492,7 @@ _test_connection_normalize_type_normalizable_setting (const char *type,
|
|||
|
||||
base_type = nm_setting_lookup_type (type);
|
||||
g_assert (base_type != G_TYPE_INVALID);
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type));
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type) != NM_SETTING_PRIORITY_INVALID);
|
||||
|
||||
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);
|
||||
|
||||
|
|
@ -3522,7 +3522,7 @@ _test_connection_normalize_type_unnormalizable_setting (const char *type)
|
|||
|
||||
base_type = nm_setting_lookup_type (type);
|
||||
g_assert (base_type != G_TYPE_INVALID);
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type));
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type) != NM_SETTING_PRIORITY_INVALID);
|
||||
|
||||
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);
|
||||
|
||||
|
|
@ -3545,7 +3545,7 @@ _test_connection_normalize_type_normalizable_type (const char *type,
|
|||
|
||||
base_type = nm_setting_lookup_type (type);
|
||||
g_assert (base_type != G_TYPE_INVALID);
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type));
|
||||
g_assert (_nm_setting_type_get_base_type_priority (base_type) != NM_SETTING_PRIORITY_INVALID);
|
||||
|
||||
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,9 +107,14 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
_("The connection was not a bridge connection."));
|
||||
return FALSE;
|
||||
if ( _nm_connection_get_setting_bluetooth_for_nap (connection)
|
||||
&& nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
|
||||
/* a bluetooth NAP setting is a compatible connection for a bridge. */
|
||||
} else {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
_("The connection was not a bridge connection."));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: check ports? */
|
||||
|
|
|
|||
|
|
@ -131,12 +131,19 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
|
||||
if ( !nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)
|
||||
|| !(s_bt = nm_connection_get_setting_bluetooth (connection))) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
_("The connection was not a Bluetooth connection."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nm_streq0 (nm_setting_bluetooth_get_connection_type (s_bt), NM_SETTING_BLUETOOTH_TYPE_NAP)) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
_("The connection is of Bluetooth NAP type."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check BT address */
|
||||
hw_addr = nm_device_bt_get_hw_address (NM_DEVICE_BT (device));
|
||||
if (hw_addr) {
|
||||
|
|
@ -145,7 +152,6 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
_("Invalid device Bluetooth address."));
|
||||
return FALSE;
|
||||
}
|
||||
s_bt = nm_connection_get_setting_bluetooth (connection);
|
||||
setting_addr = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, hw_addr, -1)) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
|
|
|
|||
|
|
@ -343,6 +343,10 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
bt_type = nm_setting_bluetooth_get_connection_type (s_bt);
|
||||
|
||||
if (nm_streq (bt_type, NM_SETTING_BLUETOOTH_TYPE_NAP))
|
||||
return FALSE;
|
||||
|
||||
if ( g_str_equal (bt_type, NM_SETTING_BLUETOOTH_TYPE_DUN)
|
||||
&& !(priv->capabilities & NM_BT_CAPABILITY_DUN))
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -90,33 +90,40 @@ typedef struct {
|
|||
char *path;
|
||||
char *addr;
|
||||
NMDevice *device;
|
||||
CList network_servers;
|
||||
CList lst_ns;
|
||||
} NetworkServer;
|
||||
|
||||
static NetworkServer*
|
||||
_find_network_server (NMBluez5Manager *self,
|
||||
const gchar *path, const gchar *addr, NMDevice *device)
|
||||
static NetworkServer *
|
||||
_find_network_server (NMBluez5Manager *self, const char *path, NMDevice *device)
|
||||
{
|
||||
NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self);
|
||||
NetworkServer *network_server;
|
||||
CList *iter;
|
||||
|
||||
c_list_for_each (iter, &priv->network_servers) {
|
||||
network_server = c_list_entry (iter, NetworkServer, network_servers);
|
||||
nm_assert (path || NM_IS_DEVICE (device));
|
||||
|
||||
/* Device and path matches are exact. */
|
||||
if ( (path && !strcmp (network_server->path, path))
|
||||
|| (device && network_server->device == device))
|
||||
return network_server;
|
||||
c_list_for_each_entry (network_server, &priv->network_servers, lst_ns) {
|
||||
if (path && !nm_streq (network_server->path, path))
|
||||
continue;
|
||||
if (device && network_server->device != device)
|
||||
continue;
|
||||
return network_server;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NetworkServer *
|
||||
_find_network_server_for_addr (NMBluez5Manager *self, const char *addr)
|
||||
{
|
||||
NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self);
|
||||
NetworkServer *network_server;
|
||||
|
||||
c_list_for_each_entry (network_server, &priv->network_servers, lst_ns) {
|
||||
/* The address lookups need a server not assigned to a device
|
||||
* and tolerate an empty address as a wildcard for "any". */
|
||||
if ( (!path && !device)
|
||||
&& !network_server->device
|
||||
&& (!addr || !strcmp (network_server->addr, addr)))
|
||||
if ( !network_server->device
|
||||
&& (!addr || nm_streq (network_server->addr, addr)))
|
||||
return network_server;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +158,7 @@ static void
|
|||
_network_server_free (NMBluez5Manager *self, NetworkServer *network_server)
|
||||
{
|
||||
_network_server_unregister (self, network_server);
|
||||
c_list_unlink (&network_server->network_servers);
|
||||
c_list_unlink (&network_server->lst_ns);
|
||||
g_free (network_server->path);
|
||||
g_free (network_server->addr);
|
||||
g_slice_free (NetworkServer, network_server);
|
||||
|
|
@ -163,7 +170,7 @@ network_server_is_available (const NMBtVTableNetworkServer *vtable,
|
|||
{
|
||||
NMBluez5Manager *self = NETWORK_SERVER_VTABLE_GET_NM_BLUEZ5_MANAGER (vtable);
|
||||
|
||||
return !!_find_network_server (self, NULL, addr, NULL);
|
||||
return !!_find_network_server_for_addr (self, addr);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -173,7 +180,10 @@ network_server_register_bridge (const NMBtVTableNetworkServer *vtable,
|
|||
{
|
||||
NMBluez5Manager *self = NETWORK_SERVER_VTABLE_GET_NM_BLUEZ5_MANAGER (vtable);
|
||||
NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self);
|
||||
NetworkServer *network_server = _find_network_server (self, NULL, addr, NULL);
|
||||
NetworkServer *network_server = _find_network_server_for_addr (self, addr);
|
||||
|
||||
nm_assert (NM_IS_DEVICE (device));
|
||||
nm_assert (!_find_network_server (self, NULL, device));
|
||||
|
||||
if (!network_server) {
|
||||
/* The device checked that a network server is available, before
|
||||
|
|
@ -205,7 +215,7 @@ network_server_unregister_bridge (const NMBtVTableNetworkServer *vtable,
|
|||
NMDevice *device)
|
||||
{
|
||||
NMBluez5Manager *self = NETWORK_SERVER_VTABLE_GET_NM_BLUEZ5_MANAGER (vtable);
|
||||
NetworkServer *network_server = _find_network_server (self, NULL, NULL, device);
|
||||
NetworkServer *network_server = _find_network_server (self, NULL, device);
|
||||
|
||||
if (network_server)
|
||||
_network_server_unregister (self, network_server);
|
||||
|
|
@ -218,7 +228,7 @@ network_server_removed (GDBusProxy *proxy, const gchar *path, NMBluez5Manager *s
|
|||
{
|
||||
NetworkServer *network_server;
|
||||
|
||||
network_server = _find_network_server (self, path, NULL, NULL);
|
||||
network_server = _find_network_server (self, path, NULL);
|
||||
if (!network_server)
|
||||
return;
|
||||
|
||||
|
|
@ -243,7 +253,7 @@ network_server_added (GDBusProxy *proxy, const gchar *path, const char *addr, NM
|
|||
network_server = g_slice_new0 (NetworkServer);
|
||||
network_server->path = g_strdup (path);
|
||||
network_server->addr = g_strdup (addr);
|
||||
c_list_link_before (&priv->network_servers, &network_server->network_servers);
|
||||
c_list_link_before (&priv->network_servers, &network_server->lst_ns);
|
||||
|
||||
_LOGI ("NAP: added interface %s", addr);
|
||||
|
||||
|
|
@ -536,7 +546,7 @@ dispose (GObject *object)
|
|||
CList *iter, *safe;
|
||||
|
||||
c_list_for_each_safe (iter, safe, &priv->network_servers)
|
||||
_network_server_free (self, c_list_entry (iter, NetworkServer, network_servers));
|
||||
_network_server_free (self, c_list_entry (iter, NetworkServer, lst_ns));
|
||||
|
||||
if (priv->proxy) {
|
||||
g_signal_handlers_disconnect_by_func (priv->proxy, G_CALLBACK (name_owner_changed_cb), self);
|
||||
|
|
|
|||
|
|
@ -51,52 +51,6 @@ G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE)
|
|||
|
||||
const NMBtVTableNetworkServer *nm_bt_vtable_network_server = NULL;
|
||||
|
||||
static gboolean
|
||||
bt_network_server_available (NMConnection *connection)
|
||||
{
|
||||
NMSettingBluetooth *s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
|
||||
if (!s_bt)
|
||||
return TRUE;
|
||||
if (!nm_bt_vtable_network_server)
|
||||
return FALSE;
|
||||
return nm_bt_vtable_network_server->is_available (nm_bt_vtable_network_server,
|
||||
nm_setting_bluetooth_get_bdaddr (s_bt));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bt_network_server_register (NMDevice *self)
|
||||
{
|
||||
NMConnection *connection = nm_device_get_applied_connection (self);
|
||||
NMSettingBluetooth *s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
|
||||
if (!s_bt)
|
||||
return TRUE;
|
||||
if (!nm_bt_vtable_network_server)
|
||||
return FALSE;
|
||||
return nm_bt_vtable_network_server->register_bridge (nm_bt_vtable_network_server,
|
||||
nm_setting_bluetooth_get_bdaddr (s_bt),
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
bt_network_server_unregister (NMDevice *self)
|
||||
{
|
||||
NMConnection *connection = nm_device_get_applied_connection (self);
|
||||
NMSettingBluetooth *s_bt;
|
||||
|
||||
if (!connection)
|
||||
return;
|
||||
s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
if (!s_bt)
|
||||
return;
|
||||
|
||||
if (!nm_bt_vtable_network_server)
|
||||
return;
|
||||
nm_bt_vtable_network_server->unregister_bridge (nm_bt_vtable_network_server,
|
||||
self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static NMDeviceCapabilities
|
||||
|
|
@ -117,8 +71,14 @@ check_connection_available (NMDevice *device,
|
|||
NMDeviceCheckConAvailableFlags flags,
|
||||
const char *specific_object)
|
||||
{
|
||||
if (!bt_network_server_available (connection))
|
||||
return FALSE;
|
||||
NMSettingBluetooth *s_bt;
|
||||
|
||||
s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
if (s_bt) {
|
||||
return nm_bt_vtable_network_server
|
||||
&& nm_bt_vtable_network_server->is_available (nm_bt_vtable_network_server,
|
||||
nm_setting_bluetooth_get_bdaddr (s_bt));
|
||||
}
|
||||
|
||||
/* Connections are always available because the carrier state is determined
|
||||
* by the bridge port carrier states, not the bridge's state.
|
||||
|
|
@ -136,9 +96,17 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||
if (!s_bridge || !nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME))
|
||||
if (!s_bridge)
|
||||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
||||
if ( nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME)
|
||||
&& _nm_connection_get_setting_bluetooth_for_nap (connection)) {
|
||||
/* a bluetooth NAP connection is handled by the bridge */
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mac_address = nm_setting_bridge_get_mac_address (s_bridge);
|
||||
if (mac_address && nm_device_is_real (device)) {
|
||||
const char *hw_addr;
|
||||
|
|
@ -380,10 +348,21 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
static NMActStageReturn
|
||||
act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
if (!bt_network_server_register (device)) {
|
||||
/* The HCI we could use is no longer present. */
|
||||
*out_failure_reason = NM_DEVICE_STATE_REASON_REMOVED;
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
NMConnection *connection;
|
||||
NMSettingBluetooth *s_bt;
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
|
||||
s_bt = _nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
if (s_bt) {
|
||||
if ( !nm_bt_vtable_network_server
|
||||
|| !nm_bt_vtable_network_server->register_bridge (nm_bt_vtable_network_server,
|
||||
nm_setting_bluetooth_get_bdaddr (s_bt),
|
||||
device)) {
|
||||
/* The HCI we could use is no longer present. */
|
||||
*out_failure_reason = NM_DEVICE_STATE_REASON_REMOVED;
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
|
@ -392,7 +371,12 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
static void
|
||||
deactivate (NMDevice *device)
|
||||
{
|
||||
bt_network_server_unregister (device);
|
||||
if (nm_bt_vtable_network_server) {
|
||||
/* always call unregister. It does nothing if the device
|
||||
* isn't registered as a hotspot bridge. */
|
||||
nm_bt_vtable_network_server->unregister_bridge (nm_bt_vtable_network_server,
|
||||
device);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "platform/nm-platform.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
|
||||
#define PLUGIN_PREFIX "libnm-device-plugin-"
|
||||
|
||||
|
|
@ -60,7 +62,7 @@ nm_device_factory_emit_component_added (NMDeviceFactory *factory, GObject *compo
|
|||
return consumed;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nm_device_factory_get_supported_types (NMDeviceFactory *factory,
|
||||
const NMLinkType **out_link_types,
|
||||
const char *const**out_setting_types)
|
||||
|
|
@ -90,56 +92,26 @@ nm_device_factory_create_device (NMDeviceFactory *factory,
|
|||
GError **error)
|
||||
{
|
||||
NMDeviceFactoryClass *klass;
|
||||
const NMLinkType *link_types = NULL;
|
||||
const char *const*setting_types = NULL;
|
||||
int i;
|
||||
NMDevice *device;
|
||||
gboolean ignore = FALSE;
|
||||
|
||||
g_return_val_if_fail (factory, NULL);
|
||||
g_return_val_if_fail (iface && *iface, NULL);
|
||||
g_return_val_if_fail (plink || connection, NULL);
|
||||
g_return_val_if_fail (!plink || !connection, NULL);
|
||||
|
||||
nm_device_factory_get_supported_types (factory, &link_types, &setting_types);
|
||||
|
||||
NM_SET_OUT (out_ignore, FALSE);
|
||||
|
||||
if (plink) {
|
||||
g_return_val_if_fail (!connection, NULL);
|
||||
g_return_val_if_fail (strcmp (iface, plink->name) == 0, NULL);
|
||||
|
||||
for (i = 0; link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) {
|
||||
if (plink->type == link_types[i])
|
||||
break;
|
||||
}
|
||||
|
||||
if (link_types[i] == NM_LINK_TYPE_UNKNOWN) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Device factory %s does not support link type %s (%d)",
|
||||
G_OBJECT_TYPE_NAME (factory),
|
||||
plink->kind, plink->type);
|
||||
return NULL;
|
||||
}
|
||||
} else if (connection) {
|
||||
for (i = 0; setting_types && setting_types[i]; i++) {
|
||||
if (nm_connection_is_type (connection, setting_types[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!setting_types[i]) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
"Device factory %s does not support connection type %s",
|
||||
G_OBJECT_TYPE_NAME (factory),
|
||||
nm_connection_get_connection_type (connection));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
nm_assert (factory == nm_device_factory_manager_find_factory_for_link_type (plink->type));
|
||||
} else if (connection)
|
||||
nm_assert (factory == nm_device_factory_manager_find_factory_for_connection (connection));
|
||||
else
|
||||
g_return_val_if_reached (NULL);
|
||||
|
||||
klass = NM_DEVICE_FACTORY_GET_CLASS (factory);
|
||||
if (!klass->create_device) {
|
||||
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
|
||||
"Device factory %s cannot manage new devices",
|
||||
G_OBJECT_TYPE_NAME (factory));
|
||||
NM_SET_OUT (out_ignore, FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -252,51 +224,45 @@ _cleanup (void)
|
|||
g_clear_pointer (&factories_by_setting, g_hash_table_unref);
|
||||
}
|
||||
|
||||
static NMDeviceFactory *
|
||||
find_factory (const NMLinkType *needle_link_types,
|
||||
const char *const*needle_setting_types)
|
||||
{
|
||||
NMDeviceFactory *found;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (factories_by_link, NULL);
|
||||
g_return_val_if_fail (factories_by_setting, NULL);
|
||||
|
||||
/* NMLinkType search */
|
||||
for (i = 0; needle_link_types && needle_link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) {
|
||||
found = g_hash_table_lookup (factories_by_link, GUINT_TO_POINTER (needle_link_types[i]));
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
|
||||
/* NMSetting name search */
|
||||
for (i = 0; needle_setting_types && needle_setting_types[i]; i++) {
|
||||
found = g_hash_table_lookup (factories_by_setting, needle_setting_types[i]);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NMDeviceFactory *
|
||||
nm_device_factory_manager_find_factory_for_link_type (NMLinkType link_type)
|
||||
{
|
||||
const NMLinkType ltypes[2] = { link_type, NM_LINK_TYPE_NONE };
|
||||
g_return_val_if_fail (factories_by_link, NULL);
|
||||
|
||||
if (link_type == NM_LINK_TYPE_UNKNOWN)
|
||||
return NULL;
|
||||
g_return_val_if_fail (link_type > NM_LINK_TYPE_UNKNOWN, NULL);
|
||||
return find_factory (ltypes, NULL);
|
||||
return g_hash_table_lookup (factories_by_link, GUINT_TO_POINTER (link_type));
|
||||
}
|
||||
|
||||
NMDeviceFactory *
|
||||
nm_device_factory_manager_find_factory_for_connection (NMConnection *connection)
|
||||
{
|
||||
const char *const stypes[2] = { nm_connection_get_connection_type (connection), NULL };
|
||||
const char *type;
|
||||
|
||||
g_assert (stypes[0]);
|
||||
return find_factory (NULL, stypes);
|
||||
g_return_val_if_fail (factories_by_setting, NULL);
|
||||
|
||||
type = nm_connection_get_connection_type (connection);
|
||||
|
||||
if ( nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME)
|
||||
&& _nm_connection_get_setting_bluetooth_for_nap (connection)) {
|
||||
/* for Bluetooth NAP connections, we return the bridge factory
|
||||
* instead of the bluetooth factory.
|
||||
*
|
||||
* In a way, this is a hack. The more orthodox solution would
|
||||
* be that device factories don't only announce supported setting
|
||||
* types, but instead match on a full fledged NMConnection.
|
||||
*
|
||||
* However, our device-factories are known at compile time.
|
||||
* There is no need to keep this generic. We *know* which
|
||||
* factory to choose. Making this generic would not make it
|
||||
* cleaner. */
|
||||
if (!g_hash_table_lookup (factories_by_setting, type)) {
|
||||
/* we need both the bluetooth and the bridge factory
|
||||
* to make this work. */
|
||||
return NULL;
|
||||
}
|
||||
type = NM_SETTING_BRIDGE_SETTING_NAME;
|
||||
}
|
||||
|
||||
return g_hash_table_lookup (factories_by_setting, type);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -331,12 +297,10 @@ nm_device_factory_manager_for_each_factory (NMDeviceFactoryManagerFactoryFunc ca
|
|||
|
||||
static gboolean
|
||||
_add_factory (NMDeviceFactory *factory,
|
||||
gboolean check_duplicates,
|
||||
const char *path,
|
||||
NMDeviceFactoryManagerFactoryFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDeviceFactory *found = NULL;
|
||||
const NMLinkType *link_types = NULL;
|
||||
const char *const*setting_types = NULL;
|
||||
int i;
|
||||
|
|
@ -345,16 +309,6 @@ _add_factory (NMDeviceFactory *factory,
|
|||
g_return_val_if_fail (factories_by_setting, FALSE);
|
||||
|
||||
nm_device_factory_get_supported_types (factory, &link_types, &setting_types);
|
||||
if (check_duplicates) {
|
||||
found = find_factory (link_types, setting_types);
|
||||
if (found) {
|
||||
nm_log_warn (LOGD_PLATFORM, "Loading device plugin failed: multiple plugins "
|
||||
"for same type (using '%s' instead of '%s')",
|
||||
(char *) g_object_get_qdata (G_OBJECT (found), plugin_path_quark ()),
|
||||
path);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (factory), plugin_path_quark (), g_strdup (path), g_free);
|
||||
for (i = 0; link_types && link_types[i] > NM_LINK_TYPE_UNKNOWN; i++)
|
||||
|
|
@ -376,7 +330,7 @@ _load_internal_factory (GType factory_gtype,
|
|||
NMDeviceFactory *factory;
|
||||
|
||||
factory = (NMDeviceFactory *) g_object_new (factory_gtype, NULL);
|
||||
_add_factory (factory, FALSE, "internal", callback, user_data);
|
||||
_add_factory (factory, "internal", callback, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -451,7 +405,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
_add_factory (factory, TRUE, g_module_name (plugin), callback, user_data);
|
||||
_add_factory (factory, g_module_name (plugin), callback, user_data);
|
||||
|
||||
g_object_unref (factory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,10 +178,6 @@ typedef NMDeviceFactory * (*NMDeviceFactoryCreateFunc) (GError **error);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void nm_device_factory_get_supported_types (NMDeviceFactory *factory,
|
||||
const NMLinkType **out_link_types,
|
||||
const char *const**out_setting_types);
|
||||
|
||||
const char *nm_device_factory_get_connection_parent (NMDeviceFactory *factory,
|
||||
NMConnection *connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -2292,7 +2292,7 @@ _log_connection_sort_hashes_fcn (gconstpointer a, gconstpointer b)
|
|||
{
|
||||
const LogConnectionSettingData *v1 = a;
|
||||
const LogConnectionSettingData *v2 = b;
|
||||
guint32 p1, p2;
|
||||
NMSettingPriority p1, p2;
|
||||
NMSetting *s1, *s2;
|
||||
|
||||
s1 = v1->setting ? v1->setting : v1->diff_base_setting;
|
||||
|
|
@ -2432,12 +2432,26 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
|
|||
if (!name)
|
||||
name = "";
|
||||
|
||||
connection_diff_are_same = nm_connection_diff (connection, diff_base, NM_SETTING_COMPARE_FLAG_EXACT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT, &connection_diff);
|
||||
connection_diff_are_same = nm_connection_diff (connection, diff_base,
|
||||
NM_SETTING_COMPARE_FLAG_EXACT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT,
|
||||
&connection_diff);
|
||||
if (connection_diff_are_same) {
|
||||
if (diff_base)
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s and %p/%s): no difference", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base));
|
||||
else
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s): no properties set", prefix, name, connection, G_OBJECT_TYPE_NAME (connection));
|
||||
const char *t1, *t2;
|
||||
|
||||
t1 = nm_connection_get_connection_type (connection);
|
||||
if (diff_base) {
|
||||
t2 = nm_connection_get_connection_type (diff_base);
|
||||
nm_log (level, domain, NULL, NULL,
|
||||
"%sconnection '%s' (%p/%s/%s%s%s and %p/%s/%s%s%s): no difference",
|
||||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1),
|
||||
diff_base, G_OBJECT_TYPE_NAME (diff_base), NM_PRINT_FMT_QUOTE_STRING (t2));
|
||||
} else {
|
||||
nm_log (level, domain, NULL, NULL,
|
||||
"%sconnection '%s' (%p/%s/%s%s%s): no properties set",
|
||||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1));
|
||||
}
|
||||
g_assert (!connection_diff);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2471,12 +2485,20 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
|
|||
if (print_header) {
|
||||
GError *err_verify = NULL;
|
||||
const char *path = nm_connection_get_path (connection);
|
||||
const char *t1, *t2;
|
||||
|
||||
t1 = nm_connection_get_connection_type (connection);
|
||||
if (diff_base) {
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s < %p/%s)%s%s%s:", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base),
|
||||
t2 = nm_connection_get_connection_type (diff_base);
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s/%s%s%s < %p/%s/%s%s%s)%s%s%s:",
|
||||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1),
|
||||
diff_base, G_OBJECT_TYPE_NAME (diff_base), NM_PRINT_FMT_QUOTE_STRING (t2),
|
||||
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
|
||||
} else {
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s):%s%s%s", prefix, name, connection, G_OBJECT_TYPE_NAME (connection),
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s/%s%s%s):%s%s%s",
|
||||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1),
|
||||
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
|
||||
}
|
||||
print_header = FALSE;
|
||||
|
|
|
|||
|
|
@ -3724,10 +3724,11 @@ validate_activation_request (NMManager *self,
|
|||
device = nm_manager_get_best_device_for_connection (self, connection, TRUE, NULL);
|
||||
|
||||
if (!device && !vpn) {
|
||||
gboolean is_software = nm_connection_is_virtual (connection);
|
||||
gs_free char *iface = NULL;
|
||||
|
||||
/* VPN and software-device connections don't need a device yet */
|
||||
if (!is_software) {
|
||||
/* VPN and software-device connections don't need a device yet,
|
||||
* but non-virtual connections do ... */
|
||||
if (!nm_connection_is_virtual (connection)) {
|
||||
g_set_error_literal (error,
|
||||
NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
||||
|
|
@ -3735,17 +3736,12 @@ validate_activation_request (NMManager *self,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (is_software) {
|
||||
char *iface;
|
||||
/* Look for an existing device with the connection's interface name */
|
||||
iface = nm_manager_get_connection_iface (self, connection, NULL, error);
|
||||
if (!iface)
|
||||
goto error;
|
||||
|
||||
/* Look for an existing device with the connection's interface name */
|
||||
iface = nm_manager_get_connection_iface (self, connection, NULL, error);
|
||||
if (!iface)
|
||||
goto error;
|
||||
|
||||
device = find_device_by_iface (self, iface, connection, NULL);
|
||||
g_free (iface);
|
||||
}
|
||||
device = find_device_by_iface (self, iface, connection, NULL);
|
||||
}
|
||||
|
||||
if ((!vpn || device_path) && !device) {
|
||||
|
|
@ -3840,8 +3836,8 @@ impl_manager_activate_connection (NMManager *self,
|
|||
connection = nm_settings_get_connection_by_path (priv->settings, connection_path);
|
||||
if (!connection) {
|
||||
error = g_error_new_literal (NM_MANAGER_ERROR,
|
||||
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
||||
"Connection could not be found.");
|
||||
NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
|
||||
"Connection could not be found.");
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue