2007-10-01 15:38:39 +00:00
|
|
|
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
|
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>
|
2008-03-14 20:37:48 +00:00
|
|
|
#include <net/if.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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 "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"
|
2007-08-28 15:00:00 +00:00
|
|
|
#include "nm-named-manager.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "autoip.h"
|
2007-08-26 15:55:27 +00:00
|
|
|
#include "nm-netlink.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-setting-ip4-config.h"
|
2007-12-31 17:05:25 +00:00
|
|
|
#include "nm-setting-connection.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;
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
char * udi;
|
2007-08-26 15:55:27 +00:00
|
|
|
char * iface; /* may change, could be renamed by user */
|
2007-12-06 14:51:43 +00:00
|
|
|
char * ip_iface;
|
2005-12-31 08:21:24 +00:00
|
|
|
NMDeviceType type;
|
|
|
|
|
guint32 capabilities;
|
|
|
|
|
char * driver;
|
|
|
|
|
|
|
|
|
|
guint32 ip4_address;
|
|
|
|
|
struct in6_addr ip6_address;
|
|
|
|
|
|
|
|
|
|
NMActRequest * act_request;
|
2007-01-04 12:06:26 +00:00
|
|
|
guint act_source_id;
|
2007-09-11 18:02:27 +00:00
|
|
|
gulong secrets_updated_id;
|
2007-09-27 04:52:03 +00:00
|
|
|
gulong secrets_failed_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-12-31 17:05:25 +00:00
|
|
|
static gboolean nm_device_check_connection_conflicts (NMDeviceInterface *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMConnection *system_connection);
|
|
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
static gboolean nm_device_activate (NMDeviceInterface *device,
|
2007-12-27 08:06:27 +00:00
|
|
|
NMActRequest *req,
|
|
|
|
|
GError **error);
|
2007-05-07 15:17:45 +00:00
|
|
|
|
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-12-31 17:05:25 +00:00
|
|
|
device_interface_class->check_connection_conflicts = nm_device_check_connection_conflicts;
|
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;
|
|
|
|
|
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->ip4_address = 0;
|
|
|
|
|
memset (&self->priv->ip6_address, 0, sizeof (struct in6_addr));
|
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;
|
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,
|
2007-11-29 14:38:07 +00:00
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
2007-02-05 12:14:09 +00:00
|
|
|
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-11-29 14:38:07 +00:00
|
|
|
if (!priv->udi) {
|
|
|
|
|
nm_warning ("No device udi provided, ignoring");
|
2007-08-26 15:55:27 +00:00
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-29 14:38:07 +00:00
|
|
|
if (!priv->iface) {
|
|
|
|
|
nm_warning ("No device interface provided, ignoring");
|
2007-08-26 15:55:27 +00:00
|
|
|
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)) {
|
2007-11-29 14:38:07 +00:00
|
|
|
nm_warning ("(%s): Device unsupported, ignoring.", priv->iface);
|
2007-08-26 15:55:27 +00:00
|
|
|
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-08-28 15:54:55 +00:00
|
|
|
priv->system_config_data = nm_system_device_get_system_config (dev);
|
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)) {
|
2007-11-29 14:38:07 +00:00
|
|
|
nm_warning ("(%s): Device otherwise managed, ignoring.", priv->iface);
|
2007-08-26 15:55:27 +00:00
|
|
|
goto error;
|
2006-01-19 18:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-02 02:50:47 +00:00
|
|
|
nm_print_device_capabilities (dev);
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
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
|
|
|
{
|
2008-03-13 19:31:08 +00:00
|
|
|
struct ifreq ifr;
|
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;
|
2008-03-13 19:31:08 +00:00
|
|
|
int err, fd;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-13 19:31:08 +00:00
|
|
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
nm_warning ("couldn't open control socket.");
|
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;
|
2008-03-13 19:31:08 +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
|
|
|
/* Get device's flags */
|
2008-03-13 19:31:08 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2008-03-14 20:37:48 +00:00
|
|
|
strncpy (ifr.ifr_name, iface, IFNAMSIZ);
|
2008-03-13 19:31:08 +00:00
|
|
|
err = ioctl (fd, SIOCGIFFLAGS, &ifr);
|
|
|
|
|
close (fd);
|
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 (!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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_udi (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return self->priv->udi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
const char *
|
2007-12-06 14:51:43 +00:00
|
|
|
nm_device_get_ip_iface (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* If it's not set, default to iface */
|
|
|
|
|
return self->priv->ip_iface ? self->priv->ip_iface : self->priv->iface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
g_free (self->priv->ip_iface);
|
|
|
|
|
self->priv->ip_iface = iface ? g_strdup (iface) : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* 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_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_can_activate (NMDevice *self, gboolean wireless_enabled)
|
|
|
|
|
{
|
|
|
|
|
if (!NM_DEVICE_GET_CLASS (self)->can_activate)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->can_activate (self, wireless_enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-09 17:58:44 +00:00
|
|
|
NMConnection *
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
nm_device_get_best_auto_connection (NMDevice *dev,
|
|
|
|
|
GSList *connections,
|
|
|
|
|
char **specific_object)
|
2007-09-09 17:58:44 +00:00
|
|
|
{
|
|
|
|
|
guint32 caps;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (dev), NULL);
|
2007-09-10 19:11:40 +00:00
|
|
|
g_return_val_if_fail (specific_object != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (*specific_object == NULL, NULL);
|
2007-09-09 17:58:44 +00:00
|
|
|
|
|
|
|
|
caps = nm_device_get_capabilities (dev);
|
|
|
|
|
/* Don't use devices that SUCK */
|
|
|
|
|
if (!(caps & NM_DEVICE_CAP_NM_SUPPORTED))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
if (!NM_DEVICE_GET_CLASS (dev)->get_best_auto_connection)
|
2007-09-09 17:58:44 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
return NM_DEVICE_GET_CLASS (dev)->get_best_auto_connection (dev, connections, specific_object);
|
2007-09-09 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
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-10-16 15:18:01 +00:00
|
|
|
setting = (NMSettingIP4Config *) nm_connection_get_setting (nm_act_request_get_connection (req),
|
2007-11-07 16:06:43 +00:00
|
|
|
NM_TYPE_SETTING_IP4_CONFIG);
|
2007-06-06 13:33:51 +00:00
|
|
|
|
|
|
|
|
/* If we did not receive IP4 configuration information, default to DHCP */
|
2008-03-13 03:11:02 +00:00
|
|
|
if (!setting || !strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_DHCP)) {
|
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
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
/* Begin a DHCP transaction on the interface */
|
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);
|
|
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
// FIXME: make our autoip implementation not suck; use avahi-autoip
|
|
|
|
|
if (get_autoip (self, &ip)) {
|
2005-12-31 08:21:24 +00:00
|
|
|
#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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-22 15:45:39 +00:00
|
|
|
static void
|
|
|
|
|
merge_ip4_config (NMIP4Config *ip4_config, NMSettingIP4Config *setting)
|
|
|
|
|
{
|
|
|
|
|
if (!setting)
|
|
|
|
|
return; /* Defaults are just fine */
|
|
|
|
|
|
|
|
|
|
if (setting->dns) {
|
2008-03-13 03:52:50 +00:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < setting->dns->len; i++) {
|
|
|
|
|
guint32 ns;
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Avoid dupes */
|
|
|
|
|
ns = g_array_index (setting->dns, guint32, i);
|
|
|
|
|
for (j = 0; j < nm_ip4_config_get_num_nameservers (ip4_config); j++) {
|
|
|
|
|
if (nm_ip4_config_get_nameserver (ip4_config, j) == ns) {
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
nm_ip4_config_add_nameserver (ip4_config, ns);
|
|
|
|
|
}
|
2007-10-22 15:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (setting->dns_search) {
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
2008-03-13 03:52:50 +00:00
|
|
|
for (iter = setting->dns_search; iter; iter = iter->next) {
|
|
|
|
|
int i;
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Avoid dupes */
|
|
|
|
|
for (i = 0; i < nm_ip4_config_get_num_searches (ip4_config); i++) {
|
|
|
|
|
const char *search = nm_ip4_config_get_search (ip4_config, i);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (search, (char *) iter->data)) {
|
|
|
|
|
found = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
nm_ip4_config_add_search (ip4_config, (char *) iter->data);
|
|
|
|
|
}
|
2007-10-22 15:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (setting->addresses) {
|
|
|
|
|
/* FIXME; add support for more than one set of address/netmask/gateway for NMIP4Config */
|
2008-03-13 03:11:02 +00:00
|
|
|
NMSettingIP4Address *addr = (NMSettingIP4Address *) setting->addresses->data;
|
2007-10-22 15:45:39 +00:00
|
|
|
|
2008-03-13 03:52:50 +00:00
|
|
|
/* Avoid dupes, but override if anything is different */
|
|
|
|
|
if ( (nm_ip4_config_get_address (ip4_config) != addr->address)
|
|
|
|
|
|| (nm_ip4_config_get_netmask (ip4_config) != addr->netmask)
|
|
|
|
|
|| (addr->gateway && (nm_ip4_config_get_gateway (ip4_config) != addr->gateway))) {
|
|
|
|
|
nm_ip4_config_set_address (ip4_config, addr->address);
|
|
|
|
|
nm_ip4_config_set_netmask (ip4_config, addr->netmask);
|
2007-10-22 15:45:39 +00:00
|
|
|
|
2008-03-13 03:52:50 +00:00
|
|
|
if (addr->gateway)
|
|
|
|
|
nm_ip4_config_set_gateway (ip4_config, addr->gateway);
|
|
|
|
|
}
|
2007-10-22 15:45:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_get_ip4_config (NMDevice *self,
|
|
|
|
|
NMIP4Config **config)
|
|
|
|
|
{
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
NMConnection *connection;
|
2008-03-13 03:11:02 +00:00
|
|
|
NMSettingIP4Config *s_ip4;
|
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);
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
2008-03-13 03:11:02 +00:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
2007-02-05 09:50:11 +00:00
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
if (nm_device_get_use_dhcp (self)) {
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
*config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
merge_ip4_config (*config, s_ip4);
|
2007-06-06 13:33:51 +00:00
|
|
|
} else {
|
2008-03-13 03:11:02 +00:00
|
|
|
g_assert (s_ip4);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_AUTOIP)) {
|
|
|
|
|
nm_device_new_ip4_autoip_config (self);
|
|
|
|
|
} else if (!strcmp (s_ip4->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
|
|
|
|
|
*config = nm_ip4_config_new ();
|
|
|
|
|
merge_ip4_config (*config, s_ip4);
|
|
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
if (!*config) {
|
|
|
|
|
/* Make sure device is up even if config fails */
|
|
|
|
|
nm_device_bring_up (self, FALSE);
|
|
|
|
|
} else
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
|
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);
|
|
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
/* DHCP failed; connection must fail */
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-12 16:12:39 +00:00
|
|
|
if (nm_device_set_ip4_config (self, ip4_config))
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED);
|
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-12 16:12:39 +00:00
|
|
|
else
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
static void
|
|
|
|
|
clear_act_request (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate * priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2007-09-11 19:20:34 +00:00
|
|
|
if (!priv->act_request)
|
2007-09-11 18:02:27 +00:00
|
|
|
return;
|
|
|
|
|
|
2007-09-14 19:51:04 +00:00
|
|
|
if (priv->secrets_updated_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->act_request,
|
|
|
|
|
priv->secrets_updated_id);
|
|
|
|
|
priv->secrets_updated_id = 0;
|
|
|
|
|
}
|
2007-09-11 18:02:27 +00:00
|
|
|
|
2007-09-27 04:52:03 +00:00
|
|
|
if (priv->secrets_failed_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->act_request,
|
|
|
|
|
priv->secrets_failed_id);
|
|
|
|
|
priv->secrets_failed_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
g_object_unref (priv->act_request);
|
|
|
|
|
priv->act_request = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
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-09-11 18:02:27 +00:00
|
|
|
clear_act_request (self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
/* Stop any ongoing DHCP transaction on this device */
|
|
|
|
|
if (nm_device_get_act_request (self) && nm_device_get_use_dhcp (self)) {
|
|
|
|
|
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/* Tear down an existing activation request, which may not have happened
|
|
|
|
|
* in nm_device_activation_cancel() above, for various reasons.
|
|
|
|
|
*/
|
2007-09-11 18:02:27 +00:00
|
|
|
clear_act_request (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
|
2008-03-11 22:26:46 +00:00
|
|
|
/* Clean up nameservers and addresses */
|
|
|
|
|
nm_device_set_ip4_config (self, NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
/* 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-12-31 17:05:25 +00:00
|
|
|
static gboolean
|
2008-01-18 03:00:12 +00:00
|
|
|
nm_device_check_connection_conflicts (NMDeviceInterface *dev_iface,
|
2007-12-31 17:05:25 +00:00
|
|
|
NMConnection *connection,
|
|
|
|
|
NMConnection *system_connection)
|
|
|
|
|
{
|
2008-01-18 03:00:12 +00:00
|
|
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (NM_DEVICE (dev_iface));
|
2007-12-31 17:05:25 +00:00
|
|
|
|
|
|
|
|
if (klass->check_connection_conflicts)
|
2008-01-18 03:00:12 +00:00
|
|
|
return klass->check_connection_conflicts (NM_DEVICE (dev_iface), connection, system_connection);
|
2007-12-31 17:05:25 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
static void
|
|
|
|
|
connection_secrets_updated_cb (NMActRequest *req,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->connection_secrets_updated)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->connection_secrets_updated (self, connection, setting_name);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-27 04:52:03 +00:00
|
|
|
static void
|
|
|
|
|
connection_secrets_failed_cb (NMActRequest *req,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *setting_name,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
2007-10-08 18:07:36 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
|
2007-09-27 04:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-14 19:51:04 +00:00
|
|
|
static gboolean
|
2007-12-27 08:06:27 +00:00
|
|
|
device_activation_precheck (NMDevice *self, NMConnection *connection, GError **error)
|
2007-09-14 19:51:04 +00:00
|
|
|
{
|
|
|
|
|
NMConnection *current_connection;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
2007-05-07 15:17:45 +00:00
|
|
|
|
2007-09-14 19:51:04 +00:00
|
|
|
if (nm_device_get_state (self) != NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
return TRUE;
|
2007-06-22 15:09:02 +00:00
|
|
|
|
2007-09-14 19:51:04 +00:00
|
|
|
if (!nm_device_is_activating (self))
|
|
|
|
|
return TRUE;
|
2007-06-22 15:09:02 +00:00
|
|
|
|
2008-02-21 04:34:34 +00:00
|
|
|
// FIXME: why not just check connection path & service?
|
2007-09-14 19:51:04 +00:00
|
|
|
current_connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
2008-02-21 04:34:34 +00:00
|
|
|
if (nm_connection_compare (connection, current_connection, COMPARE_FLAGS_EXACT)) {
|
2007-09-14 19:51:04 +00:00
|
|
|
/* Already activating or activated with the same connection */
|
2007-12-27 08:06:27 +00:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_DEVICE_INTERFACE_ERROR,
|
|
|
|
|
NM_DEVICE_INTERFACE_ERROR_CONNECTION_ACTIVATING,
|
|
|
|
|
"%s", "Connection is already activating");
|
2007-09-14 19:51:04 +00:00
|
|
|
return FALSE;
|
2007-12-27 08:06:27 +00:00
|
|
|
}
|
2007-06-22 15:09:02 +00:00
|
|
|
|
2007-09-14 19:51:04 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2007-06-22 15:09:02 +00:00
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_activate (NMDeviceInterface *device,
|
2007-12-27 08:06:27 +00:00
|
|
|
NMActRequest *req,
|
|
|
|
|
GError **error)
|
2007-09-14 19:51:04 +00:00
|
|
|
{
|
2007-10-01 15:38:39 +00:00
|
|
|
NMDevice *self = NM_DEVICE (device);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2007-09-14 19:51:04 +00:00
|
|
|
|
2007-12-27 08:06:27 +00:00
|
|
|
if (!device_activation_precheck (self, nm_act_request_get_connection (req), error)) {
|
|
|
|
|
g_assert (*error);
|
2007-10-01 15:38:39 +00:00
|
|
|
return FALSE;
|
2007-12-27 08:06:27 +00:00
|
|
|
}
|
2007-10-01 15:38:39 +00:00
|
|
|
|
|
|
|
|
priv->act_request = g_object_ref (req);
|
|
|
|
|
priv->secrets_updated_id = g_signal_connect (req,
|
|
|
|
|
"connection-secrets-updated",
|
|
|
|
|
G_CALLBACK (connection_secrets_updated_cb),
|
|
|
|
|
device);
|
|
|
|
|
priv->secrets_failed_id = g_signal_connect (req,
|
|
|
|
|
"connection-secrets-failed",
|
|
|
|
|
G_CALLBACK (connection_secrets_failed_cb),
|
|
|
|
|
device);
|
2007-09-27 04:52:03 +00:00
|
|
|
|
2007-09-25 19:35:26 +00:00
|
|
|
/* HACK: update the state a bit early to avoid a race between the
|
|
|
|
|
* scheduled stage1 handler and nm_policy_device_change_check() thinking
|
|
|
|
|
* that the activation request isn't deferred because the deferred bit
|
|
|
|
|
* gets cleared a bit too early, when the connection becomes valid.
|
|
|
|
|
*/
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE);
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage1_device_prepare (self);
|
2007-09-14 19:51:04 +00:00
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
return TRUE;
|
2007-09-14 19:51:04 +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-09-21 03:49:28 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
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-09-21 03:49:28 +00:00
|
|
|
/* There's a small race between the time when stage 1 is scheduled
|
|
|
|
|
* and when the device actually sets STATE_PREPARE when the activation
|
|
|
|
|
* handler is actually run. If there's an activation handler scheduled
|
|
|
|
|
* we're activating anyway.
|
|
|
|
|
*/
|
|
|
|
|
if (priv->act_source_id)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
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 */
|
|
|
|
|
|
2008-03-11 02:46:35 +00:00
|
|
|
static void
|
|
|
|
|
handle_dhcp_lease_change (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMIP4Config *config;
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
|
|
|
|
|
if (!nm_device_get_use_dhcp (device)) {
|
|
|
|
|
nm_warning ("got DHCP rebind for device that wasn't using DHCP.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (device)->dhcp_manager,
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
if (!config) {
|
|
|
|
|
nm_warning ("failed to get DHCP config for rebind");
|
|
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (device);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
|
|
|
|
|
merge_ip4_config (config, s_ip4);
|
|
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
|
|
|
|
|
|
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-12 16:12:39 +00:00
|
|
|
if (!nm_device_set_ip4_config (device, config)) {
|
2008-03-11 02:46:35 +00:00
|
|
|
nm_warning ("Failed to update IP4 config in response to DHCP event.");
|
2008-03-11 22:26:46 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
|
2008-03-11 02:46:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
static void
|
|
|
|
|
dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
|
|
|
|
const char *iface,
|
|
|
|
|
NMDHCPState state,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2008-03-11 02:46:35 +00:00
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
NMDeviceState dev_state;
|
2007-08-12 22:41:16 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2008-03-11 02:46:35 +00:00
|
|
|
dev_state = nm_device_get_state (device);
|
|
|
|
|
|
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 */
|
2008-03-11 02:46:35 +00:00
|
|
|
if (dev_state == NM_DEVICE_STATE_IP_CONFIG)
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage4_ip_config_get (device);
|
2008-03-11 02:46:35 +00:00
|
|
|
else if (dev_state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
handle_dhcp_lease_change (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 */
|
2008-03-11 02:46:35 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
|
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);
|
|
|
|
|
|
2008-03-11 22:26:46 +00:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_config;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
gboolean
|
2005-12-31 08:21:24 +00:00
|
|
|
nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config)
|
|
|
|
|
{
|
2007-12-06 14:51:43 +00:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
gboolean route_to_iface;
|
|
|
|
|
gboolean success;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2007-02-16 11:23:49 +00:00
|
|
|
|
|
|
|
|
if (priv->ip4_config) {
|
2008-03-11 02:46:35 +00:00
|
|
|
NMNamedManager *named_mgr;
|
|
|
|
|
|
|
|
|
|
/* Remove any previous IP4 Config from the named manager */
|
|
|
|
|
named_mgr = nm_named_manager_get ();
|
|
|
|
|
nm_named_manager_remove_ip4_config (named_mgr, priv->ip4_config);
|
|
|
|
|
g_object_unref (named_mgr);
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
g_object_unref (priv->ip4_config);
|
|
|
|
|
priv->ip4_config = NULL;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-12 17:08:59 +00:00
|
|
|
if (!config)
|
2007-12-06 14:51:43 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
priv->ip4_config = g_object_ref (config);
|
|
|
|
|
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
|
|
|
|
/* FIXME: Not sure if the following makes any sense. */
|
|
|
|
|
/* If iface and ip_iface are the same, it's a regular network device and we
|
|
|
|
|
treat it as such. However, if they differ, it's most likely something like
|
|
|
|
|
a serial device with ppp interface, so route all the traffic to it. */
|
|
|
|
|
if (strcmp (ip_iface, nm_device_get_iface (self)))
|
|
|
|
|
route_to_iface = TRUE;
|
|
|
|
|
else
|
|
|
|
|
route_to_iface = FALSE;
|
|
|
|
|
|
|
|
|
|
success = nm_system_device_set_from_ip4_config (ip_iface, config, route_to_iface);
|
|
|
|
|
if (success) {
|
|
|
|
|
nm_device_update_ip4_address (self);
|
|
|
|
|
nm_system_device_add_ip6_link_address (self);
|
|
|
|
|
nm_system_set_hostname (config);
|
|
|
|
|
nm_system_activate_nis (config);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-11 22:26:46 +00:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_IP4_CONFIG);
|
|
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
return success;
|
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)
|
|
|
|
|
{
|
2008-03-13 19:31:08 +00:00
|
|
|
struct ifreq req;
|
|
|
|
|
guint32 new_address;
|
|
|
|
|
int fd, err;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
2008-03-13 19:31:08 +00:00
|
|
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
nm_warning ("couldn't open control socket.");
|
2005-12-31 08:21:24 +00:00
|
|
|
return;
|
2008-03-13 19:31:08 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
memset (&req, 0, sizeof (struct ifreq));
|
2008-03-14 20:37:48 +00:00
|
|
|
strncpy (req.ifr_name, nm_device_get_iface (self), IFNAMSIZ);
|
2008-03-13 19:31:08 +00:00
|
|
|
err = ioctl (fd, SIOCGIFADDR, &req);
|
|
|
|
|
close (fd);
|
2008-03-14 20:37:48 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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;
|
2008-03-13 19:31:08 +00:00
|
|
|
guint32 tries = 0;
|
2007-03-12 04:49:29 +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_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
|
|
|
|
2008-03-13 19:31:08 +00:00
|
|
|
/* Wait for the device to come up if requested */
|
|
|
|
|
while (wait && !nm_device_is_up (self) && (tries++ < 50))
|
|
|
|
|
g_usleep (200);
|
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
|
|
|
{
|
2008-03-10 19:33:36 +00:00
|
|
|
NMDeviceState state;
|
2008-03-13 19:31:08 +00:00
|
|
|
guint32 tries = 0;
|
2008-03-10 19:33:36 +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));
|
|
|
|
|
|
2008-03-10 19:33:36 +00:00
|
|
|
state = nm_device_get_state (self);
|
|
|
|
|
if ((state == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (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_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);
|
|
|
|
|
|
2008-03-13 19:31:08 +00:00
|
|
|
/* Wait for the device to come up if requested */
|
|
|
|
|
while (wait && nm_device_is_up (self) && (tries++ < 50))
|
|
|
|
|
g_usleep (200);
|
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_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-12-07 15:32:45 +00:00
|
|
|
if (self->priv->dispose_has_run || !self->priv->initialized)
|
2007-08-26 15:55:27 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
clear_act_request (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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);
|
2007-12-06 14:51:43 +00:00
|
|
|
g_free (self->priv->ip_iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
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-11-29 14:38:07 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_IFACE:
|
|
|
|
|
g_free (priv->iface);
|
|
|
|
|
priv->iface = g_value_dup_string (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_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);
|
2008-03-11 22:26:46 +00:00
|
|
|
NMDeviceState state;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case NM_DEVICE_INTERFACE_PROP_UDI:
|
|
|
|
|
g_value_set_string (value, priv->udi);
|
|
|
|
|
break;
|
|
|
|
|
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_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:
|
2008-03-11 22:26:46 +00:00
|
|
|
state = nm_device_get_state (NM_DEVICE (object));
|
|
|
|
|
if ( (state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
|| (state == NM_DEVICE_STATE_IP_CONFIG))
|
|
|
|
|
g_value_set_object (value, priv->ip4_config);
|
|
|
|
|
else
|
|
|
|
|
g_value_set_object (value, NULL);
|
2007-02-16 11:23:49 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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_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
|
|
|
}
|