2005-01-21 Dan Williams <dcbw@redhat.com>
* Cache last-known-good wireless authentication method in NetworkManagerInfo, and use that method first during wireless device activation. Should speed up devices that need Shared Key authentication method since Open System is now the default. * Remove the hack to not do full activation on wired connections that are active when we launch, it causes too many problems with name resolution and was a hack in the first place. * Re-work wireless device activation again somewhat to have a clearer chain of events and to use last-known-good authentication method of the access point. Also provide better status throughout activation to ensure the applet can tell the user exactly what's going on. * Remove the "find wireless network" code and now simply attempt to activate with that access point. This reduces the delay between selecting "Other wireless Network" and actually connecting to that network. * Correctly stop the device's worker thread when its removed. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@388 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
25
ChangeLog
25
ChangeLog
@@ -1,3 +1,28 @@
|
|||||||
|
2005-01-21 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* Cache last-known-good wireless authentication method in
|
||||||
|
NetworkManagerInfo, and use that method first during
|
||||||
|
wireless device activation. Should speed up devices that
|
||||||
|
need Shared Key authentication method since Open System is
|
||||||
|
now the default.
|
||||||
|
|
||||||
|
* Remove the hack to not do full activation on wired connections
|
||||||
|
that are active when we launch, it causes too many problems
|
||||||
|
with name resolution and was a hack in the first place.
|
||||||
|
|
||||||
|
* Re-work wireless device activation again somewhat to have a
|
||||||
|
clearer chain of events and to use last-known-good
|
||||||
|
authentication method of the access point. Also provide
|
||||||
|
better status throughout activation to ensure the applet
|
||||||
|
can tell the user exactly what's going on.
|
||||||
|
|
||||||
|
* Remove the "find wireless network" code and now simply attempt
|
||||||
|
to activate with that access point. This reduces the delay
|
||||||
|
between selecting "Other wireless Network" and actually
|
||||||
|
connecting to that network.
|
||||||
|
|
||||||
|
* Correctly stop the device's worker thread when its removed.
|
||||||
|
|
||||||
2005-01-21 Dan Williams <dcbw@redhat.com>
|
2005-01-21 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* dhcpcd/client.c
|
* dhcpcd/client.c
|
||||||
|
@@ -104,6 +104,18 @@ typedef enum NMNetworkMode
|
|||||||
} NMNetworkMode;
|
} NMNetworkMode;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Authentication modes
|
||||||
|
*/
|
||||||
|
typedef enum NMDeviceAuthMethod
|
||||||
|
{
|
||||||
|
NM_DEVICE_AUTH_METHOD_UNKNOWN = 0,
|
||||||
|
NM_DEVICE_AUTH_METHOD_NONE,
|
||||||
|
NM_DEVICE_AUTH_METHOD_OPEN_SYSTEM,
|
||||||
|
NM_DEVICE_AUTH_METHOD_SHARED_KEY
|
||||||
|
} NMDeviceAuthMethod;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Info-daemon specific preference locations
|
* Info-daemon specific preference locations
|
||||||
*/
|
*/
|
||||||
|
@@ -352,6 +352,7 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
NMEncKeyType key_type = -1;
|
NMEncKeyType key_type = -1;
|
||||||
gboolean trusted = FALSE;
|
gboolean trusted = FALSE;
|
||||||
|
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
@@ -405,6 +406,15 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
}
|
}
|
||||||
g_free (gconf_key);
|
g_free (gconf_key);
|
||||||
|
|
||||||
|
/* Grab the network's last authentication mode, if known */
|
||||||
|
gconf_key = g_strdup_printf ("%s/%s/auth_method", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
|
{
|
||||||
|
auth_method = gconf_value_get_int (value);
|
||||||
|
gconf_value_free (value);
|
||||||
|
}
|
||||||
|
g_free (gconf_key);
|
||||||
|
|
||||||
/* Grab the network's trusted status */
|
/* Grab the network's trusted status */
|
||||||
gconf_key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
gconf_key = g_strdup_printf ("%s/%s/trusted", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
if ((value = gconf_client_get (info->gconf_client, gconf_key, NULL)))
|
||||||
@@ -451,6 +461,7 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
dbus_message_iter_append_int32 (&iter, timestamp);
|
dbus_message_iter_append_int32 (&iter, timestamp);
|
||||||
dbus_message_iter_append_string (&iter, key);
|
dbus_message_iter_append_string (&iter, key);
|
||||||
dbus_message_iter_append_int32 (&iter, key_type);
|
dbus_message_iter_append_int32 (&iter, key_type);
|
||||||
|
dbus_message_iter_append_int32 (&iter, auth_method);
|
||||||
dbus_message_iter_append_boolean(&iter, trusted);
|
dbus_message_iter_append_boolean(&iter, trusted);
|
||||||
|
|
||||||
dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING);
|
dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING);
|
||||||
@@ -487,6 +498,54 @@ static DBusMessage *nmi_dbus_get_network_properties (NMIAppInfo *info, DBusMessa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmi_dbus_update_network_auth_method
|
||||||
|
*
|
||||||
|
* Update a network's authentication method entry in gconf
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static DBusMessage *nmi_dbus_update_network_auth_method (NMIAppInfo *info, DBusMessage *message)
|
||||||
|
{
|
||||||
|
DBusMessage *reply_message = NULL;
|
||||||
|
char *network = NULL;
|
||||||
|
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||||
|
char *key;
|
||||||
|
GConfValue *value;
|
||||||
|
DBusError error;
|
||||||
|
char *escaped_network;
|
||||||
|
|
||||||
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
if ( !dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INT32, &auth_method, DBUS_TYPE_INVALID)
|
||||||
|
|| (strlen (network) <= 0)
|
||||||
|
|| (auth_method == NM_DEVICE_AUTH_METHOD_UNKNOWN))
|
||||||
|
{
|
||||||
|
reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments",
|
||||||
|
"NetworkManagerInfo::updateNetworkAuthMethod called with invalid arguments.");
|
||||||
|
return (reply_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure the access point exists in GConf */
|
||||||
|
escaped_network = gconf_escape_key (network, strlen (network));
|
||||||
|
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
value = gconf_client_get (info->gconf_client, key, NULL);
|
||||||
|
g_free (key);
|
||||||
|
|
||||||
|
if (value && (value->type == GCONF_VALUE_STRING))
|
||||||
|
{
|
||||||
|
key = g_strdup_printf ("%s/%s/auth_method", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
|
gconf_client_set_int (info->gconf_client, key, auth_method, NULL);
|
||||||
|
g_free (key);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (escaped_network);
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_dbus_add_network_address
|
* nmi_dbus_add_network_address
|
||||||
*
|
*
|
||||||
@@ -626,6 +685,8 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio
|
|||||||
reply_message = nmi_dbus_get_networks (info, message);
|
reply_message = nmi_dbus_get_networks (info, message);
|
||||||
else if (strcmp ("getNetworkProperties", method) == 0)
|
else if (strcmp ("getNetworkProperties", method) == 0)
|
||||||
reply_message = nmi_dbus_get_network_properties (info, message);
|
reply_message = nmi_dbus_get_network_properties (info, message);
|
||||||
|
else if (strcmp ("updateNetworkAuthMethod", method) == 0)
|
||||||
|
nmi_dbus_update_network_auth_method (info, message);
|
||||||
else if (strcmp ("addNetworkAddress", method) == 0)
|
else if (strcmp ("addNetworkAddress", method) == 0)
|
||||||
nmi_dbus_add_network_address (info, message);
|
nmi_dbus_add_network_address (info, message);
|
||||||
else
|
else
|
||||||
|
@@ -128,18 +128,11 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
|
|||||||
nm_device_get_iface (dev), nm_device_is_wireless (dev) ? "wireless" : "wired");
|
nm_device_get_iface (dev), nm_device_is_wireless (dev) ? "wireless" : "wired");
|
||||||
|
|
||||||
data->dev_list = g_slist_append (data->dev_list, dev);
|
data->dev_list = g_slist_append (data->dev_list, dev);
|
||||||
|
|
||||||
/* We don't take down wired devices that are already set up when NetworkManager gets
|
|
||||||
* launched. Plays better with the system.
|
|
||||||
*
|
|
||||||
* FIXME: IPv6 here too
|
|
||||||
*/
|
|
||||||
if (!(data->starting_up && nm_device_is_wired (dev) && nm_device_get_ip4_address (dev)))
|
|
||||||
nm_device_deactivate (dev, TRUE);
|
nm_device_deactivate (dev, TRUE);
|
||||||
|
|
||||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
||||||
|
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_LIST_CHANGE);
|
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_LIST_CHANGE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -187,20 +180,16 @@ void nm_remove_device_from_list (NMData *data, const char *udi)
|
|||||||
data->active_device_locked = FALSE;
|
data->active_device_locked = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->user_device && (dev == data->user_device))
|
nm_device_set_removed (dev, TRUE);
|
||||||
{
|
nm_device_deactivate (dev, FALSE);
|
||||||
nm_device_unref (data->user_device);
|
nm_device_worker_thread_stop (dev);
|
||||||
data->user_device = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nm_device_activation_cancel (dev);
|
|
||||||
nm_device_unref (dev);
|
nm_device_unref (dev);
|
||||||
|
|
||||||
/* Remove the device entry from the device list and free its data */
|
/* Remove the device entry from the device list and free its data */
|
||||||
data->dev_list = g_slist_remove_link (data->dev_list, element);
|
data->dev_list = g_slist_remove_link (data->dev_list, element);
|
||||||
nm_device_unref (element->data);
|
nm_device_unref (element->data);
|
||||||
g_slist_free (element);
|
g_slist_free (element);
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_LIST_CHANGE);
|
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_LIST_CHANGE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -351,7 +340,7 @@ static void nm_hal_device_property_modified (LibHalContext *ctx, const char *udi
|
|||||||
&& nm_device_is_wireless (data->active_device))
|
&& nm_device_is_wireless (data->active_device))
|
||||||
{
|
{
|
||||||
data->active_device_locked = FALSE;
|
data->active_device_locked = FALSE;
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
||||||
@@ -529,10 +518,6 @@ static NMData *nm_data_new (gboolean enable_test_devices)
|
|||||||
data->main_context = g_main_context_new ();
|
data->main_context = g_main_context_new ();
|
||||||
data->main_loop = g_main_loop_new (data->main_context, FALSE);
|
data->main_loop = g_main_loop_new (data->main_context, FALSE);
|
||||||
|
|
||||||
data->wscan_ctx = g_main_context_new ();
|
|
||||||
data->wscan_loop = g_main_loop_new (data->wscan_ctx, FALSE);
|
|
||||||
data->wscan_thread_done = FALSE;
|
|
||||||
|
|
||||||
if (pipe(data->sigterm_pipe) < 0)
|
if (pipe(data->sigterm_pipe) < 0)
|
||||||
{
|
{
|
||||||
syslog (LOG_CRIT, "Couldn't create pipe: %s", g_strerror (errno));
|
syslog (LOG_CRIT, "Couldn't create pipe: %s", g_strerror (errno));
|
||||||
@@ -556,8 +541,7 @@ static NMData *nm_data_new (gboolean enable_test_devices)
|
|||||||
|
|
||||||
/* Initialize the device list mutex to protect additions/deletions to it. */
|
/* Initialize the device list mutex to protect additions/deletions to it. */
|
||||||
data->dev_list_mutex = g_mutex_new ();
|
data->dev_list_mutex = g_mutex_new ();
|
||||||
data->user_device_mutex = g_mutex_new ();
|
if (!data->dev_list_mutex)
|
||||||
if (!data->dev_list_mutex || !data->user_device_mutex)
|
|
||||||
{
|
{
|
||||||
nm_data_free (data);
|
nm_data_free (data);
|
||||||
syslog (LOG_ERR, "Could not initialize data structure locks.");
|
syslog (LOG_ERR, "Could not initialize data structure locks.");
|
||||||
@@ -577,9 +561,8 @@ static NMData *nm_data_new (gboolean enable_test_devices)
|
|||||||
data->state_modified_idle_id = 0;
|
data->state_modified_idle_id = 0;
|
||||||
|
|
||||||
data->enable_test_devices = enable_test_devices;
|
data->enable_test_devices = enable_test_devices;
|
||||||
data->starting_up = TRUE;
|
|
||||||
|
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
|
|
||||||
return (data);
|
return (data);
|
||||||
}
|
}
|
||||||
@@ -602,7 +585,6 @@ static void nm_data_free (NMData *data)
|
|||||||
g_slist_free (data->dev_list);
|
g_slist_free (data->dev_list);
|
||||||
|
|
||||||
g_mutex_free (data->dev_list_mutex);
|
g_mutex_free (data->dev_list_mutex);
|
||||||
g_mutex_free (data->user_device_mutex);
|
|
||||||
|
|
||||||
nm_ap_list_unref (data->allowed_ap_list);
|
nm_ap_list_unref (data->allowed_ap_list);
|
||||||
nm_ap_list_unref (data->invalid_ap_list);
|
nm_ap_list_unref (data->invalid_ap_list);
|
||||||
@@ -614,30 +596,6 @@ static void nm_data_free (NMData *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_data_mark_state_changed
|
|
||||||
*
|
|
||||||
* Queue up an idle handler to deal with state changes.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void nm_data_mark_state_changed (NMData *data)
|
|
||||||
{
|
|
||||||
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
|
||||||
|
|
||||||
g_return_if_fail (data != NULL);
|
|
||||||
|
|
||||||
g_static_mutex_lock (&mutex);
|
|
||||||
if (data->state_modified_idle_id == 0)
|
|
||||||
{
|
|
||||||
GSource *source = g_idle_source_new ();
|
|
||||||
|
|
||||||
g_source_set_callback (source, nm_state_modification_monitor, data, NULL);
|
|
||||||
data->state_modified_idle_id = g_source_attach (source, data->main_context);
|
|
||||||
g_source_unref (source);
|
|
||||||
}
|
|
||||||
g_static_mutex_unlock (&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sigterm_handler (int signum)
|
static void sigterm_handler (int signum)
|
||||||
{
|
{
|
||||||
syslog (LOG_NOTICE, "Caught SIGINT/SIGTERM");
|
syslog (LOG_NOTICE, "Caught SIGINT/SIGTERM");
|
||||||
|
@@ -48,7 +48,8 @@ struct NMAccessPoint
|
|||||||
/* Things from user prefs/NetworkManagerInfo */
|
/* Things from user prefs/NetworkManagerInfo */
|
||||||
gboolean trusted;
|
gboolean trusted;
|
||||||
char *enc_key;
|
char *enc_key;
|
||||||
NMEncKeyType enc_method;
|
NMEncKeyType enc_type;
|
||||||
|
NMDeviceAuthMethod auth_method;
|
||||||
GTimeVal timestamp;
|
GTimeVal timestamp;
|
||||||
GSList *user_addresses;
|
GSList *user_addresses;
|
||||||
};
|
};
|
||||||
@@ -71,6 +72,7 @@ NMAccessPoint * nm_ap_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ap->mode = NETWORK_MODE_INFRA;
|
ap->mode = NETWORK_MODE_INFRA;
|
||||||
|
ap->auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||||
ap->refcount = 1;
|
ap->refcount = 1;
|
||||||
|
|
||||||
return (ap);
|
return (ap);
|
||||||
@@ -207,7 +209,7 @@ char * nm_ap_get_enc_key_source (const NMAccessPoint *ap)
|
|||||||
return (ap->enc_key);
|
return (ap->enc_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char * key, NMEncKeyType method)
|
void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char * key, NMEncKeyType type)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
@@ -215,7 +217,7 @@ void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char * key, NMEncKeyType
|
|||||||
g_free (ap->enc_key);
|
g_free (ap->enc_key);
|
||||||
|
|
||||||
ap->enc_key = g_strdup (key);
|
ap->enc_key = g_strdup (key);
|
||||||
ap->enc_method = method;
|
ap->enc_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *nm_ap_get_enc_key_hashed (const NMAccessPoint *ap)
|
char *nm_ap_get_enc_key_hashed (const NMAccessPoint *ap)
|
||||||
@@ -226,7 +228,7 @@ char *nm_ap_get_enc_key_hashed (const NMAccessPoint *ap)
|
|||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (ap != NULL, NULL);
|
||||||
|
|
||||||
source_key = nm_ap_get_enc_key_source (ap);
|
source_key = nm_ap_get_enc_key_source (ap);
|
||||||
switch (ap->enc_method)
|
switch (ap->enc_type)
|
||||||
{
|
{
|
||||||
case (NM_ENC_TYPE_128_BIT_PASSPHRASE):
|
case (NM_ENC_TYPE_128_BIT_PASSPHRASE):
|
||||||
if (source_key)
|
if (source_key)
|
||||||
@@ -273,6 +275,37 @@ void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the encryption method the user specified for this access point.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (ap != NULL, TRUE);
|
||||||
|
|
||||||
|
return (ap->enc_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get/set functions for auth_method
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NMDeviceAuthMethod nm_ap_get_auth_method (const NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (ap != NULL, NM_DEVICE_AUTH_METHOD_UNKNOWN);
|
||||||
|
|
||||||
|
return (ap->auth_method);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nm_ap_set_auth_method (NMAccessPoint *ap, NMDeviceAuthMethod auth_method)
|
||||||
|
{
|
||||||
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
|
ap->auth_method = auth_method;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/set functions for address
|
* Get/set functions for address
|
||||||
*
|
*
|
||||||
@@ -501,18 +534,6 @@ void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the encryption method the user specified for this access point.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const NMEncKeyType nm_ap_get_enc_method (const NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (ap != NULL, TRUE);
|
|
||||||
|
|
||||||
return (ap->enc_method);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/Set functions for user address list
|
* Get/Set functions for user address list
|
||||||
*
|
*
|
||||||
@@ -569,3 +590,30 @@ void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list)
|
|||||||
ap->user_addresses = new;
|
ap->user_addresses = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gboolean nm_ap_is_enc_key_valid (NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
const char *key;
|
||||||
|
NMEncKeyType key_type;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ap != NULL, FALSE);
|
||||||
|
|
||||||
|
key = nm_ap_get_enc_key_source (ap);
|
||||||
|
key_type = nm_ap_get_enc_type (ap);
|
||||||
|
|
||||||
|
if (nm_is_enc_key_valid (key, key_type))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean nm_is_enc_key_valid (const char *key, NMEncKeyType key_type)
|
||||||
|
{
|
||||||
|
if ( key
|
||||||
|
&& strlen (key)
|
||||||
|
&& (key_type != NM_ENC_TYPE_UNKNOWN)
|
||||||
|
&& (key_type != NM_ENC_TYPE_NONE))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
@@ -43,6 +43,10 @@ void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
|
|||||||
char * nm_ap_get_enc_key_source (const NMAccessPoint *ap);
|
char * nm_ap_get_enc_key_source (const NMAccessPoint *ap);
|
||||||
char * nm_ap_get_enc_key_hashed (const NMAccessPoint *ap);
|
char * nm_ap_get_enc_key_hashed (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char *key, NMEncKeyType type);
|
void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char *key, NMEncKeyType type);
|
||||||
|
const NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap);
|
||||||
|
|
||||||
|
NMDeviceAuthMethod nm_ap_get_auth_method (const NMAccessPoint *ap);
|
||||||
|
void nm_ap_set_auth_method (NMAccessPoint *ap, const NMDeviceAuthMethod auth_method);
|
||||||
|
|
||||||
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
|
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted);
|
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted);
|
||||||
@@ -80,9 +84,11 @@ void nm_ap_set_last_seen (NMAccessPoint *ap, const GTimeVal *last_seen);
|
|||||||
gboolean nm_ap_get_user_created (const NMAccessPoint *ap);
|
gboolean nm_ap_get_user_created (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created);
|
void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created);
|
||||||
|
|
||||||
const NMEncKeyType nm_ap_get_enc_method (const NMAccessPoint *ap);
|
|
||||||
|
|
||||||
GSList * nm_ap_get_user_addresses (const NMAccessPoint *ap);
|
GSList * nm_ap_get_user_addresses (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list);
|
void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list);
|
||||||
|
|
||||||
|
/* Helper */
|
||||||
|
gboolean nm_ap_is_enc_key_valid (NMAccessPoint *ap);
|
||||||
|
gboolean nm_is_enc_key_valid (const char *key, NMEncKeyType key_type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -312,15 +312,16 @@ void nm_ap_list_update_network_from_nmi (NMAccessPointList *list, const char *ne
|
|||||||
nm_ap_set_essid (list_ap, nm_ap_get_essid (ap));
|
nm_ap_set_essid (list_ap, nm_ap_get_essid (ap));
|
||||||
nm_ap_set_timestamp (list_ap, nm_ap_get_timestamp (ap));
|
nm_ap_set_timestamp (list_ap, nm_ap_get_timestamp (ap));
|
||||||
nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap));
|
nm_ap_set_trusted (list_ap, nm_ap_get_trusted (ap));
|
||||||
nm_ap_set_enc_key_source (list_ap, nm_ap_get_enc_key_source (ap), nm_ap_get_enc_method (ap));
|
nm_ap_set_enc_key_source (list_ap, nm_ap_get_enc_key_source (ap), nm_ap_get_enc_type (ap));
|
||||||
|
nm_ap_set_auth_method (list_ap, nm_ap_get_auth_method (ap));
|
||||||
nm_ap_set_user_addresses (list_ap, nm_ap_get_user_addresses (ap));
|
nm_ap_set_user_addresses (list_ap, nm_ap_get_user_addresses (ap));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* New AP, just add it to the list */
|
/* New AP, just add it to the list */
|
||||||
nm_ap_list_append_ap (list, ap);
|
nm_ap_list_append_ap (list, ap);
|
||||||
nm_ap_unref (ap);
|
|
||||||
}
|
}
|
||||||
|
nm_ap_unref (ap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -387,6 +388,7 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
|
|||||||
{
|
{
|
||||||
/* Merge some properties on the AP that are new from scan to scan. */
|
/* Merge some properties on the AP that are new from scan to scan. */
|
||||||
nm_ap_set_encrypted (list_ap, nm_ap_get_encrypted (merge_ap));
|
nm_ap_set_encrypted (list_ap, nm_ap_get_encrypted (merge_ap));
|
||||||
|
nm_ap_set_auth_method (list_ap, nm_ap_get_auth_method (merge_ap));
|
||||||
nm_ap_set_last_seen (list_ap, nm_ap_get_last_seen (merge_ap));
|
nm_ap_set_last_seen (list_ap, nm_ap_get_last_seen (merge_ap));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -425,7 +427,17 @@ void nm_ap_list_copy_properties (NMAccessPointList *dest, NMAccessPointList *sou
|
|||||||
if ((src_ap = nm_ap_list_get_ap_by_essid (source, nm_ap_get_essid (dest_ap))))
|
if ((src_ap = nm_ap_list_get_ap_by_essid (source, nm_ap_get_essid (dest_ap))))
|
||||||
{
|
{
|
||||||
nm_ap_set_invalid (dest_ap, nm_ap_get_invalid (src_ap));
|
nm_ap_set_invalid (dest_ap, nm_ap_get_invalid (src_ap));
|
||||||
nm_ap_set_enc_key_source (dest_ap, nm_ap_get_enc_key_source (src_ap), nm_ap_get_enc_method (src_ap));
|
nm_ap_set_enc_key_source (dest_ap, nm_ap_get_enc_key_source (src_ap), nm_ap_get_enc_type (src_ap));
|
||||||
|
if (nm_ap_get_auth_method (src_ap) != NM_DEVICE_AUTH_METHOD_UNKNOWN)
|
||||||
|
{
|
||||||
|
/* Ensure that we don't set the NONE auth method from the src_ap
|
||||||
|
* if the dest_ap has encryption enabled.
|
||||||
|
*/
|
||||||
|
if (nm_ap_get_encrypted (dest_ap) && (nm_ap_get_auth_method (src_ap) != NM_DEVICE_AUTH_METHOD_NONE))
|
||||||
|
nm_ap_set_auth_method (dest_ap, nm_ap_get_auth_method (src_ap));
|
||||||
|
else if (!nm_ap_get_encrypted (dest_ap))
|
||||||
|
nm_ap_set_auth_method (dest_ap, NM_DEVICE_AUTH_METHOD_NONE);
|
||||||
|
}
|
||||||
nm_ap_set_timestamp (dest_ap, nm_ap_get_timestamp (src_ap));
|
nm_ap_set_timestamp (dest_ap, nm_ap_get_timestamp (src_ap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "NetworkManagerDevicePrivate.h"
|
#include "NetworkManagerDevicePrivate.h"
|
||||||
#include "NetworkManagerDHCP.h"
|
#include "NetworkManagerDHCP.h"
|
||||||
#include "NetworkManagerSystem.h"
|
#include "NetworkManagerSystem.h"
|
||||||
|
#include "NetworkManagerPolicy.h"
|
||||||
#include "nm-named-manager.h"
|
#include "nm-named-manager.h"
|
||||||
#include "../dhcpcd/client.h"
|
#include "../dhcpcd/client.h"
|
||||||
|
|
||||||
@@ -344,7 +345,7 @@ gboolean nm_device_dhcp_rebind (gpointer user_data)
|
|||||||
*/
|
*/
|
||||||
nm_system_device_flush_addresses (dev);
|
nm_system_device_flush_addresses (dev);
|
||||||
nm_device_update_ip4_address (dev);
|
nm_device_update_ip4_address (dev);
|
||||||
nm_data_mark_state_changed (dev->app_data);
|
nm_policy_schedule_state_update (dev->app_data);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "NetworkManagerDbus.h"
|
#include "NetworkManagerDbus.h"
|
||||||
#include "NetworkManagerAP.h"
|
#include "NetworkManagerAP.h"
|
||||||
#include "NetworkManagerAPList.h"
|
#include "NetworkManagerAPList.h"
|
||||||
|
#include "NetworkManagerPolicy.h"
|
||||||
|
|
||||||
|
|
||||||
static int test_dev_num = 0;
|
static int test_dev_num = 0;
|
||||||
@@ -196,6 +197,12 @@ static DBusMessage *nm_dbus_nm_get_active_device (DBusConnection *connection, DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct NMNetNotFoundData
|
||||||
|
{
|
||||||
|
NMData *app_data;
|
||||||
|
char *net;
|
||||||
|
} NMNetNotFoundData;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_send_network_not_found
|
* nm_dbus_send_network_not_found
|
||||||
*
|
*
|
||||||
@@ -203,26 +210,52 @@ static DBusMessage *nm_dbus_nm_get_active_device (DBusConnection *connection, DB
|
|||||||
* not found.
|
* not found.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nm_dbus_send_network_not_found (DBusConnection *connection, const char *network)
|
static gboolean nm_dbus_send_network_not_found (gpointer user_data)
|
||||||
{
|
{
|
||||||
|
NMNetNotFoundData *cb_data = (NMNetNotFoundData *)user_data;
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||||
g_return_if_fail (network != NULL);
|
|
||||||
|
if (!cb_data->app_data || !cb_data->app_data->dbus_connection || !cb_data->net)
|
||||||
|
goto out;
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
||||||
NMI_DBUS_INTERFACE, "networkNotFound");
|
NMI_DBUS_INTERFACE, "networkNotFound");
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
syslog (LOG_ERR, "nm_dbus_send_network_not_found(): Couldn't allocate the dbus message");
|
syslog (LOG_ERR, "nm_dbus_send_network_not_found(): Couldn't allocate the dbus message");
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_STRING, cb_data->net, DBUS_TYPE_INVALID);
|
||||||
if (!dbus_connection_send (connection, message, NULL))
|
if (!dbus_connection_send (cb_data->app_data->dbus_connection, message, NULL))
|
||||||
syslog (LOG_WARNING, "nm_dbus_send_network_not_found(): could not send dbus message");
|
syslog (LOG_WARNING, "nm_dbus_send_network_not_found(): could not send dbus message");
|
||||||
|
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free (cb_data);
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nm_dbus_schedule_network_not_found_signal (NMData *data, const char *network)
|
||||||
|
{
|
||||||
|
NMNetNotFoundData *cb_data;
|
||||||
|
GSource *source;
|
||||||
|
|
||||||
|
g_return_if_fail (data != NULL);
|
||||||
|
g_return_if_fail (network != NULL);
|
||||||
|
|
||||||
|
cb_data = g_malloc0 (sizeof (NMNetNotFoundData));
|
||||||
|
cb_data->app_data = data;
|
||||||
|
cb_data->net = g_strdup (network);
|
||||||
|
|
||||||
|
source = g_idle_source_new ();
|
||||||
|
g_source_set_callback (source, nm_dbus_send_network_not_found, cb_data, NULL);
|
||||||
|
g_source_attach (source, data->main_context);
|
||||||
|
g_source_unref (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,19 +302,18 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
|
|
||||||
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "InvalidArguments",
|
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "InvalidArguments",
|
||||||
"NetworkManager::setActiveDevice called with invalid arguments.");
|
"NetworkManager::setActiveDevice called with invalid arguments.");
|
||||||
return (reply_message);
|
goto out;
|
||||||
} else syslog (LOG_INFO, "FORCE: device '%s'", dev_path);
|
} else syslog (LOG_INFO, "FORCE: device '%s'", dev_path);
|
||||||
} else syslog (LOG_INFO, "FORCE: device '%s', network '%s'", dev_path, network);
|
} else syslog (LOG_INFO, "FORCE: device '%s', network '%s'", dev_path, network);
|
||||||
|
|
||||||
/* So by now we have a valid device and possibly a network as well */
|
/* So by now we have a valid device and possibly a network as well */
|
||||||
|
|
||||||
dev = nm_dbus_get_device_from_object_path (data, dev_path);
|
dev = nm_dbus_get_device_from_object_path (data, dev_path);
|
||||||
dbus_free (dev_path);
|
|
||||||
if (!dev || (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED))
|
if (!dev || (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED))
|
||||||
{
|
{
|
||||||
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
|
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
|
||||||
"The requested network device does not exist.");
|
"The requested network device does not exist.");
|
||||||
return (reply_message);
|
goto out;
|
||||||
}
|
}
|
||||||
nm_device_ref (dev);
|
nm_device_ref (dev);
|
||||||
|
|
||||||
@@ -293,37 +325,14 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(reply_message = dbus_message_new_method_return (message)))
|
data->forcing_device = TRUE;
|
||||||
goto out;
|
nm_device_deactivate (dev, FALSE);
|
||||||
|
nm_device_schedule_force_use (dev, network, key, key_type);
|
||||||
/* If the user specificed a wireless network too, force that as well */
|
|
||||||
if (nm_device_is_wireless (dev) && !nm_device_find_and_use_essid (dev, network, key, key_type))
|
|
||||||
{
|
|
||||||
nm_dbus_send_network_not_found (data->dbus_connection, network);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (nm_try_acquire_mutex (data->user_device_mutex, __FUNCTION__))
|
|
||||||
{
|
|
||||||
if (data->user_device)
|
|
||||||
nm_device_unref (data->user_device);
|
|
||||||
data->user_device = dev;
|
|
||||||
nm_device_ref (data->user_device);
|
|
||||||
nm_unlock_mutex (data->user_device_mutex, __FUNCTION__);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nm_dbus_send_network_not_found (data->dbus_connection, network);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Have to mark our state changed since we blew away our connection trying out
|
|
||||||
* the user-requested network.
|
|
||||||
*/
|
|
||||||
nm_data_mark_state_changed (data);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
dbus_free (dev_path);
|
||||||
dbus_free (network);
|
dbus_free (network);
|
||||||
dbus_free (key);
|
dbus_free (key);
|
||||||
nm_device_unref (dev);
|
|
||||||
return (reply_message);
|
return (reply_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,6 +348,7 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti
|
|||||||
NMDevice *dev = NULL;
|
NMDevice *dev = NULL;
|
||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
char *dev_path = NULL;
|
char *dev_path = NULL;
|
||||||
|
NMAccessPoint *new_ap = NULL;
|
||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
int key_type = -1;
|
int key_type = -1;
|
||||||
@@ -380,37 +390,27 @@ static DBusMessage *nm_dbus_nm_create_wireless_network (DBusConnection *connecti
|
|||||||
if (!(reply_message = dbus_message_new_method_return (message)))
|
if (!(reply_message = dbus_message_new_method_return (message)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* If the user specificed a wireless network too, force that as well */
|
data->forcing_device = TRUE;
|
||||||
if (nm_try_acquire_mutex (data->user_device_mutex, __FUNCTION__))
|
|
||||||
{
|
new_ap = nm_ap_new ();
|
||||||
NMAccessPoint *ap = nm_ap_new ();
|
|
||||||
|
|
||||||
/* Fill in the description of the network to create */
|
/* Fill in the description of the network to create */
|
||||||
nm_ap_set_essid (ap, network);
|
nm_ap_set_essid (new_ap, network);
|
||||||
if (key && strlen (key))
|
if (nm_is_enc_key_valid (key, key_type))
|
||||||
{
|
{
|
||||||
nm_ap_set_encrypted (ap, TRUE);
|
nm_ap_set_encrypted (new_ap, TRUE);
|
||||||
nm_ap_set_enc_key_source (ap, key, key_type);
|
nm_ap_set_enc_key_source (new_ap, key, key_type);
|
||||||
|
nm_ap_set_auth_method (new_ap, NM_DEVICE_AUTH_METHOD_OPEN_SYSTEM);
|
||||||
}
|
}
|
||||||
nm_ap_set_mode (ap, NETWORK_MODE_ADHOC);
|
nm_ap_set_mode (new_ap, NETWORK_MODE_ADHOC);
|
||||||
nm_ap_set_user_created (ap, TRUE);
|
nm_ap_set_user_created (new_ap, TRUE);
|
||||||
|
|
||||||
nm_device_set_best_ap (dev, ap);
|
nm_device_set_best_ap (dev, new_ap);
|
||||||
nm_device_freeze_best_ap (dev);
|
nm_device_freeze_best_ap (dev);
|
||||||
nm_device_activation_cancel (dev);
|
nm_device_activation_cancel (dev);
|
||||||
|
|
||||||
if (data->user_device)
|
/* Schedule this device to be used next. */
|
||||||
nm_device_unref (data->user_device);
|
nm_policy_schedule_device_switch (dev, data);
|
||||||
data->user_device = dev;
|
|
||||||
nm_device_ref (data->user_device);
|
|
||||||
|
|
||||||
nm_unlock_mutex (data->user_device_mutex, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Have to mark our state changed since we blew away our connection trying out
|
|
||||||
* the user-requested network.
|
|
||||||
*/
|
|
||||||
nm_data_mark_state_changed (data);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
dbus_free (network);
|
dbus_free (network);
|
||||||
@@ -490,6 +490,53 @@ static DBusMessage *nm_dbus_nm_get_devices (DBusConnection *connection, DBusMess
|
|||||||
/* Handler code */
|
/* Handler code */
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
|
|
||||||
|
typedef struct NMStatusChangeData
|
||||||
|
{
|
||||||
|
NMDevice *dev;
|
||||||
|
DeviceStatus status;
|
||||||
|
} NMStatusChangeData;
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean nm_dbus_device_status_change_helper (gpointer user_data)
|
||||||
|
{
|
||||||
|
NMStatusChangeData *data = (NMStatusChangeData *)user_data;
|
||||||
|
NMData *app_data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
|
||||||
|
if (!data->dev || !nm_device_get_app_data (data->dev))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
app_data = nm_device_get_app_data (data->dev);
|
||||||
|
nm_dbus_signal_device_status_change (app_data->dbus_connection, data->dev, data->status);
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free (data);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void nm_dbus_schedule_device_status_change (NMDevice *dev, DeviceStatus status)
|
||||||
|
{
|
||||||
|
NMStatusChangeData *data = NULL;
|
||||||
|
GSource *source;
|
||||||
|
guint source_id = 0;
|
||||||
|
NMData *app_data;
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
app_data = nm_device_get_app_data (dev);
|
||||||
|
g_return_if_fail (app_data != NULL);
|
||||||
|
|
||||||
|
data = g_malloc0 (sizeof (NMStatusChangeData));
|
||||||
|
data->dev = dev;
|
||||||
|
data->status = status;
|
||||||
|
|
||||||
|
source = g_idle_source_new ();
|
||||||
|
g_source_set_callback (source, nm_dbus_device_status_change_helper, data, NULL);
|
||||||
|
source_id = g_source_attach (source, app_data->main_context);
|
||||||
|
g_source_unref (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_signal_device_status_change
|
* nm_dbus_signal_device_status_change
|
||||||
@@ -525,6 +572,9 @@ void nm_dbus_signal_device_status_change (DBusConnection *connection, NMDevice *
|
|||||||
case (DEVICE_LIST_CHANGE):
|
case (DEVICE_LIST_CHANGE):
|
||||||
signal = "DevicesChanged";
|
signal = "DevicesChanged";
|
||||||
break;
|
break;
|
||||||
|
case (DEVICE_STATUS_CHANGE):
|
||||||
|
signal = "DeviceStatusChanged";
|
||||||
|
break;
|
||||||
case (DEVICE_ACTIVATION_FAILED):
|
case (DEVICE_ACTIVATION_FAILED):
|
||||||
signal = "DeviceActivationFailed";
|
signal = "DeviceActivationFailed";
|
||||||
break;
|
break;
|
||||||
@@ -573,9 +623,11 @@ static char *nm_dbus_network_status_from_data (NMData *data)
|
|||||||
|
|
||||||
g_return_val_if_fail (data != NULL, NULL);
|
g_return_val_if_fail (data != NULL, NULL);
|
||||||
|
|
||||||
if (data->active_device && nm_device_is_activating (data->active_device))
|
if (data->forcing_device)
|
||||||
|
status = g_strdup ("scanning");
|
||||||
|
else if (data->active_device && nm_device_is_activating (data->active_device))
|
||||||
{
|
{
|
||||||
if (nm_device_is_wireless (data->active_device) && nm_device_is_scanning (data->active_device))
|
if (nm_device_is_wireless (data->active_device) && nm_device_get_now_scanning (data->active_device))
|
||||||
status = g_strdup ("scanning");
|
status = g_strdup ("scanning");
|
||||||
else
|
else
|
||||||
status = g_strdup ("connecting");
|
status = g_strdup ("connecting");
|
||||||
@@ -826,6 +878,7 @@ NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetwork
|
|||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
NMEncKeyType key_type = -1;
|
NMEncKeyType key_type = -1;
|
||||||
gboolean trusted = FALSE;
|
gboolean trusted = FALSE;
|
||||||
|
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||||
char **addrs = NULL;
|
char **addrs = NULL;
|
||||||
gint num_addr = -1;
|
gint num_addr = -1;
|
||||||
|
|
||||||
@@ -866,6 +919,7 @@ NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetwork
|
|||||||
DBUS_TYPE_INT32, ×tamp_secs,
|
DBUS_TYPE_INT32, ×tamp_secs,
|
||||||
DBUS_TYPE_STRING, &key,
|
DBUS_TYPE_STRING, &key,
|
||||||
DBUS_TYPE_INT32, &key_type,
|
DBUS_TYPE_INT32, &key_type,
|
||||||
|
DBUS_TYPE_INT32, &auth_method,
|
||||||
DBUS_TYPE_BOOLEAN, &trusted,
|
DBUS_TYPE_BOOLEAN, &trusted,
|
||||||
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &addrs, &num_addr,
|
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &addrs, &num_addr,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
@@ -889,6 +943,7 @@ NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetwork
|
|||||||
nm_ap_set_enc_key_source (ap, key, key_type);
|
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||||
else
|
else
|
||||||
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
||||||
|
nm_ap_set_auth_method (ap, auth_method);
|
||||||
|
|
||||||
/* Get user addresses, form into a GSList, and stuff into the AP */
|
/* Get user addresses, form into a GSList, and stuff into the AP */
|
||||||
{
|
{
|
||||||
@@ -923,6 +978,48 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_dbus_update_network_auth_method
|
||||||
|
*
|
||||||
|
* Tell NetworkManagerInfo the updated auth_method of the AP
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
gboolean nm_dbus_update_network_auth_method (DBusConnection *connection, const char *network, const NMDeviceAuthMethod auth_method)
|
||||||
|
{
|
||||||
|
DBusMessage *message;
|
||||||
|
DBusError error;
|
||||||
|
gboolean success = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (connection != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (network != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (auth_method != NM_DEVICE_AUTH_METHOD_UNKNOWN, FALSE);
|
||||||
|
|
||||||
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "updateNetworkAuthMethod");
|
||||||
|
if (!message)
|
||||||
|
{
|
||||||
|
syslog (LOG_ERR, "nm_dbus_update_network_auth_method (): Couldn't allocate the dbus message");
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
||||||
|
DBUS_TYPE_INT32, (int)auth_method,
|
||||||
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
|
/* Send message and get trusted status back from NetworkManagerInfo */
|
||||||
|
dbus_error_init (&error);
|
||||||
|
if (!dbus_connection_send (connection, message, NULL))
|
||||||
|
{
|
||||||
|
syslog (LOG_ERR, "nm_dbus_update_network_auth_method (): failed to send dbus message.");
|
||||||
|
dbus_error_free (&error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
success = TRUE;
|
||||||
|
|
||||||
|
dbus_message_unref (message);
|
||||||
|
return (success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_add_network_address
|
* nm_dbus_add_network_address
|
||||||
*
|
*
|
||||||
@@ -1076,7 +1173,7 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
|
|||||||
{
|
{
|
||||||
data->update_ap_lists = TRUE;
|
data->update_ap_lists = TRUE;
|
||||||
data->info_daemon_avail = TRUE;
|
data->info_daemon_avail = TRUE;
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
}
|
}
|
||||||
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
||||||
* may want to know about service signals.
|
* may want to know about service signals.
|
||||||
@@ -1093,7 +1190,7 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
|
|||||||
{
|
{
|
||||||
data->update_ap_lists = TRUE;
|
data->update_ap_lists = TRUE;
|
||||||
data->info_daemon_avail = FALSE;
|
data->info_daemon_avail = FALSE;
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
}
|
}
|
||||||
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
||||||
* may want to know about service signals.
|
* may want to know about service signals.
|
||||||
@@ -1322,7 +1419,7 @@ static DBusMessage *nm_dbus_devices_handle_request (DBusConnection *connection,
|
|||||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_BOOLEAN, &link, DBUS_TYPE_INVALID))
|
if (dbus_message_get_args (message, &error, DBUS_TYPE_BOOLEAN, &link, DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
nm_device_set_link_active (dev, link);
|
nm_device_set_link_active (dev, link);
|
||||||
nm_data_mark_state_changed (data);
|
nm_policy_schedule_state_update (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -35,7 +35,9 @@ typedef enum
|
|||||||
DEVICE_NO_LONGER_ACTIVE,
|
DEVICE_NO_LONGER_ACTIVE,
|
||||||
DEVICE_ACTIVATING,
|
DEVICE_ACTIVATING,
|
||||||
DEVICE_ACTIVATION_FAILED,
|
DEVICE_ACTIVATION_FAILED,
|
||||||
DEVICE_LIST_CHANGE
|
DEVICE_ACTIVATION_CANCELED,
|
||||||
|
DEVICE_LIST_CHANGE,
|
||||||
|
DEVICE_STATUS_CHANGE
|
||||||
} DeviceStatus;
|
} DeviceStatus;
|
||||||
|
|
||||||
|
|
||||||
@@ -43,11 +45,12 @@ DBusConnection *nm_dbus_init (NMData *data);
|
|||||||
|
|
||||||
gboolean nm_dbus_is_info_daemon_running (DBusConnection *connection);
|
gboolean nm_dbus_is_info_daemon_running (DBusConnection *connection);
|
||||||
|
|
||||||
|
void nm_dbus_schedule_device_status_change (NMDevice *dev, DeviceStatus status);
|
||||||
void nm_dbus_signal_device_status_change (DBusConnection *connection, NMDevice *dev, DeviceStatus status);
|
void nm_dbus_signal_device_status_change (DBusConnection *connection, NMDevice *dev, DeviceStatus status);
|
||||||
|
|
||||||
void nm_dbus_signal_network_status_change (DBusConnection *connection, NMData *data);
|
void nm_dbus_schedule_network_not_found_signal (NMData *data, const char *network);
|
||||||
|
|
||||||
void nm_dbus_signal_devices_changed (DBusConnection *connection);
|
void nm_dbus_signal_network_status_change (DBusConnection *connection, NMData *data);
|
||||||
|
|
||||||
void nm_dbus_signal_device_ip4_address_change(DBusConnection *connection, NMDevice *dev);
|
void nm_dbus_signal_device_ip4_address_change(DBusConnection *connection, NMDevice *dev);
|
||||||
|
|
||||||
@@ -61,6 +64,8 @@ NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetwo
|
|||||||
|
|
||||||
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
|
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
|
||||||
|
|
||||||
|
gboolean nm_dbus_update_network_auth_method (DBusConnection *connection, const char *network, const NMDeviceAuthMethod auth_method);
|
||||||
|
|
||||||
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -27,14 +27,6 @@
|
|||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerMain.h"
|
#include "NetworkManagerMain.h"
|
||||||
|
|
||||||
typedef enum NMDeviceAuthMethod
|
|
||||||
{
|
|
||||||
NM_DEVICE_AUTH_METHOD_UNKNOWN = 0,
|
|
||||||
NM_DEVICE_AUTH_METHOD_NONE,
|
|
||||||
NM_DEVICE_AUTH_METHOD_OPEN_SYSTEM,
|
|
||||||
NM_DEVICE_AUTH_METHOD_SHARED_KEY
|
|
||||||
} NMDeviceAuthMethod;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct NMDevice NMDevice;
|
typedef struct NMDevice NMDevice;
|
||||||
|
|
||||||
@@ -43,6 +35,7 @@ NMDevice * nm_device_new (const char *iface, const char *udi, gboolean test_
|
|||||||
|
|
||||||
void nm_device_ref (NMDevice *dev);
|
void nm_device_ref (NMDevice *dev);
|
||||||
gboolean nm_device_unref (NMDevice *dev);
|
gboolean nm_device_unref (NMDevice *dev);
|
||||||
|
void nm_device_worker_thread_stop (NMDevice *dev);
|
||||||
|
|
||||||
int nm_device_open_sock (void);
|
int nm_device_open_sock (void);
|
||||||
|
|
||||||
@@ -60,6 +53,9 @@ gboolean nm_device_is_wired (NMDevice *dev);
|
|||||||
|
|
||||||
NMData * nm_device_get_app_data (const NMDevice *dev);
|
NMData * nm_device_get_app_data (const NMDevice *dev);
|
||||||
|
|
||||||
|
gboolean nm_device_get_removed (const NMDevice *dev);
|
||||||
|
void nm_device_set_removed (NMDevice *dev, const gboolean removed);
|
||||||
|
|
||||||
gboolean nm_device_get_link_active (NMDevice *dev);
|
gboolean nm_device_get_link_active (NMDevice *dev);
|
||||||
void nm_device_set_link_active (NMDevice *dev, const gboolean active);
|
void nm_device_set_link_active (NMDevice *dev, const gboolean active);
|
||||||
void nm_device_update_link_active (NMDevice *dev, gboolean check_mii);
|
void nm_device_update_link_active (NMDevice *dev, gboolean check_mii);
|
||||||
@@ -111,13 +107,13 @@ gboolean nm_device_activation_should_cancel (NMDevice *dev);
|
|||||||
gboolean nm_device_is_activating (NMDevice *dev);
|
gboolean nm_device_is_activating (NMDevice *dev);
|
||||||
gboolean nm_device_deactivate (NMDevice *dev, gboolean just_added);
|
gboolean nm_device_deactivate (NMDevice *dev, gboolean just_added);
|
||||||
|
|
||||||
gboolean nm_device_is_scanning (NMDevice *dev);
|
gboolean nm_device_get_now_scanning (NMDevice *dev);
|
||||||
|
|
||||||
gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type);
|
void nm_device_schedule_force_use (NMDevice *dev, const char *network, const char *key, NMEncKeyType key_type);
|
||||||
|
|
||||||
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
||||||
unsigned char *network, unsigned char *key,
|
unsigned char *network, unsigned char *key,
|
||||||
NMEncKeyType enc_method);
|
NMEncKeyType enc_type);
|
||||||
|
|
||||||
void nm_device_bring_up (NMDevice *dev);
|
void nm_device_bring_up (NMDevice *dev);
|
||||||
void nm_device_bring_down (NMDevice *dev);
|
void nm_device_bring_down (NMDevice *dev);
|
||||||
|
@@ -90,6 +90,7 @@ struct NMDevice
|
|||||||
char *iface;
|
char *iface;
|
||||||
NMDeviceType type;
|
NMDeviceType type;
|
||||||
NMDriverSupportLevel driver_support_level;
|
NMDriverSupportLevel driver_support_level;
|
||||||
|
gboolean removed;
|
||||||
|
|
||||||
gboolean link_active;
|
gboolean link_active;
|
||||||
guint32 ip4_address;
|
guint32 ip4_address;
|
||||||
|
@@ -46,12 +46,6 @@ typedef struct NMData
|
|||||||
GMainLoop *main_loop;
|
GMainLoop *main_loop;
|
||||||
gboolean info_daemon_avail;
|
gboolean info_daemon_avail;
|
||||||
gboolean enable_test_devices;
|
gboolean enable_test_devices;
|
||||||
gboolean starting_up; /* Hack for not taking down an already-set-up wired device when we launch */
|
|
||||||
|
|
||||||
/* Main loop for wireless scanning thread */
|
|
||||||
GMainContext *wscan_ctx;
|
|
||||||
GMainLoop *wscan_loop;
|
|
||||||
gboolean wscan_thread_done;
|
|
||||||
|
|
||||||
guint state_modified_idle_id;
|
guint state_modified_idle_id;
|
||||||
|
|
||||||
@@ -61,8 +55,7 @@ typedef struct NMData
|
|||||||
struct NMDevice *active_device;
|
struct NMDevice *active_device;
|
||||||
gboolean active_device_locked;
|
gboolean active_device_locked;
|
||||||
|
|
||||||
struct NMDevice *user_device; /* Holds a device that the user requests NM to use. */
|
gboolean forcing_device;
|
||||||
GMutex *user_device_mutex;
|
|
||||||
|
|
||||||
gboolean update_ap_lists;
|
gboolean update_ap_lists;
|
||||||
struct NMAccessPointList *allowed_ap_list;
|
struct NMAccessPointList *allowed_ap_list;
|
||||||
@@ -75,8 +68,6 @@ struct NMDevice *nm_create_device_and_add_to_list (NMData *data, const char *ud
|
|||||||
|
|
||||||
void nm_remove_device_from_list (NMData *data, const char *udi);
|
void nm_remove_device_from_list (NMData *data, const char *udi);
|
||||||
|
|
||||||
void nm_data_mark_state_changed (NMData *data);
|
|
||||||
|
|
||||||
void nm_schedule_status_signal_broadcast (NMData *data);
|
void nm_schedule_status_signal_broadcast (NMData *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -155,7 +155,7 @@ static NMDevice * nm_policy_auto_get_best_device (NMData *data)
|
|||||||
* under certain conditions.
|
* under certain conditions.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static NMDevice * nm_policy_get_best_device (NMData *data, gboolean *should_lock_on_activate)
|
static NMDevice * nm_policy_get_best_device (NMDevice *switch_to_dev, NMData *data, gboolean *should_lock_on_activate)
|
||||||
{
|
{
|
||||||
NMDevice *best_dev = NULL;
|
NMDevice *best_dev = NULL;
|
||||||
|
|
||||||
@@ -168,19 +168,12 @@ static NMDevice * nm_policy_get_best_device (NMData *data, gboolean *should_lock
|
|||||||
if (should_lock_on_activate)
|
if (should_lock_on_activate)
|
||||||
*should_lock_on_activate = FALSE;
|
*should_lock_on_activate = FALSE;
|
||||||
|
|
||||||
/* If the user told us to switch to a particular device, do it now */
|
/* Prefer a device forced on us by the user */
|
||||||
if (nm_try_acquire_mutex (data->user_device_mutex, __FUNCTION__))
|
if (switch_to_dev && !nm_device_get_removed (switch_to_dev))
|
||||||
{
|
{
|
||||||
if (data->user_device)
|
best_dev = switch_to_dev;
|
||||||
{
|
|
||||||
best_dev = data->user_device;
|
|
||||||
|
|
||||||
nm_device_unref (data->user_device);
|
|
||||||
data->user_device = NULL;
|
|
||||||
*should_lock_on_activate = TRUE;
|
*should_lock_on_activate = TRUE;
|
||||||
}
|
}
|
||||||
nm_unlock_mutex (data->user_device_mutex, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine whether we need to clear the active device and unlock it.
|
/* Determine whether we need to clear the active device and unlock it.
|
||||||
* This occurs if the best device is removed, for example.
|
* This occurs if the best device is removed, for example.
|
||||||
@@ -249,9 +242,10 @@ gboolean nm_policy_activation_finish (gpointer user_data)
|
|||||||
if (!(data = nm_device_get_app_data (dev)))
|
if (!(data = nm_device_get_app_data (dev)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (result->success)
|
switch (result->result)
|
||||||
{
|
{
|
||||||
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_NOW_ACTIVE);
|
case DEVICE_NOW_ACTIVE:
|
||||||
|
nm_dbus_signal_device_status_change (data->dbus_connection, dev, result->result);
|
||||||
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
|
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
|
||||||
if (nm_device_is_wireless (dev))
|
if (nm_device_is_wireless (dev))
|
||||||
{
|
{
|
||||||
@@ -261,19 +255,17 @@ gboolean nm_policy_activation_finish (gpointer user_data)
|
|||||||
nm_dbus_add_network_address (data->dbus_connection, NETWORK_TYPE_ALLOWED, nm_device_get_essid (dev), &addr);
|
nm_dbus_add_network_address (data->dbus_connection, NETWORK_TYPE_ALLOWED, nm_device_get_essid (dev), &addr);
|
||||||
}
|
}
|
||||||
syslog (LOG_INFO, "Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
|
syslog (LOG_INFO, "Activation (%s) successful, device activated.", nm_device_get_iface (data->active_device));
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
case DEVICE_ACTIVATION_FAILED:
|
||||||
nm_dbus_signal_device_status_change (data->dbus_connection, dev, DEVICE_ACTIVATION_FAILED);
|
nm_dbus_signal_device_status_change (data->dbus_connection, dev, result->result);
|
||||||
if (nm_device_is_wireless (dev))
|
if (nm_device_is_wireless (dev))
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap = nm_device_get_best_ap (dev);
|
NMAccessPoint *ap = nm_device_get_best_ap (dev);
|
||||||
if (ap)
|
if (ap)
|
||||||
{
|
{
|
||||||
/* Add the AP to the invalid list and force a best ap update (list takes ownership of ap) */
|
/* Add the AP to the invalid list and force a best ap update */
|
||||||
nm_ap_list_append_ap (data->invalid_ap_list, ap);
|
nm_ap_list_append_ap (data->invalid_ap_list, ap);
|
||||||
nm_ap_unref (ap);
|
|
||||||
|
|
||||||
nm_device_update_best_ap (dev);
|
nm_device_update_best_ap (dev);
|
||||||
|
|
||||||
/* Unref because nm_device_get_best_ap() refs it before returning. */
|
/* Unref because nm_device_get_best_ap() refs it before returning. */
|
||||||
@@ -283,15 +275,27 @@ gboolean nm_policy_activation_finish (gpointer user_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
syslog (LOG_INFO, "Activation (%s) failed.", nm_device_get_iface (dev));
|
syslog (LOG_INFO, "Activation (%s) failed.", nm_device_get_iface (dev));
|
||||||
nm_data_mark_state_changed (data);
|
break;
|
||||||
|
|
||||||
|
case DEVICE_ACTIVATION_CANCELED:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_policy_schedule_state_update (data);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
nm_device_unref (dev);
|
nm_device_unref (dev);
|
||||||
g_free (result);
|
g_free (result);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct NMStateUpdateData
|
||||||
|
{
|
||||||
|
NMDevice *switch_to_dev;
|
||||||
|
NMData *app_data;
|
||||||
|
} NMStateUpdateData;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_state_modification_monitor
|
* nm_state_modification_monitor
|
||||||
@@ -303,40 +307,57 @@ out:
|
|||||||
* 2) link state change of an interface
|
* 2) link state change of an interface
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gboolean nm_state_modification_monitor (gpointer user_data)
|
static gboolean nm_policy_state_update (gpointer user_data)
|
||||||
{
|
{
|
||||||
NMData *data = (NMData *)user_data;
|
NMStateUpdateData *cb_data = (NMStateUpdateData *)user_data;
|
||||||
|
NMData *app_data;
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||||
|
|
||||||
data->state_modified_idle_id = 0;
|
app_data = cb_data->app_data;
|
||||||
|
if (!app_data)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
app_data->state_modified_idle_id = 0;
|
||||||
|
|
||||||
/* If the info daemon is now running, get our trusted/preferred ap lists from it */
|
/* If the info daemon is now running, get our trusted/preferred ap lists from it */
|
||||||
if (data->info_daemon_avail && data->update_ap_lists)
|
if (app_data->info_daemon_avail && app_data->update_ap_lists)
|
||||||
{
|
{
|
||||||
/* Query info daemon for network lists if its now running */
|
/* Query info daemon for network lists if its now running */
|
||||||
if (data->allowed_ap_list)
|
if (app_data->allowed_ap_list)
|
||||||
nm_ap_list_unref (data->allowed_ap_list);
|
nm_ap_list_unref (app_data->allowed_ap_list);
|
||||||
data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
app_data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
||||||
if (data->allowed_ap_list)
|
if (app_data->allowed_ap_list)
|
||||||
nm_ap_list_populate_from_nmi (data->allowed_ap_list, data);
|
nm_ap_list_populate_from_nmi (app_data->allowed_ap_list, app_data);
|
||||||
|
|
||||||
data->update_ap_lists = FALSE;
|
app_data->update_ap_lists = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
|
/* If we're currently waiting for a force-device operation to complete, don't try
|
||||||
|
* to change devices. We'll be notified of what device to switch to explicitly
|
||||||
|
* when the force-device operation completes.
|
||||||
|
*/
|
||||||
|
if (!cb_data->switch_to_dev && app_data->forcing_device)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
app_data->forcing_device = FALSE;
|
||||||
|
|
||||||
|
if (nm_try_acquire_mutex (app_data->dev_list_mutex, __FUNCTION__))
|
||||||
{
|
{
|
||||||
gboolean should_lock_on_activate = FALSE;
|
gboolean should_lock_on_activate = FALSE;
|
||||||
gboolean do_switch = FALSE;
|
gboolean do_switch = FALSE;
|
||||||
NMDevice *best_dev = NULL;
|
NMDevice *best_dev = NULL;
|
||||||
|
|
||||||
if ((best_dev = nm_policy_get_best_device (data, &should_lock_on_activate)))
|
if ((best_dev = nm_policy_get_best_device (cb_data->switch_to_dev, app_data, &should_lock_on_activate)))
|
||||||
nm_device_ref (best_dev);
|
nm_device_ref (best_dev);
|
||||||
|
|
||||||
/* Figure out if we need to change devices or wireless networks */
|
/* Figure out if we need to change devices or wireless networks */
|
||||||
if (best_dev != data->active_device)
|
if (best_dev != app_data->active_device)
|
||||||
{
|
{
|
||||||
|
if (best_dev)
|
||||||
syslog (LOG_INFO, " SWITCH: best device changed");
|
syslog (LOG_INFO, " SWITCH: best device changed");
|
||||||
|
else
|
||||||
|
syslog (LOG_INFO, " SWITCH: old device no longer good, but no better device was available");
|
||||||
do_switch = TRUE; /* Device changed */
|
do_switch = TRUE; /* Device changed */
|
||||||
}
|
}
|
||||||
else if (best_dev)
|
else if (best_dev)
|
||||||
@@ -356,39 +377,87 @@ gboolean nm_state_modification_monitor (gpointer user_data)
|
|||||||
if (do_switch)
|
if (do_switch)
|
||||||
{
|
{
|
||||||
/* Deactivate the old device */
|
/* Deactivate the old device */
|
||||||
if (data->active_device)
|
if (app_data->active_device)
|
||||||
{
|
{
|
||||||
nm_device_deactivate (data->active_device, FALSE);
|
nm_device_deactivate (app_data->active_device, FALSE);
|
||||||
nm_device_unref (data->active_device);
|
nm_device_unref (app_data->active_device);
|
||||||
data->active_device = NULL;
|
app_data->active_device = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_dev)
|
if (best_dev)
|
||||||
{
|
{
|
||||||
/* Begin activation on the new device */
|
/* Begin activation on the new device */
|
||||||
nm_device_ref (best_dev);
|
nm_device_ref (best_dev);
|
||||||
data->active_device = best_dev;
|
app_data->active_device = best_dev;
|
||||||
nm_device_activation_schedule_start (data->active_device);
|
nm_device_activation_schedule_start (app_data->active_device);
|
||||||
|
|
||||||
/* nm_policy_get_best_device() signals us that the user forced
|
/* nm_policy_get_best_device() signals us that the user forced
|
||||||
* a device upon us and that we should lock the active device.
|
* a device upon us and that we should lock the active device.
|
||||||
*/
|
*/
|
||||||
if (should_lock_on_activate)
|
if (should_lock_on_activate)
|
||||||
data->active_device_locked = TRUE;
|
app_data->active_device_locked = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_dev)
|
if (best_dev)
|
||||||
nm_device_unref (best_dev);
|
nm_device_unref (best_dev);
|
||||||
|
|
||||||
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
|
nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the starting up flag, so we will now take over and have our way with
|
out:
|
||||||
* any device we find out about.
|
g_free (cb_data);
|
||||||
*/
|
|
||||||
if (data->starting_up)
|
|
||||||
data->starting_up = FALSE;
|
|
||||||
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_policy_schedule_state_update
|
||||||
|
*
|
||||||
|
* Queue up an idle handler to deal with state changes.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_policy_schedule_state_update (NMData *app_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (app_data != NULL);
|
||||||
|
|
||||||
|
nm_policy_schedule_device_switch (NULL, app_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_policy_schedule_state_update
|
||||||
|
*
|
||||||
|
* Queue up an idle handler to deal with state changes when we want
|
||||||
|
* to force a particular device to be the active device.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_policy_schedule_device_switch (NMDevice *switch_to_dev, NMData *app_data)
|
||||||
|
{
|
||||||
|
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
||||||
|
|
||||||
|
g_return_if_fail (app_data != NULL);
|
||||||
|
|
||||||
|
g_static_mutex_lock (&mutex);
|
||||||
|
|
||||||
|
/* Don't queue the idle handler if switch_to_dev is NULL and there's already
|
||||||
|
* an idle handler queued. Always queue the idle handler if we were passed
|
||||||
|
* a switch_to_dev.
|
||||||
|
*/
|
||||||
|
if (switch_to_dev || (app_data->state_modified_idle_id == 0))
|
||||||
|
{
|
||||||
|
GSource *source = g_idle_source_new ();
|
||||||
|
NMStateUpdateData *cb_data = g_malloc0 (sizeof (NMStateUpdateData));
|
||||||
|
|
||||||
|
cb_data->switch_to_dev = switch_to_dev;
|
||||||
|
cb_data->app_data = app_data;
|
||||||
|
|
||||||
|
g_source_set_callback (source, nm_policy_state_update, cb_data, NULL);
|
||||||
|
app_data->state_modified_idle_id = g_source_attach (source, app_data->main_context);
|
||||||
|
g_source_unref (source);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
g_static_mutex_unlock (&mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -24,15 +24,18 @@
|
|||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerDevice.h"
|
#include "NetworkManagerDevice.h"
|
||||||
|
#include "NetworkManagerDbus.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
NMDevice *dev;
|
NMDevice *dev;
|
||||||
gboolean success;
|
DeviceStatus result;
|
||||||
} NMActivationResult;
|
} NMActivationResult;
|
||||||
|
|
||||||
|
|
||||||
gboolean nm_state_modification_monitor (gpointer user_data);
|
void nm_policy_schedule_state_update (NMData *app_data);
|
||||||
|
|
||||||
|
void nm_policy_schedule_device_switch (NMDevice *dev, NMData *app_data);
|
||||||
|
|
||||||
gboolean nm_policy_activation_finish (gpointer user_data);
|
gboolean nm_policy_activation_finish (gpointer user_data);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user