2005-12-31 08:21:24 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* Dan Williams <dcbw@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* (C) Copyright 2005 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
#include "nm-device-interface.h"
|
2007-05-07 15:17:45 +00:00
|
|
|
#include "nm-device.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device-private.h"
|
|
|
|
|
#include "NetworkManagerDbus.h"
|
|
|
|
|
#include "NetworkManagerPolicy.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
|
|
|
|
#include "NetworkManagerSystem.h"
|
|
|
|
|
#include "nm-dhcp-manager.h"
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-dbus-manager.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-dbus-nmi.h"
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "autoip.h"
|
2007-08-26 15:55:27 +00:00
|
|
|
#include "nm-netlink.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
#define NM_ACT_REQUEST_IP4_CONFIG "nm-act-request-ip4-config"
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void device_interface_init (NMDeviceInterface *device_interface_class);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_EXTENDED (NMDevice, nm_device, G_TYPE_OBJECT,
|
|
|
|
|
G_TYPE_FLAG_ABSTRACT,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_INTERFACE,
|
|
|
|
|
device_interface_init))
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
|
|
|
|
|
|
|
|
|
struct _NMDevicePrivate
|
|
|
|
|
{
|
|
|
|
|
gboolean dispose_has_run;
|
2007-08-26 15:55:27 +00:00
|
|
|
gboolean initialized;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDeviceState state;
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
char * dbus_path;
|
2005-12-31 08:21:24 +00:00
|
|
|
char * udi;
|
2007-08-26 15:55:27 +00:00
|
|
|
int index; /* Should always stay the same over lifetime of device */
|
|
|
|
|
char * iface; /* may change, could be renamed by user */
|
2005-12-31 08:21:24 +00:00
|
|
|
NMDeviceType type;
|
|
|
|
|
guint32 capabilities;
|
|
|
|
|
char * driver;
|
|
|
|
|
|
|
|
|
|
gboolean link_active;
|
|
|
|
|
guint32 ip4_address;
|
|
|
|
|
struct in6_addr ip6_address;
|
|
|
|
|
NMData * app_data;
|
|
|
|
|
|
|
|
|
|
NMActRequest * act_request;
|
2007-01-04 12:06:26 +00:00
|
|
|
guint act_source_id;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
/* IP configuration info */
|
|
|
|
|
void * system_config_data; /* Distro-specific config data (parsed config file, etc) */
|
|
|
|
|
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
|
2007-02-05 09:50:11 +00:00
|
|
|
NMDHCPManager * dhcp_manager;
|
2007-08-12 22:41:16 +00:00
|
|
|
gulong dhcp_state_sigid;
|
|
|
|
|
gulong dhcp_timeout_sigid;
|
2005-12-31 08:21:24 +00:00
|
|
|
};
|
|
|
|
|
|
2007-05-07 15:17:45 +00:00
|
|
|
static void nm_device_activate (NMDeviceInterface *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
gboolean user_requested);
|
|
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self);
|
2007-02-09 08:50:35 +00:00
|
|
|
static void nm_device_deactivate (NMDeviceInterface *device);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_set_address (NMDevice *device)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (device)->set_hw_address)
|
|
|
|
|
NM_DEVICE_GET_CLASS (device)->set_hw_address (device);
|
|
|
|
|
}
|
2006-04-27 15:49:40 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
device_interface_init (NMDeviceInterface *device_interface_class)
|
|
|
|
|
{
|
2007-02-09 08:50:35 +00:00
|
|
|
/* interface implementation */
|
2007-05-07 15:17:45 +00:00
|
|
|
device_interface_class->activate = nm_device_activate;
|
2007-02-09 08:50:35 +00:00
|
|
|
device_interface_class->deactivate = nm_device_deactivate;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_init (NMDevice * self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
self->priv->dispose_has_run = FALSE;
|
2007-08-26 15:55:27 +00:00
|
|
|
self->priv->initialized = FALSE;
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv->udi = NULL;
|
|
|
|
|
self->priv->iface = NULL;
|
2007-08-26 15:55:27 +00:00
|
|
|
self->priv->index = G_MAXUINT32;
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv->type = DEVICE_TYPE_UNKNOWN;
|
|
|
|
|
self->priv->capabilities = NM_DEVICE_CAP_NONE;
|
|
|
|
|
self->priv->driver = NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv->link_active = FALSE;
|
|
|
|
|
self->priv->ip4_address = 0;
|
|
|
|
|
memset (&self->priv->ip6_address, 0, sizeof (struct in6_addr));
|
|
|
|
|
self->priv->app_data = NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv->act_source_id = 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
self->priv->system_config_data = NULL;
|
|
|
|
|
self->priv->ip4_config = NULL;
|
|
|
|
|
|
|
|
|
|
self->priv->state = NM_DEVICE_STATE_DISCONNECTED;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static GObject*
|
|
|
|
|
constructor (GType type,
|
|
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
GObject *object;
|
|
|
|
|
NMDevice *dev;
|
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
2007-03-02 09:30:48 +00:00
|
|
|
NMDevicePrivate *priv;
|
2007-02-12 09:23:43 +00:00
|
|
|
NMDBusManager *manager;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
|
|
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
|
|
|
|
if (!object)
|
|
|
|
|
return NULL;
|
2006-01-19 18:00:48 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
dev = NM_DEVICE (object);
|
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
2007-03-02 09:30:48 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (dev);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
if (priv->index == G_MAXUINT32) {
|
|
|
|
|
nm_warning ("Interface index is a required constructor property.");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->iface = nm_netlink_index_to_iface (priv->index);
|
|
|
|
|
if (priv->iface == NULL) {
|
|
|
|
|
nm_warning ("(%d): Couldn't get interface name for device, ignoring.",
|
|
|
|
|
nm_device_get_index (dev));
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
|
2007-08-26 15:55:27 +00:00
|
|
|
if (!(priv->capabilities & NM_DEVICE_CAP_NM_SUPPORTED)) {
|
|
|
|
|
nm_warning ("(%s): Device unsupported, ignoring.",
|
|
|
|
|
nm_device_get_iface (dev));
|
|
|
|
|
goto error;
|
2006-01-03 17:07:07 +00:00
|
|
|
}
|
2006-01-02 02:50:47 +00:00
|
|
|
|
|
|
|
|
/* Grab IP config data for this device from the system configuration files */
|
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
2007-03-02 09:30:48 +00:00
|
|
|
priv->system_config_data = nm_system_device_get_system_config (dev, priv->app_data);
|
2006-01-02 02:50:47 +00:00
|
|
|
|
2006-01-19 18:00:48 +00:00
|
|
|
/* Allow distributions to flag devices as disabled */
|
2007-08-26 15:55:27 +00:00
|
|
|
if (nm_system_device_get_disabled (dev)) {
|
|
|
|
|
nm_warning ("(%s): Device otherwise managed, ignoring.",
|
|
|
|
|
nm_device_get_iface (dev));
|
|
|
|
|
goto error;
|
2006-01-19 18:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-02 02:50:47 +00:00
|
|
|
nm_print_device_capabilities (dev);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
manager = nm_dbus_manager_get ();
|
2007-08-26 15:55:27 +00:00
|
|
|
priv->dbus_path = g_strdup_printf ("%s/%d",
|
|
|
|
|
NM_DBUS_PATH_DEVICE,
|
|
|
|
|
nm_device_get_index (dev));
|
|
|
|
|
if (priv->dbus_path == NULL) {
|
|
|
|
|
nm_warning ("(%s): Not enough memory to initialize device.",
|
|
|
|
|
nm_device_get_iface (dev));
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (manager),
|
2007-08-26 15:55:27 +00:00
|
|
|
nm_device_get_dbus_path (dev),
|
|
|
|
|
object);
|
|
|
|
|
priv->initialized = TRUE;
|
2007-02-05 12:14:09 +00:00
|
|
|
return object;
|
2007-08-26 15:55:27 +00:00
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
g_object_unref (dev);
|
|
|
|
|
return NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
static gboolean
|
|
|
|
|
real_is_up (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
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
2007-03-02 09:30:48 +00:00
|
|
|
NMSock * sk;
|
|
|
|
|
struct ifreq ifr;
|
|
|
|
|
int err;
|
|
|
|
|
const char *iface;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __FUNCTION__, NULL)) == NULL)
|
|
|
|
|
return FALSE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
/* Get device's flags */
|
|
|
|
|
strncpy (ifr.ifr_name, iface, sizeof (ifr.ifr_name) - 1);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
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);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_dev_sock_close (sk);
|
|
|
|
|
if (!err)
|
|
|
|
|
return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
|
|
|
|
|
|
2007-08-21 01:47:57 +00:00
|
|
|
if (errno != ENODEV) {
|
|
|
|
|
nm_warning ("%s: could not get flags for device %s. errno = %d",
|
|
|
|
|
__func__, iface, errno);
|
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
2007-03-02 09:30:48 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint32
|
|
|
|
|
real_get_generic_capabilities (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
const char *
|
|
|
|
|
nm_device_get_dbus_path (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->dbus_path;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
const char *
|
|
|
|
|
nm_device_get_udi (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->udi;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
guint32
|
|
|
|
|
nm_device_get_index (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, G_MAXUINT32);
|
|
|
|
|
|
|
|
|
|
return self->priv->index;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* Get/set functions for iface
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_iface (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->iface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for driver
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_driver (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->driver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for type
|
|
|
|
|
*/
|
|
|
|
|
NMDeviceType
|
|
|
|
|
nm_device_get_device_type (NMDevice *self)
|
|
|
|
|
{
|
2007-02-09 08:50:35 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), DEVICE_TYPE_UNKNOWN);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
return self->priv->type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
void
|
|
|
|
|
nm_device_set_device_type (NMDevice *dev, NMDeviceType type)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (dev));
|
|
|
|
|
g_return_if_fail (NM_DEVICE_GET_PRIVATE (dev)->type == DEVICE_TYPE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
NM_DEVICE_GET_PRIVATE (dev)->type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* Accessor for capabilities
|
|
|
|
|
*/
|
|
|
|
|
guint32
|
|
|
|
|
nm_device_get_capabilities (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
|
|
|
|
|
|
|
|
|
|
return self->priv->capabilities;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Accessor for type-specific capabilities
|
|
|
|
|
*/
|
|
|
|
|
guint32
|
|
|
|
|
nm_device_get_type_capabilities (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->get_type_capabilities (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint32
|
|
|
|
|
real_get_type_capabilities (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_CAP_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_get_app_data
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
struct NMData *
|
|
|
|
|
nm_device_get_app_data (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return self->priv->app_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_get_act_request
|
|
|
|
|
*
|
|
|
|
|
* Return the devices activation request, if any.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMActRequest *
|
|
|
|
|
nm_device_get_act_request (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->act_request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for link_active
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_has_active_link (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
return self->priv->link_active;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_active_link (NMDevice *self,
|
|
|
|
|
const gboolean link_active)
|
|
|
|
|
{
|
2007-02-08 15:34:26 +00:00
|
|
|
NMDevicePrivate *priv;
|
2006-01-03 22:11:35 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
|
2007-02-08 15:34:26 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
if (priv->link_active != link_active) {
|
|
|
|
|
priv->link_active = link_active;
|
|
|
|
|
g_signal_emit_by_name (self, "carrier-changed", link_active);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage1_device_prepare
|
|
|
|
|
*
|
|
|
|
|
* Prepare for device activation
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage1_device_prepare (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
const char * iface;
|
|
|
|
|
NMActStageReturn ret;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self);
|
2006-12-28 22:13:59 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
2006-01-03 17:07:07 +00:00
|
|
|
goto out;
|
2006-12-28 22:13:59 +00:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2006-01-03 17:07:07 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage2_device_config (self);
|
2006-01-03 17:07:07 +00:00
|
|
|
|
|
|
|
|
out:
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage1_device_prepare
|
|
|
|
|
*
|
|
|
|
|
* Prepare a device for activation
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage1_device_prepare (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_source_id = g_idle_add (nm_device_activate_stage1_device_prepare, self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
nm_info ("Activation (%s) Stage 1 of 5 (Device Prepare) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:07:07 +00:00
|
|
|
static NMActStageReturn
|
2007-06-11 13:36:34 +00:00
|
|
|
real_act_stage1_prepare (NMDevice *dev)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
|
|
|
|
/* Nothing to do */
|
2006-01-03 17:07:07 +00:00
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:07:07 +00:00
|
|
|
static NMActStageReturn
|
2007-06-11 13:36:34 +00:00
|
|
|
real_act_stage2_config (NMDevice *dev)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
|
|
|
|
/* Nothing to do */
|
2006-01-03 17:07:07 +00:00
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage2_device_config
|
|
|
|
|
*
|
|
|
|
|
* Determine device parameters and set those on the device, ie
|
2007-06-27 16:18:52 +00:00
|
|
|
* for wireless devices, set SSID, keys, etc.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage2_device_config (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
const char * iface;
|
|
|
|
|
NMActStageReturn ret;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-03-12 04:49:29 +00:00
|
|
|
if (!nm_device_bring_up (self, FALSE)) {
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self);
|
2006-01-03 17:07:07 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
goto out;
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2006-01-03 17:07:07 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) successful.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage2_device_config
|
|
|
|
|
*
|
|
|
|
|
* Schedule setup of the hardware device
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage2_device_config (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_source_id = g_idle_add (nm_device_activate_stage2_device_config, self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
2007-06-11 13:36:34 +00:00
|
|
|
real_act_stage3_ip_config_start (NMDevice *self)
|
2007-06-06 13:33:51 +00:00
|
|
|
{
|
|
|
|
|
NMSettingIP4Config *setting;
|
2007-06-11 13:36:34 +00:00
|
|
|
NMActRequest *req;
|
2007-06-06 13:33:51 +00:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
req = nm_device_get_act_request (self);
|
2007-06-06 13:33:51 +00:00
|
|
|
setting = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req), "ipv4");
|
|
|
|
|
|
|
|
|
|
/* If we did not receive IP4 configuration information, default to DHCP */
|
|
|
|
|
if (!setting || setting->manual == FALSE) {
|
2006-01-03 17:47:38 +00:00
|
|
|
/* Begin a DHCP transaction on the interface */
|
2007-02-05 09:50:11 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
gboolean success;
|
2006-01-03 18:18:05 +00:00
|
|
|
|
2007-06-06 13:33:51 +00:00
|
|
|
nm_device_set_use_dhcp (self, TRUE);
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
/* DHCP manager will cancel any transaction already in progress and we do not
|
|
|
|
|
want to cancel this activation if we get "down" state from that. */
|
2007-08-12 22:41:16 +00:00
|
|
|
g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid);
|
2007-02-05 09:50:11 +00:00
|
|
|
|
|
|
|
|
success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager,
|
2007-08-12 22:41:16 +00:00
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
45);
|
2007-02-05 09:50:11 +00:00
|
|
|
|
2007-08-12 22:41:16 +00:00
|
|
|
g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid);
|
2007-02-05 09:50:11 +00:00
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
/* DHCP devices will be notified by the DHCP manager when
|
|
|
|
|
* stuff happens.
|
|
|
|
|
*/
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
2007-02-05 09:50:11 +00:00
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage3_ip_config_start
|
|
|
|
|
*
|
|
|
|
|
* Begin IP configuration with either DHCP or static IP.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
const char * iface;
|
|
|
|
|
NMActStageReturn ret;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip_config_start (self);
|
2006-01-03 17:47:38 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
goto out;
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_get (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage3_ip_config_start
|
|
|
|
|
*
|
|
|
|
|
* Schedule IP configuration start
|
|
|
|
|
*/
|
2006-01-07 16:22:17 +00:00
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
self->priv->act_source_id = g_idle_add (nm_device_activate_stage3_ip_config_start, self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
nm_info ("Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_new_ip4_autoip_config
|
|
|
|
|
*
|
|
|
|
|
* Build up an IP config with a Link Local address
|
|
|
|
|
*
|
|
|
|
|
*/
|
2006-01-03 17:07:07 +00:00
|
|
|
NMIP4Config *
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_device_new_ip4_autoip_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr ip;
|
|
|
|
|
NMIP4Config * config = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (get_autoip (self, &ip))
|
|
|
|
|
{
|
|
|
|
|
#define LINKLOCAL_BCAST 0xa9feffff
|
|
|
|
|
|
|
|
|
|
config = nm_ip4_config_new ();
|
|
|
|
|
nm_ip4_config_set_address (config, (guint32)(ip.s_addr));
|
|
|
|
|
nm_ip4_config_set_netmask (config, (guint32)(ntohl (0xFFFF0000)));
|
|
|
|
|
nm_ip4_config_set_broadcast (config, (guint32)(ntohl (LINKLOCAL_BCAST)));
|
|
|
|
|
nm_ip4_config_set_gateway (config, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_get_ip4_config (NMDevice *self,
|
|
|
|
|
NMIP4Config **config)
|
|
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMActRequest *req;
|
2006-01-03 17:47:38 +00:00
|
|
|
NMIP4Config * real_config = NULL;
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2007-06-06 13:33:51 +00:00
|
|
|
NMSettingIP4Config *setting;
|
2006-01-03 17:47:38 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
if (real_config && nm_ip4_config_get_mtu (real_config) == 0)
|
|
|
|
|
/* If the DHCP server doesn't set the MTU, get it from backend. */
|
|
|
|
|
nm_ip4_config_set_mtu (real_config, nm_system_get_mtu (self));
|
2007-06-06 13:33:51 +00:00
|
|
|
} else {
|
|
|
|
|
real_config = nm_ip4_config_new ();
|
|
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
req = nm_device_get_act_request (self);
|
2007-06-06 13:33:51 +00:00
|
|
|
setting = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req), "ipv4");
|
|
|
|
|
|
|
|
|
|
if (real_config && setting) {
|
|
|
|
|
/* If settings are provided, use them, even if it means overriding the values we got from DHCP */
|
|
|
|
|
nm_ip4_config_set_address (real_config, setting->address);
|
|
|
|
|
nm_ip4_config_set_netmask (real_config, setting->netmask);
|
|
|
|
|
|
|
|
|
|
if (setting->gateway)
|
|
|
|
|
nm_ip4_config_set_gateway (real_config, setting->gateway);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (real_config) {
|
2006-01-03 17:47:38 +00:00
|
|
|
*config = real_config;
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
2007-06-06 13:33:51 +00:00
|
|
|
} else {
|
2006-01-03 17:47:38 +00:00
|
|
|
/* Make sure device is up even if config fails */
|
2007-03-12 04:49:29 +00:00
|
|
|
if (!nm_device_bring_up (self, FALSE))
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage4_ip_config_get
|
|
|
|
|
*
|
|
|
|
|
* Retrieve the correct IP config.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage4_ip_config_get (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
NMIP4Config * ip4_config = NULL;
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
const char * iface = NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) started...", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, &ip4_config);
|
2006-01-03 17:07:07 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
goto out;
|
|
|
|
|
else if (!ip4_config || (ret == NM_ACT_STAGE_RETURN_FAILURE))
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2006-01-03 17:07:07 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
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);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2006-12-28 22:13:59 +00:00
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage4_ip_config_get
|
|
|
|
|
*
|
|
|
|
|
* Schedule creation of the IP config
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_get (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_get, self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Get) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_ip_config_timeout (NMDevice *self,
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage4_ip_config_timeout
|
|
|
|
|
*
|
|
|
|
|
* Retrieve the correct IP config.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage4_ip_config_timeout (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
NMIP4Config * ip4_config = NULL;
|
|
|
|
|
const char * iface;
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) started...", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip_config_timeout (self, &ip4_config);
|
2007-01-04 12:06:26 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
2006-01-03 17:47:38 +00:00
|
|
|
goto out;
|
2007-01-04 12:06:26 +00:00
|
|
|
} else if (!ip4_config || (ret == NM_ACT_STAGE_RETURN_FAILURE)) {
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2006-01-03 17:47:38 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
|
|
|
|
g_assert (ip4_config);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
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);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage4_ip_config_timeout
|
|
|
|
|
*
|
|
|
|
|
* Deal with a timed out DHCP transaction
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_timeout (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_source_id = g_idle_add (nm_device_activate_stage4_ip_config_timeout, self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_info ("Activation (%s) Stage 4 of 5 (IP Configure Timeout) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage5_ip_config_commit
|
|
|
|
|
*
|
|
|
|
|
* Commit the IP config on the device
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage5_ip_config_commit (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
NMIP4Config * ip4_config = NULL;
|
|
|
|
|
const char * iface;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
ip4_config = g_object_get_data (G_OBJECT (nm_device_get_act_request (self)),
|
|
|
|
|
NM_ACT_REQUEST_IP4_CONFIG);
|
2005-12-31 08:21:24 +00:00
|
|
|
g_assert (ip4_config);
|
|
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
if (self->priv->act_source_id > 0)
|
|
|
|
|
self->priv->act_source_id = 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
nm_device_set_ip4_config (self, ip4_config);
|
2006-12-28 22:13:59 +00:00
|
|
|
if (nm_system_device_set_from_ip4_config (self)) {
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_device_update_ip4_address (self);
|
|
|
|
|
nm_system_device_add_ip6_link_address (self);
|
|
|
|
|
nm_system_restart_mdns_responder ();
|
2006-01-23 21:02:39 +00:00
|
|
|
nm_system_set_hostname (self->priv->ip4_config);
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_system_activate_nis (self->priv->ip4_config);
|
2006-03-21 17:57:01 +00:00
|
|
|
nm_system_set_mtu (self);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2006-01-03 17:07:07 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->update_link)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->update_link (self);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED);
|
2006-12-28 22:13:59 +00:00
|
|
|
} else {
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2006-12-28 22:13:59 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-02-15 21:19:09 +00:00
|
|
|
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
|
2006-12-28 22:13:59 +00:00
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage5_ip_config_commit
|
|
|
|
|
*
|
|
|
|
|
* Schedule commit of the IP config
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_source_id = g_idle_add (nm_device_activate_stage5_ip_config_commit, self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-04 Dan Williams <dcbw@redhat.com>
Clean up activation cancellation. Should be a lot faster now. Observed
an issue with wireless devices between stage 2 and 3 of activation, where
activation would be cancelled, but the device thread wouldn't notice until
the supplicant association timed out. Reorganize activation such that
a cancellation handler gets immediately scheduled in the device's thread,
and devices have a chance to perform any custom cleanup too.
* src/nm-device.[ch]
- (activation_cancel_handler): new device-type-specific function
for cleaning up device-type-specific stuff on cancellation
- (cancel_activation): removed
- (nm_device_activation_cancel): subsume functionality of
real_cancel_activation, but instead of doing anything, punt
operation to a handler that's run in device-thread context
- (nm_device_schedule_activation_handle_cancel): fix spelling of
a warning message
- (activation_handle_cancel_helper): cancellation handler run in
device-thread context, calls device-type-specific cancelation,
then tears down the activation request
- (real_activation_cancel_handler): generic cancellation handler,
deals with cancelling any in-process DHCP request
- (nm_device_activate_stage1_device_prepare,
nm_device_activate_stage2_device_config,
nm_device_activate_stage3_ip_config_start,
nm_device_activate_stage4_ip_config_get,
nm_device_activate_stage4_ip_config_timeout,
nm_device_activate_stage5_ip_commit): don't call
nm_device_schedule_activation_handle_cancel() any more, since
cancellation will have been already scheduled for us by
nm_device_activation_cancel(). Just exit the function and
assume that the cancel handler will be called next.
* src/nm-device-802-3-ethernet.c
- (real_act_stage2_config): remove; didn't do anything anyway
* src/nm-device-802-11-wireless.c
- (supplicant_status_cb): ensure we don't do anything if the activation
got cancelled
- (real_activation_cancel_handler): implement; cancel user key request
on activation cancellation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1549 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-04 06:44:05 +00:00
|
|
|
static void
|
2007-06-11 13:36:34 +00:00
|
|
|
real_activation_cancel_handler (NMDevice *self)
|
2006-03-04 Dan Williams <dcbw@redhat.com>
Clean up activation cancellation. Should be a lot faster now. Observed
an issue with wireless devices between stage 2 and 3 of activation, where
activation would be cancelled, but the device thread wouldn't notice until
the supplicant association timed out. Reorganize activation such that
a cancellation handler gets immediately scheduled in the device's thread,
and devices have a chance to perform any custom cleanup too.
* src/nm-device.[ch]
- (activation_cancel_handler): new device-type-specific function
for cleaning up device-type-specific stuff on cancellation
- (cancel_activation): removed
- (nm_device_activation_cancel): subsume functionality of
real_cancel_activation, but instead of doing anything, punt
operation to a handler that's run in device-thread context
- (nm_device_schedule_activation_handle_cancel): fix spelling of
a warning message
- (activation_handle_cancel_helper): cancellation handler run in
device-thread context, calls device-type-specific cancelation,
then tears down the activation request
- (real_activation_cancel_handler): generic cancellation handler,
deals with cancelling any in-process DHCP request
- (nm_device_activate_stage1_device_prepare,
nm_device_activate_stage2_device_config,
nm_device_activate_stage3_ip_config_start,
nm_device_activate_stage4_ip_config_get,
nm_device_activate_stage4_ip_config_timeout,
nm_device_activate_stage5_ip_commit): don't call
nm_device_schedule_activation_handle_cancel() any more, since
cancellation will have been already scheduled for us by
nm_device_activation_cancel(). Just exit the function and
assume that the cancel handler will be called next.
* src/nm-device-802-3-ethernet.c
- (real_act_stage2_config): remove; didn't do anything anyway
* src/nm-device-802-11-wireless.c
- (supplicant_status_cb): ensure we don't do anything if the activation
got cancelled
- (real_activation_cancel_handler): implement; cancel user key request
on activation cancellation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1549 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-04 06:44:05 +00:00
|
|
|
{
|
2007-06-06 13:33:51 +00:00
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG &&
|
|
|
|
|
nm_device_get_use_dhcp (self)) {
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
2007-08-12 22:41:16 +00:00
|
|
|
nm_device_get_iface (self));
|
2007-06-06 13:33:51 +00:00
|
|
|
}
|
2006-03-04 Dan Williams <dcbw@redhat.com>
Clean up activation cancellation. Should be a lot faster now. Observed
an issue with wireless devices between stage 2 and 3 of activation, where
activation would be cancelled, but the device thread wouldn't notice until
the supplicant association timed out. Reorganize activation such that
a cancellation handler gets immediately scheduled in the device's thread,
and devices have a chance to perform any custom cleanup too.
* src/nm-device.[ch]
- (activation_cancel_handler): new device-type-specific function
for cleaning up device-type-specific stuff on cancellation
- (cancel_activation): removed
- (nm_device_activation_cancel): subsume functionality of
real_cancel_activation, but instead of doing anything, punt
operation to a handler that's run in device-thread context
- (nm_device_schedule_activation_handle_cancel): fix spelling of
a warning message
- (activation_handle_cancel_helper): cancellation handler run in
device-thread context, calls device-type-specific cancelation,
then tears down the activation request
- (real_activation_cancel_handler): generic cancellation handler,
deals with cancelling any in-process DHCP request
- (nm_device_activate_stage1_device_prepare,
nm_device_activate_stage2_device_config,
nm_device_activate_stage3_ip_config_start,
nm_device_activate_stage4_ip_config_get,
nm_device_activate_stage4_ip_config_timeout,
nm_device_activate_stage5_ip_commit): don't call
nm_device_schedule_activation_handle_cancel() any more, since
cancellation will have been already scheduled for us by
nm_device_activation_cancel(). Just exit the function and
assume that the cancel handler will be called next.
* src/nm-device-802-3-ethernet.c
- (real_act_stage2_config): remove; didn't do anything anyway
* src/nm-device-802-11-wireless.c
- (supplicant_status_cb): ensure we don't do anything if the activation
got cancelled
- (real_activation_cancel_handler): implement; cancel user key request
on activation cancellation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1549 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-04 06:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-03-04 Dan Williams <dcbw@redhat.com>
Clean up activation cancellation. Should be a lot faster now. Observed
an issue with wireless devices between stage 2 and 3 of activation, where
activation would be cancelled, but the device thread wouldn't notice until
the supplicant association timed out. Reorganize activation such that
a cancellation handler gets immediately scheduled in the device's thread,
and devices have a chance to perform any custom cleanup too.
* src/nm-device.[ch]
- (activation_cancel_handler): new device-type-specific function
for cleaning up device-type-specific stuff on cancellation
- (cancel_activation): removed
- (nm_device_activation_cancel): subsume functionality of
real_cancel_activation, but instead of doing anything, punt
operation to a handler that's run in device-thread context
- (nm_device_schedule_activation_handle_cancel): fix spelling of
a warning message
- (activation_handle_cancel_helper): cancellation handler run in
device-thread context, calls device-type-specific cancelation,
then tears down the activation request
- (real_activation_cancel_handler): generic cancellation handler,
deals with cancelling any in-process DHCP request
- (nm_device_activate_stage1_device_prepare,
nm_device_activate_stage2_device_config,
nm_device_activate_stage3_ip_config_start,
nm_device_activate_stage4_ip_config_get,
nm_device_activate_stage4_ip_config_timeout,
nm_device_activate_stage5_ip_commit): don't call
nm_device_schedule_activation_handle_cancel() any more, since
cancellation will have been already scheduled for us by
nm_device_activation_cancel(). Just exit the function and
assume that the cancel handler will be called next.
* src/nm-device-802-3-ethernet.c
- (real_act_stage2_config): remove; didn't do anything anyway
* src/nm-device-802-11-wireless.c
- (supplicant_status_cb): ensure we don't do anything if the activation
got cancelled
- (real_activation_cancel_handler): implement; cancel user key request
on activation cancellation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1549 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-04 06:44:05 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activation_cancel
|
|
|
|
|
*
|
|
|
|
|
* Signal activation worker that it should stop and die.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_device_activation_cancel (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2006-12-28 22:13:59 +00:00
|
|
|
NMDeviceClass *klass;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
if (!nm_device_is_activating (self))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
nm_info ("Activation (%s): cancelling...", nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
/* Break the activation chain */
|
2007-01-04 12:06:26 +00:00
|
|
|
if (self->priv->act_source_id) {
|
|
|
|
|
g_source_remove (self->priv->act_source_id);
|
|
|
|
|
self->priv->act_source_id = 0;
|
2006-12-28 22:13:59 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
klass = NM_DEVICE_CLASS (g_type_class_peek (NM_TYPE_DEVICE));
|
|
|
|
|
if (klass->activation_cancel_handler)
|
2007-06-11 13:36:34 +00:00
|
|
|
klass->activation_cancel_handler (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_object_unref (self->priv->act_request);
|
2006-12-28 22:13:59 +00:00
|
|
|
self->priv->act_request = NULL;
|
|
|
|
|
|
|
|
|
|
nm_info ("Activation (%s): cancelled.", nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_deactivate_quickly
|
|
|
|
|
*
|
|
|
|
|
* Quickly deactivate a device, for things like sleep, etc. Doesn't
|
|
|
|
|
* clean much stuff up, and nm_device_deactivate() should be called
|
|
|
|
|
* on the device eventually.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_deactivate_quickly (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMActRequest * act_request;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
nm_system_shutdown_nis ();
|
|
|
|
|
|
2007-02-19 13:09:32 +00:00
|
|
|
if (nm_device_is_activating (self))
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_device_activation_cancel (self);
|
|
|
|
|
|
|
|
|
|
/* Tear down an existing activation request, which may not have happened
|
|
|
|
|
* in nm_device_activation_cancel() above, for various reasons.
|
|
|
|
|
*/
|
2007-06-06 13:33:51 +00:00
|
|
|
if ((act_request = nm_device_get_act_request (self)) &&
|
|
|
|
|
nm_device_get_use_dhcp (self)) {
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
2007-08-12 22:41:16 +00:00
|
|
|
nm_device_get_iface (self));
|
2007-06-11 13:36:34 +00:00
|
|
|
g_object_unref (act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
self->priv->act_request = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-13 16:53:55 +00:00
|
|
|
/* Call device type-specific deactivation */
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->deactivate_quickly)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->deactivate_quickly (self);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_deactivate
|
|
|
|
|
*
|
|
|
|
|
* Remove a device's routing table entries and IP address.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2007-02-09 08:50:35 +00:00
|
|
|
static void
|
|
|
|
|
nm_device_deactivate (NMDeviceInterface *device)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-09 08:50:35 +00:00
|
|
|
NMDevice *self = NM_DEVICE (device);
|
2005-12-31 08:21:24 +00:00
|
|
|
NMIP4Config * config;
|
|
|
|
|
|
2006-01-02 02:50:47 +00:00
|
|
|
g_return_if_fail (self != NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
nm_info ("Deactivating device %s.", nm_device_get_iface (self));
|
|
|
|
|
|
|
|
|
|
nm_device_deactivate_quickly (self);
|
|
|
|
|
|
|
|
|
|
/* Remove any device nameservers and domains */
|
|
|
|
|
if ((config = nm_device_get_ip4_config (self)))
|
|
|
|
|
{
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_named_manager_remove_ip4_config (self->priv->app_data->named_manager, config);
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_device_set_ip4_config (self, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Take out any entries in the routing table and any IP address the device had. */
|
|
|
|
|
nm_system_device_flush_routes (self);
|
|
|
|
|
nm_system_device_flush_addresses (self);
|
2006-01-02 02:50:47 +00:00
|
|
|
nm_device_update_ip4_address (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-01-02 02:50:47 +00:00
|
|
|
/* Call device type-specific deactivation */
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->deactivate)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->deactivate (self);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-07 15:17:45 +00:00
|
|
|
static void
|
|
|
|
|
nm_device_activate (NMDeviceInterface *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
gboolean user_requested)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (device);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!NM_DEVICE_GET_CLASS (self)->check_connection (self, connection))
|
|
|
|
|
/* connection is invalid */
|
|
|
|
|
return;
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (self)) {
|
|
|
|
|
NMConnection *current_connection;
|
|
|
|
|
|
|
|
|
|
current_connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
|
|
|
|
|
|
|
|
|
if (nm_connection_compare (connection, current_connection))
|
|
|
|
|
/* Already activating or activated with the same connection */
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
nm_device_deactivate (device);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-07 15:17:45 +00:00
|
|
|
nm_info ("Activating device %s", nm_device_get_iface (self));
|
2007-06-11 13:36:34 +00:00
|
|
|
priv->act_request = nm_act_request_new (connection, user_requested);
|
|
|
|
|
nm_device_activate_schedule_stage1_device_prepare (self);
|
2007-05-07 15:17:45 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_is_activating
|
|
|
|
|
*
|
|
|
|
|
* Return whether or not the device is currently activating itself.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_is_activating (NMDevice *device)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
switch (nm_device_get_state (device)) {
|
|
|
|
|
case NM_DEVICE_STATE_PREPARE:
|
|
|
|
|
case NM_DEVICE_STATE_CONFIG:
|
|
|
|
|
case NM_DEVICE_STATE_NEED_AUTH:
|
|
|
|
|
case NM_DEVICE_STATE_IP_CONFIG:
|
|
|
|
|
return TRUE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
return FALSE;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-22 22:40:14 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_can_interrupt_activation (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
gboolean interrupt = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->can_interrupt_activation)
|
|
|
|
|
interrupt = NM_DEVICE_GET_CLASS (self)->can_interrupt_activation (self);
|
|
|
|
|
return interrupt;
|
|
|
|
|
}
|
2006-01-03 22:11:35 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/* IP Configuration stuff */
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
static void
|
|
|
|
|
dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
|
|
|
|
const char *iface,
|
|
|
|
|
NMDHCPState state,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2007-08-12 22:41:16 +00:00
|
|
|
NMDevice * device = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
if (strcmp (nm_device_get_iface (device), iface) != 0)
|
|
|
|
|
return;
|
2007-02-05 09:50:11 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
if (!nm_device_get_act_request (device))
|
2007-02-05 09:50:11 +00:00
|
|
|
return;
|
|
|
|
|
|
2007-08-12 22:41:16 +00:00
|
|
|
switch (state) {
|
|
|
|
|
case DHC_BOUND: /* lease obtained */
|
|
|
|
|
case DHC_RENEW: /* lease renewed */
|
|
|
|
|
case DHC_REBOOT: /* have valid lease, but now obtained a different one */
|
|
|
|
|
case DHC_REBIND: /* new, different lease */
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_get (device);
|
2007-08-12 22:41:16 +00:00
|
|
|
break;
|
|
|
|
|
case DHC_TIMEOUT: /* timed out contacting DHCP server */
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_timeout (device);
|
2007-08-12 22:41:16 +00:00
|
|
|
break;
|
|
|
|
|
case DHC_FAIL: /* all attempts to contact server timed out, sleeping */
|
|
|
|
|
case DHC_ABEND: /* dhclient exited abnormally */
|
|
|
|
|
case DHC_END: /* dhclient exited normally */
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
|
2007-02-19 13:09:32 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
|
2007-08-12 22:41:16 +00:00
|
|
|
} else if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
if (nm_device_get_use_dhcp (device)) {
|
|
|
|
|
/* dhclient quit and therefore can't renew our lease, kill the conneciton */
|
2007-08-26 15:55:27 +00:00
|
|
|
nm_device_deactivate (NM_DEVICE_INTERFACE (device));
|
2007-08-12 22:41:16 +00:00
|
|
|
}
|
2007-02-05 09:50:11 +00:00
|
|
|
}
|
2007-08-12 22:41:16 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2007-02-05 09:50:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-12 22:41:16 +00:00
|
|
|
static void
|
|
|
|
|
dhcp_timeout (NMDHCPManager *dhcp_manager,
|
|
|
|
|
const char *iface,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice * device = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
if (strcmp (nm_device_get_iface (device), iface) != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip_config_timeout (device);
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_use_dhcp (NMDevice *self)
|
|
|
|
|
{
|
2007-02-05 09:50:11 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp_manager ? TRUE : FALSE;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_use_dhcp (NMDevice *self,
|
|
|
|
|
gboolean use_dhcp)
|
|
|
|
|
{
|
2007-02-05 09:50:11 +00:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (use_dhcp) {
|
|
|
|
|
if (!priv->dhcp_manager) {
|
|
|
|
|
priv->dhcp_manager = nm_dhcp_manager_get ();
|
2007-08-12 22:41:16 +00:00
|
|
|
priv->dhcp_state_sigid = g_signal_connect (priv->dhcp_manager,
|
|
|
|
|
"state-changed",
|
|
|
|
|
G_CALLBACK (dhcp_state_changed),
|
|
|
|
|
self);
|
|
|
|
|
priv->dhcp_timeout_sigid = g_signal_connect (priv->dhcp_manager,
|
|
|
|
|
"timeout",
|
|
|
|
|
G_CALLBACK (dhcp_timeout),
|
|
|
|
|
self);
|
2007-02-05 09:50:11 +00:00
|
|
|
}
|
|
|
|
|
} else if (priv->dhcp_manager) {
|
2007-08-12 22:41:16 +00:00
|
|
|
g_signal_handler_disconnect (priv->dhcp_manager, priv->dhcp_state_sigid);
|
|
|
|
|
priv->dhcp_state_sigid = 0;
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp_manager, priv->dhcp_timeout_sigid);
|
|
|
|
|
priv->dhcp_timeout_sigid = 0;
|
2007-02-05 09:50:11 +00:00
|
|
|
g_object_unref (priv->dhcp_manager);
|
|
|
|
|
priv->dhcp_manager = NULL;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NMIP4Config *
|
|
|
|
|
nm_device_get_ip4_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->ip4_config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config)
|
|
|
|
|
{
|
2007-02-16 11:23:49 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
if (priv->ip4_config) {
|
|
|
|
|
g_object_unref (priv->ip4_config);
|
|
|
|
|
priv->ip4_config = NULL;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
if (config)
|
2007-02-16 11:23:49 +00:00
|
|
|
priv->ip4_config = g_object_ref (config);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_get_ip4_address
|
|
|
|
|
*
|
|
|
|
|
* Get a device's IPv4 address
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
guint32
|
|
|
|
|
nm_device_get_ip4_address (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return self->priv->ip4_address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_update_ip4_address (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
guint32 new_address;
|
|
|
|
|
struct ifreq req;
|
|
|
|
|
NMSock * sk;
|
|
|
|
|
int err;
|
|
|
|
|
const char * iface;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
g_return_if_fail (iface != NULL);
|
|
|
|
|
|
|
|
|
|
if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
|
2005-12-31 08:21:24 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
memset (&req, 0, sizeof (struct ifreq));
|
|
|
|
|
strncpy (req.ifr_name, iface, sizeof (req.ifr_name) - 1);
|
2006-05-25 22:37:41 +00:00
|
|
|
|
|
|
|
|
nm_ioctl_info ("%s: About to GET IFADDR.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFADDR, &req);
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: Done with GET IFADDR.", iface);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_dev_sock_close (sk);
|
|
|
|
|
if (err != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
new_address = ((struct sockaddr_in *)(&req.ifr_addr))->sin_addr.s_addr;
|
|
|
|
|
if (new_address != nm_device_get_ip4_address (self))
|
|
|
|
|
self->priv->ip4_address = new_address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_is_up (NMDevice *self)
|
|
|
|
|
{
|
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
2007-03-02 09:30:48 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->is_up)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->is_up (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
return TRUE;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* I really wish nm_v_wait_for_completion_or_timeout could translate these
|
|
|
|
|
* to first class args instead of a all this void * arg stuff, so these
|
|
|
|
|
* helpers could be nice and _tiny_. */
|
|
|
|
|
static gboolean
|
|
|
|
|
nm_completion_device_is_up_test (int tries,
|
|
|
|
|
nm_completion_args args)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (args[0]);
|
|
|
|
|
|
|
|
|
|
if (nm_device_is_up (self))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-12 04:49:29 +00:00
|
|
|
gboolean
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_device_bring_up (NMDevice *self, gboolean wait)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-03-12 04:49:29 +00:00
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
if (nm_device_is_up (self))
|
2007-03-12 04:49:29 +00:00
|
|
|
return TRUE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_info ("Bringing up device %s", nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_system_device_set_up_down (self, TRUE);
|
|
|
|
|
nm_device_update_ip4_address (self);
|
|
|
|
|
nm_device_set_address (self);
|
|
|
|
|
|
2007-03-12 04:49:29 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->bring_up) {
|
|
|
|
|
success = NM_DEVICE_GET_CLASS (self)->bring_up (self);
|
|
|
|
|
if (!success)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
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);
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED);
|
2007-03-12 04:49:29 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_device_bring_down (NMDevice *self, gboolean wait)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
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
2007-03-02 09:30:48 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
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));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
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);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_get_system_config_data
|
|
|
|
|
*
|
|
|
|
|
* Return distro-specific system configuration data for this device.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void *
|
|
|
|
|
nm_device_get_system_config_data (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->system_config_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_dispose (GObject *object)
|
|
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
if (self->priv->dispose_has_run) {
|
|
|
|
|
/* If dispose already ran, return. */
|
2005-12-31 08:21:24 +00:00
|
|
|
return;
|
2007-08-26 15:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!self->priv->initialized) {
|
|
|
|
|
/* Don't tear down stuff that might not yet be set up */
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_device_bring_down (self, FALSE);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_system_device_free_system_config (self, self->priv->system_config_data);
|
2007-02-16 11:23:49 +00:00
|
|
|
nm_device_set_ip4_config (self, NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
if (self->priv->act_request)
|
|
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
g_object_unref (self->priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
self->priv->act_request = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
if (self->priv->act_source_id) {
|
|
|
|
|
g_source_remove (self->priv->act_source_id);
|
|
|
|
|
self->priv->act_source_id = 0;
|
2006-12-28 22:13:59 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
nm_device_set_use_dhcp (self, FALSE);
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
out:
|
2007-02-05 12:14:09 +00:00
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_finalize (GObject *object)
|
|
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
g_free (self->priv->udi);
|
|
|
|
|
g_free (self->priv->iface);
|
|
|
|
|
g_free (self->priv->driver);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_UDI:
|
|
|
|
|
/* construct-only */
|
|
|
|
|
priv->udi = g_strdup (g_value_get_string (value));
|
|
|
|
|
break;
|
2007-08-26 15:55:27 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_INDEX:
|
|
|
|
|
priv->index = g_value_get_uint (value);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_DRIVER:
|
|
|
|
|
priv->driver = g_strdup (g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_APP_DATA:
|
|
|
|
|
priv->app_data = g_value_get_pointer (value);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_CAPABILITIES:
|
|
|
|
|
priv->capabilities = g_value_get_uint (value);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS:
|
|
|
|
|
priv->ip4_address = g_value_get_uint (value);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_UDI:
|
|
|
|
|
g_value_set_string (value, priv->udi);
|
|
|
|
|
break;
|
2007-08-26 15:55:27 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_INDEX:
|
|
|
|
|
g_value_set_uint (value, priv->index);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_IFACE:
|
|
|
|
|
g_value_set_string (value, priv->iface);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_DRIVER:
|
|
|
|
|
g_value_set_string (value, priv->driver);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_APP_DATA:
|
|
|
|
|
g_value_set_pointer (value, priv->app_data);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_CAPABILITIES:
|
|
|
|
|
g_value_set_uint (value, priv->capabilities);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS:
|
|
|
|
|
g_value_set_uint (value, priv->ip4_address);
|
|
|
|
|
break;
|
2007-02-16 11:23:49 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_IP4_CONFIG:
|
|
|
|
|
g_value_set_object (value, priv->ip4_config);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_STATE:
|
|
|
|
|
g_value_set_uint (value, priv->state);
|
|
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE:
|
|
|
|
|
g_value_set_uint (value, priv->type);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_class_init (NMDeviceClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (NMDevicePrivate));
|
|
|
|
|
|
|
|
|
|
/* Virtual methods */
|
2005-12-31 08:21:24 +00:00
|
|
|
object_class->dispose = nm_device_dispose;
|
|
|
|
|
object_class->finalize = nm_device_finalize;
|
2007-02-05 12:14:09 +00:00
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->constructor = constructor;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
klass->is_up = real_is_up;
|
2006-03-04 Dan Williams <dcbw@redhat.com>
Clean up activation cancellation. Should be a lot faster now. Observed
an issue with wireless devices between stage 2 and 3 of activation, where
activation would be cancelled, but the device thread wouldn't notice until
the supplicant association timed out. Reorganize activation such that
a cancellation handler gets immediately scheduled in the device's thread,
and devices have a chance to perform any custom cleanup too.
* src/nm-device.[ch]
- (activation_cancel_handler): new device-type-specific function
for cleaning up device-type-specific stuff on cancellation
- (cancel_activation): removed
- (nm_device_activation_cancel): subsume functionality of
real_cancel_activation, but instead of doing anything, punt
operation to a handler that's run in device-thread context
- (nm_device_schedule_activation_handle_cancel): fix spelling of
a warning message
- (activation_handle_cancel_helper): cancellation handler run in
device-thread context, calls device-type-specific cancelation,
then tears down the activation request
- (real_activation_cancel_handler): generic cancellation handler,
deals with cancelling any in-process DHCP request
- (nm_device_activate_stage1_device_prepare,
nm_device_activate_stage2_device_config,
nm_device_activate_stage3_ip_config_start,
nm_device_activate_stage4_ip_config_get,
nm_device_activate_stage4_ip_config_timeout,
nm_device_activate_stage5_ip_commit): don't call
nm_device_schedule_activation_handle_cancel() any more, since
cancellation will have been already scheduled for us by
nm_device_activation_cancel(). Just exit the function and
assume that the cancel handler will be called next.
* src/nm-device-802-3-ethernet.c
- (real_act_stage2_config): remove; didn't do anything anyway
* src/nm-device-802-11-wireless.c
- (supplicant_status_cb): ensure we don't do anything if the activation
got cancelled
- (real_activation_cancel_handler): implement; cancel user key request
on activation cancellation
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1549 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-04 06:44:05 +00:00
|
|
|
klass->activation_cancel_handler = real_activation_cancel_handler;
|
2005-12-31 08:21:24 +00:00
|
|
|
klass->get_type_capabilities = real_get_type_capabilities;
|
2006-01-03 17:07:07 +00:00
|
|
|
klass->get_generic_capabilities = real_get_generic_capabilities;
|
|
|
|
|
klass->act_stage1_prepare = real_act_stage1_prepare;
|
|
|
|
|
klass->act_stage2_config = real_act_stage2_config;
|
2006-01-03 17:47:38 +00:00
|
|
|
klass->act_stage3_ip_config_start = real_act_stage3_ip_config_start;
|
2006-01-03 17:07:07 +00:00
|
|
|
klass->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
|
2006-01-18 02:27:38 +00:00
|
|
|
klass->act_stage4_ip_config_timeout = real_act_stage4_ip_config_timeout;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
/* Properties */
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_UDI,
|
|
|
|
|
NM_DEVICE_INTERFACE_UDI);
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_INDEX,
|
|
|
|
|
NM_DEVICE_INTERFACE_INDEX);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_IFACE,
|
|
|
|
|
NM_DEVICE_INTERFACE_IFACE);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_DRIVER,
|
|
|
|
|
NM_DEVICE_INTERFACE_DRIVER);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_CAPABILITIES,
|
|
|
|
|
NM_DEVICE_INTERFACE_CAPABILITIES);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
|
|
|
|
NM_DEVICE_INTERFACE_IP4_ADDRESS);
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_IP4_CONFIG,
|
|
|
|
|
NM_DEVICE_INTERFACE_IP4_CONFIG);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_STATE,
|
|
|
|
|
NM_DEVICE_INTERFACE_STATE);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_APP_DATA,
|
|
|
|
|
NM_DEVICE_INTERFACE_APP_DATA);
|
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
|
|
|
|
|
NM_DEVICE_INTERFACE_DEVICE_TYPE);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
void
|
|
|
|
|
nm_device_state_changed (NMDevice *device, NMDeviceState state)
|
|
|
|
|
{
|
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
2007-03-02 09:30:48 +00:00
|
|
|
const char *iface;
|
|
|
|
|
NMDeviceState old_state;
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
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
2007-03-02 09:30:48 +00:00
|
|
|
iface = nm_device_get_iface (device);
|
|
|
|
|
old_state = device->priv->state;
|
2007-02-05 12:14:09 +00:00
|
|
|
device->priv->state = state;
|
|
|
|
|
|
2007-06-13 11:58:25 +00:00
|
|
|
g_signal_emit_by_name (device, "state-changed", state);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
switch (state) {
|
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
2007-03-02 09:30:48 +00:00
|
|
|
case NM_DEVICE_STATE_DOWN:
|
|
|
|
|
if (old_state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
case NM_DEVICE_STATE_ACTIVATED:
|
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
2007-03-02 09:30:48 +00:00
|
|
|
nm_info ("Activation (%s) successful, device activated.", iface);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_STATE_FAILED:
|
|
|
|
|
nm_info ("Activation (%s) failed.", nm_device_get_iface (device));
|
2007-02-09 08:50:35 +00:00
|
|
|
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NMDeviceState
|
|
|
|
|
nm_device_get_state (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->state;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|