summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-05-17 10:58:38 -0500
committerDan Winship <danw@gnome.org>2013-05-20 16:38:34 -0300
commitbe807819b053c67f2d704e1a8e562dcfa230e862 (patch)
treeeefd2034a373a360c0db415de72146e61d306514 /src
parent38459f5a0051040d73910deaa65be57167d384e8 (diff)
downloadNetworkManager-be807819b053c67f2d704e1a8e562dcfa230e862.tar.gz
core: clean up and simplify device capabilities handling
This is really, really old 2007-era code. Any NMDevice that gets created is already supported, so there's no reason to have every device set NM_DEVICE_CAP_NM_SUPPORTED. For those subclasses that only set that capability, we can remove the subclass method entirely. Next, it turns out that the "type capabilities" code wasn't used anywhere, so remove that too. Lastly, "cipsec" interfaces haven't been used on linux in about 5 years (they were created by the Cisco binary-only IPSec kernel module for Cisco VPNs long before vpnc and openswan came around) so we can remove that code too.
Diffstat (limited to 'src')
-rw-r--r--src/devices/nm-device-adsl.c4
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bridge.c2
-rw-r--r--src/devices/nm-device-bt.c7
-rw-r--r--src/devices/nm-device-ethernet.c11
-rw-r--r--src/devices/nm-device-generic.c7
-rw-r--r--src/devices/nm-device-infiniband.c2
-rw-r--r--src/devices/nm-device-modem.c7
-rw-r--r--src/devices/nm-device-olpc-mesh.c8
-rw-r--r--src/devices/nm-device-private.h3
-rw-r--r--src/devices/nm-device-vlan.c2
-rw-r--r--src/devices/nm-device-wifi.c16
-rw-r--r--src/devices/nm-device.c58
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/devices/wimax/nm-device-wimax.c7
15 files changed, 11 insertions, 126 deletions
diff --git a/src/devices/nm-device-adsl.c b/src/devices/nm-device-adsl.c
index 5b2d5444ff..b16137d4b7 100644
--- a/src/devices/nm-device-adsl.c
+++ b/src/devices/nm-device-adsl.c
@@ -88,9 +88,7 @@ typedef struct {
static guint32
get_generic_capabilities (NMDevice *dev)
{
- return ( NM_DEVICE_CAP_NM_SUPPORTED
- | NM_DEVICE_CAP_CARRIER_DETECT
- | NM_DEVICE_CAP_NONSTANDARD_CARRIER);
+ return (NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NONSTANDARD_CARRIER);
}
static gboolean
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 9e6e359ade..a15cc617db 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -91,7 +91,7 @@ get_hw_address_length (NMDevice *device)
static guint32
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
+ return NM_DEVICE_CAP_CARRIER_DETECT;
}
static gboolean
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 7afbab7279..d85c0ddeae 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -72,7 +72,7 @@ nm_bridge_error_quark (void)
static guint32
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
+ return NM_DEVICE_CAP_CARRIER_DETECT;
}
static gboolean
diff --git a/src/devices/nm-device-bt.c b/src/devices/nm-device-bt.c
index 813384ad2c..0abd8fb7fb 100644
--- a/src/devices/nm-device-bt.c
+++ b/src/devices/nm-device-bt.c
@@ -369,12 +369,6 @@ complete_connection (NMDevice *device,
return TRUE;
}
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static const GByteArray *
get_connection_hw_address (NMDevice *device,
NMConnection *connection)
@@ -1269,7 +1263,6 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
object_class->finalize = finalize;
device_class->can_auto_connect = can_auto_connect;
- device_class->get_generic_capabilities = get_generic_capabilities;
device_class->deactivate = deactivate;
device_class->act_stage2_config = act_stage2_config;
device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 4e6892ad3f..273defaf57 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -454,18 +454,11 @@ static guint32
get_generic_capabilities (NMDevice *dev)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
- guint32 caps = NM_DEVICE_CAP_NONE;
-
- /* cipsec devices are also explicitly unsupported at this time */
- if (strstr (nm_device_get_iface (dev), "cipsec"))
- return NM_DEVICE_CAP_NONE;
if (supports_ethtool_carrier_detect (self) || supports_mii_carrier_detect (self))
- caps |= NM_DEVICE_CAP_CARRIER_DETECT;
-
- caps |= NM_DEVICE_CAP_NM_SUPPORTED;
+ return NM_DEVICE_CAP_CARRIER_DETECT;
- return caps;
+ return NM_DEVICE_CAP_NONE;
}
static gboolean
diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c
index 6aa19ac48e..1b15932d60 100644
--- a/src/devices/nm-device-generic.c
+++ b/src/devices/nm-device-generic.c
@@ -58,12 +58,6 @@ nm_device_generic_error_quark (void)
/**************************************************************/
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static gboolean
is_available (NMDevice *device)
{
@@ -196,7 +190,6 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass)
object_class->get_property = get_property;
object_class->set_property = set_property;
- parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->is_available = is_available;
parent_class->check_connection_compatible = check_connection_compatible;
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index ae01e30228..853943aa92 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -119,7 +119,7 @@ get_hw_address_length (NMDevice *device)
static guint32
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
+ return NM_DEVICE_CAP_CARRIER_DETECT;
}
static NMActStageReturn
diff --git a/src/devices/nm-device-modem.c b/src/devices/nm-device-modem.c
index 60228ab5e8..f56d0c5d7b 100644
--- a/src/devices/nm-device-modem.c
+++ b/src/devices/nm-device-modem.c
@@ -214,12 +214,6 @@ device_state_changed (NMDevice *device,
reason);
}
-static guint32
-get_generic_capabilities (NMDevice *device)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static guint
get_hw_address_length (NMDevice *device)
{
@@ -484,7 +478,6 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
object_class->get_property = get_property;
object_class->set_property = set_property;
- device_class->get_generic_capabilities = get_generic_capabilities;
device_class->get_hw_address_length = get_hw_address_length;
device_class->check_connection_compatible = check_connection_compatible;
device_class->complete_connection = complete_connection;
diff --git a/src/devices/nm-device-olpc-mesh.c b/src/devices/nm-device-olpc-mesh.c
index e73e3c24f2..5d43dd7c37 100644
--- a/src/devices/nm-device-olpc-mesh.c
+++ b/src/devices/nm-device-olpc-mesh.c
@@ -113,12 +113,6 @@ nm_olpc_mesh_error_quark (void)
return quark;
}
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static void
nm_device_olpc_mesh_init (NMDeviceOlpcMesh * self)
{
@@ -477,8 +471,6 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
object_class->set_property = set_property;
object_class->dispose = dispose;
- parent_class->get_type_capabilities = NULL;
- parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->is_up = is_up;
parent_class->bring_up = bring_up;
parent_class->take_down = take_down;
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index 538d2293ca..9e7d0d85e8 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -56,9 +56,6 @@ gboolean nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6);
void nm_device_set_firmware_missing (NMDevice *self, gboolean missing);
-guint32 nm_device_get_capabilities (NMDevice *dev);
-guint32 nm_device_get_type_capabilities (NMDevice *dev);
-
void nm_device_activate_schedule_stage1_device_prepare (NMDevice *device);
void nm_device_activate_schedule_stage2_device_config (NMDevice *device);
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 7f13bf4e3a..3745369881 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -79,7 +79,7 @@ static guint32
get_generic_capabilities (NMDevice *dev)
{
/* We assume VLAN interfaces always support carrier detect */
- return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NM_SUPPORTED;
+ return NM_DEVICE_CAP_CARRIER_DETECT;
}
static gboolean
diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c
index 128248bdb1..33ef53db05 100644
--- a/src/devices/nm-device-wifi.c
+++ b/src/devices/nm-device-wifi.c
@@ -274,12 +274,6 @@ ipw_rfkill_state_work (gpointer user_data)
/*****************************************************************/
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static GObject*
constructor (GType type,
guint n_construct_params,
@@ -3352,14 +3346,6 @@ can_interrupt_activation (NMDevice *dev)
return FALSE;
}
-
-static guint32
-get_type_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_WIFI_GET_PRIVATE (dev)->capabilities;
-}
-
-
static const GByteArray *
get_connection_hw_address (NMDevice *device,
NMConnection *connection)
@@ -3652,8 +3638,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
object_class->set_property = set_property;
object_class->dispose = dispose;
- parent_class->get_type_capabilities = get_type_capabilities;
- parent_class->get_generic_capabilities = get_generic_capabilities;
parent_class->hw_bring_up = hw_bring_up;
parent_class->is_up = is_up;
parent_class->bring_up = bring_up;
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 1438b5fafe..c789fe90be 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -348,7 +348,7 @@ nm_device_init (NMDevice *self)
int i;
priv->type = NM_DEVICE_TYPE_UNKNOWN;
- priv->capabilities = NM_DEVICE_CAP_NONE;
+ priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
priv->state = NM_DEVICE_STATE_UNMANAGED;
priv->state_reason = NM_DEVICE_STATE_REASON_NONE;
priv->dhcp_timeout = 0;
@@ -507,11 +507,8 @@ constructor (GType type,
goto error;
}
- priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
- if (!device_has_capability (dev, NM_DEVICE_CAP_NM_SUPPORTED)) {
- nm_log_warn (LOGD_DEVICE, "(%s): Device unsupported, ignoring.", priv->iface);
- goto error;
- }
+ if (NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities)
+ priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
priv->dhcp_manager = nm_dhcp_manager_get ();
@@ -603,12 +600,6 @@ hw_is_up (NMDevice *device)
return ifindex > 0 ? nm_system_iface_is_up (ifindex) : TRUE;
}
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return 0;
-}
-
void
nm_device_set_path (NMDevice *self, const char *path)
{
@@ -822,36 +813,6 @@ nm_device_get_priority (NMDevice *dev)
}
}
-
-/*
- * Accessor for capabilities
- */
-guint32
-nm_device_get_capabilities (NMDevice *self)
-{
- g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
-
- return NM_DEVICE_GET_PRIVATE (self)->capabilities;
-}
-
-/*
- * Accessor for type-specific capabilities
- */
-guint32
-nm_device_get_type_capabilities (NMDevice *self)
-{
- g_return_val_if_fail (self != NULL, NM_DEVICE_CAP_NONE);
-
- return NM_DEVICE_GET_CLASS (self)->get_type_capabilities (self);
-}
-
-static guint32
-get_type_capabilities (NMDevice *self)
-{
- return NM_DEVICE_CAP_NONE;
-}
-
-
const char *
nm_device_get_type_desc (NMDevice *self)
{
@@ -1555,18 +1516,12 @@ nm_device_get_best_auto_connection (NMDevice *dev,
GSList *connections,
char **specific_object)
{
- guint32 caps;
GSList *iter;
g_return_val_if_fail (NM_IS_DEVICE (dev), NULL);
g_return_val_if_fail (specific_object != NULL, NULL);
g_return_val_if_fail (*specific_object == NULL, NULL);
- caps = nm_device_get_capabilities (dev);
- /* Don't use devices that SUCK */
- if (!(caps & NM_DEVICE_CAP_NM_SUPPORTED))
- return NULL;
-
for (iter = connections; iter; iter = iter->next) {
NMConnection *connection = NM_CONNECTION (iter->data);
@@ -4819,9 +4774,6 @@ set_property (GObject *object, guint prop_id,
g_free (priv->firmware_version);
priv->firmware_version = g_strdup (g_value_get_string (value));
break;
- case PROP_CAPABILITIES:
- priv->capabilities = g_value_get_uint (value);
- break;
case PROP_IP4_ADDRESS:
priv->ip4_address = g_value_get_uint (value);
break;
@@ -5021,8 +4973,6 @@ nm_device_class_init (NMDeviceClass *klass)
object_class->constructor = constructor;
object_class->constructed = constructed;
- klass->get_type_capabilities = get_type_capabilities;
- klass->get_generic_capabilities = get_generic_capabilities;
klass->is_available = is_available;
klass->act_stage1_prepare = act_stage1_prepare;
klass->act_stage2_config = act_stage2_config;
@@ -5097,7 +5047,7 @@ nm_device_class_init (NMDeviceClass *klass)
"Capabilities",
"Capabilities",
0, G_MAXUINT32, NM_DEVICE_CAP_NONE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_CARRIER,
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index e62664cdb9..9ba79c92f8 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -120,7 +120,6 @@ typedef struct {
void (* update_initial_hw_address) (NMDevice *self);
guint (* get_hw_address_length) (NMDevice *self);
- guint32 (* get_type_capabilities) (NMDevice *self);
guint32 (* get_generic_capabilities) (NMDevice *self);
gboolean (* is_available) (NMDevice *self);
diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c
index 763373abe6..565fa2b569 100644
--- a/src/devices/wimax/nm-device-wimax.c
+++ b/src/devices/wimax/nm-device-wimax.c
@@ -557,12 +557,6 @@ can_auto_connect (NMDevice *device,
return FALSE;
}
-static guint32
-get_generic_capabilities (NMDevice *dev)
-{
- return NM_DEVICE_CAP_NM_SUPPORTED;
-}
-
static gboolean
is_available (NMDevice *device)
{
@@ -1421,7 +1415,6 @@ nm_device_wimax_class_init (NMDeviceWimaxClass *klass)
device_class->check_connection_available = check_connection_available;
device_class->complete_connection = complete_connection;
device_class->can_auto_connect = can_auto_connect;
- device_class->get_generic_capabilities = get_generic_capabilities;
device_class->is_available = is_available;
device_class->act_stage1_prepare = act_stage1_prepare;
device_class->act_stage2_config = act_stage2_config;