mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 04:48:10 +02:00
2007-06-11 Tambet Ingo <tambet@ximian.com>
* src/nm-device.c: Make the activation stage virtual functions take NMDevice argument. The activation request is easy to retrieve. * src/nm-activation-request.c: Convert to GObject. Do not include half of NM headers just to be a convenient location for devices to store random stuff. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2587 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
327b1a5162
commit
9d1808c4e5
12 changed files with 240 additions and 324 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2007-06-11 Tambet Ingo <tambet@ximian.com>
|
||||
|
||||
* src/nm-device.c: Make the activation stage virtual functions take NMDevice
|
||||
argument. The activation request is easy to retrieve.
|
||||
|
||||
* src/nm-activation-request.c: Convert to GObject. Do not include half of NM headers
|
||||
just to be a convenient location for devices to store random stuff.
|
||||
|
||||
2007-06-11 Christopher Aillon <caillon@redhat.com>
|
||||
|
||||
Patch from Alex Smith <alex@alex-smith.me.uk>
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ main (int argc, char *argv[])
|
|||
nm_data);
|
||||
|
||||
manager = nm_manager_new ();
|
||||
g_object_set_data (manager, "NM_DATA_HACK", nm_data);
|
||||
g_object_set_data (G_OBJECT (manager), "NM_DATA_HACK", nm_data);
|
||||
policy = nm_policy_new (manager);
|
||||
|
||||
nm_dbus_manager_register_signal_handler (dbus_mgr,
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ nm_dbus_nmi_signal_handler (DBusConnection *connection,
|
|||
/* Update a single wireless network's data */
|
||||
nm_debug ("NetworkManagerInfo triggered update of wireless network '%s'", network);
|
||||
nm_dbus_update_one_allowed_network (network,
|
||||
(NMData *) g_object_get_data (manager, "NM_DATA_HACK"));
|
||||
(NMData *) g_object_get_data (G_OBJECT (manager), "NM_DATA_HACK"));
|
||||
handled = TRUE;
|
||||
}
|
||||
} else if (dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "UserInterfaceActivated")) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include "nm-named-manager.h"
|
||||
|
||||
|
||||
typedef struct NMActRequest NMActRequest;
|
||||
typedef struct NMVPNActRequest NMVPNActRequest;
|
||||
typedef struct NMVPNManager NMVPNManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,124 +20,74 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include "nm-activation-request.h"
|
||||
#include "nm-device.h"
|
||||
#include "NetworkManagerDbus.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT)
|
||||
|
||||
struct NMActRequest
|
||||
{
|
||||
int refcount;
|
||||
NMDevice * dev;
|
||||
#define NM_ACT_REQUEST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACT_REQUEST, NMActRequestPrivate))
|
||||
|
||||
typedef struct {
|
||||
NMConnection *connection;
|
||||
NMIP4Config * ip4_config;
|
||||
gboolean user_requested;
|
||||
} NMActRequestPrivate;
|
||||
|
||||
gboolean user_requested;
|
||||
|
||||
DBusPendingCall * user_key_pcall;
|
||||
};
|
||||
|
||||
NMActRequest * nm_act_request_new (NMDevice *dev, NMConnection *connection, gboolean user_requested)
|
||||
static void
|
||||
nm_act_request_init (NMActRequest *req)
|
||||
{
|
||||
NMActRequest * req;
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||
|
||||
nm_connection_destroy (priv->connection);
|
||||
|
||||
G_OBJECT_CLASS (nm_act_request_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_act_request_class_init (NMActRequestClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
|
||||
g_type_class_add_private (req_class, sizeof (NMActRequestPrivate));
|
||||
|
||||
object_class->finalize = finalize;
|
||||
}
|
||||
|
||||
NMActRequest *
|
||||
nm_act_request_new (NMConnection *connection, gboolean user_requested)
|
||||
{
|
||||
GObject *obj;
|
||||
NMActRequestPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (dev != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
req = g_slice_new0 (NMActRequest);
|
||||
req->refcount = 1;
|
||||
obj = g_object_new (NM_TYPE_ACT_REQUEST, NULL);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
req->dev = g_object_ref (G_OBJECT (dev));
|
||||
req->connection = connection;
|
||||
req->user_requested = user_requested;
|
||||
priv = NM_ACT_REQUEST_GET_PRIVATE (obj);
|
||||
|
||||
return req;
|
||||
priv->connection = connection;
|
||||
priv->user_requested = user_requested;
|
||||
|
||||
return NM_ACT_REQUEST (obj);
|
||||
}
|
||||
|
||||
void nm_act_request_ref (NMActRequest *req)
|
||||
NMConnection *
|
||||
nm_act_request_get_connection (NMActRequest *req)
|
||||
{
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL);
|
||||
|
||||
req->refcount++;
|
||||
return NM_ACT_REQUEST_GET_PRIVATE (req)->connection;
|
||||
}
|
||||
|
||||
|
||||
void nm_act_request_unref (NMActRequest *req)
|
||||
gboolean
|
||||
nm_act_request_get_user_requested (NMActRequest *req)
|
||||
{
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
|
||||
|
||||
req->refcount--;
|
||||
if (req->refcount <= 0) {
|
||||
g_object_unref (G_OBJECT (req->dev));
|
||||
/* FIXME: destroy connection? */
|
||||
g_slice_free (NMActRequest, req);
|
||||
}
|
||||
}
|
||||
|
||||
NMDevice * nm_act_request_get_dev (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
||||
return req->dev;
|
||||
}
|
||||
|
||||
|
||||
NMConnection * nm_act_request_get_connection (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
||||
return req->connection;
|
||||
}
|
||||
|
||||
|
||||
gboolean nm_act_request_get_user_requested (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
return req->user_requested;
|
||||
}
|
||||
|
||||
|
||||
NMIP4Config * nm_act_request_get_ip4_config (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
||||
return req->ip4_config;
|
||||
}
|
||||
|
||||
void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config)
|
||||
{
|
||||
g_return_if_fail (req != NULL);
|
||||
|
||||
if (req->ip4_config)
|
||||
{
|
||||
g_object_unref (req->ip4_config);
|
||||
req->ip4_config = NULL;
|
||||
}
|
||||
|
||||
if (ip4_config)
|
||||
req->ip4_config = g_object_ref (ip4_config);
|
||||
}
|
||||
|
||||
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
||||
return req->user_key_pcall;
|
||||
}
|
||||
|
||||
void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall)
|
||||
{
|
||||
g_return_if_fail (req != NULL);
|
||||
|
||||
if (req->user_key_pcall)
|
||||
dbus_pending_call_unref (req->user_key_pcall);
|
||||
req->user_key_pcall = pcall;
|
||||
if (req->user_key_pcall)
|
||||
dbus_pending_call_ref (req->user_key_pcall);
|
||||
return NM_ACT_REQUEST_GET_PRIVATE (req)->user_requested;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,26 +22,31 @@
|
|||
#ifndef NM_ACTIVATION_REQUEST_H
|
||||
#define NM_ACTIVATION_REQUEST_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include "NetworkManager.h"
|
||||
#include "NetworkManagerMain.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib-object.h>
|
||||
#include "nm-connection.h"
|
||||
|
||||
NMActRequest * nm_act_request_new (NMDevice *dev, NMConnection *connection, gboolean user_requested);
|
||||
void nm_act_request_ref (NMActRequest *req);
|
||||
void nm_act_request_unref (NMActRequest *req);
|
||||
#define NM_TYPE_ACT_REQUEST (nm_act_request_get_type ())
|
||||
#define NM_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACT_REQUEST, NMActRequest))
|
||||
#define NM_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACT_REQUEST, NMActRequestClass))
|
||||
#define NM_IS_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_ACT_REQUEST))
|
||||
#define NM_IS_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_ACT_REQUEST))
|
||||
#define NM_ACT_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACT_REQUEST, NMActRequestClass))
|
||||
|
||||
NMDevice * nm_act_request_get_dev (NMActRequest *req);
|
||||
NMConnection * nm_act_request_get_connection (NMActRequest *req);
|
||||
gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
} NMActRequest;
|
||||
|
||||
NMIP4Config * nm_act_request_get_ip4_config (NMActRequest *req);
|
||||
void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config);
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
} NMActRequestClass;
|
||||
|
||||
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req);
|
||||
void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall);
|
||||
GType nm_act_request_get_type (void);
|
||||
|
||||
#endif
|
||||
NMActRequest *nm_act_request_new (NMConnection *connection,
|
||||
gboolean user_requested);
|
||||
|
||||
NMConnection *nm_act_request_get_connection (NMActRequest *req);
|
||||
gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
||||
|
||||
#endif /* NM_ACTIVATION_REQUEST_H */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,25 @@
|
|||
#include "nm-utils.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
||||
#define NM_ACT_REQUEST_PENDING_CALL "nm-act-request-pending-call"
|
||||
|
||||
typedef struct {
|
||||
NMDevice *device;
|
||||
NMActRequest *req;
|
||||
} UserKeyInfo;
|
||||
|
||||
static void
|
||||
user_key_info_destroy (gpointer data)
|
||||
{
|
||||
UserKeyInfo *info = (UserKeyInfo *) data;
|
||||
|
||||
g_object_set_data (G_OBJECT (info->req), NM_ACT_REQUEST_PENDING_CALL, NULL);
|
||||
|
||||
g_object_unref (info->device);
|
||||
g_object_unref (info->req);
|
||||
|
||||
g_slice_free (UserKeyInfo, info);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_dbus_get_user_key_for_network_cb
|
||||
|
|
@ -40,20 +59,21 @@
|
|||
*/
|
||||
static void
|
||||
nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall,
|
||||
NMActRequest *req)
|
||||
UserKeyInfo *info)
|
||||
{
|
||||
DBusMessage * reply = NULL;
|
||||
NMData * data;
|
||||
NMDevice * dev;
|
||||
NMActRequest *req;
|
||||
NMAccessPoint * ap;
|
||||
NMAPSecurity * security;
|
||||
DBusMessageIter iter;
|
||||
|
||||
g_return_if_fail (pcall != NULL);
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (info != NULL);
|
||||
|
||||
dev = nm_act_request_get_dev (req);
|
||||
g_assert (dev);
|
||||
dev = info->device;
|
||||
req = info->req;
|
||||
|
||||
data = nm_device_get_app_data (dev);
|
||||
g_assert (data);
|
||||
|
|
@ -106,14 +126,13 @@ nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall,
|
|||
dbus_message_iter_init (reply, &iter);
|
||||
if ((security = nm_ap_security_new_deserialize (&iter))) {
|
||||
nm_ap_set_security (ap, security);
|
||||
nm_device_activate_schedule_stage2_device_config (req);
|
||||
nm_device_activate_schedule_stage2_device_config (dev);
|
||||
}
|
||||
nm_act_request_set_user_key_pending_call (req, NULL);
|
||||
|
||||
out:
|
||||
if (reply)
|
||||
dbus_message_unref (reply);
|
||||
nm_act_request_unref (req);
|
||||
g_object_unref (req);
|
||||
dbus_pending_call_unref (pcall);
|
||||
}
|
||||
|
||||
|
|
@ -125,20 +144,22 @@ out:
|
|||
*
|
||||
*/
|
||||
void
|
||||
nm_dbus_get_user_key_for_network (NMActRequest *req,
|
||||
nm_dbus_get_user_key_for_network (NMDevice *dev,
|
||||
NMActRequest *req,
|
||||
const gboolean new_key)
|
||||
{
|
||||
NMDBusManager * dbus_mgr = NULL;
|
||||
DBusConnection *dbus_connection;
|
||||
DBusMessage * message;
|
||||
DBusPendingCall * pcall;
|
||||
NMDevice * dev;
|
||||
UserKeyInfo *info;
|
||||
NMAccessPoint * ap;
|
||||
gint32 attempt = 1;
|
||||
char * dev_path;
|
||||
char * net_path;
|
||||
const char * essid;
|
||||
|
||||
g_return_if_fail (NM_IS_DEVICE (dev));
|
||||
g_return_if_fail (req != NULL);
|
||||
|
||||
dbus_mgr = nm_dbus_manager_get ();
|
||||
|
|
@ -148,9 +169,6 @@ nm_dbus_get_user_key_for_network (NMActRequest *req,
|
|||
goto out;
|
||||
}
|
||||
|
||||
dev = nm_act_request_get_dev (req);
|
||||
g_assert (dev);
|
||||
|
||||
ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (dev));
|
||||
g_assert (ap);
|
||||
|
||||
|
|
@ -177,16 +195,19 @@ nm_dbus_get_user_key_for_network (NMActRequest *req,
|
|||
DBUS_TYPE_INT32, &attempt,
|
||||
DBUS_TYPE_BOOLEAN, &new_key,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
info = g_slice_new (UserKeyInfo);
|
||||
info->device = g_object_ref (dev);
|
||||
info->req = g_object_ref (req);
|
||||
|
||||
pcall = nm_dbus_send_with_callback (dbus_connection,
|
||||
message,
|
||||
(DBusPendingCallNotifyFunction) nm_dbus_get_user_key_for_network_cb,
|
||||
req,
|
||||
NULL,
|
||||
user_key_info_destroy,
|
||||
__func__);
|
||||
if (pcall) {
|
||||
nm_act_request_ref (req);
|
||||
nm_act_request_set_user_key_pending_call (req, pcall);
|
||||
}
|
||||
if (pcall)
|
||||
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_PENDING_CALL, pcall);
|
||||
} else {
|
||||
nm_warning ("bad object path data");
|
||||
}
|
||||
|
|
@ -228,7 +249,8 @@ nm_dbus_cancel_get_user_key_for_network (NMActRequest *req)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if ((pcall = nm_act_request_get_user_key_pending_call (req)))
|
||||
pcall = (DBusPendingCall *) g_object_get_data (G_OBJECT (req), NM_ACT_REQUEST_PENDING_CALL);
|
||||
if (pcall)
|
||||
dbus_pending_call_cancel (pcall);
|
||||
|
||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
#include "NetworkManager.h"
|
||||
#include "NetworkManagerAP.h"
|
||||
|
||||
void nm_dbus_get_user_key_for_network (NMActRequest *req, const gboolean new_key);
|
||||
void nm_dbus_get_user_key_for_network (NMDevice *dev,
|
||||
NMActRequest *req,
|
||||
const gboolean new_key);
|
||||
|
||||
void nm_dbus_cancel_get_user_key_for_network (NMActRequest *req);
|
||||
|
||||
|
|
|
|||
|
|
@ -2173,7 +2173,7 @@ link_timeout_cb (gpointer user_data)
|
|||
" asking for new key.", nm_device_get_iface (dev));
|
||||
cleanup_association_attempt (self, TRUE);
|
||||
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH);
|
||||
nm_dbus_get_user_key_for_network (req, TRUE);
|
||||
nm_dbus_get_user_key_for_network (dev, req, TRUE);
|
||||
} else {
|
||||
nm_info ("%s: link timed out.", nm_device_get_iface (dev));
|
||||
nm_device_set_active_link (dev, FALSE);
|
||||
|
|
@ -2276,7 +2276,6 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
|||
struct state_cb_data * cb_data = (struct state_cb_data *) user_data;
|
||||
NMDevice80211Wireless * self;
|
||||
NMDevice * dev;
|
||||
NMActRequest * req;
|
||||
guint32 new_state, old_state;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
|
|
@ -2286,14 +2285,13 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
|||
new_state = cb_data->new_state;
|
||||
old_state = cb_data->old_state;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
if (!req) {
|
||||
if (!nm_device_get_act_request (NM_DEVICE (self))) {
|
||||
/* The device is not activating or already activated; do nothing. */
|
||||
goto out;
|
||||
}
|
||||
|
||||
nm_debug ("(%s) Supplicant interface state change: %d -> %d",
|
||||
nm_device_get_iface (NM_DEVICE (self)), old_state, new_state);
|
||||
nm_device_get_iface (dev), old_state, new_state);
|
||||
|
||||
if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED) {
|
||||
remove_supplicant_interface_connection_error_handler (self);
|
||||
|
|
@ -2308,9 +2306,9 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
|
|||
|
||||
nm_info ("Activation (%s/wireless) Stage 2 of 5 (Device Configure) "
|
||||
"successful. Connected to wireless network '%s'.",
|
||||
nm_device_get_iface (NM_DEVICE (self)),
|
||||
nm_device_get_iface (dev),
|
||||
nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||
nm_device_activate_schedule_stage3_ip_config_start (req);
|
||||
nm_device_activate_schedule_stage3_ip_config_start (dev);
|
||||
}
|
||||
} else if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED) {
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (dev)) {
|
||||
|
|
@ -2462,12 +2460,10 @@ supplicant_iface_connection_error_cb_handler (gpointer user_data)
|
|||
{
|
||||
struct iface_con_error_cb_data * cb_data = (struct iface_con_error_cb_data *) user_data;
|
||||
NMDevice80211Wireless * self;
|
||||
NMActRequest * req;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
|
||||
self = cb_data->self;
|
||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||
|
||||
if (!nm_device_is_activating (NM_DEVICE (self)))
|
||||
goto out;
|
||||
|
|
@ -2536,7 +2532,6 @@ supplicant_connection_timeout_cb (gpointer user_data)
|
|||
{
|
||||
NMDevice * dev = NM_DEVICE (user_data);
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (user_data);
|
||||
NMActRequest * req = nm_device_get_act_request (dev);
|
||||
NMAccessPoint * ap = nm_device_802_11_wireless_get_activation_ap (self);
|
||||
gboolean has_key;
|
||||
|
||||
|
|
@ -2554,7 +2549,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
|
|||
nm_device_get_iface (dev));
|
||||
|
||||
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH);
|
||||
nm_dbus_get_user_key_for_network (req, TRUE);
|
||||
nm_dbus_get_user_key_for_network (dev, nm_device_get_act_request (dev), TRUE);
|
||||
} else {
|
||||
if (nm_device_is_activating (dev)) {
|
||||
nm_info ("Activation (%s/wireless): association took too long, "
|
||||
|
|
@ -2603,8 +2598,7 @@ remove_supplicant_timeouts (NMDevice80211Wireless *self)
|
|||
|
||||
|
||||
static NMSupplicantConfig *
|
||||
build_supplicant_config (NMDevice80211Wireless *self,
|
||||
NMActRequest *req)
|
||||
build_supplicant_config (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMSupplicantConfig * config = NULL;
|
||||
NMAccessPoint * ap = NULL;
|
||||
|
|
@ -2612,7 +2606,6 @@ build_supplicant_config (NMDevice80211Wireless *self,
|
|||
gboolean is_adhoc;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (req != NULL, NULL);
|
||||
|
||||
ap = nm_device_802_11_wireless_get_activation_ap (self);
|
||||
g_assert (ap);
|
||||
|
|
@ -2683,13 +2676,14 @@ real_set_hw_address (NMDevice *dev)
|
|||
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage1_prepare (NMDevice *dev,
|
||||
NMActRequest *req)
|
||||
real_act_stage1_prepare (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless *self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMActRequest *req;
|
||||
NMSettingWireless *setting;
|
||||
gboolean success;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
setting = (NMSettingWireless *) nm_connection_get_setting (nm_act_request_get_connection (req),
|
||||
"802-11-wireless");
|
||||
g_assert (setting);
|
||||
|
|
@ -2700,8 +2694,7 @@ real_act_stage1_prepare (NMDevice *dev,
|
|||
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage2_config (NMDevice *dev,
|
||||
NMActRequest *req)
|
||||
real_act_stage2_config (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMAccessPoint * ap = nm_device_802_11_wireless_get_activation_ap (self);
|
||||
|
|
@ -2718,11 +2711,11 @@ real_act_stage2_config (NMDevice *dev,
|
|||
/* If we need an encryption key, get one */
|
||||
if (ap_need_key (self, ap, &ask_user)) {
|
||||
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH);
|
||||
nm_dbus_get_user_key_for_network (req, ask_user);
|
||||
nm_dbus_get_user_key_for_network (dev, nm_device_get_act_request (dev), ask_user);
|
||||
return NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
|
||||
config = build_supplicant_config (self, req);
|
||||
config = build_supplicant_config (self);
|
||||
if (config == NULL) {
|
||||
nm_warning ("Activation (%s/wireless): couldn't build wireless "
|
||||
"configuration.", iface);
|
||||
|
|
@ -2764,8 +2757,7 @@ out:
|
|||
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage3_ip_config_start (NMDevice *dev,
|
||||
NMActRequest *req)
|
||||
real_act_stage3_ip_config_start (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMAccessPoint * ap = nm_device_802_11_wireless_get_activation_ap (self);
|
||||
|
|
@ -2784,7 +2776,7 @@ real_act_stage3_ip_config_start (NMDevice *dev,
|
|||
/* Chain up to parent */
|
||||
klass = NM_DEVICE_802_11_WIRELESS_GET_CLASS (self);
|
||||
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
|
||||
ret = parent_class->act_stage3_ip_config_start (dev, req);
|
||||
ret = parent_class->act_stage3_ip_config_start (dev);
|
||||
}
|
||||
else
|
||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
|
@ -2795,7 +2787,6 @@ real_act_stage3_ip_config_start (NMDevice *dev,
|
|||
|
||||
static NMActStageReturn
|
||||
real_act_stage4_get_ip4_config (NMDevice *dev,
|
||||
NMActRequest *req,
|
||||
NMIP4Config **config)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
|
|
@ -2820,7 +2811,7 @@ real_act_stage4_get_ip4_config (NMDevice *dev,
|
|||
/* Chain up to parent */
|
||||
klass = NM_DEVICE_802_11_WIRELESS_GET_CLASS (self);
|
||||
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
|
||||
ret = parent_class->act_stage4_get_ip4_config (dev, req, &real_config);
|
||||
ret = parent_class->act_stage4_get_ip4_config (dev, &real_config);
|
||||
}
|
||||
*config = real_config;
|
||||
|
||||
|
|
@ -2830,7 +2821,6 @@ real_act_stage4_get_ip4_config (NMDevice *dev,
|
|||
|
||||
static NMActStageReturn
|
||||
real_act_stage4_ip_config_timeout (NMDevice *dev,
|
||||
NMActRequest *req,
|
||||
NMIP4Config **config)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
|
|
@ -2858,7 +2848,7 @@ real_act_stage4_ip_config_timeout (NMDevice *dev,
|
|||
nm_debug ("Activation (%s/wireless): could not get IP configuration info for '%s', asking for new key.",
|
||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH);
|
||||
nm_dbus_get_user_key_for_network (req, TRUE);
|
||||
nm_dbus_get_user_key_for_network (dev, nm_device_get_act_request (dev), TRUE);
|
||||
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
||||
}
|
||||
else if (nm_ap_get_mode (ap) == IW_MODE_ADHOC)
|
||||
|
|
@ -2869,7 +2859,7 @@ real_act_stage4_ip_config_timeout (NMDevice *dev,
|
|||
/* For Ad-Hoc networks, chain up to parent to get a Zeroconf IP */
|
||||
klass = NM_DEVICE_802_11_WIRELESS_GET_CLASS (self);
|
||||
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
|
||||
ret = parent_class->act_stage4_ip_config_timeout (dev, req, &real_config);
|
||||
ret = parent_class->act_stage4_ip_config_timeout (dev, &real_config);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2887,16 +2877,14 @@ static void
|
|||
activation_success_handler (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMActRequest *req;
|
||||
struct ether_addr addr;
|
||||
NMAccessPoint * ap;
|
||||
gboolean automatic;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
ap = nm_device_802_11_wireless_get_activation_ap (self);
|
||||
|
||||
/* Cache details in the info-daemon since the connect was successful */
|
||||
automatic = !nm_act_request_get_user_requested (req);
|
||||
automatic = !nm_act_request_get_user_requested (nm_device_get_act_request (dev));
|
||||
|
||||
/* If it's a user-created ad-hoc network, add it to the device's scan list */
|
||||
if (!automatic && (nm_ap_get_mode (ap) == IW_MODE_ADHOC) && nm_ap_get_user_created (ap))
|
||||
|
|
@ -2919,10 +2907,8 @@ activation_failure_handler (NMDevice *dev)
|
|||
{
|
||||
NMData * app_data;
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMActRequest *req;
|
||||
NMAccessPoint * ap;
|
||||
|
||||
req = nm_device_get_act_request (dev);
|
||||
app_data = nm_device_get_app_data (dev);
|
||||
g_assert (app_data);
|
||||
|
||||
|
|
@ -2954,8 +2940,7 @@ activation_failure_handler (NMDevice *dev)
|
|||
}
|
||||
|
||||
static void
|
||||
real_activation_cancel_handler (NMDevice *dev,
|
||||
NMActRequest *req)
|
||||
real_activation_cancel_handler (NMDevice *dev)
|
||||
{
|
||||
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
|
||||
NMDevice80211WirelessClass * klass;
|
||||
|
|
@ -2964,10 +2949,10 @@ real_activation_cancel_handler (NMDevice *dev,
|
|||
/* Chain up to parent first */
|
||||
klass = NM_DEVICE_802_11_WIRELESS_GET_CLASS (self);
|
||||
parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
|
||||
parent_class->activation_cancel_handler (dev, req);
|
||||
parent_class->activation_cancel_handler (dev);
|
||||
|
||||
if (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH)
|
||||
nm_dbus_cancel_get_user_key_for_network (req);
|
||||
nm_dbus_cancel_get_user_key_for_network (nm_device_get_act_request (dev));
|
||||
|
||||
cleanup_association_attempt (self, TRUE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@
|
|||
#define NM_DEVICE_PRIVATE_H
|
||||
|
||||
#include "nm-device.h"
|
||||
#include "NetworkManagerMain.h"
|
||||
|
||||
void nm_device_set_device_type (NMDevice *dev, NMDeviceType type);
|
||||
void nm_device_set_active_link (NMDevice *dev, const gboolean active);
|
||||
NMIP4Config * nm_device_new_ip4_autoip_config (NMDevice *self);
|
||||
|
||||
void nm_device_activate_schedule_stage3_ip_config_start (struct NMActRequest *req);
|
||||
void nm_device_activate_schedule_stage3_ip_config_start (NMDevice *device);
|
||||
|
||||
void nm_device_state_changed (NMDevice *device, NMDeviceState state);
|
||||
|
||||
|
|
|
|||
210
src/nm-device.c
210
src/nm-device.c
|
|
@ -38,6 +38,8 @@
|
|||
#include "nm-utils.h"
|
||||
#include "autoip.h"
|
||||
|
||||
#define NM_ACT_REQUEST_IP4_CONFIG "nm-act-request-ip4-config"
|
||||
|
||||
static void device_interface_init (NMDeviceInterface *device_interface_class);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (NMDevice, nm_device, G_TYPE_OBJECT,
|
||||
|
|
@ -78,7 +80,7 @@ static void nm_device_activate (NMDeviceInterface *device,
|
|||
NMConnection *connection,
|
||||
gboolean user_requested);
|
||||
|
||||
static void nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req);
|
||||
static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self);
|
||||
static void nm_device_deactivate (NMDeviceInterface *device);
|
||||
|
||||
static void
|
||||
|
|
@ -361,16 +363,10 @@ nm_device_set_active_link (NMDevice *self,
|
|||
static gboolean
|
||||
nm_device_activate_stage1_device_prepare (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
const char * iface;
|
||||
NMActStageReturn ret;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
if (self->priv->act_source_id > 0)
|
||||
self->priv->act_source_id = 0;
|
||||
|
|
@ -379,7 +375,7 @@ nm_device_activate_stage1_device_prepare (gpointer user_data)
|
|||
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE);
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, req);
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
||||
goto out;
|
||||
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
||||
|
|
@ -388,7 +384,7 @@ nm_device_activate_stage1_device_prepare (gpointer user_data)
|
|||
}
|
||||
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
||||
|
||||
nm_device_activate_schedule_stage2_device_config (req);
|
||||
nm_device_activate_schedule_stage2_device_config (self);
|
||||
|
||||
out:
|
||||
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) complete.", iface);
|
||||
|
|
@ -403,32 +399,30 @@ out:
|
|||
*
|
||||
*/
|
||||
void
|
||||
nm_device_activate_schedule_stage1_device_prepare (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage1_device_prepare (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage1_device_prepare, req);
|
||||
self->priv->act_source_id = id;
|
||||
priv->act_source_id = g_idle_add (nm_device_activate_stage1_device_prepare, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) scheduled...",
|
||||
nm_device_get_iface (self));
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage1_prepare (NMDevice *dev, NMActRequest *req)
|
||||
real_act_stage1_prepare (NMDevice *dev)
|
||||
{
|
||||
/* Nothing to do */
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage2_config (NMDevice *dev, NMActRequest *req)
|
||||
real_act_stage2_config (NMDevice *dev)
|
||||
{
|
||||
/* Nothing to do */
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
|
@ -444,16 +438,10 @@ real_act_stage2_config (NMDevice *dev, NMActRequest *req)
|
|||
static gboolean
|
||||
nm_device_activate_stage2_device_config (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
const char * iface;
|
||||
NMActStageReturn ret;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
if (self->priv->act_source_id > 0)
|
||||
self->priv->act_source_id = 0;
|
||||
|
|
@ -467,7 +455,7 @@ nm_device_activate_stage2_device_config (gpointer user_data)
|
|||
goto out;
|
||||
}
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, req);
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
||||
goto out;
|
||||
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
||||
|
|
@ -479,7 +467,7 @@ nm_device_activate_stage2_device_config (gpointer user_data)
|
|||
|
||||
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) successful.", iface);
|
||||
|
||||
nm_device_activate_schedule_stage3_ip_config_start (req);
|
||||
nm_device_activate_schedule_stage3_ip_config_start (self);
|
||||
|
||||
out:
|
||||
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) complete.", iface);
|
||||
|
|
@ -494,18 +482,16 @@ out:
|
|||
*
|
||||
*/
|
||||
void
|
||||
nm_device_activate_schedule_stage2_device_config (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage2_device_config (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage2_device_config, req);
|
||||
self->priv->act_source_id = id;
|
||||
priv->act_source_id = g_idle_add (nm_device_activate_stage2_device_config, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -513,12 +499,13 @@ nm_device_activate_schedule_stage2_device_config (NMActRequest *req)
|
|||
|
||||
|
||||
static NMActStageReturn
|
||||
real_act_stage3_ip_config_start (NMDevice *self,
|
||||
NMActRequest *req)
|
||||
real_act_stage3_ip_config_start (NMDevice *self)
|
||||
{
|
||||
NMSettingIP4Config *setting;
|
||||
NMActRequest *req;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
setting = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req), "ipv4");
|
||||
|
||||
/* If we did not receive IP4 configuration information, default to DHCP */
|
||||
|
|
@ -560,16 +547,10 @@ real_act_stage3_ip_config_start (NMDevice *self,
|
|||
static gboolean
|
||||
nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self = NULL;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
const char * iface;
|
||||
NMActStageReturn ret;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
if (self->priv->act_source_id > 0)
|
||||
self->priv->act_source_id = 0;
|
||||
|
|
@ -578,7 +559,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
|||
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
|
||||
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG);
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip_config_start (self, req);
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip_config_start (self);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
||||
goto out;
|
||||
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
||||
|
|
@ -588,7 +569,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
|||
}
|
||||
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
||||
|
||||
nm_device_activate_schedule_stage4_ip_config_get (req);
|
||||
nm_device_activate_schedule_stage4_ip_config_get (self);
|
||||
|
||||
out:
|
||||
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
|
||||
|
|
@ -602,18 +583,16 @@ out:
|
|||
* Schedule IP configuration start
|
||||
*/
|
||||
void
|
||||
nm_device_activate_schedule_stage3_ip_config_start (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage3_ip_config_start, req);
|
||||
self->priv->act_source_id = id;
|
||||
self->priv->act_source_id = g_idle_add (nm_device_activate_stage3_ip_config_start, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -651,9 +630,9 @@ nm_device_new_ip4_autoip_config (NMDevice *self)
|
|||
|
||||
static NMActStageReturn
|
||||
real_act_stage4_get_ip4_config (NMDevice *self,
|
||||
NMActRequest *req,
|
||||
NMIP4Config **config)
|
||||
{
|
||||
NMActRequest *req;
|
||||
NMIP4Config * real_config = NULL;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
NMSettingIP4Config *setting;
|
||||
|
|
@ -661,8 +640,6 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||
g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
g_assert (req);
|
||||
|
||||
if (nm_device_get_use_dhcp (self)) {
|
||||
real_config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -674,6 +651,7 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||
real_config = nm_ip4_config_new ();
|
||||
}
|
||||
|
||||
req = nm_device_get_act_request (self);
|
||||
setting = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req), "ipv4");
|
||||
|
||||
if (real_config && setting) {
|
||||
|
|
@ -707,17 +685,11 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
|||
static gboolean
|
||||
nm_device_activate_stage4_ip_config_get (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self = NULL;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
NMIP4Config * ip4_config = NULL;
|
||||
NMActStageReturn ret;
|
||||
const char * iface = NULL;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
if (self->priv->act_source_id > 0)
|
||||
self->priv->act_source_id = 0;
|
||||
|
|
@ -725,7 +697,7 @@ nm_device_activate_stage4_ip_config_get (gpointer user_data)
|
|||
iface = nm_device_get_iface (self);
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) started...", iface);
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, req, &ip4_config);
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, &ip4_config);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
||||
goto out;
|
||||
else if (!ip4_config || (ret == NM_ACT_STAGE_RETURN_FAILURE))
|
||||
|
|
@ -735,8 +707,10 @@ nm_device_activate_stage4_ip_config_get (gpointer user_data)
|
|||
}
|
||||
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
||||
|
||||
nm_act_request_set_ip4_config (req, ip4_config);
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (req);
|
||||
g_object_set_data (G_OBJECT (nm_device_get_act_request (self)),
|
||||
NM_ACT_REQUEST_IP4_CONFIG, ip4_config);
|
||||
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (self);
|
||||
|
||||
out:
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) complete.", iface);
|
||||
|
|
@ -751,18 +725,16 @@ out:
|
|||
*
|
||||
*/
|
||||
void
|
||||
nm_device_activate_schedule_stage4_ip_config_get (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage4_ip_config_get (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage4_ip_config_get, req);
|
||||
self->priv->act_source_id = id;
|
||||
priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_get, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) scheduled...",
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -771,14 +743,11 @@ nm_device_activate_schedule_stage4_ip_config_get (NMActRequest *req)
|
|||
|
||||
static NMActStageReturn
|
||||
real_act_stage4_ip_config_timeout (NMDevice *self,
|
||||
NMActRequest *req,
|
||||
NMIP4Config **config)
|
||||
{
|
||||
g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
g_assert (req);
|
||||
|
||||
/* Wired network, no DHCP reply. Let's get an IP via Zeroconf. */
|
||||
nm_info ("No DHCP reply received. Automatically obtaining IP via Zeroconf.");
|
||||
*config = nm_device_new_ip4_autoip_config (self);
|
||||
|
|
@ -796,17 +765,11 @@ real_act_stage4_ip_config_timeout (NMDevice *self,
|
|||
static gboolean
|
||||
nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self = NULL;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
NMIP4Config * ip4_config = NULL;
|
||||
const char * iface;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
if (self->priv->act_source_id > 0)
|
||||
self->priv->act_source_id = 0;
|
||||
|
|
@ -814,7 +777,7 @@ nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
|
|||
iface = nm_device_get_iface (self);
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) started...", iface);
|
||||
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip_config_timeout (self, req, &ip4_config);
|
||||
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip_config_timeout (self, &ip4_config);
|
||||
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
||||
goto out;
|
||||
} else if (!ip4_config || (ret == NM_ACT_STAGE_RETURN_FAILURE)) {
|
||||
|
|
@ -824,8 +787,10 @@ nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
|
|||
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
||||
g_assert (ip4_config);
|
||||
|
||||
nm_act_request_set_ip4_config (req, ip4_config);
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (req);
|
||||
g_object_set_data (G_OBJECT (nm_device_get_act_request (self)),
|
||||
NM_ACT_REQUEST_IP4_CONFIG, ip4_config);
|
||||
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (self);
|
||||
|
||||
out:
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) complete.", iface);
|
||||
|
|
@ -840,18 +805,16 @@ out:
|
|||
*
|
||||
*/
|
||||
void
|
||||
nm_device_activate_schedule_stage4_ip_config_timeout (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage4_ip_config_timeout (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, req);
|
||||
self->priv->act_source_id = id;
|
||||
priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) scheduled...",
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -867,17 +830,12 @@ nm_device_activate_schedule_stage4_ip_config_timeout (NMActRequest *req)
|
|||
static gboolean
|
||||
nm_device_activate_stage5_ip_config_commit (gpointer user_data)
|
||||
{
|
||||
NMActRequest * req = (NMActRequest *) user_data;
|
||||
NMDevice * self = NULL;
|
||||
NMDevice *self = NM_DEVICE (user_data);
|
||||
NMIP4Config * ip4_config = NULL;
|
||||
const char * iface;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
|
||||
ip4_config = nm_act_request_get_ip4_config (req);
|
||||
ip4_config = g_object_get_data (G_OBJECT (nm_device_get_act_request (self)),
|
||||
NM_ACT_REQUEST_IP4_CONFIG);
|
||||
g_assert (ip4_config);
|
||||
|
||||
/* Clear the activation source ID now that this stage has run */
|
||||
|
|
@ -917,18 +875,16 @@ nm_device_activate_stage5_ip_config_commit (gpointer user_data)
|
|||
* Schedule commit of the IP config
|
||||
*/
|
||||
static void
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req)
|
||||
nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self)
|
||||
{
|
||||
NMDevice * self = NULL;
|
||||
guint id;
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (req != NULL);
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
self = nm_act_request_get_dev (req);
|
||||
g_assert (self);
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
g_return_if_fail (priv->act_request);
|
||||
|
||||
id = g_idle_add (nm_device_activate_stage5_ip_config_commit, req);
|
||||
self->priv->act_source_id = id;
|
||||
priv->act_source_id = g_idle_add (nm_device_activate_stage5_ip_config_commit, self);
|
||||
|
||||
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) scheduled...",
|
||||
nm_device_get_iface (self));
|
||||
|
|
@ -936,12 +892,8 @@ nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req)
|
|||
|
||||
|
||||
static void
|
||||
real_activation_cancel_handler (NMDevice *self,
|
||||
NMActRequest *req)
|
||||
real_activation_cancel_handler (NMDevice *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (req != NULL);
|
||||
|
||||
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG &&
|
||||
nm_device_get_use_dhcp (self)) {
|
||||
|
||||
|
|
@ -978,9 +930,9 @@ nm_device_activation_cancel (NMDevice *self)
|
|||
|
||||
klass = NM_DEVICE_CLASS (g_type_class_peek (NM_TYPE_DEVICE));
|
||||
if (klass->activation_cancel_handler)
|
||||
klass->activation_cancel_handler (self, self->priv->act_request);
|
||||
klass->activation_cancel_handler (self);
|
||||
|
||||
nm_act_request_unref (self->priv->act_request);
|
||||
g_object_unref (self->priv->act_request);
|
||||
self->priv->act_request = NULL;
|
||||
|
||||
nm_info ("Activation (%s): cancelled.", nm_device_get_iface (self));
|
||||
|
|
@ -1016,7 +968,7 @@ nm_device_deactivate_quickly (NMDevice *self)
|
|||
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||
nm_device_get_iface (self),
|
||||
FALSE);
|
||||
nm_act_request_unref (act_request);
|
||||
g_object_unref (act_request);
|
||||
self->priv->act_request = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1081,8 +1033,8 @@ nm_device_activate (NMDeviceInterface *device,
|
|||
return;
|
||||
|
||||
nm_info ("Activating device %s", nm_device_get_iface (self));
|
||||
priv->act_request = nm_act_request_new (self, connection, user_requested);
|
||||
nm_device_activate_schedule_stage1_device_prepare (priv->act_request);
|
||||
priv->act_request = nm_act_request_new (connection, user_requested);
|
||||
nm_device_activate_schedule_stage1_device_prepare (self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1132,10 +1084,8 @@ dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMDevice *device = NM_DEVICE (user_data);
|
||||
NMActRequest *req;
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
if (!req)
|
||||
if (!nm_device_get_act_request (device))
|
||||
return;
|
||||
|
||||
if (!strcmp (nm_device_get_iface (device), iface) && nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
|
||||
|
|
@ -1144,10 +1094,10 @@ dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
|||
case DHCDBD_RENEW: /* lease renewed */
|
||||
case DHCDBD_REBOOT: /* have valid lease, but now obtained a different one */
|
||||
case DHCDBD_REBIND: /* new, different lease */
|
||||
nm_device_activate_schedule_stage4_ip_config_get (req);
|
||||
nm_device_activate_schedule_stage4_ip_config_get (device);
|
||||
break;
|
||||
case DHCDBD_TIMEOUT: /* timed out contacting DHCP server */
|
||||
nm_device_activate_schedule_stage4_ip_config_timeout (req);
|
||||
nm_device_activate_schedule_stage4_ip_config_timeout (device);
|
||||
break;
|
||||
case DHCDBD_FAIL: /* all attempts to contact server timed out, sleeping */
|
||||
case DHCDBD_ABEND: /* dhclient exited abnormally */
|
||||
|
|
@ -1396,7 +1346,7 @@ nm_device_dispose (GObject *object)
|
|||
|
||||
if (self->priv->act_request)
|
||||
{
|
||||
nm_act_request_unref (self->priv->act_request);
|
||||
g_object_unref (self->priv->act_request);
|
||||
self->priv->act_request = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <netinet/in.h>
|
||||
|
||||
#include "NetworkManager.h"
|
||||
#include "nm-activation-request.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-connection.h"
|
||||
|
||||
|
|
@ -73,7 +74,6 @@ struct _NMDevice
|
|||
};
|
||||
|
||||
struct NMData;
|
||||
struct NMActRequest;
|
||||
|
||||
struct _NMDeviceClass
|
||||
{
|
||||
|
|
@ -92,21 +92,17 @@ struct _NMDeviceClass
|
|||
|
||||
gboolean (* check_connection) (NMDevice *self, NMConnection *connection);
|
||||
|
||||
NMActStageReturn (* act_stage1_prepare) (NMDevice *self, struct NMActRequest *req);
|
||||
NMActStageReturn (* act_stage2_config) (NMDevice *self, struct NMActRequest *req);
|
||||
NMActStageReturn (* act_stage3_ip_config_start)(NMDevice *self,
|
||||
struct NMActRequest *req);
|
||||
NMActStageReturn (* act_stage1_prepare) (NMDevice *self);
|
||||
NMActStageReturn (* act_stage2_config) (NMDevice *self);
|
||||
NMActStageReturn (* act_stage3_ip_config_start) (NMDevice *self);
|
||||
NMActStageReturn (* act_stage4_get_ip4_config) (NMDevice *self,
|
||||
struct NMActRequest *req,
|
||||
NMIP4Config **config);
|
||||
NMIP4Config **config);
|
||||
NMActStageReturn (* act_stage4_ip_config_timeout) (NMDevice *self,
|
||||
struct NMActRequest *req,
|
||||
NMIP4Config **config);
|
||||
void (* deactivate) (NMDevice *self);
|
||||
void (* deactivate_quickly) (NMDevice *self);
|
||||
|
||||
void (* activation_cancel_handler) (NMDevice *self,
|
||||
struct NMActRequest *req);
|
||||
void (* activation_cancel_handler) (NMDevice *self);
|
||||
|
||||
gboolean (* can_interrupt_activation) (NMDevice *self);
|
||||
};
|
||||
|
|
@ -146,13 +142,13 @@ void nm_device_bring_down (NMDevice *dev, gboolean wait);
|
|||
|
||||
void * nm_device_get_system_config_data (NMDevice *dev);
|
||||
|
||||
struct NMActRequest * nm_device_get_act_request (NMDevice *dev);
|
||||
NMActRequest * nm_device_get_act_request (NMDevice *dev);
|
||||
|
||||
|
||||
void nm_device_activate_schedule_stage1_device_prepare (struct NMActRequest *req);
|
||||
void nm_device_activate_schedule_stage2_device_config (struct NMActRequest *req);
|
||||
void nm_device_activate_schedule_stage4_ip_config_get (struct NMActRequest *req);
|
||||
void nm_device_activate_schedule_stage4_ip_config_timeout (struct NMActRequest *req);
|
||||
void nm_device_activate_schedule_stage1_device_prepare (NMDevice *device);
|
||||
void nm_device_activate_schedule_stage2_device_config (NMDevice *device);
|
||||
void nm_device_activate_schedule_stage4_ip_config_get (NMDevice *device);
|
||||
void nm_device_activate_schedule_stage4_ip_config_timeout (NMDevice *device);
|
||||
gboolean nm_device_deactivate_quickly (NMDevice *dev);
|
||||
gboolean nm_device_is_activating (NMDevice *dev);
|
||||
void nm_device_activation_cancel (NMDevice *dev);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue