NetworkManager r3620 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3620 - in trunk: . src
- Date: Wed, 30 Apr 2008 13:54:00 +0100 (BST)
Author: dcbw
Date: Wed Apr 30 12:54:00 2008
New Revision: 3620
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3620&view=rev
Log:
2008-04-30 Dan Williams <dcbw redhat com>
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_is_up, nm_system_device_is_up_with_iface): new
functions to check device flags for IFF_UP
* src/nm-serial-device.c
- (real_is_up): remove; NMDevice now returns TRUE if the subclass doesn't
implement is_up
* src/nm-device-802-3-ethernet.c
src/nm-device-802-11-wireless.c
- (real_hw_is_up): call nm_system_device_is_up()
* src/nm-device.c
- (real_hw_is_up): move to nm_system_device_is_up_with_iface()
- (real_is_up): remove; nm_device_is_up() returns TRUE if subclass
does not implement
Modified:
trunk/ChangeLog
trunk/src/NetworkManagerSystem.c
trunk/src/NetworkManagerSystem.h
trunk/src/nm-device-802-11-wireless.c
trunk/src/nm-device-802-3-ethernet.c
trunk/src/nm-device.c
trunk/src/nm-serial-device.c
Modified: trunk/src/NetworkManagerSystem.c
==============================================================================
--- trunk/src/NetworkManagerSystem.c (original)
+++ trunk/src/NetworkManagerSystem.c Wed Apr 30 12:54:00 2008
@@ -436,6 +436,41 @@
return success;
}
+gboolean
+nm_system_device_is_up (NMDevice *device)
+{
+ g_return_val_if_fail (device != NULL, FALSE);
+
+ return nm_system_device_is_up_with_iface (nm_device_get_iface (device));
+}
+
+gboolean
+nm_system_device_is_up_with_iface (const char *iface)
+{
+ struct ifreq ifr;
+ int err, fd;
+
+ fd = socket (PF_INET, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ nm_warning ("couldn't open control socket.");
+ return FALSE;
+ }
+
+ /* Get device's flags */
+ strncpy (ifr.ifr_name, iface, IFNAMSIZ);
+ err = ioctl (fd, SIOCGIFFLAGS, &ifr);
+ close (fd);
+
+ if (!err)
+ return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
+
+ if (errno != ENODEV) {
+ nm_warning ("%s: could not get flags for device %s. errno = %d",
+ __func__, iface, errno);
+ }
+
+ return FALSE;
+}
gboolean
nm_system_device_set_mtu (const char *iface, guint32 mtu)
Modified: trunk/src/NetworkManagerSystem.h
==============================================================================
--- trunk/src/NetworkManagerSystem.h (original)
+++ trunk/src/NetworkManagerSystem.h Wed Apr 30 12:54:00 2008
@@ -70,6 +70,9 @@
gboolean nm_system_device_set_up_down (NMDevice *dev, gboolean up);
gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up);
+gboolean nm_system_device_is_up (NMDevice *device);
+gboolean nm_system_device_is_up_with_iface (const char *iface);
+
gboolean nm_system_device_update_resolv_conf (void *data, int len, const char *domain_name);
void nm_system_set_hostname (NMIP4Config *config);
Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c (original)
+++ trunk/src/nm-device-802-11-wireless.c Wed Apr 30 12:54:00 2008
@@ -733,7 +733,7 @@
static gboolean
real_hw_is_up (NMDevice *device)
{
- return NM_DEVICE_CLASS (nm_device_802_11_wireless_parent_class)->hw_is_up (device);
+ return nm_system_device_is_up (device);
}
static gboolean
Modified: trunk/src/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.c (original)
+++ trunk/src/nm-device-802-3-ethernet.c Wed Apr 30 12:54:00 2008
@@ -342,7 +342,7 @@
static gboolean
real_hw_is_up (NMDevice *device)
{
- return NM_DEVICE_CLASS (nm_device_802_3_ethernet_parent_class)->hw_is_up (device);
+ return nm_system_device_is_up (device);
}
static gboolean
Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c (original)
+++ trunk/src/nm-device.c Wed Apr 30 12:54:00 2008
@@ -196,37 +196,6 @@
return NULL;
}
-
-static gboolean
-real_hw_is_up (NMDevice *self)
-{
- struct ifreq ifr;
- const char *iface;
- int err, fd;
-
- fd = socket (PF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- nm_warning ("couldn't open control socket.");
- return FALSE;
- }
-
- /* Get device's flags */
- iface = nm_device_get_iface (self);
- strncpy (ifr.ifr_name, iface, IFNAMSIZ);
- err = ioctl (fd, SIOCGIFFLAGS, &ifr);
- close (fd);
-
- if (!err)
- return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
-
- if (errno != ENODEV) {
- nm_warning ("%s: could not get flags for device %s. errno = %d",
- __func__, iface, errno);
- }
-
- return FALSE;
-}
-
static gboolean
nm_device_hw_is_up (NMDevice *self)
{
@@ -1475,12 +1444,6 @@
}
static gboolean
-real_is_up (NMDevice *self)
-{
- return TRUE;
-}
-
-static gboolean
nm_device_bring_up (NMDevice *self, gboolean wait)
{
gboolean success;
@@ -1693,8 +1656,6 @@
object_class->get_property = get_property;
object_class->constructor = constructor;
- klass->hw_is_up = real_hw_is_up;
- klass->is_up = real_is_up;
klass->get_type_capabilities = real_get_type_capabilities;
klass->get_generic_capabilities = real_get_generic_capabilities;
klass->act_stage1_prepare = real_act_stage1_prepare;
Modified: trunk/src/nm-serial-device.c
==============================================================================
--- trunk/src/nm-serial-device.c (original)
+++ trunk/src/nm-serial-device.c Wed Apr 30 12:54:00 2008
@@ -1010,13 +1010,6 @@
nm_serial_device_close (self);
}
-static gboolean
-real_is_up (NMDevice *device)
-{
- /* Serial devices are always "up" */
- return TRUE;
-}
-
static guint32
real_get_generic_capabilities (NMDevice *dev)
{
@@ -1052,7 +1045,6 @@
object_class->finalize = finalize;
parent_class->get_generic_capabilities = real_get_generic_capabilities;
- parent_class->is_up = real_is_up;
parent_class->act_stage2_config = real_act_stage2_config;
parent_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
parent_class->deactivate_quickly = real_deactivate_quickly;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]