summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bond.h6
-rw-r--r--src/devices/nm-device-bridge.c2
-rw-r--r--src/devices/nm-device-bridge.h6
-rw-r--r--src/devices/nm-device-ethernet.c62
-rw-r--r--src/devices/nm-device-ethernet.h6
-rw-r--r--src/devices/nm-device-infiniband.c2
-rw-r--r--src/devices/nm-device-infiniband.h6
-rw-r--r--src/devices/nm-device-vlan.h2
-rw-r--r--src/devices/nm-device-wired.c161
-rw-r--r--src/devices/nm-device-wired.h52
-rw-r--r--src/settings/nm-settings.c3
13 files changed, 77 insertions, 235 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d34e911fa2..e90b46ce84 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -87,8 +87,6 @@ nm_sources = \
devices/nm-device-vlan.h \
devices/nm-device-wifi.c \
devices/nm-device-wifi.h \
- devices/nm-device-wired.c \
- devices/nm-device-wired.h \
\
dhcp-manager/nm-dhcp-client.c \
dhcp-manager/nm-dhcp-client.h \
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index fa74b124e0..9e6e359ade 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -39,7 +39,7 @@
#include "nm-device-bond-glue.h"
-G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE_WIRED)
+G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE)
#define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate))
diff --git a/src/devices/nm-device-bond.h b/src/devices/nm-device-bond.h
index cea1a0e3e7..d1606dd610 100644
--- a/src/devices/nm-device-bond.h
+++ b/src/devices/nm-device-bond.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include "nm-device-wired.h"
+#include "nm-device.h"
G_BEGIN_DECLS
@@ -43,11 +43,11 @@ typedef enum {
#define NM_DEVICE_BOND_SLAVES "slaves"
typedef struct {
- NMDeviceWired parent;
+ NMDevice parent;
} NMDeviceBond;
typedef struct {
- NMDeviceWiredClass parent;
+ NMDeviceClass parent;
} NMDeviceBondClass;
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index a8f16c523e..7afbab7279 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -39,7 +39,7 @@
#include "nm-device-bridge-glue.h"
-G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE_WIRED)
+G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE)
#define NM_DEVICE_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BRIDGE, NMDeviceBridgePrivate))
diff --git a/src/devices/nm-device-bridge.h b/src/devices/nm-device-bridge.h
index 8f96521750..7113686f34 100644
--- a/src/devices/nm-device-bridge.h
+++ b/src/devices/nm-device-bridge.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include "nm-device-wired.h"
+#include "nm-device.h"
G_BEGIN_DECLS
@@ -43,11 +43,11 @@ typedef enum {
#define NM_DEVICE_BRIDGE_SLAVES "slaves"
typedef struct {
- NMDeviceWired parent;
+ NMDevice parent;
} NMDeviceBridge;
typedef struct {
- NMDeviceWiredClass parent;
+ NMDeviceClass parent;
} NMDeviceBridgeClass;
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index f2ed9c4897..4e6892ad3f 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
+#include <linux/version.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/if.h>
@@ -59,7 +60,7 @@
#include "nm-device-ethernet-glue.h"
-G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE_WIRED)
+G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
#define NM_DEVICE_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetPrivate))
@@ -84,6 +85,8 @@ typedef struct {
guint8 perm_hw_addr[ETH_ALEN]; /* Permanent MAC address */
guint8 initial_hw_addr[ETH_ALEN]; /* Initial MAC address (as seen when NM starts) */
+ guint32 speed;
+
Supplicant supplicant;
guint supplicant_timeout_id;
@@ -1317,6 +1320,60 @@ get_connection_hw_address (NMDevice *device,
}
static void
+get_link_speed (NMDevice *device)
+{
+ NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
+ struct ifreq ifr;
+ struct ethtool_cmd edata = {
+ .cmd = ETHTOOL_GSET,
+ };
+ guint32 speed;
+ int fd;
+
+ fd = socket (PF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ nm_log_warn (LOGD_HW | LOGD_ETHER, "couldn't open ethtool control socket.");
+ return;
+ }
+
+ memset (&ifr, 0, sizeof (struct ifreq));
+ strncpy (ifr.ifr_name, nm_device_get_iface (device), IFNAMSIZ);
+ ifr.ifr_data = (char *) &edata;
+
+ if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) {
+ close (fd);
+ return;
+ }
+ close (fd);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+ speed = edata.speed;
+#else
+ speed = ethtool_cmd_speed (&edata);
+#endif
+ if (speed == G_MAXUINT16 || speed == G_MAXUINT32)
+ speed = 0;
+
+ if (priv->speed == speed)
+ return;
+
+ priv->speed = speed;
+ g_object_notify (G_OBJECT (device), "speed");
+
+ nm_log_dbg (LOGD_HW | LOGD_ETHER, "(%s): speed is now %d Mb/s",
+ nm_device_get_iface (device), speed);
+}
+
+static void
+carrier_changed (NMDevice *device, gboolean carrier)
+{
+ if (carrier)
+ get_link_speed (device);
+
+ NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->carrier_changed (device, carrier);
+}
+
+static void
dispose (GObject *object)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object);
@@ -1342,7 +1399,7 @@ get_property (GObject *object, guint prop_id,
g_value_take_string (value, nm_utils_hwaddr_ntoa (&priv->perm_hw_addr, ARPHRD_ETHER));
break;
case PROP_SPEED:
- g_value_set_uint (value, nm_device_wired_get_speed (NM_DEVICE_WIRED (self)));
+ g_value_set_uint (value, priv->speed);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1392,6 +1449,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
parent_class->spec_match_list = spec_match_list;
parent_class->match_l2_config = match_l2_config;
parent_class->get_connection_hw_address = get_connection_hw_address;
+ parent_class->carrier_changed = carrier_changed;
parent_class->state_changed = device_state_changed;
diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h
index 117dfd590d..bfe453a783 100644
--- a/src/devices/nm-device-ethernet.h
+++ b/src/devices/nm-device-ethernet.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
-#include "nm-device-wired.h"
+#include "nm-device.h"
G_BEGIN_DECLS
@@ -46,11 +46,11 @@ typedef enum
#define NM_DEVICE_ETHERNET_SPEED "speed"
typedef struct {
- NMDeviceWired parent;
+ NMDevice parent;
} NMDeviceEthernet;
typedef struct {
- NMDeviceWiredClass parent;
+ NMDeviceClass parent;
} NMDeviceEthernetClass;
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index b951936097..ae01e30228 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -37,7 +37,7 @@
#include "nm-device-infiniband-glue.h"
-G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE_WIRED)
+G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE)
#define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate))
diff --git a/src/devices/nm-device-infiniband.h b/src/devices/nm-device-infiniband.h
index 73f5173650..baded8546f 100644
--- a/src/devices/nm-device-infiniband.h
+++ b/src/devices/nm-device-infiniband.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include "nm-device-wired.h"
+#include "nm-device.h"
G_BEGIN_DECLS
@@ -41,11 +41,11 @@ typedef enum {
} NMInfinibandError;
typedef struct {
- NMDeviceWired parent;
+ NMDevice parent;
} NMDeviceInfiniband;
typedef struct {
- NMDeviceWiredClass parent;
+ NMDeviceClass parent;
} NMDeviceInfinibandClass;
diff --git a/src/devices/nm-device-vlan.h b/src/devices/nm-device-vlan.h
index c5c5317330..faa60af360 100644
--- a/src/devices/nm-device-vlan.h
+++ b/src/devices/nm-device-vlan.h
@@ -23,7 +23,7 @@
#include <glib-object.h>
-#include "nm-device-wired.h"
+#include "nm-device.h"
G_BEGIN_DECLS
diff --git a/src/devices/nm-device-wired.c b/src/devices/nm-device-wired.c
deleted file mode 100644
index b57ad15090..0000000000
--- a/src/devices/nm-device-wired.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* 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) 2005 - 2012 Red Hat, Inc.
- * Copyright (C) 2006 - 2008 Novell, Inc.
- */
-
-#include "config.h"
-#include <glib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_infiniband.h>
-#include <netinet/ether.h>
-#include <linux/sockios.h>
-#include <linux/version.h>
-#include <linux/ethtool.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-
-#include "nm-device-wired.h"
-#include "nm-device-private.h"
-#include "nm-dhcp-manager.h"
-#include "nm-logging.h"
-#include "nm-system.h"
-#include "nm-utils.h"
-#include "NetworkManagerUtils.h"
-
-
-G_DEFINE_TYPE (NMDeviceWired, nm_device_wired, NM_TYPE_DEVICE)
-
-#define NM_DEVICE_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WIRED, NMDeviceWiredPrivate))
-
-#define NM_DEVICE_WIRED_LOG_LEVEL(dev) ((nm_device_get_device_type (dev) == NM_DEVICE_TYPE_INFINIBAND) ? LOGD_INFINIBAND : LOGD_ETHER)
-
-typedef struct {
- guint32 speed;
-} NMDeviceWiredPrivate;
-
-
-/* Returns speed in Mb/s */
-static guint32
-ethtool_get_speed (NMDeviceWired *self)
-{
- int fd;
- struct ifreq ifr;
- struct ethtool_cmd edata = {
- .cmd = ETHTOOL_GSET,
- };
- guint32 speed = 0;
-
- g_return_val_if_fail (self != NULL, 0);
-
- fd = socket (PF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- nm_log_warn (LOGD_HW, "couldn't open control socket.");
- return 0;
- }
-
- memset (&ifr, 0, sizeof (struct ifreq));
- strncpy (ifr.ifr_name, nm_device_get_iface (NM_DEVICE (self)), IFNAMSIZ);
- ifr.ifr_data = (char *) &edata;
-
- if (ioctl (fd, SIOCETHTOOL, &ifr) < 0)
- goto out;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
- speed = edata.speed;
-#else
- speed = ethtool_cmd_speed (&edata);
-#endif
-
- if (speed == G_MAXUINT16 || speed == G_MAXUINT32)
- speed = 0;
-
-out:
- close (fd);
- return speed;
-}
-
-static void
-set_speed (NMDeviceWired *self, const guint32 speed)
-{
- NMDeviceWiredPrivate *priv;
-
- g_return_if_fail (NM_IS_DEVICE (self));
-
- priv = NM_DEVICE_WIRED_GET_PRIVATE (self);
- if (priv->speed == speed)
- return;
-
- priv->speed = speed;
- g_object_notify (G_OBJECT (self), "speed");
-
- nm_log_dbg (LOGD_HW | NM_DEVICE_WIRED_LOG_LEVEL (NM_DEVICE (self)),
- "(%s): speed is now %d Mb/s",
- nm_device_get_iface (NM_DEVICE (self)),
- speed);
-}
-
-static void
-carrier_changed (NMDevice *device, gboolean carrier)
-{
- NMDeviceWired *wired_device = NM_DEVICE_WIRED (device);
-
- if (carrier)
- set_speed (wired_device, ethtool_get_speed (wired_device));
-
- G_OBJECT_CLASS (nm_device_wired_parent_class)->carrier_changed (device, carrier);
-}
-
-static void
-nm_device_wired_init (NMDeviceWired * self)
-{
-}
-
-static void
-nm_device_wired_class_init (NMDeviceWiredClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof (NMDeviceWiredPrivate));
-
- /* virtual methods */
-
- parent_class->carrier_changed = carrier_changed;
-}
-
-/**
- * nm_device_wired_get_speed:
- * @dev: an #NMDeviceWired
- *
- * Get @dev's speed
- *
- * Return value: @dev's speed in Mb/s
- */
-guint32
-nm_device_wired_get_speed (NMDeviceWired *dev)
-{
- NMDeviceWiredPrivate *priv;
-
- g_return_val_if_fail (dev != NULL, 0);
-
- priv = NM_DEVICE_WIRED_GET_PRIVATE (dev);
- return priv->speed;
-}
diff --git a/src/devices/nm-device-wired.h b/src/devices/nm-device-wired.h
deleted file mode 100644
index 1400374690..0000000000
--- a/src/devices/nm-device-wired.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* 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) 2005 - 2012 Red Hat, Inc.
- * Copyright (C) 2006 - 2008 Novell, Inc.
- */
-
-#ifndef NM_DEVICE_WIRED_H
-#define NM_DEVICE_WIRED_H
-
-#include <glib-object.h>
-
-#include "nm-device.h"
-
-G_BEGIN_DECLS
-
-#define NM_TYPE_DEVICE_WIRED (nm_device_wired_get_type ())
-#define NM_DEVICE_WIRED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WIRED, NMDeviceWired))
-#define NM_DEVICE_WIRED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WIRED, NMDeviceWiredClass))
-#define NM_IS_DEVICE_WIRED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WIRED))
-#define NM_IS_DEVICE_WIRED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WIRED))
-#define NM_DEVICE_WIRED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WIRED, NMDeviceWiredClass))
-
-typedef struct {
- NMDevice parent;
-} NMDeviceWired;
-
-typedef struct {
- NMDeviceClass parent;
-} NMDeviceWiredClass;
-
-GType nm_device_wired_get_type (void);
-
-guint32 nm_device_wired_get_speed (NMDeviceWired *dev);
-
-G_END_DECLS
-
-#endif /* NM_DEVICE_WIRED_H */
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index aa6abeb0b2..9eeee9ead0 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -54,7 +54,6 @@
#include <nm-utils.h>
#include "nm-device-ethernet.h"
-#include "nm-device-wired.h"
#include "nm-dbus-glib-types.h"
#include "nm-settings.h"
#include "nm-settings-connection.h"
@@ -1481,7 +1480,7 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device)
{
NMDefaultWiredConnection *connection;
- if (!NM_IS_DEVICE_WIRED (device))
+ if (!NM_IS_DEVICE_ETHERNET (device))
return;
connection = (NMDefaultWiredConnection *) g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_TAG);