diff options
Diffstat (limited to 'libnm-glib/nm-device-ethernet.c')
| -rw-r--r-- | libnm-glib/nm-device-ethernet.c | 92 |
1 files changed, 14 insertions, 78 deletions
diff --git a/libnm-glib/nm-device-ethernet.c b/libnm-glib/nm-device-ethernet.c index 932c6bda..44b27427 100644 --- a/libnm-glib/nm-device-ethernet.c +++ b/libnm-glib/nm-device-ethernet.c @@ -18,17 +18,9 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2007 - 2008 Novell, Inc. - * Copyright (C) 2007 - 2011 Red Hat, Inc. + * Copyright (C) 2007 - 2010 Red Hat, Inc. */ -#include <config.h> -#include <string.h> -#include <netinet/ether.h> - -#include <nm-setting-connection.h> -#include <nm-setting-wired.h> -#include <nm-setting-pppoe.h> - #include "nm-device-ethernet.h" #include "nm-device-private.h" #include "nm-object-private.h" @@ -73,7 +65,7 @@ enum { * * Creates a new #NMDeviceEthernet. * - * Returns: (transfer full): a new device + * Returns: a new device **/ GObject * nm_device_ethernet_new (DBusGConnection *connection, const char *path) @@ -107,8 +99,7 @@ nm_device_ethernet_get_hw_address (NMDeviceEthernet *device) if (!priv->hw_address) { priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_HW_ADDRESS, - NULL); + DBUS_PROP_HW_ADDRESS); } return priv->hw_address; @@ -134,8 +125,7 @@ nm_device_ethernet_get_permanent_hw_address (NMDeviceEthernet *device) if (!priv->perm_hw_address) { priv->perm_hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_PERM_HW_ADDRESS, - NULL); + DBUS_PROP_PERM_HW_ADDRESS); } return priv->perm_hw_address; @@ -160,8 +150,7 @@ nm_device_ethernet_get_speed (NMDeviceEthernet *device) if (!priv->speed) { priv->speed = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_SPEED, - NULL); + DBUS_PROP_SPEED); } return priv->speed; @@ -186,67 +175,13 @@ nm_device_ethernet_get_carrier (NMDeviceEthernet *device) if (!priv->carrier_valid) { priv->carrier = _nm_object_get_boolean_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, - DBUS_PROP_CARRIER, - NULL); + DBUS_PROP_CARRIER); priv->carrier_valid = TRUE; } return priv->carrier; } -static GSList * -filter_connections (NMDevice *device, const GSList *connections) -{ - GSList *filtered = NULL; - const GSList *iter; - - for (iter = connections; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); - NMSettingConnection *s_con; - NMSettingWired *s_wired; - const char *ctype; - gboolean is_pppoe = FALSE; - - s_con = (NMSettingConnection *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION); - g_assert (s_con); - - ctype = nm_setting_connection_get_connection_type (s_con); - if (!strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) - is_pppoe = TRUE; - else if (strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) != 0) - continue; - - s_wired = (NMSettingWired *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRED); - /* Wired setting optional for PPPoE */ - if (!is_pppoe && !s_wired) - continue; - - if (s_wired) { - const GByteArray *mac; - const char *perm_str; - struct ether_addr *perm_mac; - - /* FIXME: filter using s390 subchannels when they are exported over the bus */ - - /* Check MAC address */ - perm_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); - if (perm_str) { - perm_mac = ether_aton (perm_str); - mac = nm_setting_wired_get_mac_address (s_wired); - if (mac && perm_mac && memcmp (mac->data, perm_mac->ether_addr_octet, ETH_ALEN)) - continue; - } - } - - /* Connection applies to this device */ - filtered = g_slist_prepend (filtered, candidate); - } - - return g_slist_reverse (filtered); -} - -/***********************************************************/ - static void nm_device_ethernet_init (NMDeviceEthernet *device) { @@ -322,8 +257,11 @@ finalize (GObject *object) { NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object); - g_free (priv->hw_address); - g_free (priv->perm_hw_address); + if (priv->hw_address) + g_free (priv->hw_address); + + if (priv->perm_hw_address) + g_free (priv->perm_hw_address); G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object); } @@ -356,19 +294,17 @@ get_property (GObject *object, } static void -nm_device_ethernet_class_init (NMDeviceEthernetClass *eth_class) +nm_device_ethernet_class_init (NMDeviceEthernetClass *device_class) { - GObjectClass *object_class = G_OBJECT_CLASS (eth_class); - NMDeviceClass *device_class = NM_DEVICE_CLASS (eth_class); + GObjectClass *object_class = G_OBJECT_CLASS (device_class); - g_type_class_add_private (eth_class, sizeof (NMDeviceEthernetPrivate)); + g_type_class_add_private (device_class, sizeof (NMDeviceEthernetPrivate)); /* virtual methods */ object_class->constructor = constructor; object_class->dispose = dispose; object_class->finalize = finalize; object_class->get_property = get_property; - device_class->filter_connections = filter_connections; /* properties */ |