2008-10-11 19:57:45 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2008-11-03 04:13:42 +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.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2007 - 2008 Novell, Inc.
|
2010-04-21 14:58:25 -07:00
|
|
|
* Copyright (C) 2007 - 2010 Red Hat, Inc.
|
2008-11-03 04:13:42 +00:00
|
|
|
*/
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
#include <dbus/dbus-glib.h>
|
|
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
#include "nm-marshal.h"
|
2008-03-12 18:31:00 +00:00
|
|
|
#include "nm-setting-connection.h"
|
2007-02-05 12:14:09 +00:00
|
|
|
#include "nm-device-interface.h"
|
2010-04-07 12:31:39 -07:00
|
|
|
#include "nm-logging.h"
|
2009-07-30 10:39:57 -04:00
|
|
|
#include "nm-properties-changed-signal.h"
|
2010-03-25 11:36:19 -07:00
|
|
|
#include "nm-rfkill.h"
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
static void impl_device_disconnect (NMDeviceInterface *device,
|
|
|
|
|
DBusGMethodInvocation *context);
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-device-interface-glue.h"
|
|
|
|
|
|
2007-09-09 22:18:42 +00:00
|
|
|
GQuark
|
|
|
|
|
nm_device_interface_error_quark (void)
|
|
|
|
|
{
|
2007-12-27 08:06:27 +00:00
|
|
|
static GQuark quark = 0;
|
|
|
|
|
if (!quark)
|
|
|
|
|
quark = g_quark_from_static_string ("nm-device-interface-error");
|
|
|
|
|
return quark;
|
2007-09-09 22:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This should really be standard. */
|
|
|
|
|
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
|
nm_device_interface_error_get_type (void)
|
|
|
|
|
{
|
|
|
|
|
static GType etype = 0;
|
|
|
|
|
|
|
|
|
|
if (etype == 0) {
|
|
|
|
|
static const GEnumValue values[] = {
|
2007-12-27 08:06:27 +00:00
|
|
|
/* Connection is already activating. */
|
|
|
|
|
ENUM_ENTRY (NM_DEVICE_INTERFACE_ERROR_CONNECTION_ACTIVATING, "ConnectionActivating"),
|
|
|
|
|
/* Connection is invalid for this device. */
|
|
|
|
|
ENUM_ENTRY (NM_DEVICE_INTERFACE_ERROR_CONNECTION_INVALID, "ConnectionInvalid"),
|
2009-09-18 09:05:11 -07:00
|
|
|
/* Operation could not be performed because the device is not active. */
|
|
|
|
|
ENUM_ENTRY (NM_DEVICE_INTERFACE_ERROR_NOT_ACTIVE, "NotActive"),
|
2007-09-09 22:18:42 +00:00
|
|
|
{ 0, 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
etype = g_enum_register_static ("NMDeviceInterfaceError", values);
|
|
|
|
|
}
|
|
|
|
|
return etype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
nm_device_interface_init (gpointer g_iface)
|
|
|
|
|
{
|
|
|
|
|
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
|
|
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Properties */
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_INTERFACE_UDI,
|
2009-06-11 00:39:12 -04:00
|
|
|
"UDI",
|
|
|
|
|
"Unique Device Identifier",
|
2007-02-05 12:14:09 +00:00
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_INTERFACE_IFACE,
|
|
|
|
|
"Interface",
|
|
|
|
|
"Interface",
|
|
|
|
|
NULL,
|
2010-06-10 10:16:39 -07:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_INTERFACE_IP_IFACE,
|
|
|
|
|
"IP Interface",
|
|
|
|
|
"IP Interface",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_INTERFACE_DRIVER,
|
|
|
|
|
"Driver",
|
|
|
|
|
"Driver",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_INTERFACE_CAPABILITIES,
|
|
|
|
|
"Capabilities",
|
|
|
|
|
"Capabilities",
|
|
|
|
|
0, G_MAXUINT32, NM_DEVICE_CAP_NONE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_INTERFACE_IP4_ADDRESS,
|
|
|
|
|
"IP4 address",
|
|
|
|
|
"IP4 address",
|
|
|
|
|
0, G_MAXUINT32, 0, /* FIXME */
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2007-02-16 11:23:49 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
2008-10-06 19:30:59 +00:00
|
|
|
g_param_spec_boxed (NM_DEVICE_INTERFACE_IP4_CONFIG,
|
2007-02-16 11:23:49 +00:00
|
|
|
"IP4 Config",
|
|
|
|
|
"IP4 Config",
|
2008-10-06 19:30:59 +00:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2007-02-16 11:23:49 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2008-07-17 17:04:13 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
2008-08-07 15:26:32 +00:00
|
|
|
g_param_spec_boxed (NM_DEVICE_INTERFACE_DHCP4_CONFIG,
|
2008-07-17 17:04:13 +00:00
|
|
|
"DHCP4 Config",
|
|
|
|
|
"DHCP4 Config",
|
2008-08-07 15:26:32 +00:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2008-07-17 17:04:13 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_INTERFACE_IP6_CONFIG,
|
|
|
|
|
"IP6 Config",
|
|
|
|
|
"IP6 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_INTERFACE_DHCP6_CONFIG,
|
|
|
|
|
"DHCP6 Config",
|
|
|
|
|
"DHCP6 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_INTERFACE_STATE,
|
|
|
|
|
"State",
|
|
|
|
|
"State",
|
|
|
|
|
0, G_MAXUINT32, NM_DEVICE_STATE_UNKNOWN,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_INTERFACE_DEVICE_TYPE,
|
|
|
|
|
"DeviceType",
|
|
|
|
|
"DeviceType",
|
2008-06-10 15:54:23 +00:00
|
|
|
0, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN,
|
2009-11-04 10:42:21 -08:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
|
2007-02-05 12:14:09 +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
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface, g_param_spec_boolean (NM_DEVICE_INTERFACE_MANAGED,
|
|
|
|
|
"Managed",
|
|
|
|
|
"Managed",
|
2009-06-11 00:39:12 -04:00
|
|
|
FALSE,
|
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_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2010-05-25 10:52:25 -07:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface, g_param_spec_boolean (NM_DEVICE_INTERFACE_FIRMWARE_MISSING,
|
|
|
|
|
"FirmwareMissing",
|
|
|
|
|
"Firmware missing",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2009-07-07 14:24:12 -04:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_INTERFACE_TYPE_DESC,
|
|
|
|
|
"Type Description",
|
|
|
|
|
"Device type description",
|
|
|
|
|
NULL,
|
2009-07-30 10:39:57 -04:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
|
2009-07-07 14:24:12 -04:00
|
|
|
|
2010-03-25 11:36:19 -07:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface, g_param_spec_uint (NM_DEVICE_INTERFACE_RFKILL_TYPE,
|
|
|
|
|
"Rfkill Type",
|
|
|
|
|
"Type of rfkill switch (if any) supported by this device",
|
|
|
|
|
RFKILL_TYPE_WLAN,
|
|
|
|
|
RFKILL_TYPE_MAX,
|
|
|
|
|
RFKILL_TYPE_UNKNOWN,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT));
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
g_object_interface_install_property
|
|
|
|
|
(g_iface,
|
|
|
|
|
g_param_spec_int (NM_DEVICE_INTERFACE_IFINDEX,
|
|
|
|
|
"Ifindex",
|
|
|
|
|
"Ifindex",
|
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
|
G_PARAM_READABLE | NM_PROPERTY_PARAM_NO_EXPORT));
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
/* Signals */
|
2007-02-08 15:34:26 +00:00
|
|
|
g_signal_new ("state-changed",
|
2007-02-05 12:14:09 +00:00
|
|
|
iface_type,
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDeviceInterface, state_changed),
|
|
|
|
|
NULL, NULL,
|
2008-08-26 09:34:31 +00:00
|
|
|
_nm_marshal_VOID__UINT_UINT_UINT,
|
2008-07-11 10:28:53 +00:00
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
|
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
g_signal_new (NM_DEVICE_INTERFACE_DISCONNECT_REQUEST,
|
|
|
|
|
iface_type,
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
0, NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__POINTER,
|
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
dbus_g_object_type_install_info (iface_type,
|
|
|
|
|
&dbus_glib_nm_device_interface_object_info);
|
|
|
|
|
|
2007-12-27 08:06:27 +00:00
|
|
|
dbus_g_error_domain_register (NM_DEVICE_INTERFACE_ERROR,
|
|
|
|
|
NULL,
|
|
|
|
|
NM_TYPE_DEVICE_INTERFACE_ERROR);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
initialized = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
|
nm_device_interface_get_type (void)
|
|
|
|
|
{
|
|
|
|
|
static GType device_interface_type = 0;
|
|
|
|
|
|
|
|
|
|
if (!device_interface_type) {
|
|
|
|
|
const GTypeInfo device_interface_info = {
|
|
|
|
|
sizeof (NMDeviceInterface), /* class_size */
|
|
|
|
|
nm_device_interface_init, /* base_init */
|
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
|
NULL, /* class_data */
|
|
|
|
|
0,
|
|
|
|
|
0, /* n_preallocs */
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
device_interface_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
|
|
|
"NMDeviceInterface",
|
|
|
|
|
&device_interface_info, 0);
|
|
|
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (device_interface_type, G_TYPE_OBJECT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return device_interface_type;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-26 15:38:51 +00:00
|
|
|
/* FIXME: This should be public and nm_device_get_iface() should be removed. */
|
2008-03-14 22:05:17 +00:00
|
|
|
static char *
|
2007-09-26 15:38:51 +00:00
|
|
|
nm_device_interface_get_iface (NMDeviceInterface *device)
|
|
|
|
|
{
|
2008-03-14 22:05:17 +00:00
|
|
|
char *iface = NULL;
|
2007-09-26 15:38:51 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), NULL);
|
|
|
|
|
|
|
|
|
|
g_object_get (device, NM_DEVICE_INTERFACE_IFACE, &iface, NULL);
|
|
|
|
|
|
|
|
|
|
return iface;
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-31 17:05:25 +00:00
|
|
|
gboolean
|
2008-04-02 17:44:52 +00:00
|
|
|
nm_device_interface_check_connection_compatible (NMDeviceInterface *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
2007-12-31 17:05:25 +00:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
2008-04-02 17:44:52 +00:00
|
|
|
g_return_val_if_fail (error != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (*error == NULL, FALSE);
|
2007-12-31 17:05:25 +00:00
|
|
|
|
2008-04-02 17:44:52 +00:00
|
|
|
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->check_connection_compatible)
|
|
|
|
|
return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->check_connection_compatible (device, connection, error);
|
|
|
|
|
return TRUE;
|
2007-12-31 17:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_interface_activate (NMDeviceInterface *device,
|
2007-12-27 08:06:27 +00:00
|
|
|
NMActRequest *req,
|
|
|
|
|
GError **error)
|
2007-05-07 15:17:45 +00:00
|
|
|
{
|
2007-12-27 08:06:27 +00:00
|
|
|
gboolean success;
|
2008-03-12 18:31:00 +00:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingConnection *s_con;
|
2008-03-14 22:05:17 +00:00
|
|
|
char *iface;
|
2007-12-27 08:06:27 +00:00
|
|
|
|
2007-10-01 15:38:39 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
|
|
|
|
|
|
2008-03-12 18:31:00 +00:00
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
|
2008-03-14 22:05:17 +00:00
|
|
|
iface = nm_device_interface_get_iface (device);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) starting connection '%s'", iface,
|
|
|
|
|
nm_setting_connection_get_id (s_con));
|
2008-03-14 22:05:17 +00:00
|
|
|
g_free (iface);
|
|
|
|
|
|
2007-12-27 08:06:27 +00:00
|
|
|
success = NM_DEVICE_INTERFACE_GET_INTERFACE (device)->activate (device, req, error);
|
|
|
|
|
if (!success)
|
|
|
|
|
g_assert (*error);
|
|
|
|
|
|
|
|
|
|
return success;
|
2007-05-07 15:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-16 13:18:24 +02:00
|
|
|
gboolean
|
|
|
|
|
nm_device_interface_disconnect (NMDeviceInterface *device,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2009-09-18 09:05:11 -07:00
|
|
|
gboolean success = FALSE;
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2009-09-18 09:05:11 -07:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
switch (nm_device_interface_get_state (device)) {
|
|
|
|
|
case NM_DEVICE_STATE_UNKNOWN:
|
|
|
|
|
case NM_DEVICE_STATE_UNMANAGED:
|
|
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
|
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_DEVICE_INTERFACE_ERROR,
|
|
|
|
|
NM_DEVICE_INTERFACE_ERROR_NOT_ACTIVE,
|
|
|
|
|
"Cannot disconnect an inactive device.");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
success = NM_DEVICE_INTERFACE_GET_INTERFACE (device)->disconnect (device, error);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2009-09-18 09:05:11 -07:00
|
|
|
return success;
|
|
|
|
|
}
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2010-06-04 00:42:10 -07:00
|
|
|
static void
|
2009-09-16 13:18:24 +02:00
|
|
|
impl_device_disconnect (NMDeviceInterface *device,
|
2010-06-04 00:42:10 -07:00
|
|
|
DBusGMethodInvocation *context)
|
2009-09-16 13:18:24 +02:00
|
|
|
{
|
2010-06-04 00:42:10 -07:00
|
|
|
g_signal_emit_by_name (device, NM_DEVICE_INTERFACE_DISCONNECT_REQUEST, context);
|
2009-09-16 13:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
void
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_interface_deactivate (NMDeviceInterface *device, NMDeviceStateReason reason)
|
2007-02-05 12:14:09 +00:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE_INTERFACE (device));
|
|
|
|
|
|
2008-10-11 19:57:45 +00:00
|
|
|
NM_DEVICE_INTERFACE_GET_INTERFACE (device)->deactivate (device, reason);
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2008-03-20 21:19:21 +00:00
|
|
|
NMDeviceState
|
|
|
|
|
nm_device_interface_get_state (NMDeviceInterface *device)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceState state;
|
|
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (device), "state", &state, NULL);
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
gboolean
|
|
|
|
|
nm_device_interface_spec_match_list (NMDeviceInterface *device,
|
|
|
|
|
const GSList *specs)
|
|
|
|
|
{
|
2009-08-03 17:15:03 -04:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->spec_match_list)
|
|
|
|
|
return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->spec_match_list (device, specs);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
NMConnection *
|
|
|
|
|
nm_device_interface_connection_match_config (NMDeviceInterface *device,
|
|
|
|
|
const GSList *connections)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), NULL);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->connection_match_config)
|
|
|
|
|
return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->connection_match_config (device, connections);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_interface_can_assume_connection (NMDeviceInterface *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
return !!NM_DEVICE_INTERFACE_GET_INTERFACE (device)->connection_match_config;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-22 23:36:57 -08:00
|
|
|
void
|
|
|
|
|
nm_device_interface_set_enabled (NMDeviceInterface *device, gboolean enabled)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE_INTERFACE (device));
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->set_enabled)
|
2010-03-25 12:18:26 -07:00
|
|
|
NM_DEVICE_INTERFACE_GET_INTERFACE (device)->set_enabled (device, enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_interface_get_enabled (NMDeviceInterface *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_INTERFACE_GET_INTERFACE (device)->get_enabled)
|
|
|
|
|
return NM_DEVICE_INTERFACE_GET_INTERFACE (device)->get_enabled (device);
|
|
|
|
|
return TRUE;
|
2009-12-22 23:36:57 -08:00
|
|
|
}
|
|
|
|
|
|