2008-07-09 14:05:49 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2005-12-31 08:21:24 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* 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.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2010-01-08 17:16:05 -08:00
|
|
|
* Copyright (C) 2005 - 2010 Red Hat, Inc.
|
2008-11-03 04:13:42 +00:00
|
|
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
2005-12-31 08:21:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#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>
|
2008-07-09 14:05:49 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
#include <arpa/inet.h>
|
2008-08-15 15:34:28 +00:00
|
|
|
#include <fcntl.h>
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-12-31 18:57:36 -05:00
|
|
|
#include "nm-glib-compat.h"
|
2007-02-05 12:14:09 +00:00
|
|
|
#include "nm-device-interface.h"
|
2007-05-07 15:17:45 +00:00
|
|
|
#include "nm-device.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device-private.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
2010-03-02 15:06:14 -08:00
|
|
|
#include "nm-system.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#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"
|
2010-04-07 12:31:39 -07:00
|
|
|
#include "nm-logging.h"
|
2010-04-20 17:22:58 -07:00
|
|
|
#include "nm-netlink-monitor.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-setting-ip4-config.h"
|
2009-07-29 12:12:41 -04:00
|
|
|
#include "nm-setting-ip6-config.h"
|
2007-12-31 17:05:25 +00:00
|
|
|
#include "nm-setting-connection.h"
|
2008-05-29 20:58:52 +00:00
|
|
|
#include "nm-dnsmasq-manager.h"
|
2008-07-17 17:04:13 +00:00
|
|
|
#include "nm-dhcp4-config.h"
|
2009-07-30 13:50:42 -04:00
|
|
|
#include "nm-ip6-manager.h"
|
2009-07-15 17:22:10 -04:00
|
|
|
#include "nm-marshal.h"
|
2010-03-25 11:36:19 -07:00
|
|
|
#include "nm-rfkill.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"
|
2009-07-29 12:12:41 -04:00
|
|
|
#define NM_ACT_REQUEST_IP6_CONFIG "nm-act-request-ip6-config"
|
2007-06-11 13:36:34 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void device_interface_init (NMDeviceInterface *device_interface_class);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
G_DEFINE_TYPE_EXTENDED (NMDevice, nm_device, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_DEVICE_INTERFACE, device_interface_init))
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
enum {
|
|
|
|
|
AUTOCONNECT_ALLOWED,
|
|
|
|
|
LAST_SIGNAL,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
typedef struct {
|
|
|
|
|
gboolean disposed;
|
|
|
|
|
gboolean initialized;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDeviceState state;
|
2008-04-17 23:04:34 +00:00
|
|
|
guint failed_to_disconnected_id;
|
2009-09-14 13:24:29 -07:00
|
|
|
guint unavailable_to_disconnected_id;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
char * udi;
|
|
|
|
|
char * path;
|
|
|
|
|
char * iface; /* may change, could be renamed by user */
|
2010-04-21 14:58:25 -07:00
|
|
|
int ifindex;
|
2009-07-07 14:34:01 -04:00
|
|
|
char * ip_iface;
|
2010-04-21 14:58:25 -07:00
|
|
|
int ip_ifindex;
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDeviceType type;
|
|
|
|
|
char * type_desc;
|
|
|
|
|
guint32 capabilities;
|
|
|
|
|
char * driver;
|
|
|
|
|
gboolean managed; /* whether managed by NM or not */
|
2010-03-25 11:36:19 -07:00
|
|
|
RfKillType rfkill_type;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
guint32 ip4_address;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
NMActRequest * act_request;
|
2007-01-04 12:06:26 +00:00
|
|
|
guint act_source_id;
|
2009-07-07 14:34:01 -04:00
|
|
|
gpointer act_source_func;
|
2009-07-29 12:12:41 -04:00
|
|
|
guint act_source6_id;
|
|
|
|
|
gpointer act_source6_func;
|
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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
gboolean ip4_ready;
|
|
|
|
|
gboolean ip6_ready;
|
|
|
|
|
|
2010-01-13 18:06:05 -08:00
|
|
|
/* Generic DHCP stuff */
|
2010-01-13 17:59:54 -08:00
|
|
|
NMDHCPManager * dhcp_manager;
|
2010-01-13 18:06:05 -08:00
|
|
|
guint32 dhcp_timeout;
|
|
|
|
|
GByteArray * dhcp_anycast_address;
|
2010-01-13 17:59:54 -08:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
/* IP4 configuration info */
|
2009-07-07 14:34:01 -04:00
|
|
|
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
|
2010-01-12 22:09:28 -08:00
|
|
|
NMDHCPClient * dhcp4_client;
|
2010-01-13 18:06:05 -08:00
|
|
|
gulong dhcp4_state_sigid;
|
|
|
|
|
gulong dhcp4_timeout_sigid;
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDHCP4Config * dhcp4_config;
|
2008-05-29 20:58:52 +00:00
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
/* dnsmasq stuff for shared connections */
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDnsMasqManager *dnsmasq_manager;
|
|
|
|
|
gulong dnsmasq_state_id;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
/* avahi-autoipd stuff */
|
2009-07-07 14:34:01 -04:00
|
|
|
GPid aipd_pid;
|
|
|
|
|
guint aipd_watch;
|
|
|
|
|
guint aipd_timeout;
|
|
|
|
|
guint32 aipd_addr;
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
/* IP6 configuration info */
|
2009-07-30 13:50:42 -04:00
|
|
|
NMIP6Config * ip6_config;
|
|
|
|
|
NMIP6Manager * ip6_manager;
|
|
|
|
|
gulong ip6_addrconf_sigid;
|
|
|
|
|
gulong ip6_config_changed_sigid;
|
|
|
|
|
gboolean ip6_waiting_for_config;
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
NMDHCPClient * dhcp6_client;
|
2010-05-01 10:16:38 -07:00
|
|
|
guint32 dhcp6_mode;
|
2010-01-14 00:45:10 -08:00
|
|
|
gulong dhcp6_state_sigid;
|
|
|
|
|
gulong dhcp6_timeout_sigid;
|
|
|
|
|
NMDHCP6Config * dhcp6_config;
|
|
|
|
|
|
2009-09-16 13:18:24 +02:00
|
|
|
/* inhibit autoconnect feature */
|
|
|
|
|
gboolean autoconnect_inhibit;
|
2009-07-07 14:34:01 -04:00
|
|
|
} NMDevicePrivate;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-04-02 17:44:52 +00:00
|
|
|
static gboolean check_connection_compatible (NMDeviceInterface *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error);
|
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);
|
2009-06-11 00:39:12 -04:00
|
|
|
static void nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason);
|
2009-09-16 13:18:24 +02:00
|
|
|
static gboolean device_disconnect (NMDeviceInterface *device, GError **error);
|
2009-08-03 17:15:03 -04:00
|
|
|
static gboolean spec_match_list (NMDeviceInterface *device, const GSList *specs);
|
|
|
|
|
static NMConnection *connection_match_config (NMDeviceInterface *device, const GSList *connections);
|
2007-05-07 15:17:45 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self, int family);
|
2008-10-11 19:57:45 +00:00
|
|
|
|
|
|
|
|
static void nm_device_take_down (NMDevice *dev, gboolean wait, NMDeviceStateReason reason);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
static gboolean nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
static gboolean nm_device_is_up (NMDevice *self);
|
|
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
static gboolean nm_device_set_ip4_config (NMDevice *dev,
|
|
|
|
|
NMIP4Config *config,
|
|
|
|
|
gboolean assumed,
|
|
|
|
|
NMDeviceStateReason *reason);
|
|
|
|
|
static gboolean nm_device_set_ip6_config (NMDevice *dev,
|
|
|
|
|
NMIP6Config *config,
|
|
|
|
|
gboolean assumed,
|
|
|
|
|
NMDeviceStateReason *reason);
|
2008-11-07 13:57:39 +00:00
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
static NMActStageReturn dhcp6_start (NMDevice *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
guint32 dhcp_opt,
|
|
|
|
|
NMDeviceStateReason *reason);
|
|
|
|
|
|
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 */
|
2008-04-02 17:44:52 +00:00
|
|
|
device_interface_class->check_connection_compatible = check_connection_compatible;
|
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;
|
2009-09-16 13:18:24 +02:00
|
|
|
device_interface_class->disconnect = device_disconnect;
|
2009-08-03 17:15:03 -04:00
|
|
|
device_interface_class->spec_match_list = spec_match_list;
|
|
|
|
|
device_interface_class->connection_match_config = connection_match_config;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
static void
|
2009-07-07 14:34:01 -04:00
|
|
|
nm_device_init (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->type = NM_DEVICE_TYPE_UNKNOWN;
|
|
|
|
|
priv->capabilities = NM_DEVICE_CAP_NONE;
|
|
|
|
|
priv->state = NM_DEVICE_STATE_UNMANAGED;
|
2009-07-15 13:48:28 -04:00
|
|
|
priv->dhcp_timeout = 0;
|
2010-03-25 11:36:19 -07:00
|
|
|
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
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) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_DEVICE, "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) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_DEVICE, "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)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DEVICE, "(%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
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
if (NM_DEVICE_GET_CLASS (dev)->update_hw_address)
|
|
|
|
|
NM_DEVICE_GET_CLASS (dev)->update_hw_address (dev);
|
2006-01-02 02:50:47 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
priv->dhcp_manager = nm_dhcp_manager_get ();
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_hw_is_up (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->hw_is_up)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->hw_is_up (self);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
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 guint32
|
|
|
|
|
real_get_generic_capabilities (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
void
|
|
|
|
|
nm_device_set_path (NMDevice *self, const char *path)
|
|
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->path == NULL);
|
|
|
|
|
|
|
|
|
|
priv->path = g_strdup (path);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_path (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->path;
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_udi (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->udi;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for iface
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_iface (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->iface;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
int
|
|
|
|
|
nm_device_get_ifindex (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ifindex;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2007-12-06 14:51:43 +00:00
|
|
|
/* If it's not set, default to iface */
|
2009-07-07 14:34:01 -04:00
|
|
|
return priv->ip_iface ? priv->ip_iface : priv->iface;
|
2007-12-06 14:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
int
|
|
|
|
|
nm_device_get_ip_ifindex (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, 0);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
/* If it's not set, default to iface */
|
|
|
|
|
return priv->ip_iface ? priv->ip_ifindex : priv->ifindex;
|
|
|
|
|
}
|
2007-12-06 14:51:43 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
|
|
|
|
{
|
2010-04-21 14:58:25 -07:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_free (priv->ip_iface);
|
|
|
|
|
priv->ip_ifindex = 0;
|
|
|
|
|
|
|
|
|
|
priv->ip_iface = g_strdup (iface);
|
|
|
|
|
if (priv->ip_iface) {
|
|
|
|
|
priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface);
|
|
|
|
|
if (!priv->ip_ifindex) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", iface);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-12-06 14:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->driver;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for type
|
|
|
|
|
*/
|
|
|
|
|
NMDeviceType
|
|
|
|
|
nm_device_get_device_type (NMDevice *self)
|
|
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->type;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-09-30 15:04:10 +00:00
|
|
|
int
|
|
|
|
|
nm_device_get_priority (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (dev), -1);
|
|
|
|
|
|
|
|
|
|
return (int) nm_device_get_device_type (dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->capabilities;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-07-07 14:24:12 -04:00
|
|
|
const char *
|
|
|
|
|
nm_device_get_type_desc (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->type_desc;
|
2009-07-07 14:24:12 -04:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* 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);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->act_request;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
2009-09-14 13:33:06 -07:00
|
|
|
nm_device_is_available (NMDevice *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
|
|
|
{
|
2009-09-14 13:33:06 -07:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->is_available)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->is_available (self);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
return TRUE;
|
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
|
|
|
}
|
|
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
static gboolean
|
|
|
|
|
autoconnect_allowed_accumulator (GSignalInvocationHint *ihint,
|
|
|
|
|
GValue *return_accu,
|
|
|
|
|
const GValue *handler_return, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
if (!g_value_get_boolean (handler_return))
|
|
|
|
|
g_value_set_boolean (return_accu, FALSE);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_autoconnect_allowed (NMDevice *self)
|
|
|
|
|
{
|
2009-09-16 13:18:24 +02:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-15 17:22:10 -04:00
|
|
|
GValue instance = { 0, };
|
|
|
|
|
GValue retval = { 0, };
|
|
|
|
|
|
|
|
|
|
g_value_init (&instance, G_TYPE_OBJECT);
|
|
|
|
|
g_value_take_object (&instance, self);
|
|
|
|
|
|
|
|
|
|
g_value_init (&retval, G_TYPE_BOOLEAN);
|
2009-09-16 13:18:24 +02:00
|
|
|
if (priv->autoconnect_inhibit)
|
|
|
|
|
g_value_set_boolean (&retval, FALSE);
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boolean (&retval, TRUE);
|
2009-07-15 17:22:10 -04:00
|
|
|
|
|
|
|
|
/* Use g_signal_emitv() rather than g_signal_emit() to avoid the return
|
|
|
|
|
* value being changed if no handlers are connected */
|
|
|
|
|
g_signal_emitv (&instance, signals[AUTOCONNECT_ALLOWED], 0, &retval);
|
|
|
|
|
return g_value_get_boolean (&retval);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
static void
|
|
|
|
|
dnsmasq_state_changed_cb (NMDnsMasqManager *manager, guint32 status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
|
case NM_DNSMASQ_STATUS_DEAD:
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
|
2008-05-29 20:58:52 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-23 17:36:52 -04:00
|
|
|
static void
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (NMDevice *self, gboolean remove_source, int family)
|
2009-03-23 17:36:52 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
guint *act_source_id;
|
|
|
|
|
gpointer *act_source_func;
|
|
|
|
|
|
|
|
|
|
if (family == AF_INET6) {
|
|
|
|
|
act_source_id = &priv->act_source6_id;
|
|
|
|
|
act_source_func = &priv->act_source6_func;
|
|
|
|
|
} else {
|
|
|
|
|
act_source_id = &priv->act_source_id;
|
|
|
|
|
act_source_func = &priv->act_source_func;
|
|
|
|
|
}
|
2009-03-23 17:36:52 -04:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (*act_source_id) {
|
2009-03-23 17:36:52 -04:00
|
|
|
if (remove_source)
|
2009-07-29 12:12:41 -04:00
|
|
|
g_source_remove (*act_source_id);
|
|
|
|
|
*act_source_id = 0;
|
|
|
|
|
*act_source_func = NULL;
|
2009-03-23 17:36:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (NMDevice *self, GSourceFunc func, int family)
|
2009-03-23 17:36:52 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
guint *act_source_id;
|
|
|
|
|
gpointer *act_source_func;
|
2009-03-23 17:36:52 -04:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (family == AF_INET6) {
|
|
|
|
|
act_source_id = &priv->act_source6_id;
|
|
|
|
|
act_source_func = &priv->act_source6_func;
|
|
|
|
|
} else {
|
|
|
|
|
act_source_id = &priv->act_source_id;
|
|
|
|
|
act_source_func = &priv->act_source_func;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
if (*act_source_id) {
|
|
|
|
|
nm_log_err (LOGD_DEVICE, "activation stage already scheduled");
|
|
|
|
|
}
|
2009-03-23 17:36:52 -04:00
|
|
|
|
|
|
|
|
/* Don't bother rescheduling the same function that's about to
|
|
|
|
|
* run anyway. Fixes issues with crappy wireless drivers sending
|
|
|
|
|
* streams of associate events before NM has had a chance to process
|
|
|
|
|
* the first one.
|
|
|
|
|
*/
|
2009-07-29 12:12:41 -04:00
|
|
|
if (!*act_source_id || (*act_source_func != func)) {
|
|
|
|
|
activation_source_clear (self, TRUE, family);
|
|
|
|
|
*act_source_id = g_idle_add (func, self);
|
|
|
|
|
*act_source_func = func;
|
2009-03-23 17:36:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static void
|
2009-07-30 13:50:42 -04:00
|
|
|
ip6_addrconf_complete (NMIP6Manager *ip6_manager,
|
2010-04-21 14:58:25 -07:00
|
|
|
int ifindex,
|
2010-01-14 22:57:51 -08:00
|
|
|
guint dhcp_opts,
|
|
|
|
|
gboolean success,
|
|
|
|
|
gpointer user_data)
|
2009-07-29 12:12:41 -04:00
|
|
|
{
|
2009-07-30 13:50:42 -04:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-01-27 16:20:09 -08:00
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
NMDeviceState state;
|
2009-07-30 13:50:42 -04:00
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
if (ifindex != nm_device_get_ip_ifindex (self))
|
2009-07-30 13:50:42 -04:00
|
|
|
return;
|
2010-01-27 16:20:09 -08:00
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
if (!req)
|
2009-07-30 13:50:42 -04:00
|
|
|
return;
|
2010-01-27 16:20:09 -08:00
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
2009-07-30 13:50:42 -04:00
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
if (!priv->ip6_waiting_for_config)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->ip6_waiting_for_config = FALSE;
|
|
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_timeout (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-01 10:16:38 -07:00
|
|
|
priv->dhcp6_mode = dhcp_opts;
|
2010-01-27 16:20:09 -08:00
|
|
|
|
|
|
|
|
/* If addrconf is all that's required, we're done */
|
2010-05-01 10:16:38 -07:00
|
|
|
if (priv->dhcp6_mode == IP6_DHCP_OPT_NONE) {
|
2010-01-27 16:20:09 -08:00
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the router said to use DHCP for managed or otherconf, do it */
|
|
|
|
|
|
|
|
|
|
/* Don't re-start DHCPv6 if it's already in progress */
|
|
|
|
|
state = nm_device_interface_get_state (NM_DEVICE_INTERFACE (self));
|
|
|
|
|
if ((state != NM_DEVICE_STATE_IP_CONFIG) || priv->dhcp6_client)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_DHCP6,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) starting DHCPv6"
|
|
|
|
|
" as requested by IPv6 router...",
|
|
|
|
|
priv->iface);
|
2010-01-27 16:20:09 -08:00
|
|
|
|
2010-05-01 10:16:38 -07:00
|
|
|
ret = dhcp6_start (self, connection, priv->dhcp6_mode, &reason);
|
2010-01-27 16:20:09 -08:00
|
|
|
switch (ret) {
|
|
|
|
|
case NM_ACT_STAGE_RETURN_SUCCESS:
|
|
|
|
|
/* Shouldn't get this, but handle it anyway */
|
|
|
|
|
g_warn_if_reached ();
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (self);
|
|
|
|
|
break;
|
|
|
|
|
case NM_ACT_STAGE_RETURN_POSTPONE:
|
|
|
|
|
/* Success; wait for DHCPv6 to complete */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
break;
|
2009-07-30 13:50:42 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
ip6_config_changed (NMIP6Manager *ip6_manager,
|
2010-04-21 14:58:25 -07:00
|
|
|
int ifindex,
|
2010-01-14 22:57:51 -08:00
|
|
|
guint dhcp_opts,
|
|
|
|
|
gpointer user_data)
|
2009-07-30 13:50:42 -04:00
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
if (ifindex != nm_device_get_ip_ifindex (self))
|
2009-07-30 13:50:42 -04:00
|
|
|
return;
|
|
|
|
|
if (!nm_device_get_act_request (self))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-05-01 10:16:38 -07:00
|
|
|
/* FIXME: re-run DHCPv6 here to get any new nameservers or whatever */
|
|
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (self);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
static gboolean
|
|
|
|
|
ip6_method_matches (NMConnection *connection, const char *match)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
const char *method = NULL;
|
|
|
|
|
|
|
|
|
|
s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
|
|
|
|
if (s_ip6)
|
|
|
|
|
method = nm_setting_ip6_config_get_method (s_ip6);
|
|
|
|
|
|
|
|
|
|
return method && !strcmp (method, match);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-30 16:10:29 -07:00
|
|
|
static gboolean
|
2010-01-14 00:45:10 -08:00
|
|
|
addrconf6_setup (NMDevice *self)
|
2009-07-30 13:50:42 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
req = nm_device_get_act_request (self);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_assert (req);
|
2009-07-29 12:12:41 -04:00
|
|
|
connection = nm_act_request_get_connection (req);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_assert (connection);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
if (!priv->ip6_manager) {
|
|
|
|
|
priv->ip6_manager = nm_ip6_manager_get ();
|
|
|
|
|
priv->ip6_addrconf_sigid = g_signal_connect (priv->ip6_manager,
|
2010-01-14 00:45:10 -08:00
|
|
|
"addrconf-complete",
|
|
|
|
|
G_CALLBACK (ip6_addrconf_complete),
|
|
|
|
|
self);
|
2009-07-30 13:50:42 -04:00
|
|
|
priv->ip6_config_changed_sigid = g_signal_connect (priv->ip6_manager,
|
2010-01-14 00:45:10 -08:00
|
|
|
"config-changed",
|
|
|
|
|
G_CALLBACK (ip6_config_changed),
|
|
|
|
|
self);
|
2009-07-30 13:50:42 -04:00
|
|
|
}
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
2010-04-21 14:58:25 -07:00
|
|
|
nm_ip6_manager_prepare_interface (priv->ip6_manager,
|
|
|
|
|
nm_device_get_ip_ifindex (self),
|
|
|
|
|
s_ip6);
|
2010-04-30 16:10:29 -07:00
|
|
|
priv->ip6_waiting_for_config = TRUE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2009-07-30 13:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-01-14 00:45:10 -08:00
|
|
|
addrconf6_cleanup (NMDevice *self)
|
2009-07-30 13:50:42 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2009-10-19 15:38:21 -07:00
|
|
|
if (!priv->ip6_manager)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (priv->ip6_addrconf_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->ip6_manager,
|
|
|
|
|
priv->ip6_addrconf_sigid);
|
|
|
|
|
priv->ip6_addrconf_sigid = 0;
|
2009-07-30 13:50:42 -04:00
|
|
|
}
|
2009-10-19 15:38:21 -07:00
|
|
|
if (priv->ip6_config_changed_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->ip6_manager,
|
|
|
|
|
priv->ip6_config_changed_sigid);
|
|
|
|
|
priv->ip6_config_changed_sigid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-21 15:20:16 -07:00
|
|
|
nm_ip6_manager_cancel_addrconf (priv->ip6_manager, nm_device_get_ip_ifindex (self));
|
2009-10-19 15:38:21 -07:00
|
|
|
g_object_unref (priv->ip6_manager);
|
|
|
|
|
priv->ip6_manager = NULL;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage1_prepare (NMDevice *self, NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2010-01-27 16:20:09 -08:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
const char *iface;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
priv->ip4_ready = priv->ip6_ready = FALSE;
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, &reason);
|
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) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
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:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage1_device_prepare, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "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
|
2008-07-11 10:28:53 +00:00
|
|
|
real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
|
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;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2008-08-18 18:29:47 +00:00
|
|
|
gboolean no_firmware = FALSE;
|
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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
|
|
|
|
|
if (no_firmware)
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING);
|
|
|
|
|
else
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
2007-03-12 04:49:29 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, &reason);
|
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
|
|
|
{
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
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
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "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:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage2_device_config, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
|
2006-12-28 22:13:59 +00:00
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
static void
|
|
|
|
|
aipd_timeout_remove (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->aipd_timeout) {
|
|
|
|
|
g_source_remove (priv->aipd_timeout);
|
|
|
|
|
priv->aipd_timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->aipd_watch) {
|
|
|
|
|
g_source_remove (priv->aipd_watch);
|
|
|
|
|
priv->aipd_watch = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 19:42:54 +00:00
|
|
|
if (priv->aipd_pid > 0) {
|
|
|
|
|
kill (priv->aipd_pid, SIGKILL);
|
2008-08-27 17:22:32 +00:00
|
|
|
|
|
|
|
|
/* ensure the child is reaped */
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "waiting for avahi-autoipd pid %d to exit", priv->aipd_pid);
|
2008-08-27 17:22:32 +00:00
|
|
|
waitpid (priv->aipd_pid, NULL, 0);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "avahi-autoip pid %d cleaned up", priv->aipd_pid);
|
2008-08-27 17:22:32 +00:00
|
|
|
|
2008-07-27 19:42:54 +00:00
|
|
|
priv->aipd_pid = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_timeout_remove (self);
|
|
|
|
|
|
|
|
|
|
priv->aipd_addr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMIP4Config *
|
2008-07-11 10:28:53 +00:00
|
|
|
aipd_get_ip4_config (NMDevice *self, NMDeviceStateReason *reason)
|
2008-07-09 14:05:49 +00:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMIP4Config *config = NULL;
|
2008-10-29 14:35:25 +00:00
|
|
|
NMIP4Address *addr;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->aipd_addr > 0, NULL);
|
|
|
|
|
|
|
|
|
|
config = nm_ip4_config_new ();
|
2008-07-11 10:28:53 +00:00
|
|
|
if (!config) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-29 14:35:25 +00:00
|
|
|
addr = nm_ip4_address_new ();
|
|
|
|
|
nm_ip4_address_set_address (addr, (guint32) priv->aipd_addr);
|
|
|
|
|
nm_ip4_address_set_prefix (addr, 16);
|
2008-07-09 14:05:49 +00:00
|
|
|
nm_ip4_config_take_address (config, addr);
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-07-11 10:28:53 +00:00
|
|
|
handle_autoip_change (NMDevice *self, NMDeviceStateReason *reason)
|
2008-07-09 14:05:49 +00:00
|
|
|
{
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMIP4Config *config;
|
|
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
config = aipd_get_ip4_config (self, reason);
|
2008-07-09 14:05:49 +00:00
|
|
|
if (!config) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "failed to get autoip config for rebind");
|
2008-07-09 14:05:49 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
|
|
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
if (!nm_device_set_ip4_config (self, config, FALSE, reason)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): failed to update IP4 config in response to autoip event.",
|
2008-07-09 14:05:49 +00:00
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
|
|
|
|
#define IPV4LL_NETMASK (htonl (0xFFFF0000L))
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_handle_autoip4_event (NMDevice *self,
|
|
|
|
|
const char *event,
|
|
|
|
|
const char *address)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection = NULL;
|
|
|
|
|
NMSettingIP4Config *s_ip4 = NULL;
|
|
|
|
|
NMDeviceState state;
|
2008-10-29 14:35:25 +00:00
|
|
|
const char *iface, *method = NULL;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
if (!req)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
if (!connection)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Ignore if the connection isn't an AutoIP connection */
|
|
|
|
|
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
2008-10-29 14:35:25 +00:00
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
|
|
|
|
if (!s_ip4 || !method || strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
state = nm_device_get_state (self);
|
|
|
|
|
|
|
|
|
|
if (strcmp (event, "BIND") == 0) {
|
|
|
|
|
struct in_addr ip;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
if (inet_pton (AF_INET, address, &ip) <= 0) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd.",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ip.s_addr & IPV4LL_NETMASK) != IPV4LL_NETWORK) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd (not link-local).",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
|
case NM_DEVICE_STATE_IP_CONFIG:
|
|
|
|
|
if (priv->aipd_addr) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): already have autoip address!", iface);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->aipd_addr = ip.s_addr;
|
|
|
|
|
aipd_timeout_remove (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage4_ip4_config_get (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_STATE_ACTIVATED:
|
|
|
|
|
priv->aipd_addr = ip.s_addr;
|
2008-07-11 10:28:53 +00:00
|
|
|
if (!handle_autoip_change (self, &reason))
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2008-07-09 14:05:49 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): unexpected avahi-autoip event %s for %s.",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, event, address);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): autoip address %s no longer valid because '%s'.",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address, event);
|
|
|
|
|
|
|
|
|
|
/* The address is gone; terminate the connection or fail activation */
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_watch_cb (GPid pid, gint status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMDeviceState state;
|
|
|
|
|
const char *iface;
|
|
|
|
|
|
|
|
|
|
if (!priv->aipd_watch)
|
|
|
|
|
return;
|
|
|
|
|
priv->aipd_watch = 0;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
if (WIFEXITED (status)) {
|
|
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "(%s): avahi-autoipd exited with error code %d",
|
|
|
|
|
iface, WEXITSTATUS (status));
|
|
|
|
|
} else if (WIFSTOPPED (status)) {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd stopped unexpectedly with signal %d",
|
|
|
|
|
iface, WSTOPSIG (status));
|
|
|
|
|
} else if (WIFSIGNALED (status)) {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died with signal %d",
|
|
|
|
|
iface, WTERMSIG (status));
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died from an unknown cause", iface);
|
|
|
|
|
}
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
|
|
|
|
state = nm_device_get_state (self);
|
|
|
|
|
if (nm_device_is_activating (self) || (state == NM_DEVICE_STATE_ACTIVATED))
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_FAILED);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
aipd_timeout_cb (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!priv->aipd_timeout)
|
|
|
|
|
return FALSE;
|
|
|
|
|
priv->aipd_timeout = 0;
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_AUTOIP4, "(%s): avahi-autoipd timed out.", nm_device_get_iface (self));
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage4_ip4_config_timeout (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
/* We are in the child process at this point.
|
|
|
|
|
* Give child it's own program group for signal
|
|
|
|
|
* separation.
|
|
|
|
|
*/
|
|
|
|
|
pid_t pid = getpid ();
|
|
|
|
|
setpgid (pid, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
aipd_exec (NMDevice *self, GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
char *argv[5];
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
const char **aipd_binary = NULL;
|
|
|
|
|
static const char *aipd_paths[] = {
|
|
|
|
|
"/usr/sbin/avahi-autoipd",
|
|
|
|
|
"/usr/local/sbin/avahi-autoipd",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
|
|
|
|
/* Find avahi-autoipd */
|
|
|
|
|
aipd_binary = aipd_paths;
|
|
|
|
|
while (*aipd_binary != NULL) {
|
|
|
|
|
if (g_file_test (*aipd_binary, G_FILE_TEST_EXISTS))
|
|
|
|
|
break;
|
|
|
|
|
aipd_binary++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!*aipd_binary) {
|
|
|
|
|
g_set_error (error, 0, 0, "%s", "couldn't find avahi-autoipd");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
argv[0] = (char *) (*aipd_binary);
|
|
|
|
|
argv[1] = "--script";
|
|
|
|
|
argv[2] = LIBEXECDIR "/nm-avahi-autoipd.action";
|
2008-10-22 16:32:13 +00:00
|
|
|
argv[3] = (char *) nm_device_get_ip_iface (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
argv[4] = NULL;
|
|
|
|
|
|
|
|
|
|
success = g_spawn_async ("/", argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
|
|
|
|
&aipd_child_setup, NULL, &(priv->aipd_pid), error);
|
|
|
|
|
if (!success)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Monitor the child process so we know when it dies */
|
|
|
|
|
priv->aipd_watch = g_child_watch_add (priv->aipd_pid, aipd_watch_cb, self);
|
|
|
|
|
|
|
|
|
|
/* Start a timeout to bound the address attempt */
|
2008-12-31 18:57:36 -05:00
|
|
|
priv->aipd_timeout = g_timeout_add_seconds (20, aipd_timeout_cb, self);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-01-12 22:09:28 -08:00
|
|
|
static void
|
|
|
|
|
dhcp4_add_option_cb (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
nm_dhcp4_config_add_option (NM_DHCP4_CONFIG (user_data),
|
|
|
|
|
(const char *) key,
|
|
|
|
|
(const char *) value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-01-14 00:45:10 -08:00
|
|
|
dhcp6_add_option_cb (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
nm_dhcp6_config_add_option (NM_DHCP6_CONFIG (user_data),
|
|
|
|
|
(const char *) key,
|
|
|
|
|
(const char *) value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_dhcp_lease_change (NMDevice *device, gboolean ipv6)
|
2010-01-12 22:09:28 -08:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2010-01-14 00:45:10 -08:00
|
|
|
NMIP4Config *ip4_config;
|
2010-01-12 22:09:28 -08:00
|
|
|
NMSettingIP4Config *s_ip4;
|
2010-01-14 00:45:10 -08:00
|
|
|
NMIP6Config *ip6_config;
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
2010-01-12 22:09:28 -08:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
gboolean assumed;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (device);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
2010-01-14 00:45:10 -08:00
|
|
|
assumed = nm_act_request_get_assumed (req);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
if (ipv6) {
|
|
|
|
|
ip6_config = nm_dhcp_client_get_ip6_config (priv->dhcp6_client, FALSE);
|
|
|
|
|
if (!ip6_config) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to get DHCPv6 config for rebind",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
2010-01-14 00:45:10 -08:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
s_ip6 = NM_SETTING_IP6_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG));
|
|
|
|
|
nm_utils_merge_ip6_config (ip6_config, s_ip6);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP6_CONFIG, ip6_config);
|
|
|
|
|
|
|
|
|
|
if (nm_device_set_ip6_config (device, ip6_config, assumed, &reason)) {
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp6_client,
|
|
|
|
|
dhcp6_add_option_cb,
|
|
|
|
|
priv->dhcp6_config);
|
|
|
|
|
} else {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to update IPv6 config in response to DHCP event.",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
2010-01-14 00:45:10 -08:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
} else {
|
2010-01-14 00:45:10 -08:00
|
|
|
ip4_config = nm_dhcp_client_get_ip4_config (priv->dhcp4_client, FALSE);
|
|
|
|
|
if (!ip4_config) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to get DHCPv4 config for rebind",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
2010-01-14 00:45:10 -08:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
|
|
|
|
|
nm_utils_merge_ip4_config (ip4_config, s_ip4);
|
|
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, ip4_config);
|
|
|
|
|
|
|
|
|
|
if (nm_device_set_ip4_config (device, ip4_config, assumed, &reason)) {
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
|
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp4_client,
|
|
|
|
|
dhcp4_add_option_cb,
|
|
|
|
|
priv->dhcp4_config);
|
|
|
|
|
} else {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to update IPv4 config in response to DHCP event.",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
2010-01-14 00:45:10 -08:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp_state_changed (NMDHCPClient *client,
|
|
|
|
|
NMDHCPState state,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
NMDeviceState dev_state;
|
2010-01-14 00:45:10 -08:00
|
|
|
gboolean ipv6;
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
ipv6 = nm_dhcp_client_get_ipv6 (client);
|
2010-01-12 22:09:28 -08:00
|
|
|
dev_state = nm_device_get_state (device);
|
|
|
|
|
|
2010-05-01 09:26:57 -07:00
|
|
|
if (ipv6) {
|
|
|
|
|
nm_log_dbg (LOGD_DHCP6, "(%s): new DHCPv6 client state %d",
|
|
|
|
|
nm_device_get_iface (device), dev_state);
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_dbg (LOGD_DHCP4, "(%s): new DHCPv4 client state %d",
|
|
|
|
|
nm_device_get_iface (device), dev_state);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 22:09:28 -08:00
|
|
|
switch (state) {
|
|
|
|
|
case DHC_BOUND4: /* lease obtained */
|
2010-01-14 00:45:10 -08:00
|
|
|
case DHC_BOUND6:
|
2010-01-12 22:09:28 -08:00
|
|
|
case DHC_RENEW4: /* lease renewed */
|
2010-01-14 00:45:10 -08:00
|
|
|
case DHC_RENEW6: /* lease renewed */
|
2010-01-12 22:09:28 -08:00
|
|
|
case DHC_REBOOT: /* have valid lease, but now obtained a different one */
|
|
|
|
|
case DHC_REBIND4: /* new, different lease */
|
2010-01-14 00:45:10 -08:00
|
|
|
case DHC_REBIND6: /* new, different lease */
|
|
|
|
|
if (dev_state == NM_DEVICE_STATE_IP_CONFIG) {
|
|
|
|
|
if (ipv6)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (device);
|
|
|
|
|
else
|
|
|
|
|
nm_device_activate_schedule_stage4_ip4_config_get (device);
|
|
|
|
|
} else if (dev_state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
handle_dhcp_lease_change (device, ipv6);
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
|
|
|
|
case DHC_TIMEOUT: /* timed out contacting DHCP server */
|
2010-01-14 00:45:10 -08:00
|
|
|
if (ipv6) {
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_timeout (device);
|
|
|
|
|
} else {
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip4_config_timeout (device);
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
2010-05-01 10:16:38 -07:00
|
|
|
case DHC_END: /* dhclient exited normally */
|
|
|
|
|
/* In IPv6 info-only mode, the client doesn't handle leases so it
|
|
|
|
|
* may exit right after getting a response from the server. That's
|
|
|
|
|
* normal. In that case we just ignore the exit.
|
|
|
|
|
*/
|
|
|
|
|
if (ipv6 && (priv->dhcp6_mode == IP6_DHCP_OPT_OTHERCONF))
|
|
|
|
|
break;
|
|
|
|
|
/* Otherwise, fall through */
|
2010-01-12 22:09:28 -08:00
|
|
|
case DHC_FAIL: /* all attempts to contact server timed out, sleeping */
|
|
|
|
|
case DHC_ABEND: /* dhclient exited abnormally */
|
2010-01-14 00:45:10 -08:00
|
|
|
if (ipv6)
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
else
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
/* dhclient quit and can't get/renew a lease; so kill the connection */
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG)
|
2010-01-12 22:09:28 -08:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_DHCP_FAILED);
|
2010-01-13 17:59:54 -08:00
|
|
|
else if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
core: fail connections if IP configuration expires
Need to mark these connections invalid too, otherwise they'll just be
retried over and over and over. Ran into a problem with DHCPv6 where
lease expiration (cached lease really) was *negative*, which caused
the lease to expire immediately after being bound. Previously the
policy wouldn't mark connections like this as invalid because they
hadn't failed during activation.
NetworkManager: <info> (eth0): carrier now ON (device state 2)
NetworkManager: <info> (eth0): device state change: 2 -> 3 (reason 40)
NetworkManager: <info> Activation (eth0) starting connection 'dhcp6 test'
NetworkManager: <info> (eth0): device state change: 3 -> 4 (reason 0)
NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) scheduled...
NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) started...
NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) scheduled...
NetworkManager: <info> Activation (eth0) Stage 1 of 5 (Device Prepare) complete.
NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) starting...
NetworkManager: <info> (eth0): device state change: 4 -> 5 (reason 0)
NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) successful.
NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) scheduled.
NetworkManager: <info> Activation (eth0) Stage 2 of 5 (Device Configure) complete.
NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
NetworkManager: <info> (eth0): device state change: 5 -> 7 (reason 0)
NetworkManager: <info> Activation (eth0) Beginning DHCPv6 transaction (timeout in 45 seconds)
NetworkManager: <info> dhclient started with pid 6639
NetworkManager: <info> Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
Internet Systems Consortium DHCP Client 4.1.1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
NetworkManager: <info> (eth0): DHCPv6 state changed nbi -> preinit6
Bound to *:546
Listening on Socket/eth0
Sending on Socket/eth0
PRC: Confirming active lease (INIT-REBOOT).
XMT: Forming Confirm, 0 ms elapsed.
XMT: X-- IA_NA 5a:47:1f:71
XMT: | X-- Confirm Address 3ffe:501:ffff::4
XMT: V IA_NA appended.
XMT: Confirm on eth0, interval 1090ms.
send_packet6: Cannot assign requested address
dhc6: sendpacket6() sent -1 of 80 bytes
XMT: Forming Confirm, 1090 ms elapsed.
XMT: X-- IA_NA 5a:47:1f:71
XMT: | X-- Confirm Address 3ffe:501:ffff::4
XMT: V IA_NA appended.
XMT: Confirm on eth0, interval 2120ms.
send_packet6: Cannot assign requested address
dhc6: sendpacket6() sent -1 of 80 bytes
XMT: Forming Confirm, 3210 ms elapsed.
XMT: X-- IA_NA 5a:47:1f:71
XMT: | X-- Confirm Address 3ffe:501:ffff::4
XMT: V IA_NA appended.
XMT: Confirm on eth0, interval 4320ms.
XMT: Forming Confirm, 7530 ms elapsed.
XMT: X-- IA_NA 5a:47:1f:71
XMT: | X-- Confirm Address 3ffe:501:ffff::4
XMT: V IA_NA appended.
XMT: Confirm on eth0, interval 2470ms.
Max retransmission duration exceeded.
PRC: Bound to lease 00:01:00:01:12:e1:92:d9:00:14:22:fd:06:e7.
PRC: Rebind event scheduled in -8604281 seconds, to run for 110 seconds.
PRC: Depreference scheduled in -8604241 seconds.
PRC: Expiration scheduled in -8604171 seconds.
PRC: Rebinding lease on eth0.
PRC: Depreference scheduled in -8604241 seconds.
PRC: Expiration scheduled in -8604171 seconds.
NetworkManager: <info> (eth0): DHCPv6 state changed preinit6 -> bound6
NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP6 Configure Get) scheduled...
NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP6 Configure Get) started...
NetworkManager: <info> address 3ffe:501:ffff::4
NetworkManager: <info> prefix 64
NetworkManager: <info> nameserver '2000::2'
NetworkManager: <info> domain search 'ibm.com.'
NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) scheduled...
NetworkManager: <info> Activation (eth0) Stage 4 of 5 (IP6 Configure Get) complete.
NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) started...
PRC: Address 3ffe:501:ffff::4 depreferred.
PRC: Expiration scheduled in -8604171 seconds.
PRC: Address 3ffe:501:ffff::4 expired.
PRC: Bound lease is devoid of active addresses. Re-initializing.
PRC: Soliciting for leases (INIT).
XMT: Forming Solicit, 0 ms elapsed.
XMT: X-- IA_NA 5a:47:1f:71
XMT: | X-- Request renew in +3600
XMT: | X-- Request rebind in +5400
XMT: Solicit on eth0, interval 1040ms.
Stopping nscd: [ OK ]
Starting nscd: [ OK ]
NetworkManager: <info> (eth0): device state change: 7 -> 8 (reason 0)
NetworkManager: <info> Activation (eth0) successful, device activated.
NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) complete.
NetworkManager: <info> (eth0): DHCPv6 state changed bound6 -> depref6
NetworkManager: <info> (eth0): DHCPv6 state changed depref6 -> expire6
2010-04-23 15:52:09 -07:00
|
|
|
case DHC_STOP:
|
|
|
|
|
case DHC_STOP6:
|
|
|
|
|
case DHC_EXPIRE:
|
|
|
|
|
case DHC_EXPIRE6:
|
|
|
|
|
if (dev_state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
if (ipv6)
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
else
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
|
|
|
|
|
|
|
|
|
/* dhclient quit and can't get/renew a lease; so kill the connection */
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2010-01-12 22:09:28 -08:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp_timeout (NMDHCPClient *client, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
if (!nm_device_get_act_request (device))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-01-15 12:50:38 -08:00
|
|
|
nm_dhcp_client_stop (client);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
|
|
|
|
|
if (nm_dhcp_client_get_ipv6 (client))
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_timeout (device);
|
|
|
|
|
else
|
|
|
|
|
nm_device_activate_schedule_stage4_ip4_config_timeout (device);
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
2009-07-29 12:12:41 -04:00
|
|
|
real_act_stage3_ip4_config_start (NMDevice *self, NMDeviceStateReason *reason)
|
2007-06-06 13:33:51 +00:00
|
|
|
{
|
2010-04-23 12:56:33 -07:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-05-03 00:51:09 -04:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingConnection *s_con;
|
2008-07-03 16:22:17 +00:00
|
|
|
NMSettingIP4Config *s_ip4;
|
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;
|
2009-05-03 00:51:09 -04:00
|
|
|
const char *ip_iface, *method = NULL, *uuid;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2008-10-22 16:32:13 +00:00
|
|
|
/* Use the IP interface (not the control interface) for IP stuff */
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2009-08-20 20:58:18 +02:00
|
|
|
/* Make sure the interface is up before trying to do anything with it */
|
|
|
|
|
if (!nm_system_device_is_up_with_iface (ip_iface))
|
|
|
|
|
nm_system_device_set_up_down_with_iface (ip_iface, TRUE, NULL);
|
|
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
req = nm_device_get_act_request (self);
|
2009-05-03 00:51:09 -04:00
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
uuid = nm_setting_connection_get_uuid (s_con);
|
|
|
|
|
|
|
|
|
|
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, 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-10-29 14:35:25 +00:00
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
|
|
|
|
if (!s_ip4 || !method || !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
2009-07-15 13:53:49 -04:00
|
|
|
guint8 *anycast = NULL;
|
|
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
/* Begin a DHCP transaction on the interface */
|
|
|
|
|
|
2009-07-15 13:53:49 -04:00
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
anycast = priv->dhcp_anycast_address->data;
|
2006-01-03 18:18:05 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
/* Clear old exported DHCP options */
|
|
|
|
|
if (priv->dhcp4_config)
|
|
|
|
|
g_object_unref (priv->dhcp4_config);
|
|
|
|
|
priv->dhcp4_config = nm_dhcp4_config_new ();
|
2007-06-06 13:33:51 +00:00
|
|
|
|
2010-01-13 16:51:20 -08:00
|
|
|
priv->dhcp4_client = nm_dhcp_manager_start_ip4 (priv->dhcp_manager,
|
|
|
|
|
ip_iface,
|
|
|
|
|
uuid,
|
|
|
|
|
s_ip4,
|
|
|
|
|
priv->dhcp_timeout,
|
|
|
|
|
anycast);
|
2010-01-12 22:09:28 -08:00
|
|
|
if (priv->dhcp4_client) {
|
2010-01-13 18:06:05 -08:00
|
|
|
priv->dhcp4_state_sigid = g_signal_connect (priv->dhcp4_client,
|
|
|
|
|
"state-changed",
|
|
|
|
|
G_CALLBACK (dhcp_state_changed),
|
|
|
|
|
self);
|
|
|
|
|
priv->dhcp4_timeout_sigid = g_signal_connect (priv->dhcp4_client,
|
|
|
|
|
"timeout",
|
|
|
|
|
G_CALLBACK (dhcp_timeout),
|
|
|
|
|
self);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2007-02-05 09:50:11 +00:00
|
|
|
/* DHCP devices will be notified by the DHCP manager when
|
|
|
|
|
* stuff happens.
|
|
|
|
|
*/
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
2008-07-11 10:28:53 +00:00
|
|
|
} else {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
|
2007-02-05 09:50:11 +00:00
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2008-07-11 10:28:53 +00:00
|
|
|
}
|
2008-10-29 14:35:25 +00:00
|
|
|
} else if (s_ip4 && !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) {
|
2008-07-09 14:05:49 +00:00
|
|
|
GError *error = NULL;
|
2008-10-22 16:32:13 +00:00
|
|
|
const char *iface = nm_device_get_iface (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
/* Start avahi-autoipd */
|
|
|
|
|
if (aipd_exec (self, &error)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_AUTOIP4,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) started"
|
|
|
|
|
" avahi-autoipd...", iface);
|
2008-07-09 14:05:49 +00:00
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_AUTOIP4,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
|
|
|
|
|
" to start avahi-autoipd: %s", iface, error->message);
|
2008-07-09 14:05:49 +00:00
|
|
|
g_error_free (error);
|
|
|
|
|
aipd_cleanup (self);
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED;
|
2008-07-09 14:05:49 +00:00
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
2010-04-23 12:56:33 -07:00
|
|
|
} else if (s_ip4 && !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
|
|
|
|
|
/* Nothing to do... */
|
|
|
|
|
priv->ip4_ready = TRUE;
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_STOP;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
static NMActStageReturn
|
|
|
|
|
dhcp6_start (NMDevice *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
guint32 dhcp_opt,
|
|
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
guint8 *anycast = NULL;
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
const char *uuid;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
|
|
|
|
|
if (!connection) {
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Begin a DHCP transaction on the interface */
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
anycast = priv->dhcp_anycast_address->data;
|
|
|
|
|
|
|
|
|
|
/* Clear old exported DHCP options */
|
|
|
|
|
if (priv->dhcp6_config)
|
|
|
|
|
g_object_unref (priv->dhcp6_config);
|
|
|
|
|
priv->dhcp6_config = nm_dhcp6_config_new ();
|
|
|
|
|
|
|
|
|
|
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
uuid = nm_setting_connection_get_uuid (s_con);
|
|
|
|
|
|
|
|
|
|
s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
|
|
|
|
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
priv->dhcp6_client = nm_dhcp_manager_start_ip6 (priv->dhcp_manager,
|
|
|
|
|
ip_iface,
|
|
|
|
|
uuid,
|
|
|
|
|
s_ip6,
|
|
|
|
|
priv->dhcp_timeout,
|
|
|
|
|
anycast,
|
|
|
|
|
(dhcp_opt == IP6_DHCP_OPT_OTHERCONF) ? TRUE : FALSE);
|
|
|
|
|
if (priv->dhcp6_client) {
|
|
|
|
|
priv->dhcp6_state_sigid = g_signal_connect (priv->dhcp6_client,
|
|
|
|
|
"state-changed",
|
|
|
|
|
G_CALLBACK (dhcp_state_changed),
|
|
|
|
|
self);
|
|
|
|
|
priv->dhcp6_timeout_sigid = g_signal_connect (priv->dhcp6_client,
|
|
|
|
|
"timeout",
|
|
|
|
|
G_CALLBACK (dhcp_timeout),
|
|
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
/* DHCP devices will be notified by the DHCP manager when stuff happens */
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage3_ip6_config_start (NMDevice *self, NMDeviceStateReason *reason)
|
|
|
|
|
{
|
2009-07-30 13:50:42 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-01-27 16:20:09 -08:00
|
|
|
const char *ip_iface;
|
2010-04-30 15:49:41 -07:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2010-01-14 00:45:10 -08:00
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection;
|
2009-07-30 13:50:42 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
2010-05-01 10:16:38 -07:00
|
|
|
priv->dhcp6_mode = IP6_DHCP_OPT_NONE;
|
|
|
|
|
|
2010-04-30 15:49:41 -07:00
|
|
|
if ( ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|
|
|
|
|
|| ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) {
|
2010-04-30 16:10:29 -07:00
|
|
|
if (!addrconf6_setup (self)) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2010-04-21 14:58:25 -07:00
|
|
|
nm_ip6_manager_begin_addrconf (priv->ip6_manager, nm_device_get_ip_ifindex (self));
|
2010-01-14 00:45:10 -08:00
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
2010-05-01 10:16:38 -07:00
|
|
|
} else if (ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
|
|
|
|
|
priv->dhcp6_mode = IP6_DHCP_OPT_MANAGED;
|
|
|
|
|
ret = dhcp6_start (self, connection, priv->dhcp6_mode, reason);
|
|
|
|
|
} else if (ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
|
2010-04-23 12:56:33 -07:00
|
|
|
priv->ip6_ready = TRUE;
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_STOP;
|
2010-04-30 15:49:41 -07:00
|
|
|
} else if (ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
|
|
|
|
|
/* Other methods (shared) aren't implemented yet */
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2010-04-30 16:10:29 -07:00
|
|
|
out:
|
2010-01-14 00:45:10 -08:00
|
|
|
return ret;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage3_ip_config_start
|
|
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Begin automatic/manual IP configuration
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
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);
|
2008-07-11 10:28:53 +00:00
|
|
|
const char *iface;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_SUCCESS)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip4_config_get (self);
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
2010-04-23 12:56:33 -07:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_STOP) {
|
|
|
|
|
/* Nothing to do */
|
2009-07-29 12:12:41 -04:00
|
|
|
} else
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_SUCCESS)
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (self);
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
goto out;
|
2010-04-23 12:56:33 -07:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_STOP) {
|
|
|
|
|
/* Nothing to do */
|
2009-07-29 12:12:41 -04:00
|
|
|
} else
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage3_ip_config_start, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-06-10 02:52:33 +00:00
|
|
|
static GHashTable *shared_ips = NULL;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
release_shared_ip (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_hash_table_remove (shared_ips, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint32
|
|
|
|
|
reserve_shared_ip (void)
|
|
|
|
|
{
|
|
|
|
|
guint32 start = (guint32) ntohl (0x0a2a2b01); /* 10.42.43.1 */
|
|
|
|
|
guint32 count = 0;
|
|
|
|
|
|
2008-06-10 20:47:12 +00:00
|
|
|
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
2008-06-10 02:52:33 +00:00
|
|
|
count += ntohl (0x100);
|
|
|
|
|
if (count > ntohl (0xFE00)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "ran out of shared IP addresses!");
|
2008-06-10 02:52:33 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 20:47:12 +00:00
|
|
|
g_hash_table_insert (shared_ips, GUINT_TO_POINTER (start + count), GUINT_TO_POINTER (TRUE));
|
2008-06-10 02:52:33 +00:00
|
|
|
return start + count;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
static NMIP4Config *
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_new_ip4_shared_config (NMDevice *self, NMDeviceStateReason *reason)
|
2008-05-29 20:58:52 +00:00
|
|
|
{
|
|
|
|
|
NMIP4Config *config = NULL;
|
2008-10-29 14:35:25 +00:00
|
|
|
NMIP4Address *addr;
|
2008-06-10 02:52:33 +00:00
|
|
|
guint32 tmp_addr;
|
2008-05-29 20:58:52 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2008-06-10 02:52:33 +00:00
|
|
|
if (G_UNLIKELY (shared_ips == NULL))
|
|
|
|
|
shared_ips = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
|
|
|
|
tmp_addr = reserve_shared_ip ();
|
2008-07-11 10:28:53 +00:00
|
|
|
if (!tmp_addr) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
2008-06-10 02:52:33 +00:00
|
|
|
return NULL;
|
2008-07-11 10:28:53 +00:00
|
|
|
}
|
2008-06-10 02:52:33 +00:00
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
config = nm_ip4_config_new ();
|
2008-10-29 14:35:25 +00:00
|
|
|
addr = nm_ip4_address_new ();
|
|
|
|
|
nm_ip4_address_set_address (addr, tmp_addr);
|
|
|
|
|
nm_ip4_address_set_prefix (addr, 24);
|
2008-05-29 20:58:52 +00:00
|
|
|
nm_ip4_config_take_address (config, addr);
|
|
|
|
|
|
2008-06-10 02:52:33 +00:00
|
|
|
/* Remove the address lock when the object gets disposed */
|
|
|
|
|
g_object_set_data_full (G_OBJECT (config), "shared-ip",
|
2008-10-29 14:35:25 +00:00
|
|
|
GUINT_TO_POINTER (tmp_addr), release_shared_ip);
|
2008-06-10 02:52:33 +00:00
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_get_ip4_config (NMDevice *self,
|
2008-07-11 10:28:53 +00:00
|
|
|
NMIP4Config **config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
2006-01-03 17:47:38 +00:00
|
|
|
{
|
2008-05-29 20:58:52 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (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
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
NMConnection *connection;
|
2008-03-13 03:11:02 +00:00
|
|
|
NMSettingIP4Config *s_ip4;
|
2008-10-22 16:32:13 +00:00
|
|
|
const char *ip_iface;
|
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-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2008-10-22 16:32:13 +00:00
|
|
|
/* Use the IP interface (not the control interface) for IP stuff */
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2008-07-17 17:04:13 +00:00
|
|
|
|
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
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
if (priv->dhcp4_client) {
|
|
|
|
|
/* DHCP */
|
2010-01-12 22:09:28 -08:00
|
|
|
*config = nm_dhcp_client_get_ip4_config (priv->dhcp4_client, FALSE);
|
2008-07-17 17:04:13 +00:00
|
|
|
if (*config) {
|
2009-08-17 19:48:42 -05:00
|
|
|
/* Merge user-defined overrides into the IP4Config to be applied */
|
2008-06-10 02:52:33 +00:00
|
|
|
nm_utils_merge_ip4_config (*config, s_ip4);
|
2008-07-17 17:04:13 +00:00
|
|
|
|
2009-01-18 23:19:09 -05:00
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
2010-01-14 00:45:10 -08:00
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp4_client,
|
|
|
|
|
dhcp4_add_option_cb,
|
|
|
|
|
priv->dhcp4_config);
|
2009-01-18 23:19:09 -05:00
|
|
|
|
2008-07-17 17:04:13 +00:00
|
|
|
/* Notify of new DHCP4 config */
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
|
|
|
|
|
} else
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_ERROR;
|
2007-06-06 13:33:51 +00:00
|
|
|
} else {
|
2010-01-13 17:59:54 -08:00
|
|
|
/* Not DHCP */
|
2008-10-29 14:35:25 +00:00
|
|
|
const char *method;
|
|
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
g_assert (s_ip4);
|
|
|
|
|
|
2008-10-29 14:35:25 +00:00
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
g_assert (method);
|
|
|
|
|
|
|
|
|
|
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) {
|
2008-07-11 10:28:53 +00:00
|
|
|
*config = aipd_get_ip4_config (self, reason);
|
2008-10-29 14:35:25 +00:00
|
|
|
} else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
|
2008-03-13 03:11:02 +00:00
|
|
|
*config = nm_ip4_config_new ();
|
2009-08-17 19:48:42 -05:00
|
|
|
if (*config) {
|
|
|
|
|
/* Merge user-defined overrides into the IP4Config to be applied */
|
2008-06-10 02:52:33 +00:00
|
|
|
nm_utils_merge_ip4_config (*config, s_ip4);
|
2009-08-17 19:48:42 -05:00
|
|
|
} else
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
2008-10-29 14:35:25 +00:00
|
|
|
} else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
|
2008-07-11 10:28:53 +00:00
|
|
|
*config = nm_device_new_ip4_shared_config (self, reason);
|
2008-06-10 02:52:33 +00:00
|
|
|
if (*config)
|
2008-10-22 16:32:13 +00:00
|
|
|
priv->dnsmasq_manager = nm_dnsmasq_manager_new (ip_iface);
|
2010-04-15 14:59:29 -07:00
|
|
|
} else if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
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 */
|
2008-08-18 18:29:47 +00:00
|
|
|
nm_device_bring_up (self, FALSE, NULL);
|
2008-03-13 03:11:02 +00:00
|
|
|
} 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
|
|
|
/*
|
2009-07-29 12:12:41 -04:00
|
|
|
* nm_device_activate_stage4_ip4_config_get
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Retrieve the correct IPv4 config.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_stage4_ip4_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);
|
2008-07-11 10:28:53 +00:00
|
|
|
NMIP4Config *ip4_config = NULL;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret;
|
2008-07-11 10:28:53 +00:00
|
|
|
const char *iface = NULL;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, AF_INET);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 Configure Get) started...",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip4_config (self, &ip4_config, &reason);
|
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
|
|
|
{
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
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);
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 Configure Get) complete.",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-07-29 12:12:41 -04:00
|
|
|
* nm_device_activate_schedule_stage4_ip4_config_get
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Schedule creation of the IPv4 config
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage4_ip4_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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage4_ip4_config_get, AF_INET);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 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
|
2009-07-29 12:12:41 -04:00
|
|
|
real_act_stage4_ip4_config_timeout (NMDevice *self,
|
|
|
|
|
NMIP4Config **config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
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-07-17 17:04:13 +00:00
|
|
|
/* Notify of invalid DHCP4 config object */
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
|
|
|
|
|
|
2008-03-13 03:11:02 +00:00
|
|
|
/* DHCP failed; connection must fail */
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
2008-03-13 03:11:02 +00:00
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
2009-07-29 12:12:41 -04:00
|
|
|
* nm_device_activate_stage4_ip4_config_timeout
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Time out on retrieving the IPv4 config.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_stage4_ip4_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);
|
2008-07-11 10:28:53 +00:00
|
|
|
NMIP4Config *ip4_config = NULL;
|
|
|
|
|
const char *iface;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, AF_INET);
|
2007-01-04 12:06:26 +00:00
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) started...",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip4_config_timeout (self, &ip4_config, &reason);
|
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)) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
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);
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET);
|
|
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) complete.",
|
|
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage4_ip4_config_timeout
|
|
|
|
|
*
|
|
|
|
|
* Deal with a timeout of the IPv4 configuration
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_device_activate_schedule_stage4_ip4_config_timeout (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
|
|
|
|
|
|
|
|
|
activation_source_schedule (self, nm_device_activate_stage4_ip4_config_timeout, AF_INET);
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP4 Configure Timeout) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2010-05-01 08:12:25 -07:00
|
|
|
static void
|
|
|
|
|
merge_dhcp_config_to_master (NMIP6Config *dst, NMIP6Config *src)
|
|
|
|
|
{
|
|
|
|
|
guint32 i;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (src != NULL);
|
|
|
|
|
g_return_if_fail (dst != NULL);
|
|
|
|
|
|
|
|
|
|
/* addresses */
|
|
|
|
|
for (i = 0; i < nm_ip6_config_get_num_addresses (src); i++)
|
|
|
|
|
nm_ip6_config_add_address (dst, nm_ip6_config_get_address (src, i));
|
|
|
|
|
|
|
|
|
|
/* ptp address; only replace if src doesn't have one */
|
|
|
|
|
if (!nm_ip6_config_get_ptp_address (dst))
|
|
|
|
|
nm_ip6_config_set_ptp_address (dst, nm_ip6_config_get_ptp_address (src));
|
|
|
|
|
|
|
|
|
|
/* nameservers */
|
|
|
|
|
for (i = 0; i < nm_ip6_config_get_num_nameservers (src); i++)
|
|
|
|
|
nm_ip6_config_add_nameserver (dst, nm_ip6_config_get_nameserver (src, i));
|
|
|
|
|
|
|
|
|
|
/* routes */
|
|
|
|
|
for (i = 0; i < nm_ip6_config_get_num_routes (src); i++)
|
|
|
|
|
nm_ip6_config_add_route (dst, nm_ip6_config_get_route (src, i));
|
|
|
|
|
|
|
|
|
|
/* domains */
|
|
|
|
|
for (i = 0; i < nm_ip6_config_get_num_domains (src); i++)
|
|
|
|
|
nm_ip6_config_add_domain (dst, nm_ip6_config_get_domain (src, i));
|
|
|
|
|
|
|
|
|
|
/* dns searches */
|
|
|
|
|
for (i = 0; i < nm_ip6_config_get_num_searches (src); i++)
|
|
|
|
|
nm_ip6_config_add_search (dst, nm_ip6_config_get_search (src, i));
|
|
|
|
|
|
|
|
|
|
if (!nm_ip6_config_get_mss (dst))
|
|
|
|
|
nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src));
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_get_ip6_config (NMDevice *self,
|
|
|
|
|
NMIP6Config **config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
2010-01-14 00:45:10 -08:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
|
|
|
|
/* Use the IP interface (not the control interface) for IP stuff */
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
|
|
|
|
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
2010-04-30 16:10:29 -07:00
|
|
|
if ( ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_AUTO)
|
|
|
|
|
|| ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) {
|
2010-04-21 14:58:25 -07:00
|
|
|
*config = nm_ip6_manager_get_ip6_config (priv->ip6_manager,
|
|
|
|
|
nm_device_get_ip_ifindex (self));
|
2010-04-30 15:49:41 -07:00
|
|
|
if (!*config) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
} else if (ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
|
|
|
|
|
*config = nm_ip6_config_new ();
|
|
|
|
|
if (!*config) {
|
2010-01-14 00:45:10 -08:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
2010-01-27 16:20:09 -08:00
|
|
|
goto out;
|
2010-01-14 00:45:10 -08:00
|
|
|
}
|
2010-01-27 16:20:09 -08:00
|
|
|
} else if (ip6_method_matches (connection, NM_SETTING_IP6_CONFIG_METHOD_DHCP))
|
|
|
|
|
g_assert (priv->dhcp6_client); /* sanity check */
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
/* Autoconf might have triggered DHCPv6 too */
|
|
|
|
|
if (priv->dhcp6_client) {
|
2010-05-01 08:12:25 -07:00
|
|
|
NMIP6Config *dhcp;
|
|
|
|
|
|
|
|
|
|
dhcp = nm_dhcp_client_get_ip6_config (priv->dhcp6_client, FALSE);
|
|
|
|
|
if (!dhcp) {
|
2010-01-14 00:45:10 -08:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_ERROR;
|
2010-04-30 15:49:41 -07:00
|
|
|
goto out;
|
2010-01-14 00:45:10 -08:00
|
|
|
}
|
2010-04-30 15:49:41 -07:00
|
|
|
|
2010-05-01 08:12:25 -07:00
|
|
|
/* For "managed" and DHCP-only setups, we use only the DHCP-supplied
|
|
|
|
|
* IPv6 config. But when autoconf is enabled, we have to merge the
|
|
|
|
|
* autoconf config and the DHCP-supplied config, then merge the
|
|
|
|
|
* user's overrides from the connection to get the final configuration
|
|
|
|
|
* that gets applied to the device.
|
|
|
|
|
*/
|
|
|
|
|
if (*config) {
|
|
|
|
|
/* Merge autoconf and DHCP configs */
|
|
|
|
|
merge_dhcp_config_to_master (*config, dhcp);
|
|
|
|
|
g_object_unref (dhcp);
|
|
|
|
|
dhcp = NULL;
|
|
|
|
|
} else {
|
|
|
|
|
*config = dhcp;
|
|
|
|
|
}
|
2010-04-30 15:49:41 -07:00
|
|
|
|
2010-05-01 08:12:25 -07:00
|
|
|
/* Copy the new DHCPv6 configuration into the DHCP config object that's
|
|
|
|
|
* exported over D-Bus to clients.
|
|
|
|
|
*/
|
2010-04-30 15:49:41 -07:00
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp6_client,
|
|
|
|
|
dhcp6_add_option_cb,
|
|
|
|
|
priv->dhcp6_config);
|
|
|
|
|
|
|
|
|
|
/* Notify of new DHCP6 config */
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP6_CONFIG);
|
|
|
|
|
}
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2010-05-01 08:12:25 -07:00
|
|
|
/* Merge user-defined overrides into the IP6Config to be applied */
|
|
|
|
|
if (*config) {
|
|
|
|
|
s_ip6 = (NMSettingIP6Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
|
|
|
|
nm_utils_merge_ip6_config (*config, s_ip6);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
out:
|
2010-04-30 15:49:41 -07:00
|
|
|
return *config ? NM_ACT_STAGE_RETURN_SUCCESS : NM_ACT_STAGE_RETURN_FAILURE;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage4_ip6_config_get
|
|
|
|
|
*
|
|
|
|
|
* Retrieve the correct IPv6 config.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
nm_device_activate_stage4_ip6_config_get (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMIP6Config *ip6_config = NULL;
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
const char *iface = NULL;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
|
|
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
activation_source_clear (self, FALSE, AF_INET6);
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) started...",
|
|
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_get_ip6_config (self, &ip6_config, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
goto out;
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
|
|
|
|
{
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
|
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (nm_device_get_act_request (self)),
|
|
|
|
|
NM_ACT_REQUEST_IP6_CONFIG, ip6_config);
|
|
|
|
|
|
|
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET6);
|
|
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) complete.",
|
|
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage4_ip6_config_get
|
|
|
|
|
*
|
|
|
|
|
* Schedule creation of the IPv6 config
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_device_activate_schedule_stage4_ip6_config_get (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
|
|
|
|
|
|
|
|
|
activation_source_schedule (self, nm_device_activate_stage4_ip6_config_get, AF_INET6);
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Get) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static NMActStageReturn
|
|
|
|
|
real_act_stage4_ip6_config_timeout (NMDevice *self,
|
|
|
|
|
NMIP6Config **config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (config != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
g_return_val_if_fail (*config == NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
/* Notify of invalid DHCP6 config object */
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP6_CONFIG);
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage4_ip6_config_timeout
|
|
|
|
|
*
|
|
|
|
|
* Time out on retrieving the IPv6 config.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
nm_device_activate_stage4_ip6_config_timeout (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMIP6Config *ip6_config = NULL;
|
|
|
|
|
const char *iface;
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
|
|
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
activation_source_clear (self, FALSE, AF_INET6);
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) started...",
|
|
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip6_config_timeout (self, &ip6_config, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
|
|
|
|
goto out;
|
|
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2010-04-23 21:51:09 -07:00
|
|
|
g_assert (ip6_config);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (nm_device_get_act_request (self)),
|
|
|
|
|
NM_ACT_REQUEST_IP6_CONFIG, ip6_config);
|
|
|
|
|
|
|
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET6);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) complete.",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-07-29 12:12:41 -04:00
|
|
|
* nm_device_activate_schedule_stage4_ip6_config_timeout
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Deal with a timeout of the IPv6 configuration
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage4_ip6_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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage4_ip6_config_timeout, AF_INET6);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 4 of 5 (IP6 Configure Timeout) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-15 15:34:28 +00:00
|
|
|
static void
|
|
|
|
|
share_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
/* We are in the child process at this point */
|
|
|
|
|
pid_t pid = getpid ();
|
|
|
|
|
setpgid (pid, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
share_init (void)
|
|
|
|
|
{
|
2009-07-29 12:12:41 -04:00
|
|
|
int status;
|
2008-08-15 15:34:28 +00:00
|
|
|
char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc",
|
|
|
|
|
"nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323",
|
|
|
|
|
NULL };
|
|
|
|
|
char **iter;
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_forward", "1\n")) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "Error starting IP forwarding: (%d) %s",
|
|
|
|
|
errno, strerror (errno));
|
2009-07-29 12:12:41 -04:00
|
|
|
return FALSE;
|
2008-08-15 15:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_dynaddr", "1\n")) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "error starting IP forwarding: (%d) %s",
|
|
|
|
|
errno, strerror (errno));
|
2008-08-15 15:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (iter = modules; *iter; iter++) {
|
|
|
|
|
char *argv[3] = { "/sbin/modprobe", *iter, NULL };
|
|
|
|
|
char *envp[1] = { NULL };
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
|
|
|
|
|
share_child_setup, NULL, NULL, NULL, &status, &error)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "error loading NAT module %s: (%d) %s",
|
|
|
|
|
*iter, error ? error->code : 0,
|
|
|
|
|
(error && error->message) ? error->message : "unknown");
|
2008-08-15 15:34:28 +00:00
|
|
|
if (error)
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_share_rule (NMActRequest *req, const char *table, const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
char *cmd;
|
|
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
cmd = g_strdup_vprintf (fmt, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
|
|
nm_act_request_add_share_rule (req, table, cmd);
|
|
|
|
|
g_free (cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
start_sharing (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
char str_addr[INET_ADDRSTRLEN + 1];
|
|
|
|
|
char str_mask[INET_ADDRSTRLEN + 1];
|
|
|
|
|
guint32 netmask, network;
|
|
|
|
|
NMIP4Config *ip4_config;
|
2008-10-29 14:35:25 +00:00
|
|
|
NMIP4Address *ip4_addr;
|
2008-10-22 16:32:13 +00:00
|
|
|
const char *ip_iface;
|
2008-08-15 15:34:28 +00:00
|
|
|
|
2008-10-22 16:32:13 +00:00
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2008-08-15 15:34:28 +00:00
|
|
|
|
|
|
|
|
ip4_config = nm_device_get_ip4_config (self);
|
|
|
|
|
if (!ip4_config)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
ip4_addr = nm_ip4_config_get_address (ip4_config, 0);
|
2008-10-29 14:35:25 +00:00
|
|
|
if (!ip4_addr || !nm_ip4_address_get_address (ip4_addr))
|
2008-08-15 15:34:28 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2008-10-29 14:35:25 +00:00
|
|
|
netmask = nm_utils_ip4_prefix_to_netmask (nm_ip4_address_get_prefix (ip4_addr));
|
2008-08-15 15:34:28 +00:00
|
|
|
if (!inet_ntop (AF_INET, &netmask, str_mask, sizeof (str_mask)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2008-10-29 14:35:25 +00:00
|
|
|
network = nm_ip4_address_get_address (ip4_addr) & netmask;
|
2008-08-15 15:34:28 +00:00
|
|
|
if (!inet_ntop (AF_INET, &network, str_addr, sizeof (str_addr)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!share_init ())
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
|
2008-10-22 16:32:13 +00:00
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 53 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 67 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 67 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --in-interface %s --jump REJECT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --out-interface %s --jump REJECT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --in-interface %s --out-interface %s --jump ACCEPT", ip_iface, ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --source %s/%s --in-interface %s --jump ACCEPT", str_addr, str_mask, ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --destination %s/%s --out-interface %s --match state --state ESTABLISHED,RELATED --jump ACCEPT", str_addr, str_mask, ip_iface);
|
2008-08-15 15:34:28 +00:00
|
|
|
add_share_rule (req, "nat", "POSTROUTING --source %s/%s --destination ! %s/%s --jump MASQUERADE", str_addr, str_mask, str_addr, str_mask);
|
|
|
|
|
|
|
|
|
|
nm_act_request_set_shared (req, TRUE);
|
|
|
|
|
|
|
|
|
|
if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, ip4_config, &error)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "(%s/%s): failed to start dnsmasq: %s",
|
2008-10-22 16:32:13 +00:00
|
|
|
nm_device_get_iface (self), ip_iface, error->message);
|
2008-08-15 15:34:28 +00:00
|
|
|
g_error_free (error);
|
|
|
|
|
nm_act_request_set_shared (req, FALSE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->dnsmasq_state_id = g_signal_connect (priv->dnsmasq_manager, "state-changed",
|
|
|
|
|
G_CALLBACK (dnsmasq_state_changed_cb),
|
|
|
|
|
self);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
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);
|
2009-08-05 18:03:09 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-30 13:50:42 -04:00
|
|
|
NMActRequest *act_request;
|
2008-05-29 20:58:52 +00:00
|
|
|
NMIP4Config *ip4_config = NULL;
|
2009-07-29 12:12:41 -04:00
|
|
|
NMIP6Config *ip6_config = NULL;
|
2008-10-29 14:35:25 +00:00
|
|
|
const char *iface, *method = NULL;
|
2008-05-29 20:58:52 +00:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2009-08-05 18:03:09 -04:00
|
|
|
gboolean assumed;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Get the new IP4 and IP6 configs; since this stage gets rerun
|
|
|
|
|
* when automatic configuration changes (DHCP lease renewal, new
|
|
|
|
|
* IPv6 router advertisement, etc), it's possible that only one of
|
|
|
|
|
* them will be set.
|
|
|
|
|
*/
|
|
|
|
|
act_request = nm_device_get_act_request (self);
|
|
|
|
|
|
|
|
|
|
ip4_config = g_object_get_data (G_OBJECT (act_request),
|
2007-06-11 13:36:34 +00:00
|
|
|
NM_ACT_REQUEST_IP4_CONFIG);
|
2009-07-30 13:50:42 -04:00
|
|
|
g_object_set_data (G_OBJECT (act_request),
|
|
|
|
|
NM_ACT_REQUEST_IP4_CONFIG, NULL);
|
|
|
|
|
|
|
|
|
|
ip6_config = g_object_get_data (G_OBJECT (act_request),
|
2009-07-29 12:12:41 -04:00
|
|
|
NM_ACT_REQUEST_IP6_CONFIG);
|
2009-07-30 13:50:42 -04:00
|
|
|
g_object_set_data (G_OBJECT (act_request),
|
|
|
|
|
NM_ACT_REQUEST_IP6_CONFIG, 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 */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2006-12-28 22:13:59 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
|
|
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
assumed = nm_act_request_get_assumed (priv->act_request);
|
|
|
|
|
|
2010-04-23 21:52:10 -07:00
|
|
|
if (!ip6_config && !ip4_config) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE,
|
|
|
|
|
"Activation (%s) Stage 5 of 5 (IP Configure Commit) failed (no IP configuration found)",
|
|
|
|
|
iface);
|
|
|
|
|
nm_device_state_changed (self,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
if (ip4_config && !nm_device_set_ip4_config (self, ip4_config, assumed, &reason)) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2008-05-29 20:58:52 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
if (ip6_config && !nm_device_set_ip6_config (self, ip6_config, assumed, &reason)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 5 of 5 (IP Configure Commit) IPv6 failed",
|
|
|
|
|
iface);
|
2010-04-23 21:52:10 -07:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
goto out;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
connection = nm_act_request_get_connection (nm_device_get_act_request (self));
|
2008-10-29 14:35:25 +00:00
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
if (ip4_config) {
|
|
|
|
|
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
|
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
2010-04-15 14:54:22 -07:00
|
|
|
if (s_ip4 && !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
|
2009-07-30 13:50:42 -04:00
|
|
|
if (!start_sharing (self)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IP Configure Commit) start sharing failed.", iface);
|
2009-07-30 13:50:42 -04:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2008-05-29 20:58:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE);
|
2008-05-29 20:58:52 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
|
|
|
|
|
iface);
|
2008-09-05 02:55:40 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
/* Balance IP config creation; device takes ownership in set_ip*_config() */
|
2009-07-30 13:50:42 -04:00
|
|
|
if (ip4_config)
|
|
|
|
|
g_object_unref (ip4_config);
|
2009-08-05 18:03:09 -04:00
|
|
|
if (ip6_config)
|
|
|
|
|
g_object_unref (ip6_config);
|
2008-09-05 02:55:40 +00:00
|
|
|
|
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
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self, int family)
|
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
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (family == AF_INET)
|
|
|
|
|
priv->ip4_ready = TRUE;
|
|
|
|
|
else if (family == AF_INET6)
|
|
|
|
|
priv->ip6_ready = TRUE;
|
|
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Note that these are only set FALSE at stage3, so once you've
|
|
|
|
|
* made it all the way through activation once, you can jump back
|
|
|
|
|
* into stage4 (eg, for a DHCP lease change) and not worry about
|
|
|
|
|
* needing both IPv4 and IPv6 to complete.
|
|
|
|
|
*/
|
2009-07-29 12:12:41 -04:00
|
|
|
if (!priv->ip4_ready || !priv->ip6_ready)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
activation_source_schedule (self, nm_device_activate_stage5_ip_config_commit, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE,
|
|
|
|
|
"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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-10 02:01:13 +00:00
|
|
|
nm_act_request_set_default (priv->act_request, FALSE);
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
g_object_unref (priv->act_request);
|
|
|
|
|
priv->act_request = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
static void
|
|
|
|
|
delayed_transitions_clear (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->failed_to_disconnected_id) {
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): clearing failed->disconnected transition",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-09-14 13:24:29 -07:00
|
|
|
g_source_remove (priv->failed_to_disconnected_id);
|
|
|
|
|
priv->failed_to_disconnected_id = 0;
|
|
|
|
|
}
|
|
|
|
|
if (priv->unavailable_to_disconnected_id) {
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): clearing unavailable->disconnected transition",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-09-14 13:24:29 -07:00
|
|
|
g_source_remove (priv->unavailable_to_disconnected_id);
|
|
|
|
|
priv->unavailable_to_disconnected_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
static void
|
|
|
|
|
dhcp4_cleanup (NMDevice *self, gboolean stop)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp4_config) {
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP4_CONFIG);
|
|
|
|
|
g_object_unref (priv->dhcp4_config);
|
|
|
|
|
priv->dhcp4_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp4_client) {
|
|
|
|
|
/* Stop any ongoing DHCP transaction on this device */
|
2010-01-13 18:06:05 -08:00
|
|
|
if (priv->dhcp4_state_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp4_client, priv->dhcp4_state_sigid);
|
|
|
|
|
priv->dhcp4_state_sigid = 0;
|
2010-01-13 17:59:54 -08:00
|
|
|
}
|
|
|
|
|
|
2010-01-13 18:06:05 -08:00
|
|
|
if (priv->dhcp4_timeout_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp4_client, priv->dhcp4_timeout_sigid);
|
|
|
|
|
priv->dhcp4_timeout_sigid = 0;
|
2010-01-13 17:59:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stop)
|
|
|
|
|
nm_dhcp_client_stop (priv->dhcp4_client);
|
|
|
|
|
|
|
|
|
|
g_object_unref (priv->dhcp4_client);
|
|
|
|
|
priv->dhcp4_client = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
static void
|
|
|
|
|
dhcp6_cleanup (NMDevice *self, gboolean stop)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2010-05-01 10:16:38 -07:00
|
|
|
priv->dhcp6_mode = IP6_DHCP_OPT_NONE;
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
if (priv->dhcp6_config) {
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_DHCP6_CONFIG);
|
|
|
|
|
g_object_unref (priv->dhcp6_config);
|
|
|
|
|
priv->dhcp6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp6_client) {
|
|
|
|
|
if (priv->dhcp6_state_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp6_client, priv->dhcp6_state_sigid);
|
|
|
|
|
priv->dhcp6_state_sigid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp6_timeout_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp6_client, priv->dhcp6_timeout_sigid);
|
|
|
|
|
priv->dhcp6_timeout_sigid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stop)
|
|
|
|
|
nm_dhcp_client_stop (priv->dhcp6_client);
|
|
|
|
|
|
|
|
|
|
g_object_unref (priv->dhcp6_client);
|
|
|
|
|
priv->dhcp6_client = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dnsmasq_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!priv->dnsmasq_manager)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (priv->dnsmasq_state_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dnsmasq_manager, priv->dnsmasq_state_id);
|
|
|
|
|
priv->dnsmasq_state_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_dnsmasq_manager_stop (priv->dnsmasq_manager);
|
|
|
|
|
g_object_unref (priv->dnsmasq_manager);
|
|
|
|
|
priv->dnsmasq_manager = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-03-17 20:59:54 +00:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-17 20:59:54 +00:00
|
|
|
/* Break the activation chain */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, TRUE, AF_INET);
|
|
|
|
|
activation_source_clear (self, TRUE, AF_INET6);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
/* Clear any delayed transitions */
|
|
|
|
|
delayed_transitions_clear (self);
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
dhcp4_cleanup (self, TRUE);
|
|
|
|
|
dhcp6_cleanup (self, TRUE);
|
|
|
|
|
addrconf6_cleanup (self);
|
|
|
|
|
dnsmasq_cleanup (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
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);
|
|
|
|
|
|
2008-08-14 17:45:47 +00:00
|
|
|
/* Tear down an existing activation request */
|
|
|
|
|
clear_act_request (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
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-09 08:50:35 +00:00
|
|
|
NMDevice *self = NM_DEVICE (device);
|
2008-10-11 19:57:45 +00:00
|
|
|
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
|
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
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): deactivating device (reason: %d).",
|
|
|
|
|
nm_device_get_iface (self), reason);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
nm_device_deactivate_quickly (self);
|
|
|
|
|
|
|
|
|
|
/* Take out any entries in the routing table and any IP address the device had. */
|
2009-07-29 12:12:41 -04:00
|
|
|
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
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Clean up nameservers and addresses */
|
|
|
|
|
nm_device_set_ip4_config (self, NULL, FALSE, &ignored);
|
|
|
|
|
nm_device_set_ip6_config (self, NULL, FALSE, &ignored);
|
|
|
|
|
|
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);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-16 13:18:24 +02:00
|
|
|
static gboolean
|
|
|
|
|
device_disconnect (NMDeviceInterface *device,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (NM_DEVICE (device));
|
2009-09-18 09:05:11 -07:00
|
|
|
|
2009-09-16 13:18:24 +02:00
|
|
|
priv->autoconnect_inhibit = TRUE;
|
|
|
|
|
nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-31 17:05:25 +00:00
|
|
|
static gboolean
|
2008-04-02 17:44:52 +00:00
|
|
|
check_connection_compatible (NMDeviceInterface *dev_iface,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
2007-12-31 17:05:25 +00:00
|
|
|
{
|
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
|
|
|
|
2008-04-02 17:44:52 +00:00
|
|
|
if (klass->check_connection_compatible)
|
|
|
|
|
return klass->check_connection_compatible (NM_DEVICE (dev_iface), connection, error);
|
2007-12-31 17:05:25 +00:00
|
|
|
|
2008-04-02 17:44:52 +00:00
|
|
|
return TRUE;
|
2007-12-31 17:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
static void
|
|
|
|
|
connection_secrets_updated_cb (NMActRequest *req,
|
|
|
|
|
NMConnection *connection,
|
2008-03-17 19:37:23 +00:00
|
|
|
GSList *updated_settings,
|
2008-07-01 20:21:31 +00:00
|
|
|
RequestSecretsCaller caller,
|
2007-09-11 18:02:27 +00:00
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->connection_secrets_updated)
|
2008-07-01 20:21:31 +00:00
|
|
|
NM_DEVICE_GET_CLASS (self)->connection_secrets_updated (self, connection, updated_settings, caller);
|
2007-09-11 18:02:27 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-27 04:52:03 +00:00
|
|
|
static void
|
|
|
|
|
connection_secrets_failed_cb (NMActRequest *req,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *setting_name,
|
2008-07-01 20:21:31 +00:00
|
|
|
RequestSecretsCaller caller,
|
2007-09-27 04:52:03 +00:00
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS);
|
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-11-19 16:20:47 +00:00
|
|
|
if (nm_connection_compare (connection, current_connection, NM_SETTING_COMPARE_FLAG_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
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
if (!nm_act_request_get_assumed (req)) {
|
|
|
|
|
/* 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, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
nm_device_activate_schedule_stage1_device_prepare (self);
|
|
|
|
|
} else {
|
|
|
|
|
/* If it's an assumed connection, let the device subclass short-circuit
|
|
|
|
|
* the normal connection process and just copy its IP configs from the
|
|
|
|
|
* interface.
|
|
|
|
|
*/
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (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-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
NMDHCP4Config *
|
|
|
|
|
nm_device_get_dhcp4_config (NMDevice *self)
|
|
|
|
|
{
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp4_config;
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
NMIP4Config *
|
|
|
|
|
nm_device_get_ip4_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-11 22:26:46 +00:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_config;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_set_ip4_config (NMDevice *self,
|
|
|
|
|
NMIP4Config *new_config,
|
2009-08-05 18:03:09 -04:00
|
|
|
gboolean assumed,
|
2008-11-07 13:57:39 +00:00
|
|
|
NMDeviceStateReason *reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-12-06 14:51:43 +00:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
2008-11-07 13:57:39 +00:00
|
|
|
NMIP4Config *old_config = NULL;
|
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
NMIP4ConfigCompareFlags diff = NM_IP4_COMPARE_FLAG_ALL;
|
|
|
|
|
NMNamedManager *named_mgr;
|
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);
|
2008-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, FALSE);
|
2007-12-06 14:51:43 +00:00
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-08-12 08:05:16 +00:00
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2007-02-16 11:23:49 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
old_config = priv->ip4_config;
|
2008-03-11 02:46:35 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
if (new_config && old_config)
|
|
|
|
|
diff = nm_ip4_config_diff (new_config, old_config);
|
|
|
|
|
|
|
|
|
|
/* No actual change, do nothing */
|
|
|
|
|
if (diff == NM_IP4_COMPARE_FLAG_NONE)
|
|
|
|
|
return TRUE;
|
2008-03-11 02:46:35 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
named_mgr = nm_named_manager_get ();
|
|
|
|
|
if (old_config) {
|
|
|
|
|
/* Remove any previous IP4 Config from the named manager */
|
|
|
|
|
nm_named_manager_remove_ip4_config (named_mgr, ip_iface, old_config);
|
|
|
|
|
g_object_unref (old_config);
|
2007-02-16 11:23:49 +00:00
|
|
|
priv->ip4_config = NULL;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
if (new_config) {
|
|
|
|
|
priv->ip4_config = g_object_ref (new_config);
|
2007-12-06 14:51:43 +00:00
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
/* Don't touch the device's actual IP config if the connection is
|
|
|
|
|
* assumed when NM starts.
|
|
|
|
|
*/
|
|
|
|
|
if (!assumed)
|
|
|
|
|
success = nm_system_apply_ip4_config (ip_iface, new_config, nm_device_get_priority (self), diff);
|
|
|
|
|
|
|
|
|
|
if (success || assumed) {
|
2008-11-07 13:57:39 +00:00
|
|
|
/* Export over D-Bus */
|
|
|
|
|
if (!nm_ip4_config_get_dbus_path (new_config))
|
|
|
|
|
nm_ip4_config_export (new_config);
|
2007-12-06 14:51:43 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
/* Add the DNS information to the named manager */
|
|
|
|
|
nm_named_manager_add_ip4_config (named_mgr, ip_iface, new_config, NM_NAMED_IP_CONFIG_TYPE_DEFAULT);
|
2008-09-05 02:55:40 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
nm_device_update_ip4_address (self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (named_mgr);
|
2007-12-06 14:51:43 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_address;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_update_ip4_address (NMDevice *self)
|
|
|
|
|
{
|
2008-03-13 19:31:08 +00:00
|
|
|
struct ifreq req;
|
|
|
|
|
guint32 new_address;
|
2008-10-30 05:52:20 +00:00
|
|
|
int fd;
|
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) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_IP4, "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-10-22 16:32:13 +00:00
|
|
|
strncpy (req.ifr_name, nm_device_get_ip_iface (self), IFNAMSIZ);
|
2008-10-30 05:52:20 +00:00
|
|
|
if (ioctl (fd, SIOCGIFADDR, &req) == 0) {
|
|
|
|
|
new_address = ((struct sockaddr_in *)(&req.ifr_addr))->sin_addr.s_addr;
|
|
|
|
|
if (new_address != nm_device_get_ip4_address (self))
|
2009-07-07 14:34:01 -04:00
|
|
|
NM_DEVICE_GET_PRIVATE (self)->ip4_address = new_address;
|
2008-10-30 05:52:20 +00:00
|
|
|
}
|
2008-03-13 19:31:08 +00:00
|
|
|
close (fd);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_set_ip6_config (NMDevice *self,
|
|
|
|
|
NMIP6Config *new_config,
|
2009-08-05 18:03:09 -04:00
|
|
|
gboolean assumed,
|
2009-07-29 12:12:41 -04:00
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
NMIP6Config *old_config = NULL;
|
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
NMIP6ConfigCompareFlags diff = NM_IP6_COMPARE_FLAG_ALL;
|
|
|
|
|
NMNamedManager *named_mgr;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
g_return_val_if_fail (reason != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
|
|
|
|
old_config = priv->ip6_config;
|
|
|
|
|
|
|
|
|
|
if (new_config && old_config)
|
|
|
|
|
diff = nm_ip6_config_diff (new_config, old_config);
|
|
|
|
|
|
|
|
|
|
/* No actual change, do nothing */
|
|
|
|
|
if (diff == NM_IP6_COMPARE_FLAG_NONE)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
named_mgr = nm_named_manager_get ();
|
|
|
|
|
if (old_config) {
|
|
|
|
|
/* Remove any previous IP6 Config from the named manager */
|
|
|
|
|
nm_named_manager_remove_ip6_config (named_mgr, ip_iface, old_config);
|
|
|
|
|
g_object_unref (old_config);
|
|
|
|
|
priv->ip6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_config) {
|
|
|
|
|
priv->ip6_config = g_object_ref (new_config);
|
|
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
/* Don't touch the device's actual IP config if the connection is
|
|
|
|
|
* assumed when NM starts.
|
|
|
|
|
*/
|
|
|
|
|
if (!assumed)
|
|
|
|
|
success = nm_system_apply_ip6_config (ip_iface, new_config, nm_device_get_priority (self), diff);
|
|
|
|
|
|
|
|
|
|
if (success || assumed) {
|
2009-07-29 12:12:41 -04:00
|
|
|
/* Export over D-Bus */
|
|
|
|
|
if (!nm_ip6_config_get_dbus_path (new_config))
|
|
|
|
|
nm_ip6_config_export (new_config);
|
|
|
|
|
|
|
|
|
|
/* Add the DNS information to the named manager */
|
|
|
|
|
nm_named_manager_add_ip6_config (named_mgr, ip_iface, new_config, NM_NAMED_IP_CONFIG_TYPE_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_object_unref (named_mgr);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_INTERFACE_IP6_CONFIG);
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
NMDHCP6Config *
|
|
|
|
|
nm_device_get_dhcp6_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp6_config;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
NMIP6Config *
|
|
|
|
|
nm_device_get_ip6_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip6_config;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
static gboolean
|
2005-12-31 08:21:24 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2008-05-14 01:55:49 +00:00
|
|
|
gboolean
|
2008-08-18 18:29:47 +00:00
|
|
|
nm_device_hw_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
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
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (nm_device_hw_is_up (self))
|
|
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): bringing up device.", nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->hw_bring_up) {
|
2008-08-18 18:29:47 +00:00
|
|
|
success = NM_DEVICE_GET_CLASS (self)->hw_bring_up (self, no_firmware);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (!success)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wait for the device to come up if requested */
|
2008-08-18 18:29:47 +00:00
|
|
|
while (block && !nm_device_hw_is_up (self) && (tries++ < 50))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
g_usleep (200);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (!nm_device_hw_is_up (self)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_HW, "(%s): device not up after timeout!", nm_device_get_iface (self));
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
/* Can only get HW address of some devices when they are up */
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->update_hw_address)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->update_hw_address (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
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
nm_device_update_ip4_address (self);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-14 01:55:49 +00:00
|
|
|
void
|
2008-08-18 18:29:47 +00:00
|
|
|
nm_device_hw_take_down (NMDevice *self, gboolean block)
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
{
|
|
|
|
|
guint32 tries = 0;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
if (!nm_device_hw_is_up (self))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): taking down device.", nm_device_get_iface (self));
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->hw_take_down)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->hw_take_down (self);
|
|
|
|
|
|
|
|
|
|
/* Wait for the device to come up if requested */
|
2008-08-18 18:29:47 +00:00
|
|
|
while (block && nm_device_hw_is_up (self) && (tries++ < 50))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
g_usleep (200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-08-18 18:29:47 +00:00
|
|
|
nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
{
|
2008-08-18 18:29:47 +00:00
|
|
|
gboolean success = FALSE;
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
if (!nm_device_hw_bring_up (self, block, no_firmware))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (nm_device_is_up (self))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): preparing device.", nm_device_get_iface (self));
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->bring_up)
|
2007-03-12 04:49:29 +00:00
|
|
|
success = NM_DEVICE_GET_CLASS (self)->bring_up (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
return success;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-10-11 19:57:45 +00:00
|
|
|
static void
|
|
|
|
|
nm_device_take_down (NMDevice *self, gboolean block, NMDeviceStateReason reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
2008-05-14 02:56:01 +00:00
|
|
|
if (nm_device_get_act_request (self))
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (self), reason);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (nm_device_is_up (self)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): cleaning up...", nm_device_get_iface (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
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->take_down)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->take_down (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
|
|
|
|
2008-08-18 18:29:47 +00:00
|
|
|
nm_device_hw_take_down (self, block);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-07-07 14:34:01 -04:00
|
|
|
dispose (GObject *object)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-08-03 17:15:03 -04:00
|
|
|
gboolean take_down = TRUE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
if (priv->disposed || !priv->initialized)
|
2007-08-26 15:55:27 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv->disposed = TRUE;
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
/* Don't down can-assume-connection capable devices that are activated with
|
|
|
|
|
* a connection that can be assumed.
|
|
|
|
|
*/
|
2009-09-28 10:49:55 -07:00
|
|
|
if ( nm_device_interface_can_assume_connection (NM_DEVICE_INTERFACE (self))
|
|
|
|
|
&& (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) {
|
2009-08-03 17:15:03 -04:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
|
|
|
|
const char *method = NULL;
|
|
|
|
|
|
|
|
|
|
/* Only system connections can be left up */
|
|
|
|
|
connection = nm_act_request_get_connection (priv->act_request);
|
|
|
|
|
if ( connection
|
|
|
|
|
&& (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)) {
|
|
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Only static or DHCP IPv4 connections can be left up.
|
|
|
|
|
* All IPv6 connections can be left up, so we don't have
|
|
|
|
|
* to check that.
|
|
|
|
|
*/
|
2009-08-03 17:15:03 -04:00
|
|
|
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
|
|
|
|
g_assert (s_ip4);
|
|
|
|
|
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
if ( !method
|
|
|
|
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|
|
|
|
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
|
|
|
|
|
take_down = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
/* Clear any delayed transitions */
|
|
|
|
|
delayed_transitions_clear (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
/* Clean up and stop DHCP */
|
|
|
|
|
dhcp4_cleanup (self, take_down);
|
2010-01-14 00:45:10 -08:00
|
|
|
dhcp6_cleanup (self, take_down);
|
|
|
|
|
addrconf6_cleanup (self);
|
|
|
|
|
dnsmasq_cleanup (self);
|
2010-01-13 17:59:54 -08:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
/* Take the device itself down and clear its IPv4 configuration */
|
2009-08-03 17:15:03 -04:00
|
|
|
if (priv->managed && take_down) {
|
2008-10-11 19:57:45 +00:00
|
|
|
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
|
2008-07-11 10:28:53 +00:00
|
|
|
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_take_down (self, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
|
2009-08-05 18:03:09 -04:00
|
|
|
nm_device_set_ip4_config (self, NULL, FALSE, &ignored);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, TRUE, AF_INET);
|
|
|
|
|
activation_source_clear (self, TRUE, AF_INET6);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
clear_act_request (self);
|
2008-05-29 20:58:52 +00:00
|
|
|
|
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
|
2009-07-07 14:34:01 -04:00
|
|
|
finalize (GObject *object)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
g_object_unref (priv->dhcp_manager);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
g_free (priv->udi);
|
|
|
|
|
g_free (priv->iface);
|
|
|
|
|
g_free (priv->ip_iface);
|
|
|
|
|
g_free (priv->driver);
|
|
|
|
|
g_free (priv->type_desc);
|
2009-07-15 13:53:49 -04:00
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
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);
|
2010-04-21 14:58:25 -07:00
|
|
|
priv->ifindex = 0;
|
2007-11-29 14:38:07 +00:00
|
|
|
priv->iface = g_value_dup_string (value);
|
2010-04-21 14:58:25 -07:00
|
|
|
if (priv->iface) {
|
|
|
|
|
priv->ifindex = nm_netlink_iface_to_index (priv->iface);
|
|
|
|
|
if (priv->ifindex < 0) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", priv->iface);
|
|
|
|
|
}
|
|
|
|
|
}
|
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;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_MANAGED:
|
|
|
|
|
priv->managed = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2009-07-07 22:25:58 -04:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE:
|
|
|
|
|
g_return_if_fail (priv->type == NM_DEVICE_TYPE_UNKNOWN);
|
|
|
|
|
priv->type = g_value_get_uint (value);
|
|
|
|
|
break;
|
2009-07-07 14:24:12 -04:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_TYPE_DESC:
|
|
|
|
|
g_free (priv->type_desc);
|
|
|
|
|
priv->type_desc = g_value_dup_string (value);
|
|
|
|
|
break;
|
2010-03-25 11:36:19 -07:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_RFKILL_TYPE:
|
|
|
|
|
priv->rfkill_type = g_value_get_uint (value);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
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)
|
|
|
|
|
{
|
2008-07-17 17:04:13 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-03-11 22:26:46 +00:00
|
|
|
NMDeviceState state;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2008-07-17 17:04:13 +00:00
|
|
|
state = nm_device_get_state (self);
|
|
|
|
|
|
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;
|
2010-04-21 14:58:25 -07:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_IFINDEX:
|
|
|
|
|
g_value_set_int (value, priv->ifindex);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
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:
|
2009-03-23 14:38:33 -04:00
|
|
|
if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG)) {
|
|
|
|
|
if (priv->ip4_config) {
|
|
|
|
|
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_value_set_boxed (value, "/");
|
2007-02-16 11:23:49 +00:00
|
|
|
break;
|
2008-07-17 17:04:13 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_DHCP4_CONFIG:
|
|
|
|
|
if ( ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
|
2010-01-13 17:59:54 -08:00
|
|
|
&& priv->dhcp4_client)
|
2008-08-07 15:26:32 +00:00
|
|
|
g_value_set_boxed (value, nm_dhcp4_config_get_dbus_path (priv->dhcp4_config));
|
2008-07-17 17:04:13 +00:00
|
|
|
else
|
2008-08-07 15:26:32 +00:00
|
|
|
g_value_set_boxed (value, "/");
|
2008-07-17 17:04:13 +00:00
|
|
|
break;
|
2009-07-29 12:12:41 -04:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_IP6_CONFIG:
|
|
|
|
|
if ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG)) {
|
|
|
|
|
if (priv->ip6_config) {
|
|
|
|
|
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
2010-01-14 00:45:10 -08:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_DHCP6_CONFIG:
|
|
|
|
|
if ( ((state == NM_DEVICE_STATE_ACTIVATED) || (state == NM_DEVICE_STATE_IP_CONFIG))
|
|
|
|
|
&& priv->dhcp6_client)
|
|
|
|
|
g_value_set_boxed (value, nm_dhcp6_config_get_dbus_path (priv->dhcp6_config));
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
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;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_MANAGED:
|
|
|
|
|
g_value_set_boolean (value, priv->managed);
|
|
|
|
|
break;
|
2009-07-07 14:24:12 -04:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_TYPE_DESC:
|
|
|
|
|
g_value_set_string (value, priv->type_desc);
|
|
|
|
|
break;
|
2010-03-25 11:36:19 -07:00
|
|
|
case NM_DEVICE_INTERFACE_PROP_RFKILL_TYPE:
|
|
|
|
|
g_value_set_uint (value, priv->rfkill_type);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
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 */
|
2009-07-07 14:34:01 -04:00
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
object_class->finalize = 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
|
|
|
|
|
|
|
|
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;
|
2009-07-29 12:12:41 -04:00
|
|
|
klass->act_stage3_ip4_config_start = real_act_stage3_ip4_config_start;
|
|
|
|
|
klass->act_stage3_ip6_config_start = real_act_stage3_ip6_config_start;
|
2006-01-03 17:07:07 +00:00
|
|
|
klass->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
|
2009-07-29 12:12:41 -04:00
|
|
|
klass->act_stage4_get_ip6_config = real_act_stage4_get_ip6_config;
|
|
|
|
|
klass->act_stage4_ip4_config_timeout = real_act_stage4_ip4_config_timeout;
|
|
|
|
|
klass->act_stage4_ip6_config_timeout = real_act_stage4_ip6_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);
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_IFINDEX,
|
|
|
|
|
NM_DEVICE_INTERFACE_IFINDEX);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
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);
|
|
|
|
|
|
2008-07-17 17:04:13 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_DHCP4_CONFIG,
|
|
|
|
|
NM_DEVICE_INTERFACE_DHCP4_CONFIG);
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_IP6_CONFIG,
|
|
|
|
|
NM_DEVICE_INTERFACE_IP6_CONFIG);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_DHCP6_CONFIG,
|
|
|
|
|
NM_DEVICE_INTERFACE_DHCP6_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);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_MANAGED,
|
|
|
|
|
NM_DEVICE_INTERFACE_MANAGED);
|
2009-07-07 14:24:12 -04:00
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_TYPE_DESC,
|
|
|
|
|
NM_DEVICE_INTERFACE_TYPE_DESC);
|
2009-07-15 17:22:10 -04:00
|
|
|
|
2010-03-25 11:36:19 -07:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
|
NM_DEVICE_INTERFACE_PROP_RFKILL_TYPE,
|
|
|
|
|
NM_DEVICE_INTERFACE_RFKILL_TYPE);
|
|
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
signals[AUTOCONNECT_ALLOWED] =
|
|
|
|
|
g_signal_new ("autoconnect-allowed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
autoconnect_allowed_accumulator, NULL,
|
|
|
|
|
_nm_marshal_BOOLEAN__VOID,
|
|
|
|
|
G_TYPE_BOOLEAN, 0);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-17 23:04:34 +00:00
|
|
|
static gboolean
|
|
|
|
|
failed_to_disconnected (gpointer user_data)
|
|
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): running failed->disconnected transition",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-07-07 14:34:01 -04:00
|
|
|
priv->failed_to_disconnected_id = 0;
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
|
2008-04-17 23:04:34 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
static gboolean
|
|
|
|
|
unavailable_to_disconnected (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): running unavailable->disconnected transition",
|
|
|
|
|
nm_device_get_iface (self));
|
2009-09-14 13:24:29 -07:00
|
|
|
priv->unavailable_to_disconnected_id = 0;
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
void
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (NMDevice *device,
|
|
|
|
|
NMDeviceState state,
|
|
|
|
|
NMDeviceStateReason reason)
|
2007-02-05 12:14:09 +00:00
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (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
|
|
|
NMDeviceState old_state;
|
2008-04-27 14:30:06 +00:00
|
|
|
NMActRequest *req;
|
2008-08-18 18:29:47 +00:00
|
|
|
gboolean no_firmware = FALSE;
|
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
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
if (priv->state == state)
|
2008-03-24 02:56:25 +00:00
|
|
|
return;
|
|
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
old_state = priv->state;
|
|
|
|
|
priv->state = state;
|
2009-05-12 12:05:47 -04:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): device state change: %d -> %d (reason %d)",
|
|
|
|
|
nm_device_get_iface (device), old_state, state, reason);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
/* Clear any delayed transitions */
|
|
|
|
|
delayed_transitions_clear (device);
|
2007-06-13 11:58:25 +00:00
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
/* Cache the activation request for the dispatcher */
|
|
|
|
|
req = priv->act_request ? g_object_ref (priv->act_request) : NULL;
|
|
|
|
|
|
2008-04-17 23:04:34 +00:00
|
|
|
/* Handle the new state here; but anything that could trigger
|
|
|
|
|
* another state change should be done below.
|
|
|
|
|
*/
|
2007-02-05 12:14:09 +00:00
|
|
|
switch (state) {
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
case NM_DEVICE_STATE_UNMANAGED:
|
|
|
|
|
if (old_state > NM_DEVICE_STATE_UNMANAGED)
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_take_down (device, TRUE, reason);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
break;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
2008-08-18 18:29:47 +00:00
|
|
|
if (old_state == NM_DEVICE_STATE_UNMANAGED) {
|
2010-04-07 12:31:39 -07:00
|
|
|
if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "%s: firmware may be missing.", nm_device_get_iface (device));
|
|
|
|
|
}
|
2008-08-18 18:29:47 +00:00
|
|
|
}
|
2009-08-05 18:03:09 -04:00
|
|
|
/* Ensure the device gets deactivated in response to stuff like
|
|
|
|
|
* carrier changes or rfkill. But don't deactivate devices that are
|
|
|
|
|
* about to assume a connection since that defeats the purpose of
|
|
|
|
|
* assuming the device's existing connection.
|
|
|
|
|
*/
|
|
|
|
|
if (reason != NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED)
|
|
|
|
|
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device), reason);
|
|
|
|
|
break;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
if (old_state != NM_DEVICE_STATE_UNAVAILABLE)
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device), reason);
|
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
|
|
|
break;
|
2008-04-17 23:04:34 +00:00
|
|
|
default:
|
2009-09-16 13:18:24 +02:00
|
|
|
priv->autoconnect_inhibit = FALSE;
|
2008-04-17 23:04:34 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_INTERFACE_STATE);
|
2009-05-12 12:05:47 -04:00
|
|
|
g_signal_emit_by_name (device, "state-changed", state, old_state, reason);
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
/* Post-process the event after internal notification */
|
|
|
|
|
|
2008-04-17 23:04:34 +00:00
|
|
|
switch (state) {
|
2009-09-14 13:24:29 -07:00
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
|
|
|
|
/* If the device can activate now (ie, it's got a carrier, the supplicant
|
|
|
|
|
* is active, or whatever) schedule a delayed transition to DISCONNECTED
|
|
|
|
|
* to get things rolling. The device can't transition immediately becuase
|
|
|
|
|
* we can't change states again from the state handler for a variety of
|
|
|
|
|
* reasons.
|
|
|
|
|
*/
|
2010-04-07 16:41:44 -07:00
|
|
|
if (nm_device_is_available (device)) {
|
2010-04-08 15:51:54 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): device is available, will transition to DISCONNECTED",
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_device_get_iface (device));
|
2009-09-14 13:24:29 -07:00
|
|
|
priv->unavailable_to_disconnected_id = g_idle_add (unavailable_to_disconnected, device);
|
2010-04-08 15:51:54 -07:00
|
|
|
} else {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): device not yet available for transition to DISCONNECTED",
|
|
|
|
|
nm_device_get_iface (device));
|
2010-04-07 16:41:44 -07:00
|
|
|
}
|
2009-09-14 13:24:29 -07:00
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
case NM_DEVICE_STATE_ACTIVATED:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) successful, device activated.",
|
|
|
|
|
nm_device_get_iface (device));
|
2008-04-27 14:30:06 +00:00
|
|
|
nm_utils_call_dispatcher ("up", nm_act_request_get_connection (req), device, NULL);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_STATE_FAILED:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_DEVICE, "Activation (%s) failed.", nm_device_get_iface (device));
|
2009-09-14 13:24:29 -07:00
|
|
|
/* Schedule the transition to DISCONNECTED. The device can't transition
|
|
|
|
|
* immediately becuase we can't change states again from the state
|
|
|
|
|
* handler for a variety of reasons.
|
|
|
|
|
*/
|
2008-04-27 14:30:06 +00:00
|
|
|
priv->failed_to_disconnected_id = g_idle_add (failed_to_disconnected, device);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2008-04-27 14:30:06 +00:00
|
|
|
|
|
|
|
|
if (old_state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
nm_utils_call_dispatcher ("down", nm_act_request_get_connection (req), device, NULL);
|
|
|
|
|
|
|
|
|
|
/* Dispose of the cached activation request */
|
|
|
|
|
if (req)
|
|
|
|
|
g_object_unref (req);
|
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
|
|
|
}
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_get_managed (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->managed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_set_managed (NMDevice *device,
|
|
|
|
|
gboolean managed,
|
|
|
|
|
NMDeviceStateReason reason)
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
2008-04-22 19:07:00 +00:00
|
|
|
if (priv->managed == managed)
|
|
|
|
|
return;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2008-04-22 19:07:00 +00:00
|
|
|
priv->managed = managed;
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): now %s",
|
|
|
|
|
nm_device_get_iface (device),
|
|
|
|
|
managed ? "managed" : "unmanaged");
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2008-04-22 19:07:00 +00:00
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_INTERFACE_MANAGED);
|
|
|
|
|
|
|
|
|
|
/* If now managed, jump to unavailable */
|
2008-07-11 10:28:53 +00:00
|
|
|
if (managed)
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, reason);
|
2008-07-11 10:28:53 +00:00
|
|
|
else
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, reason);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static gboolean
|
2009-08-03 17:15:03 -04:00
|
|
|
spec_match_list (NMDeviceInterface *device, const GSList *specs)
|
2009-06-11 00:39:12 -04:00
|
|
|
{
|
|
|
|
|
NMDevice *self;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (device != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
self = NM_DEVICE (device);
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->spec_match_list)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->spec_match_list (self, specs);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
static NMConnection *
|
|
|
|
|
connection_match_config (NMDeviceInterface *device, const GSList *connections)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (device != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (device)->connection_match_config)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (device)->connection_match_config (NM_DEVICE (device), connections);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 13:48:28 -04:00
|
|
|
void
|
2009-07-15 13:53:49 -04:00
|
|
|
nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout)
|
2009-07-15 13:48:28 -04:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
NM_DEVICE_GET_PRIVATE (device)->dhcp_timeout = timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 13:53:49 -04:00
|
|
|
void
|
|
|
|
|
nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp_anycast_address) {
|
|
|
|
|
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
|
|
|
|
priv->dhcp_anycast_address = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addr) {
|
|
|
|
|
priv->dhcp_anycast_address = g_byte_array_sized_new (ETH_ALEN);
|
|
|
|
|
g_byte_array_append (priv->dhcp_anycast_address, addr, ETH_ALEN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-16 13:18:24 +02:00
|
|
|
void
|
|
|
|
|
nm_device_clear_autoconnect_inhibit (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
g_return_if_fail (priv);
|
|
|
|
|
priv->autoconnect_inhibit = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|