2007-03-02 Tambet Ingo <tambet@ximian.com>

* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
	We get signalled when it changes.

	* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
	when it changes.

	* libnm-glib/nm-device.c: Cache the device state property.

	* libnm-glib/nm-access-point.c: Cache the strength property.

	* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
	The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
	and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
	until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
	the device is down, activating, or activated (in case of A/B/G cards).
	Remove some old dead ifdef'ed out code that used to configure wireless devices,
	it's all done through supplicant now.

	* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
	counting issues with pending calls which caused leaks and crashes when
	interface was removed (now that the interface actually gets removed).

	* src/nm-call-store.c: Make a copy of data before running a foreach
	with user callback on it - The most common usage pattern is to cancel
	(and thus remove) all pending calls with foreach which would modify
	the hash table we're iterating over.

	* src/nm-manager.c: When a device is added, make sure it is "up". When
	it's removed or disabled due to disabling wireless or networking, bring
	it down.

	* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.

	* src/nm-device-802-11-wireless.c: 
	* src/nm-device-802-3-ethernet.c: 
	* src/nm-device.c:
		- Remove "init" virtual function, all gobjects have a place for that
		  already (constructor).
		- Replace "start" virtual function with "bring_up", devices can be
		  brought up and down more than just on startup now.
		- Add "is_up" virtual function.
		- Implement one way to bring a device down instead of previous 4 different
		  ways, each of witch did something different.

	* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
	all it needs is the device interface.

	Get rid of NMData.dev_list (3 members to go).
	Get rif of NMData in a lot of places.

	* gnome/libnm_glib/libnm_glib.c: Make it compile again.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Tambet Ingo
2007-03-02 09:30:48 +00:00
committed by Tambet Ingo
parent ee4cdd4778
commit 352caa34c6
25 changed files with 874 additions and 1092 deletions

View File

@@ -1,3 +1,57 @@
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
2007-02-23 Dan Williams <dcbw@redhat.com>
Patch from Andy Whitcroft <apw@shadowen.org> (Gnome.org #410426)

View File

@@ -30,6 +30,8 @@
#include "libnm_glib.h"
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange"
struct libnm_glib_ctx
{

View File

@@ -138,6 +138,7 @@ typedef enum NMNetworkType
typedef enum
{
NM_DEVICE_STATE_UNKNOWN = 0,
NM_DEVICE_STATE_DOWN,
NM_DEVICE_STATE_DISCONNECTED,
NM_DEVICE_STATE_PREPARE,
NM_DEVICE_STATE_CONFIG,

View File

@@ -226,7 +226,6 @@ test_devices (NMClient *client)
g_print ("\n");
}
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
g_slist_free (list);
return TRUE;
@@ -288,15 +287,12 @@ do_stuff (gpointer user_data)
g_signal_connect (device, "state-changed",
G_CALLBACK (device_state_changed),
NULL);
/* FIXME: This ref is never released */
g_object_ref (device);
nm_device_802_3_ethernet_activate (device, TRUE);
break;
}
}
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
g_slist_free (list);
return FALSE;

View File

@@ -6,6 +6,12 @@
G_DEFINE_TYPE (NMAccessPoint, nm_access_point, DBUS_TYPE_G_PROXY)
#define NM_ACCESS_POINT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_ACCESS_POINT, NMAccessPointPrivate))
typedef struct {
int strength;
} NMAccessPointPrivate;
enum {
STRENGTH_CHANGED,
@@ -26,6 +32,8 @@ nm_access_point_class_init (NMAccessPointClass *ap_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
/* signals */
signals[STRENGTH_CHANGED] =
g_signal_new ("strength-changed",
@@ -64,7 +72,12 @@ nm_access_point_new (DBusGConnection *connection, const char *path)
static void
strength_changed_proxy (NMAccessPoint *ap, guchar strength)
{
g_signal_emit (ap, signals[STRENGTH_CHANGED], 0, strength);
NMAccessPointPrivate *priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
if (priv->strength != strength) {
priv->strength = strength;
g_signal_emit (ap, signals[STRENGTH_CHANGED], 0, strength);
}
}
guint32
@@ -190,16 +203,21 @@ nm_access_point_get_rate (NMAccessPoint *ap)
int
nm_access_point_get_strength (NMAccessPoint *ap)
{
GValue value = {0,};
int strength = 0;
NMAccessPointPrivate *priv;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Strength",
&value))
strength = g_value_get_int (&value);
priv = NM_ACCESS_POINT_GET_PRIVATE (ap);
return strength;
if (priv->strength == 0) {
GValue value = {0,};
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
NM_DBUS_INTERFACE_ACCESS_POINT,
"Strength",
&value))
priv->strength = g_value_get_int (&value);
}
return priv->strength;
}

View File

@@ -8,6 +8,14 @@
G_DEFINE_TYPE (NMClient, nm_client, DBUS_TYPE_G_PROXY)
#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
typedef struct {
NMState state;
gboolean have_device_list;
GHashTable *devices;
} NMClientPrivate;
enum {
DEVICE_ADDED,
DEVICE_REMOVED,
@@ -25,6 +33,20 @@ static void client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer
static void
nm_client_init (NMClient *client)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
priv->state = NM_STATE_UNKNOWN;
priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
}
static void
finalize (GObject *object)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
g_hash_table_destroy (priv->devices);
}
static void
@@ -32,6 +54,11 @@ nm_client_class_init (NMClientClass *client_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (client_class);
g_type_class_add_private (client_class, sizeof (NMClientPrivate));
/* virtual methods */
object_class->finalize = finalize;
/* signals */
signals[DEVICE_ADDED] =
g_signal_new ("device-added",
@@ -117,8 +144,44 @@ static void
client_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
{
NMClient *client = NM_CLIENT (proxy);
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
g_signal_emit (client, signals[STATE_CHANGE], 0, state);
if (priv->state != state) {
priv->state = state;
g_signal_emit (client, signals[STATE_CHANGE], 0, state);
}
}
static NMDevice *
get_device (NMClient *client, const char *path, gboolean create_if_not_found)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
NMDevice *device;
device = g_hash_table_lookup (priv->devices, path);
if (!device && create_if_not_found) {
DBusGConnection *connection = NULL;
NMDeviceType type;
g_object_get (client, "connection", &connection, NULL);
type = nm_device_type_for_path (connection, path);
switch (type) {
case DEVICE_TYPE_802_3_ETHERNET:
device = NM_DEVICE (nm_device_802_3_ethernet_new (connection, path));
break;
case DEVICE_TYPE_802_11_WIRELESS:
device = NM_DEVICE (nm_device_802_11_wireless_new (connection, path));
break;
default:
device = nm_device_new (connection, path);
}
if (device)
g_hash_table_insert (priv->devices, g_strdup (path), device);
}
return device;
}
static void
@@ -126,12 +189,10 @@ client_device_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMClient *client = NM_CLIENT (proxy);
NMDevice *device;
DBusGConnection *connection = NULL;
g_object_get (client, "connection", &connection, NULL);
device = nm_device_new (connection, path);
g_signal_emit (client, signals[DEVICE_ADDED], 0, device);
g_object_unref (device);
device = get_device (client, path, TRUE);
if (device)
g_signal_emit (client, signals[DEVICE_ADDED], 0, device);
}
static void
@@ -139,54 +200,56 @@ client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMClient *client = NM_CLIENT (proxy);
NMDevice *device;
DBusGConnection *connection = NULL;
g_object_get (client, "connection", &connection, NULL);
device = nm_device_new (connection, path);
g_signal_emit (client, signals[DEVICE_REMOVED], 0, device);
g_object_unref (device);
device = get_device (client, path, FALSE);
if (device) {
g_signal_emit (client, signals[DEVICE_REMOVED], 0, device);
g_hash_table_remove (NM_CLIENT_GET_PRIVATE (client)->devices, path);
}
}
static void
devices_to_slist (gpointer key, gpointer value, gpointer user_data)
{
GSList **list = (GSList **) user_data;
*list = g_slist_prepend (*list, value);
}
GSList *
nm_client_get_devices (NMClient *client)
{
NMClientPrivate *priv;
GSList *list = NULL;
GPtrArray *array = NULL;
GError *err = NULL;
g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
priv = NM_CLIENT_GET_PRIVATE (client);
if (priv->have_device_list) {
g_hash_table_foreach (priv->devices, devices_to_slist, &list);
return list;
}
if (!org_freedesktop_NetworkManager_get_devices (DBUS_G_PROXY (client), &array, &err)) {
g_warning ("Error in get_devices: %s", err->message);
g_error_free (err);
} else {
DBusGConnection *connection = NULL;
int i;
g_object_get (client, "connection", &connection, NULL);
for (i = 0; i < array->len; i++) {
NMDevice *device;
const char *path = g_ptr_array_index (array, i);
NMDeviceType type = nm_device_type_for_path (connection, path);
switch (type) {
case DEVICE_TYPE_802_3_ETHERNET:
device = NM_DEVICE (nm_device_802_3_ethernet_new (connection, path));
break;
case DEVICE_TYPE_802_11_WIRELESS:
device = NM_DEVICE (nm_device_802_11_wireless_new (connection, path));
break;
default:
device = nm_device_new (connection, path);
break;
}
list = g_slist_append (list, device);
device = get_device (client, (const char *) g_ptr_array_index (array, i), TRUE);
if (device)
list = g_slist_append (list, device);
}
g_ptr_array_free (array, TRUE);
priv->have_device_list = TRUE;
}
return list;
@@ -227,16 +290,21 @@ nm_client_wireless_set_enabled (NMClient *client, gboolean enabled)
NMState
nm_client_get_state (NMClient *client)
{
GValue value = {0,};
NMState state = NM_STATE_UNKNOWN;
NMClientPrivate *priv;
g_return_val_if_fail (NM_IS_CLIENT (client), state);
g_return_val_if_fail (NM_IS_CLIENT (client), NM_STATE_UNKNOWN);
if (nm_dbus_get_property (DBUS_G_PROXY (client),
NM_DBUS_INTERFACE,
"State",
&value))
state = g_value_get_uint (&value);
priv = NM_CLIENT_GET_PRIVATE (client);
return state;
if (priv->state == NM_STATE_UNKNOWN) {
GValue value = {0,};
if (nm_dbus_get_property (DBUS_G_PROXY (client),
NM_DBUS_INTERFACE,
"State",
&value))
priv->state = g_value_get_uint (&value);
}
return priv->state;
}

View File

@@ -6,6 +6,13 @@
G_DEFINE_TYPE (NMDevice80211Wireless, nm_device_802_11_wireless, NM_TYPE_DEVICE)
#define NM_DEVICE_802_11_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessPrivate))
typedef struct {
gboolean have_network_list;
GHashTable *networks;
} NMDevice80211WirelessPrivate;
enum {
NETWORK_ADDED,
NETWORK_REMOVED,
@@ -21,6 +28,19 @@ static void network_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_
static void
nm_device_802_11_wireless_init (NMDevice80211Wireless *device)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device);
priv->networks = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
}
static void
finalize (GObject *object)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (object);
g_hash_table_destroy (priv->networks);
}
static void
@@ -28,6 +48,11 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *device_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
g_type_class_add_private (device_class, sizeof (NMDevice80211WirelessPrivate));
/* virtual methods */
object_class->finalize = finalize;
/* signals */
signals[NETWORK_ADDED] =
g_signal_new ("network-added",
@@ -136,6 +161,26 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
return bitrate;
}
static NMAccessPoint *
get_network (NMDevice80211Wireless *device, const char *path, gboolean create_if_not_found)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device);
NMAccessPoint *ap;
ap = g_hash_table_lookup (priv->networks, path);
if (!ap && create_if_not_found) {
DBusGConnection *connection = NULL;
g_object_get (device, "connection", &connection, NULL);
ap = nm_access_point_new (connection, path);
if (ap)
g_hash_table_insert (priv->networks, g_strdup (path), ap);
}
return ap;
}
NMAccessPoint *
nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
{
@@ -148,41 +193,54 @@ nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
"ActiveNetwork",
&value)) {
DBusGConnection *connection = NULL;
g_assert (G_VALUE_TYPE (&value) == DBUS_TYPE_G_OBJECT_PATH);
g_object_get (device, "connection", &connection, NULL);
ap = nm_access_point_new (connection, (const char *) g_value_get_boxed (&value));
ap = get_network (device, (const char *) g_value_get_boxed (&value), TRUE);
}
return ap;
}
static void
networks_to_slist (gpointer key, gpointer value, gpointer user_data)
{
GSList **list = (GSList **) user_data;
*list = g_slist_prepend (*list, value);
}
GSList *
nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device)
{
NMDevice80211WirelessPrivate *priv;
GSList *list = NULL;
GPtrArray *array = NULL;
GError *err = NULL;
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), NULL);
priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device);
if (priv->have_network_list) {
g_hash_table_foreach (priv->networks, networks_to_slist, &list);
return list;
}
if (!org_freedesktop_NetworkManager_Device_Wireless_get_active_networks (DBUS_G_PROXY (device), &array, &err)) {
g_warning ("Error in get_networks: %s", err->message);
g_error_free (err);
} else {
DBusGConnection *connection = NULL;
int i;
g_object_get (device, "connection", &connection, NULL);
for (i = 0; i < array->len; i++) {
NMAccessPoint *ap = nm_access_point_new (connection, g_ptr_array_index (array, i));
list = g_slist_prepend (list, ap);
NMAccessPoint *ap = get_network (device, (const char *) g_ptr_array_index (array, i), TRUE);
if (ap)
list = g_slist_prepend (list, ap);
}
list = g_slist_reverse (list);
g_ptr_array_free (array, TRUE);
list = g_slist_reverse (list);
priv->have_network_list = TRUE;
}
return list;
@@ -212,12 +270,10 @@ network_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (proxy);
NMAccessPoint *ap;
DBusGConnection *connection = NULL;
g_object_get (proxy, "connection", &connection, NULL);
ap = nm_access_point_new (connection, path);
g_signal_emit (device, signals[NETWORK_ADDED], 0, ap);
g_object_unref (ap);
ap = get_network (device, path, TRUE);
if (device)
g_signal_emit (device, signals[NETWORK_ADDED], 0, ap);
}
static void
@@ -225,10 +281,10 @@ network_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
{
NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (proxy);
NMAccessPoint *ap;
DBusGConnection *connection = NULL;
g_object_get (proxy, "connection", &connection, NULL);
ap = nm_access_point_new (connection, path);
g_signal_emit (device, signals[NETWORK_REMOVED], 0, ap);
g_object_unref (ap);
ap = get_network (device, path, FALSE);
if (device) {
g_signal_emit (device, signals[NETWORK_REMOVED], 0, ap);
g_hash_table_remove (NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (device)->networks, path);
}
}

View File

@@ -6,6 +6,12 @@
G_DEFINE_TYPE (NMDevice, nm_device, DBUS_TYPE_G_PROXY)
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
typedef struct {
NMDeviceState state;
} NMDevicePrivate;
enum {
STATE_CHANGED,
@@ -49,6 +55,8 @@ nm_device_class_init (NMDeviceClass *device_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
g_type_class_add_private (device_class, sizeof (NMDevicePrivate));
/* virtual methods */
object_class->constructor = constructor;
@@ -69,8 +77,12 @@ static void
device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
g_signal_emit (device, signals[STATE_CHANGED], 0, state);
if (priv->state != state) {
priv->state = state;
g_signal_emit (device, signals[STATE_CHANGED], 0, state);
}
}
NMDevice *
@@ -192,18 +204,23 @@ nm_device_get_ip4_config (NMDevice *device)
NMDeviceState
nm_device_get_state (NMDevice *device)
{
NMDeviceState state = NM_DEVICE_STATE_UNKNOWN;
GValue value = {0,};
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE,
"State",
&value))
state = g_value_get_uint (&value);
priv = NM_DEVICE_GET_PRIVATE (device);
return state;
if (priv->state == NM_DEVICE_STATE_UNKNOWN) {
GValue value = {0,};
if (nm_dbus_get_property (DBUS_G_PROXY (device),
NM_DBUS_INTERFACE_DEVICE,
"State",
&value))
priv->state = g_value_get_uint (&value);
}
return priv->state;
}
NMDeviceType

View File

@@ -403,14 +403,15 @@ main (int argc, char *argv[])
G_CALLBACK (nm_name_owner_changed_handler),
nm_data);
manager = nm_manager_new ();
g_object_set_data (manager, "NM_DATA_HACK", nm_data);
policy = nm_policy_new (manager);
nm_dbus_manager_register_signal_handler (dbus_mgr,
NMI_DBUS_INTERFACE,
NULL,
nm_dbus_nmi_signal_handler,
nm_data);
manager = nm_manager_new ();
policy = nm_policy_new (manager);
manager);
/* Initialize the supplicant manager */
sup_mgr = nm_supplicant_manager_get ();

View File

@@ -135,11 +135,11 @@ nm_dbus_nmi_signal_handler (DBusConnection *connection,
DBusMessage *message,
gpointer user_data)
{
NMData * data = (NMData *) user_data;
NMManager *manager = NM_MANAGER (user_data);
const char * object_path;
gboolean handled = FALSE;
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (manager != NULL, FALSE);
if (!(object_path = dbus_message_get_path (message)))
return FALSE;
@@ -155,16 +155,21 @@ nm_dbus_nmi_signal_handler (DBusConnection *connection,
DBUS_TYPE_STRING, &network,
DBUS_TYPE_INVALID)) {
/* Update a single wireless network's data */
nm_debug ("NetworkManagerInfo triggered update of wireless network "
"'%s'",
network);
nm_dbus_update_one_allowed_network (network, 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"));
handled = TRUE;
}
} else if (dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "UserInterfaceActivated")) {
nm_device_802_11_wireless_set_scan_interval (data,
NULL,
NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
GSList *iter;
for (iter = nm_manager_get_devices (manager); iter; iter = iter-> next) {
NMDevice *device = NM_DEVICE (iter->data);
if (NM_IS_DEVICE_802_11_WIRELESS (device))
nm_device_802_11_wireless_reset_scan_interval (NM_DEVICE_802_11_WIRELESS (device));
}
handled = TRUE;
}

View File

@@ -37,8 +37,6 @@ typedef struct NMData
{
NMNamedManager * named_manager;
GSList * dev_list;
struct NMAccessPointList *allowed_ap_list;
struct NMAccessPointList *invalid_ap_list;
} NMData;

View File

@@ -427,20 +427,15 @@ nm_policy_device_list_update_from_allowed_list (gpointer user_data)
void
nm_policy_schedule_device_ap_lists_update_from_allowed (NMData *app_data)
{
GSource * source;
guint id;
g_return_if_fail (app_data != NULL);
if (device_list_update_id > 0)
return;
id = g_idle_add (nm_policy_device_list_update_from_allowed_list, app_data);
device_list_update_id = id;
source = g_main_context_find_source_by_id (NULL, id);
if (source) {
g_source_set_priority (source, G_PRIORITY_HIGH_IDLE);
}
device_list_update_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
nm_policy_device_list_update_from_allowed_list,
app_data,
NULL);
}
/*****************************************************************************/
@@ -502,12 +497,6 @@ device_added (NMManager *manager, NMDevice *device, gpointer user_data)
G_CALLBACK (device_carrier_changed),
policy);
/* FIXME: */
{
NMData *nm_data = nm_device_get_app_data (device);
nm_data->dev_list = g_slist_append (nm_data->dev_list, device);
}
if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
g_signal_connect (device, "network-added",
G_CALLBACK (wireless_networks_changed),
@@ -525,12 +514,6 @@ device_removed (NMManager *manager, NMDevice *device, gpointer user_data)
{
NMPolicy *policy = (NMPolicy *) user_data;
/* FIXME: */
{
NMData *nm_data = nm_device_get_app_data (device);
nm_data->dev_list = g_slist_remove (nm_data->dev_list, device);
}
schedule_change_check (policy);
}

View File

@@ -49,7 +49,7 @@ struct NMSock
int fd;
char *func;
char *desc;
NMDevice *dev;
char *iface;
};
static GSList * sock_list = NULL;
@@ -61,12 +61,12 @@ static GSList * sock_list = NULL;
* Open a socket to a network device and store some debug info about it.
*
*/
NMSock *nm_dev_sock_open (NMDevice *dev, SockType type, const char *func_name, const char *desc)
NMSock *
nm_dev_sock_open (const char *iface, SockType type, const char *func_name, const char *desc)
{
NMSock *sock = NULL;
sock = g_malloc0 (sizeof (NMSock));
sock = g_slice_new (NMSock);
sock->fd = -1;
switch (type)
@@ -91,19 +91,17 @@ NMSock *nm_dev_sock_open (NMDevice *dev, SockType type, const char *func_name, c
if (sock->fd < 0)
{
g_free (sock);
nm_warning ("Could not open control socket for device '%s'.", dev ? nm_device_get_iface (dev) : "none");
g_slice_free (NMSock, sock);
nm_warning ("Could not open control socket for device '%s'.", iface ? iface : "none");
return NULL;
}
sock->func = func_name ? g_strdup (func_name) : NULL;
sock->desc = desc ? g_strdup (desc) : NULL;
sock->dev = dev;
if (sock->dev)
g_object_ref (G_OBJECT (sock->dev));
sock->iface = iface ? g_strdup (iface) : NULL;
/* Add the sock to our global sock list for tracking */
sock_list = g_slist_append (sock_list, sock);
sock_list = g_slist_prepend (sock_list, sock);
return sock;
}
@@ -124,8 +122,7 @@ void nm_dev_sock_close (NMSock *sock)
close (sock->fd);
g_free (sock->func);
g_free (sock->desc);
if (sock->dev)
g_object_unref (G_OBJECT (sock->dev));
g_free (sock->iface);
memset (sock, 0, sizeof (NMSock));
@@ -138,7 +135,7 @@ void nm_dev_sock_close (NMSock *sock)
}
}
g_free (sock);
g_slice_free (NMSock, sock);
}
@@ -172,8 +169,8 @@ void nm_print_open_socks (void)
NMSock *sock = (NMSock *)(elt->data);
if (sock) {
i++;
nm_debug (" %d: %s fd:%d F:'%s' D:'%s'", i, sock->dev ? nm_device_get_iface (sock->dev) : "",
sock->fd, sock->func, sock->desc);
nm_debug (" %d: %s fd:%d F:'%s' D:'%s'", i, sock->iface ? sock->iface : "",
sock->fd, sock->func, sock->desc);
}
}
nm_debug ("Open Sockets List Done.");

View File

@@ -44,7 +44,11 @@ typedef enum SockType
typedef struct NMSock NMSock;
NMSock * nm_dev_sock_open (NMDevice *dev, SockType type, const char *func_name, const char *desc);
NMSock * nm_dev_sock_open (const char *iface,
SockType type,
const char *func_name,
const char *desc);
void nm_dev_sock_close (NMSock *sock);
int nm_dev_sock_get_fd (NMSock *sock);
void nm_print_open_socks (void);

View File

@@ -214,15 +214,17 @@ gboolean get_autoip (NMDevice *dev, struct in_addr *out_ip)
int nprobes = 0;
int nannounce = 0;
gboolean success = FALSE;
const char *iface;
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (out_ip != NULL, FALSE);
out_ip->s_addr = 0;
iface = nm_device_get_iface (dev);
/* initialize saddr */
memset (&saddr, 0, sizeof (saddr));
strncpy (saddr.sa_data, nm_device_get_iface (dev), sizeof (saddr.sa_data));
strncpy (saddr.sa_data, iface, sizeof (saddr.sa_data));
if (NM_IS_DEVICE_802_3_ETHERNET (dev))
nm_device_802_3_ethernet_get_address (NM_DEVICE_802_3_ETHERNET (dev), &addr);
@@ -232,16 +234,16 @@ gboolean get_autoip (NMDevice *dev, struct in_addr *out_ip)
goto out;
/* open an ARP socket */
if ((sk = nm_dev_sock_open (dev, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
if ((sk = nm_dev_sock_open (iface, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
{
nm_warning ("%s: Couldn't open network control socket.", nm_device_get_iface (dev));
nm_warning ("%s: Couldn't open network control socket.", iface);
goto out;
}
/* bind to the ARP socket */
if (bind (nm_dev_sock_get_fd (sk), &saddr, sizeof (saddr)) < 0)
{
nm_warning ("%s: Couldn't bind to the device.", nm_device_get_iface (dev));
nm_warning ("%s: Couldn't bind to the device.", iface);
goto out;
}
@@ -317,7 +319,7 @@ gboolean get_autoip (NMDevice *dev, struct in_addr *out_ip)
}
#ifdef ARP_DEBUG
nm_warning ("autoip: (%s) recv arp type=%d, op=%d, ", nm_device_get_iface (dev), ntohs(p.ethhdr.ether_type), ntohs(p.operation));
nm_warning ("autoip: (%s) recv arp type=%d, op=%d, ", iface, ntohs(p.ethhdr.ether_type), ntohs(p.operation));
{
struct in_addr a;
memcpy (&(a.s_addr), &(p.sInaddr), sizeof (a.s_addr));
@@ -335,7 +337,7 @@ gboolean get_autoip (NMDevice *dev, struct in_addr *out_ip)
&& (memcmp (&addr, &p.tHaddr, ETH_ALEN) != 0))
{
#ifdef ARP_DEBUG
nm_warning ("autoip: (%s) ARP conflict for IP address %s.\n", nm_device_get_iface (dev), inet_ntoa(ip));
nm_warning ("autoip: (%s) ARP conflict for IP address %s.\n", iface, inet_ntoa(ip));
#endif
/* Ok, start all over again */

View File

@@ -69,25 +69,55 @@ typedef struct {
} StoreForeachInfo;
static void
call_callback (gpointer key, gpointer value, gpointer user_data)
call_callback (gpointer call_id, gpointer user_data)
{
StoreForeachInfo *info = (StoreForeachInfo *) user_data;
if (info->count >= 0) {
if (info->callback (info->object, key, info->user_data))
if (info->callback (info->object, call_id, info->user_data))
info->count++;
else
info->count = -1;
}
}
static void
prepend_id (gpointer key, gpointer value, gpointer user_data)
{
GSList **list = (GSList **) user_data;
*list = g_slist_prepend (*list, key);
}
static GSList *
get_call_ids (GHashTable *hash)
{
GSList *ids = NULL;
g_hash_table_foreach (hash, prepend_id, &ids);
return ids;
}
static void
call_all_callbacks (gpointer key, gpointer value, gpointer user_data)
{
StoreForeachInfo *info = (StoreForeachInfo *) user_data;
GSList *ids;
info->object = G_OBJECT (key);
g_hash_table_foreach ((GHashTable *) value, call_callback, info);
/* Create a copy of the hash keys (call_ids) so that the callback is
free to modify the store */
ids = get_call_ids ((GHashTable *) value);
g_slist_foreach (ids, call_callback, info);
g_slist_free (ids);
}
static void
duplicate_hash (gpointer key, gpointer value, gpointer user_data)
{
g_hash_table_insert ((GHashTable *) user_data, key, value);
}
int
@@ -108,6 +138,7 @@ nm_call_store_foreach (NMCallStore *store,
if (object) {
GHashTable *call_ids_hash;
GSList *ids;
call_ids_hash = g_hash_table_lookup (store, object);
if (!call_ids_hash) {
@@ -115,9 +146,19 @@ nm_call_store_foreach (NMCallStore *store,
return -1;
}
g_hash_table_foreach (call_ids_hash, call_callback, &info);
/* Create a copy of the hash keys (call_ids) so that the callback is
free to modify the store */
ids = get_call_ids (call_ids_hash);
g_slist_foreach (ids, call_callback, &info);
g_slist_free (ids);
} else {
g_hash_table_foreach (store, call_all_callbacks, &info);
GHashTable *copy;
/* Create a copy of the main store so that callbacks can modify it */
copy = g_hash_table_new (NULL, NULL);
g_hash_table_foreach (store, duplicate_hash, copy);
g_hash_table_foreach (copy, call_all_callbacks, &info);
g_hash_table_destroy (copy);
}
return info.count;

File diff suppressed because it is too large Load Diff

View File

@@ -48,14 +48,6 @@ G_BEGIN_DECLS
#define NM_DEVICE_802_11_WIRELESS_BITRATE "bitrate"
#define NM_DEVICE_802_11_WIRELESS_ACTIVE_NETWORK "active-network"
typedef enum NMWirelessScanInterval
{
NM_WIRELESS_SCAN_INTERVAL_INIT = 0,
NM_WIRELESS_SCAN_INTERVAL_ACTIVE,
NM_WIRELESS_SCAN_INTERVAL_INACTIVE
} NMWirelessScanInterval;
#ifndef NM_DEVICE_802_11_WIRELESS_DEFINED
#define NM_DEVICE_802_11_WIRELESS_DEFINED
typedef struct _NMDevice80211Wireless NMDevice80211Wireless;
@@ -116,9 +108,7 @@ NMAccessPoint * nm_device_802_11_wireless_get_activation_ap (NMDevice80211Wirele
const char *essid,
NMAPSecurity *security);
void nm_device_802_11_wireless_set_scan_interval (struct NMData *data,
NMDevice80211Wireless *dev,
NMWirelessScanInterval interval);
void nm_device_802_11_wireless_reset_scan_interval (NMDevice80211Wireless *dev);
void nm_device_802_11_wireless_copy_allowed_to_dev_list (NMDevice80211Wireless *self,
struct NMAccessPointList *allowed_list);
@@ -136,8 +126,6 @@ NMAccessPoint * nm_device_802_11_wireless_ap_list_get_ap_by_essid (NMDevice80211
int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *self);
gint8 nm_device_802_11_wireless_get_signal_strength (NMDevice80211Wireless *self);
gboolean nm_device_802_11_wireless_can_activate (NMDevice80211Wireless * self);

View File

@@ -21,7 +21,6 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <netinet/in.h>
#include <string.h>
#include <net/ethernet.h>
@@ -30,14 +29,11 @@
#include "nm-device-802-3-ethernet.h"
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "NetworkManagerMain.h"
#include "nm-activation-request.h"
#include "NetworkManagerUtils.h"
#include "NetworkManagerPolicy.h"
#include "nm-supplicant-manager.h"
#include "nm-netlink-monitor.h"
#include "nm-utils.h"
#include "kernel-types.h"
static gboolean impl_device_802_3_ethernet_activate (NMDevice8023Ethernet *device,
gboolean user_requested,
@@ -50,8 +46,7 @@ G_DEFINE_TYPE (NMDevice8023Ethernet, nm_device_802_3_ethernet, NM_TYPE_DEVICE)
#define NM_DEVICE_802_3_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023EthernetPrivate))
struct _NMDevice8023EthernetPrivate
{
typedef struct {
gboolean dispose_has_run;
struct ether_addr hw_addr;
@@ -61,7 +56,7 @@ struct _NMDevice8023EthernetPrivate
guint link_source_id;
NMSupplicantInterface * sup_iface;
};
} NMDevice8023EthernetPrivate;
enum {
PROP_0,
@@ -74,63 +69,42 @@ enum {
static gboolean supports_mii_carrier_detect (NMDevice8023Ethernet *dev);
static gboolean supports_ethtool_carrier_detect (NMDevice8023Ethernet *dev);
static void nm_device_802_3_ethernet_link_activated (NMNetlinkMonitor *monitor,
const char *iface,
gpointer user_data);
static void nm_device_802_3_ethernet_link_deactivated (NMNetlinkMonitor *monitor,
const char *iface,
gpointer user_data);
static void supplicant_iface_state_cb (NMSupplicantInterface * iface,
guint32 new_state,
guint32 old_state,
NMDevice80211Wireless *self);
static void
nm_device_802_3_ethernet_init (NMDevice8023Ethernet * self)
static GObject*
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
self->priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
self->priv->dispose_has_run = FALSE;
self->priv->link_source_id = 0;
GObject *object;
memset (&(self->priv->hw_addr), 0, sizeof (struct ether_addr));
object = G_OBJECT_CLASS (nm_device_802_3_ethernet_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
nm_device_set_device_type (NM_DEVICE (self), DEVICE_TYPE_802_3_ETHERNET);
NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object)->carrier_file_path =
g_strdup_printf ("/sys/class/net/%s/carrier", nm_device_get_iface (NM_DEVICE (object)));
return object;
}
static void
real_init (NMDevice *dev)
nm_device_802_3_ethernet_init (NMDevice8023Ethernet * self)
{
NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
NMData * app_data;
NMNetlinkMonitor * monitor;
NMSupplicantManager * sup_mgr;
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
app_data = nm_device_get_app_data (NM_DEVICE (self));
monitor = nm_netlink_monitor_get ();
priv->dispose_has_run = FALSE;
priv->link_source_id = 0;
self->priv->link_connected_id = g_signal_connect (monitor, "interface-connected",
G_CALLBACK (nm_device_802_3_ethernet_link_activated), self);
memset (&(priv->hw_addr), 0, sizeof (struct ether_addr));
self->priv->link_disconnected_id = g_signal_connect (monitor, "interface-disconnected",
G_CALLBACK (nm_device_802_3_ethernet_link_deactivated), self);
g_object_unref (monitor);
sup_mgr = nm_supplicant_manager_get ();
self->priv->sup_iface = nm_supplicant_manager_get_iface (sup_mgr,
nm_device_get_iface (NM_DEVICE (self)),
FALSE);
if (self->priv->sup_iface == NULL) {
nm_warning ("Couldn't initialize supplicant interface for %s.",
nm_device_get_iface (NM_DEVICE (self)));
} else {
g_signal_connect (G_OBJECT (self->priv->sup_iface),
"state",
G_CALLBACK (supplicant_iface_state_cb),
self);
}
g_object_unref (sup_mgr);
nm_device_set_device_type (NM_DEVICE (self), DEVICE_TYPE_802_3_ETHERNET);
}
static void
@@ -165,10 +139,8 @@ probe_link (NMDevice8023Ethernet *self)
gchar * contents;
gsize length;
if (nm_device_get_removed (NM_DEVICE (self)))
return FALSE;
if (g_file_get_contents (self->priv->carrier_file_path, &contents, &length, NULL))
if (g_file_get_contents (NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->carrier_file_path,
&contents, &length, NULL))
{
have_link = (gboolean) atoi (contents);
g_free (contents);
@@ -188,9 +160,7 @@ probe_link (NMDevice8023Ethernet *self)
static void
real_update_link (NMDevice *dev)
{
NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
nm_device_set_active_link (NM_DEVICE (self), probe_link (self));
nm_device_set_active_link (dev, probe_link NM_DEVICE_802_3_ETHERNET (dev));
}
@@ -203,28 +173,76 @@ real_update_link (NMDevice *dev)
static gboolean
nm_device_802_3_periodic_update (gpointer data)
{
NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (data);
g_return_val_if_fail (self != NULL, TRUE);
nm_device_set_active_link (NM_DEVICE (self), probe_link (self));
nm_device_set_active_link (NM_DEVICE (data),
probe_link NM_DEVICE_802_3_ETHERNET (data));
return TRUE;
}
static gboolean
real_is_up (NMDevice *device)
{
if (!NM_DEVICE_CLASS (nm_device_802_3_ethernet_parent_class)->is_up (device))
return FALSE;
return NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device)->link_source_id != 0;
}
static void
real_start (NMDevice *dev)
real_bring_up (NMDevice *dev)
{
NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
guint id;
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (dev);
NMNetlinkMonitor *monitor;
NMSupplicantManager *sup_mgr;
const char *iface;
self->priv->carrier_file_path = g_strdup_printf ("/sys/class/net/%s/carrier",
nm_device_get_iface (NM_DEVICE (dev)));
monitor = nm_netlink_monitor_get ();
priv->link_connected_id = g_signal_connect (monitor, "interface-connected",
G_CALLBACK (nm_device_802_3_ethernet_link_activated),
dev);
priv->link_disconnected_id = g_signal_connect (monitor, "interface-disconnected",
G_CALLBACK (nm_device_802_3_ethernet_link_deactivated),
dev);
g_object_unref (monitor);
iface = nm_device_get_iface (dev);
sup_mgr = nm_supplicant_manager_get ();
priv->sup_iface = nm_supplicant_manager_get_iface (sup_mgr, iface, FALSE);
if (priv->sup_iface)
g_signal_connect (priv->sup_iface,
"state",
G_CALLBACK (supplicant_iface_state_cb),
dev);
else
nm_warning ("Couldn't initialize supplicant interface for %s.", iface);
g_object_unref (sup_mgr);
/* Peridoically update link status */
id = g_timeout_add (2000, nm_device_802_3_periodic_update, self);
self->priv->link_source_id = id;
priv->link_source_id = g_timeout_add (2000, nm_device_802_3_periodic_update, dev);
}
static void
real_bring_down (NMDevice *dev)
{
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (dev);
NMSupplicantManager *sup_mgr;
NMNetlinkMonitor *monitor;
if (priv->link_source_id) {
g_source_remove (priv->link_source_id);
priv->link_source_id = 0;
}
sup_mgr = nm_supplicant_manager_get ();
nm_supplicant_manager_release_iface (sup_mgr, priv->sup_iface);
priv->sup_iface = NULL;
g_object_unref (sup_mgr);
monitor = nm_netlink_monitor_get ();
g_signal_handler_disconnect (monitor, priv->link_connected_id);
g_signal_handler_disconnect (monitor, priv->link_disconnected_id);
g_object_unref (monitor);
}
@@ -296,7 +314,7 @@ nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *self, struct ether_a
g_return_if_fail (self != NULL);
g_return_if_fail (addr != NULL);
memcpy (addr, &(self->priv->hw_addr), sizeof (struct ether_addr));
memcpy (addr, &(NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->hw_addr), sizeof (struct ether_addr));
}
@@ -308,7 +326,7 @@ real_set_hw_address (NMDevice *dev)
NMSock *sk;
int ret;
sk = nm_dev_sock_open (dev, DEV_GENERAL, __FUNCTION__, NULL);
sk = nm_dev_sock_open (nm_device_get_iface (dev), DEV_GENERAL, __FUNCTION__, NULL);
if (!sk)
return;
@@ -317,7 +335,8 @@ real_set_hw_address (NMDevice *dev)
ret = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFHWADDR, &req);
if (ret == 0)
memcpy (&(self->priv->hw_addr), &(req.ifr_hwaddr.sa_data), sizeof (struct ether_addr));
memcpy (&(NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->hw_addr),
&(req.ifr_hwaddr.sa_data), sizeof (struct ether_addr));
nm_dev_sock_close (sk);
}
@@ -357,46 +376,6 @@ real_can_interrupt_activation (NMDevice *dev)
return interrupt;
}
static void
nm_device_802_3_ethernet_dispose (GObject *object)
{
NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (object);
NMSupplicantManager * sup_mgr;
NMNetlinkMonitor *monitor;
if (self->priv->dispose_has_run)
/* If dispose did already run, return. */
return;
/* Make sure dispose does not run twice. */
self->priv->dispose_has_run = TRUE;
/*
* In dispose, you are supposed to free all types referenced from this
* object which might themselves hold a reference to self. Generally,
* the most simple solution is to unref all members on which you own a
* reference.
*/
sup_mgr = nm_supplicant_manager_get ();
nm_supplicant_manager_release_iface (sup_mgr, self->priv->sup_iface);
self->priv->sup_iface = NULL;
g_object_unref (sup_mgr);
monitor = nm_netlink_monitor_get ();
g_signal_handler_disconnect (monitor,
self->priv->link_connected_id);
g_signal_handler_disconnect (monitor,
self->priv->link_disconnected_id);
g_object_unref (monitor);
if (self->priv->link_source_id) {
g_source_remove (self->priv->link_source_id);
self->priv->link_source_id = 0;
}
G_OBJECT_CLASS (nm_device_802_3_ethernet_parent_class)->dispose (object);
}
static void
nm_device_802_3_ethernet_finalize (GObject *object)
{
@@ -441,13 +420,14 @@ nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *klass)
g_type_class_add_private (object_class, sizeof (NMDevice8023EthernetPrivate));
/* virtual methods */
object_class->constructor = constructor;
object_class->get_property = get_property;
object_class->dispose = nm_device_802_3_ethernet_dispose;
object_class->finalize = nm_device_802_3_ethernet_finalize;
parent_class->get_generic_capabilities = real_get_generic_capabilities;
parent_class->init = real_init;
parent_class->start = real_start;
parent_class->is_up = real_is_up;
parent_class->bring_up = real_bring_up;
parent_class->bring_down = real_bring_down;
parent_class->update_link = real_update_link;
parent_class->can_interrupt_activation = real_can_interrupt_activation;
parent_class->set_hw_address = real_set_hw_address;
@@ -511,7 +491,7 @@ supports_ethtool_carrier_detect (NMDevice8023Ethernet *self)
g_return_val_if_fail (self != NULL, FALSE);
iface = nm_device_get_iface (NM_DEVICE (self));
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_GENERAL, __func__, NULL)) == NULL)
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
{
nm_warning ("cannot open socket on interface %s for ethtool detect: %s",
iface, strerror (errno));
@@ -547,7 +527,7 @@ nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self)
g_return_val_if_fail (self != NULL, FALSE);
iface = nm_device_get_iface (NM_DEVICE (self));
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_GENERAL, __func__, NULL)) == NULL)
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
{
nm_warning ("cannot open socket on interface %s for ethtool: %s",
iface, strerror (errno));
@@ -608,7 +588,7 @@ supports_mii_carrier_detect (NMDevice8023Ethernet *self)
g_return_val_if_fail (self != NULL, FALSE);
iface = nm_device_get_iface (NM_DEVICE (self));
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_GENERAL, __FUNCTION__, NULL)) == NULL)
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __FUNCTION__, NULL)) == NULL)
{
nm_warning ("cannot open socket on interface %s for MII detect; errno=%d",
iface, errno);

View File

@@ -23,7 +23,6 @@
#define NM_DEVICE_802_3_ETHERNET_H
#include <glib-object.h>
#include <dbus/dbus.h>
#include <net/ethernet.h>
#include "nm-device.h"
@@ -38,25 +37,16 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_802_3_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_802_3_ETHERNET))
#define NM_DEVICE_802_3_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023EthernetClass))
typedef struct _NMDevice8023Ethernet NMDevice8023Ethernet;
typedef struct _NMDevice8023EthernetClass NMDevice8023EthernetClass;
typedef struct _NMDevice8023EthernetPrivate NMDevice8023EthernetPrivate;
#define NM_DEVICE_802_3_ETHERNET_HW_ADDRESS "hw-address"
#define NM_DEVICE_802_3_ETHERNET_SPEED "speed"
struct _NMDevice8023Ethernet
{
typedef struct {
NMDevice parent;
} NMDevice8023Ethernet;
/*< private >*/
NMDevice8023EthernetPrivate *priv;
};
struct _NMDevice8023EthernetClass
{
typedef struct {
NMDeviceClass parent;
};
} NMDevice8023EthernetClass;
GType nm_device_802_3_ethernet_get_type (void);

View File

@@ -25,15 +25,8 @@
#include "nm-device.h"
#include "NetworkManagerMain.h"
typedef struct NMDbusCBData {
NMDevice * dev;
NMAccessPoint * ap;
NMData * data;
} NMDbusCBData;
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);

View File

@@ -28,8 +28,6 @@
#include "nm-device.h"
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "nm-device-802-3-ethernet.h"
#include "nm-device-802-11-wireless.h"
#include "NetworkManagerDbus.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerUtils.h"
@@ -60,7 +58,6 @@ struct _NMDevicePrivate
NMDeviceType type;
guint32 capabilities;
char * driver;
gboolean removed;
gboolean link_active;
guint32 ip4_address;
@@ -79,9 +76,6 @@ struct _NMDevicePrivate
static void nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req);
static void nm_device_deactivate (NMDeviceInterface *device);
void nm_device_bring_up (NMDevice *dev);
gboolean nm_device_bring_up_wait (NMDevice *self, gboolean cancelable);
static void
nm_device_set_address (NMDevice *device)
@@ -108,7 +102,6 @@ nm_device_init (NMDevice * self)
self->priv->type = DEVICE_TYPE_UNKNOWN;
self->priv->capabilities = NM_DEVICE_CAP_NONE;
self->priv->driver = NULL;
self->priv->removed = FALSE;
self->priv->link_active = FALSE;
self->priv->ip4_address = 0;
@@ -131,6 +124,7 @@ constructor (GType type,
{
GObject *object;
NMDevice *dev;
NMDevicePrivate *priv;
NMDBusManager *manager;
char *path;
@@ -142,24 +136,17 @@ constructor (GType type,
return NULL;
dev = NM_DEVICE (object);
priv = NM_DEVICE_GET_PRIVATE (dev);
dev->priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
if (!(dev->priv->capabilities & NM_DEVICE_CAP_NM_SUPPORTED))
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
if (!(priv->capabilities & NM_DEVICE_CAP_NM_SUPPORTED))
{
g_object_unref (G_OBJECT (dev));
return NULL;
}
/* Have to bring the device up before checking link status and other stuff */
nm_device_bring_up_wait (dev, FALSE);
nm_device_update_ip4_address (dev);
/* Update the device's hardware address */
nm_device_set_address (dev);
/* Grab IP config data for this device from the system configuration files */
dev->priv->system_config_data = nm_system_device_get_system_config (dev, dev->priv->app_data);
priv->system_config_data = nm_system_device_get_system_config (dev, priv->app_data);
nm_device_set_use_dhcp (dev, nm_system_device_get_use_dhcp (dev));
/* Allow distributions to flag devices as disabled */
@@ -171,12 +158,6 @@ constructor (GType type,
nm_print_device_capabilities (dev);
/* Call type-specific initialization */
if (NM_DEVICE_GET_CLASS (dev)->init)
NM_DEVICE_GET_CLASS (dev)->init (dev);
NM_DEVICE_GET_CLASS (dev)->start (dev);
manager = nm_dbus_manager_get ();
path = nm_dbus_get_object_path_for_device (dev);
@@ -188,6 +169,37 @@ constructor (GType type,
}
static gboolean
real_is_up (NMDevice *self)
{
NMSock * sk;
struct ifreq ifr;
int err;
const char *iface;
iface = nm_device_get_iface (self);
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __FUNCTION__, NULL)) == NULL)
return FALSE;
/* Get device's flags */
strncpy (ifr.ifr_name, iface, sizeof (ifr.ifr_name) - 1);
nm_ioctl_info ("%s: About to GET IFFLAGS.", iface);
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFFLAGS, &ifr);
nm_ioctl_info ("%s: Done with GET IFFLAGS.", iface);
nm_dev_sock_close (sk);
if (!err)
return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
if (errno != ENODEV)
{
nm_warning ("nm_device_is_up() could not get flags for device %s. errno = %d", iface, errno);
}
return FALSE;
}
static guint32
real_get_generic_capabilities (NMDevice *dev)
{
@@ -195,22 +207,6 @@ real_get_generic_capabilities (NMDevice *dev)
}
static void
real_start (NMDevice *dev)
{
}
void
nm_device_stop (NMDevice *self)
{
g_return_if_fail (self != NULL);
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self));
nm_device_bring_down (self);
}
/*
* Get/set functions for UDI
*/
@@ -310,27 +306,6 @@ nm_device_get_app_data (NMDevice *self)
}
/*
* Get/Set for "removed" flag
*/
gboolean
nm_device_get_removed (NMDevice *self)
{
g_return_val_if_fail (self != NULL, TRUE);
return self->priv->removed;
}
void
nm_device_set_removed (NMDevice *self,
const gboolean removed)
{
g_return_if_fail (self != NULL);
self->priv->removed = removed;
}
/*
* nm_device_get_act_request
*
@@ -383,7 +358,6 @@ nm_device_activate (NMDevice *device,
NMActRequest *req)
{
NMDevicePrivate *priv;
NMData *data = NULL;
g_return_if_fail (NM_IS_DEVICE (device));
g_return_if_fail (req != NULL);
@@ -396,9 +370,6 @@ nm_device_activate (NMDevice *device,
nm_info ("Activation (%s) started...", nm_device_get_iface (device));
data = nm_act_request_get_data (req);
g_assert (data);
nm_act_request_ref (req);
priv->act_request = req;
@@ -417,15 +388,11 @@ nm_device_activate_stage1_device_prepare (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMDevice * self;
NMData * data;
const char * iface;
NMActStageReturn ret;
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -504,15 +471,11 @@ nm_device_activate_stage2_device_config (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMDevice * self;
NMData * data;
const char * iface;
NMActStageReturn ret;
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -524,9 +487,7 @@ nm_device_activate_stage2_device_config (gpointer user_data)
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG);
/* Bring the device up */
if (!nm_device_is_up (self))
nm_device_bring_up (self);
nm_device_bring_up (self, FALSE);
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, req);
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
@@ -577,12 +538,8 @@ static NMActStageReturn
real_act_stage3_ip_config_start (NMDevice *self,
NMActRequest *req)
{
NMData * data = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
data = nm_act_request_get_data (req);
g_assert (data);
/* DHCP devices try DHCP, non-DHCP default to SUCCESS */
if (nm_device_get_use_dhcp (self))
{
@@ -622,16 +579,12 @@ static gboolean
nm_device_activate_stage3_ip_config_start (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMData * data = NULL;
NMDevice * self = NULL;
const char * iface;
NMActStageReturn ret;
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -719,7 +672,6 @@ real_act_stage4_get_ip4_config (NMDevice *self,
NMActRequest *req,
NMIP4Config **config)
{
NMData * data;
NMIP4Config * real_config = NULL;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
@@ -727,8 +679,6 @@ real_act_stage4_get_ip4_config (NMDevice *self,
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
g_assert (req);
data = nm_act_request_get_data (req);
g_assert (data);
if (nm_device_get_use_dhcp (self)) {
real_config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
@@ -748,8 +698,7 @@ real_act_stage4_get_ip4_config (NMDevice *self,
else
{
/* Make sure device is up even if config fails */
if (!nm_device_is_up (self))
nm_device_bring_up (self);
nm_device_bring_up (self, FALSE);
}
return ret;
@@ -766,7 +715,6 @@ static gboolean
nm_device_activate_stage4_ip_config_get (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMData * data = NULL;
NMDevice * self = NULL;
NMIP4Config * ip4_config = NULL;
NMActStageReturn ret;
@@ -774,9 +722,6 @@ nm_device_activate_stage4_ip_config_get (gpointer user_data)
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -859,7 +804,6 @@ static gboolean
nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMData * data = NULL;
NMDevice * self = NULL;
NMIP4Config * ip4_config = NULL;
const char * iface;
@@ -867,9 +811,6 @@ nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -934,16 +875,12 @@ static gboolean
nm_device_activate_stage5_ip_config_commit (gpointer user_data)
{
NMActRequest * req = (NMActRequest *) user_data;
NMData * data = NULL;
NMDevice * self = NULL;
NMIP4Config * ip4_config = NULL;
const char * iface;
g_return_val_if_fail (req != NULL, FALSE);
data = nm_act_request_get_data (req);
g_assert (data);
self = nm_act_request_get_dev (req);
g_assert (self);
@@ -1035,8 +972,6 @@ nm_device_activation_cancel (NMDevice *self)
if (!nm_device_is_activating (self))
return;
g_assert (self->priv->app_data);
nm_info ("Activation (%s): cancelling...", nm_device_get_iface (self));
/* Break the activation chain */
@@ -1105,22 +1040,18 @@ static void
nm_device_deactivate (NMDeviceInterface *device)
{
NMDevice *self = NM_DEVICE (device);
NMData * app_data;
NMIP4Config * config;
g_return_if_fail (self != NULL);
g_return_if_fail (self->priv->app_data != NULL);
nm_info ("Deactivating device %s.", nm_device_get_iface (self));
nm_device_deactivate_quickly (self);
app_data = self->priv->app_data;
/* Remove any device nameservers and domains */
if ((config = nm_device_get_ip4_config (self)))
{
nm_named_manager_remove_ip4_config (app_data->named_manager, config);
nm_named_manager_remove_ip4_config (self->priv->app_data->named_manager, config);
nm_device_set_ip4_config (self, NULL);
}
@@ -1296,13 +1227,13 @@ nm_device_update_ip4_address (NMDevice *self)
const char * iface;
g_return_if_fail (self != NULL);
g_return_if_fail (self->priv->app_data != NULL);
g_return_if_fail (nm_device_get_iface (self) != NULL);
if ((sk = nm_dev_sock_open (self, DEV_GENERAL, __func__, NULL)) == NULL)
return;
iface = nm_device_get_iface (self);
g_return_if_fail (iface != NULL);
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
return;
memset (&req, 0, sizeof (struct ifreq));
strncpy (req.ifr_name, iface, sizeof (req.ifr_name) - 1);
@@ -1320,62 +1251,15 @@ nm_device_update_ip4_address (NMDevice *self)
}
/*
* nm_device_set_up_down
*
* Set the up flag on the device on or off
*
*/
static void
nm_device_set_up_down (NMDevice *self,
gboolean up)
{
g_return_if_fail (self != NULL);
nm_system_device_set_up_down (self, up);
/*
* Make sure that we have a valid MAC address, some cards reload firmware when they
* are brought up.
*/
nm_device_set_address (self);
}
/*
* Interface state functions: bring up, down, check
*
*/
gboolean
nm_device_is_up (NMDevice *self)
{
NMSock * sk;
struct ifreq ifr;
int err;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
g_return_val_if_fail (self != NULL, FALSE);
if (NM_DEVICE_GET_CLASS (self)->is_up)
return NM_DEVICE_GET_CLASS (self)->is_up (self);
if ((sk = nm_dev_sock_open (self, DEV_GENERAL, __FUNCTION__, NULL)) == NULL)
return (FALSE);
/* Get device's flags */
strncpy (ifr.ifr_name, nm_device_get_iface (self), sizeof (ifr.ifr_name) - 1);
nm_ioctl_info ("%s: About to GET IFFLAGS.", nm_device_get_iface (self));
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFFLAGS, &ifr);
nm_ioctl_info ("%s: Done with GET IFFLAGS.", nm_device_get_iface (self));
nm_dev_sock_close (sk);
if (!err)
return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
if (errno != ENODEV)
{
nm_warning ("nm_device_is_up() could not get flags for device %s. errno = %d",
nm_device_get_iface (self), errno );
}
return FALSE;
return TRUE;
}
/* I really wish nm_v_wait_for_completion_or_timeout could translate these
@@ -1386,56 +1270,65 @@ nm_completion_device_is_up_test (int tries,
nm_completion_args args)
{
NMDevice *self = NM_DEVICE (args[0]);
gboolean *err = args[1];
gboolean cancelable = GPOINTER_TO_INT (args[2]);
g_return_val_if_fail (self != NULL, TRUE);
g_return_val_if_fail (err != NULL, TRUE);
*err = FALSE;
if (cancelable /* && nm_device_activation_should_cancel (self) */) {
*err = TRUE;
return TRUE;
}
if (nm_device_is_up (self))
return TRUE;
return FALSE;
}
void
nm_device_bring_up (NMDevice *self)
nm_device_bring_up (NMDevice *self, gboolean wait)
{
g_return_if_fail (self != NULL);
g_return_if_fail (NM_IS_DEVICE (self));
nm_device_set_up_down (self, TRUE);
}
if (nm_device_is_up (self))
return;
gboolean
nm_device_bring_up_wait (NMDevice *self,
gboolean cancelable)
{
gboolean err = FALSE;
nm_completion_args args;
nm_info ("Bringing up device %s", nm_device_get_iface (self));
g_return_val_if_fail (self != NULL, TRUE);
nm_system_device_set_up_down (self, TRUE);
nm_device_update_ip4_address (self);
nm_device_set_address (self);
nm_device_bring_up (self);
if (NM_DEVICE_GET_CLASS (self)->bring_up)
NM_DEVICE_GET_CLASS (self)->bring_up (self);
args[0] = self;
args[1] = &err;
args[2] = GINT_TO_POINTER (cancelable);
nm_wait_for_completion (400, G_USEC_PER_SEC / 200, NULL, nm_completion_device_is_up_test, args);
if (err)
nm_info ("failed to bring up device %s", self->priv->iface);
return err;
if (wait) {
nm_completion_args args;
args[0] = self;
nm_wait_for_completion (400, G_USEC_PER_SEC / 200, NULL, nm_completion_device_is_up_test, args);
}
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED);
}
void
nm_device_bring_down (NMDevice *self)
nm_device_bring_down (NMDevice *self, gboolean wait)
{
g_return_if_fail (self != NULL);
g_return_if_fail (NM_IS_DEVICE (self));
nm_device_set_up_down (self, FALSE);
if (!nm_device_is_up (self))
return;
nm_info ("Bringing down device %s", nm_device_get_iface (self));
if (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self));
if (NM_DEVICE_GET_CLASS (self)->bring_down)
NM_DEVICE_GET_CLASS (self)->bring_down (self);
nm_system_device_set_up_down (self, FALSE);
if (wait) {
nm_completion_args args;
args[0] = self;
nm_wait_for_completion (400, G_USEC_PER_SEC / 200, NULL, nm_completion_device_is_up_test, args);
}
nm_device_state_changed (self, NM_DEVICE_STATE_DOWN);
}
/*
@@ -1472,6 +1365,8 @@ nm_device_dispose (GObject *object)
* reference.
*/
nm_device_bring_down (self, FALSE);
nm_system_device_free_system_config (self, self->priv->system_config_data);
nm_device_set_ip4_config (self, NULL);
@@ -1591,10 +1486,10 @@ nm_device_class_init (NMDeviceClass *klass)
object_class->get_property = get_property;
object_class->constructor = constructor;
klass->is_up = real_is_up;
klass->activation_cancel_handler = real_activation_cancel_handler;
klass->get_type_capabilities = real_get_type_capabilities;
klass->get_generic_capabilities = real_get_generic_capabilities;
klass->start = real_start;
klass->act_stage1_prepare = real_act_stage1_prepare;
klass->act_stage2_config = real_act_stage2_config;
klass->act_stage3_ip_config_start = real_act_stage3_ip_config_start;
@@ -1643,13 +1538,22 @@ nm_device_class_init (NMDeviceClass *klass)
void
nm_device_state_changed (NMDevice *device, NMDeviceState state)
{
const char *iface;
NMDeviceState old_state;
g_return_if_fail (NM_IS_DEVICE (device));
iface = nm_device_get_iface (device);
old_state = device->priv->state;
device->priv->state = state;
switch (state) {
case NM_DEVICE_STATE_DOWN:
if (old_state == NM_DEVICE_STATE_ACTIVATED)
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
break;
case NM_DEVICE_STATE_ACTIVATED:
nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (device));
nm_info ("Activation (%s) successful, device activated.", iface);
break;
case NM_DEVICE_STATE_FAILED:
nm_info ("Activation (%s) failed.", nm_device_get_iface (device));

View File

@@ -82,6 +82,7 @@ struct _NMDeviceClass
void (* set_active_link) (NMDevice *self, gboolean active);
void (* update_link) (NMDevice *self);
gboolean (* is_up) (NMDevice *self);
void (* bring_up) (NMDevice *self);
void (* bring_down) (NMDevice *self);
@@ -90,8 +91,6 @@ struct _NMDeviceClass
guint32 (* get_type_capabilities) (NMDevice *self);
guint32 (* get_generic_capabilities) (NMDevice *self);
void (* init) (NMDevice *self);
void (* start) (NMDevice *self);
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,
@@ -114,8 +113,6 @@ struct _NMDeviceClass
GType nm_device_get_type (void);
void nm_device_stop (NMDevice *self);
const char * nm_device_get_udi (NMDevice *dev);
const char * nm_device_get_iface (NMDevice *dev);
@@ -128,14 +125,7 @@ guint32 nm_device_get_type_capabilities (NMDevice *dev);
struct NMData * nm_device_get_app_data (NMDevice *dev);
gboolean nm_device_get_removed (NMDevice *dev);
void nm_device_set_removed (NMDevice *dev,
const gboolean removed);
gboolean nm_device_has_active_link (NMDevice *dev);
void nm_device_set_active_link (NMDevice *dev,
const gboolean active);
guint32 nm_device_get_ip4_address (NMDevice *dev);
void nm_device_update_ip4_address (NMDevice *dev);
struct in6_addr * nm_device_get_ip6_address (NMDevice *dev);
@@ -148,8 +138,10 @@ NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
void nm_device_set_ip4_config (NMDevice *dev,
NMIP4Config *config);
void nm_device_bring_down (NMDevice *dev);
gboolean nm_device_is_up (NMDevice *dev);
gboolean nm_device_is_up (NMDevice *dev);
void nm_device_bring_up (NMDevice *dev, gboolean wait);
void nm_device_bring_down (NMDevice *dev, gboolean wait);
void * nm_device_get_system_config_data (NMDevice *dev);

View File

@@ -58,7 +58,6 @@ device_stop_and_free (gpointer data, gpointer user_data)
{
NMDevice *device = NM_DEVICE (data);
nm_device_set_removed (device, TRUE);
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
g_object_unref (device);
}
@@ -209,12 +208,10 @@ manager_set_wireless_enabled (NMManager *manager, gboolean enabled)
/* Tear down all wireless devices */
for (iter = priv->devices; iter; iter = iter->next) {
if (NM_IS_DEVICE_802_11_WIRELESS (iter->data)) {
NMDevice *dev = NM_DEVICE (iter->data);
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) {
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (dev));
nm_device_bring_down (dev);
}
if (enabled)
nm_device_bring_up (NM_DEVICE (iter->data), FALSE);
else
nm_device_bring_down (NM_DEVICE (iter->data), FALSE);
}
}
}
@@ -252,6 +249,12 @@ nm_manager_add_device (NMManager *manager, NMDevice *device)
g_signal_connect (device, "state-changed",
G_CALLBACK (manager_device_state_changed),
manager);
if (!priv->sleeping) {
if (!NM_IS_DEVICE_802_11_WIRELESS (device) || priv->wireless_enabled)
nm_device_bring_up (device, TRUE);
}
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
manager_device_added (manager, device);
@@ -280,9 +283,6 @@ nm_manager_remove_device (NMManager *manager, NMDevice *device)
g_signal_handlers_disconnect_by_func (device, manager_device_state_changed, manager);
nm_device_set_removed (device, TRUE);
nm_device_stop (device);
manager_device_removed (manager, device);
g_object_unref (device);
break;
@@ -407,13 +407,8 @@ nm_manager_sleep (NMManager *manager, gboolean sleep)
/* Just deactivate and down all devices from the device list,
* we'll remove them in 'wake' for speed's sake.
*/
for (iter = priv->devices; iter; iter = iter->next) {
NMDevice *dev = NM_DEVICE (iter->data);
nm_device_set_removed (dev, TRUE);
nm_device_deactivate_quickly (dev);
nm_system_device_set_up_down (dev, FALSE);
}
for (iter = priv->devices; iter; iter = iter->next)
nm_device_bring_down (NM_DEVICE (iter->data), FALSE);
} else {
nm_info ("Waking up from sleep.");

View File

@@ -149,7 +149,7 @@ nm_supplicant_info_new (NMSupplicantInterface *interface,
NMSupplicantInfo *info;
info = g_slice_new0 (NMSupplicantInfo);
info->interface = interface;
info->interface = g_object_ref (interface);
info->proxy = g_object_ref (proxy);
info->store = store;
@@ -160,7 +160,7 @@ static void
nm_supplicant_info_set_call (NMSupplicantInfo *info, DBusGProxyCall *call)
{
if (call) {
nm_call_store_add (info->store, g_object_ref (info->proxy), (gpointer) call);
nm_call_store_add (info->store, info->proxy, (gpointer) call);
info->call = call;
}
}
@@ -174,6 +174,7 @@ nm_supplicant_info_destroy (gpointer user_data)
nm_call_store_remove (info->store, G_OBJECT (info->proxy), info->call);
g_object_unref (info->proxy);
g_object_unref (info->interface);
g_slice_free (NMSupplicantInfo, info);
}