diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 3fa34e52d3..1d539ea388 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -321,18 +321,12 @@ take_down (NMDevice *dev) } NMDevice * -nm_device_ethernet_new (const char *udi, - const char *iface, - const char *driver) +nm_device_ethernet_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (driver != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Ethernet", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, NULL); diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h index bfe453a783..bcaf270a03 100644 --- a/src/devices/nm-device-ethernet.h +++ b/src/devices/nm-device-ethernet.h @@ -58,9 +58,7 @@ typedef struct { GType nm_device_ethernet_get_type (void); -NMDevice *nm_device_ethernet_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_ethernet_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index bf202a6857..7b7efc8702 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -25,6 +25,7 @@ #include #include "NetworkManager.h" +#include "nm-platform.h" /* WARNING: this file is private API between NetworkManager and its internal * device plugins. Its API can change at any time and is not guaranteed to be @@ -49,15 +50,11 @@ * * Returns: the device object (a subclass of #NMDevice) or %NULL */ -GObject *nm_device_factory_create_device (const char *devpath, - const char *ifname, - const char *driver, +GObject *nm_device_factory_create_device (NMPlatformLink *platform_device, GError **error); /* Should match nm_device_factory() */ -typedef GObject * (*NMDeviceFactoryCreateFunc) (const char *devpath, - const char *ifname, - const char *driver, +typedef GObject * (*NMDeviceFactoryCreateFunc) (NMPlatformLink *platform_device, GError **error); /** diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index bb6fc6ce16..103d76feea 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -104,16 +104,12 @@ check_connection_compatible (NMDevice *device, /**************************************************************/ NMDevice * -nm_device_generic_new (const char *udi, - const char *iface, - const char *driver) +nm_device_generic_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GENERIC, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Generic", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, NULL); diff --git a/src/devices/nm-device-generic.h b/src/devices/nm-device-generic.h index 634e6aeee6..e7b7090b17 100644 --- a/src/devices/nm-device-generic.h +++ b/src/devices/nm-device-generic.h @@ -54,9 +54,7 @@ typedef struct { GType nm_device_generic_get_type (void); -NMDevice *nm_device_generic_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_generic_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index 004934137b..dbd38401e8 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -23,6 +23,7 @@ #include #include "nm-device-gre.h" +#include "nm-device-private.h" #include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-manager.h" @@ -108,16 +109,12 @@ link_changed (NMDevice *device) /**************************************************************/ NMDevice * -nm_device_gre_new (const char *udi, - const char *iface, - const char *driver) +nm_device_gre_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GRE, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Gre", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, NULL); diff --git a/src/devices/nm-device-gre.h b/src/devices/nm-device-gre.h index bbe12ce718..610b380507 100644 --- a/src/devices/nm-device-gre.h +++ b/src/devices/nm-device-gre.h @@ -56,9 +56,7 @@ typedef struct { GType nm_device_gre_get_type (void); -NMDevice *nm_device_gre_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_gre_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 853943aa92..ab182081e8 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -93,18 +93,12 @@ nm_device_infiniband_init (NMDeviceInfiniband * self) } NMDevice * -nm_device_infiniband_new (const char *udi, - const char *iface, - const char *driver) +nm_device_infiniband_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (driver != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "InfiniBand", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND, NULL); diff --git a/src/devices/nm-device-infiniband.h b/src/devices/nm-device-infiniband.h index baded8546f..8c630fb806 100644 --- a/src/devices/nm-device-infiniband.h +++ b/src/devices/nm-device-infiniband.h @@ -52,9 +52,7 @@ typedef struct { GType nm_device_infiniband_get_type (void); -NMDevice *nm_device_infiniband_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_infiniband_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 8ebd0fff1f..4d7f5029cd 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -23,6 +23,7 @@ #include #include "nm-device-macvlan.h" +#include "nm-device-private.h" #include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-manager.h" @@ -88,16 +89,12 @@ link_changed (NMDevice *device) /**************************************************************/ NMDevice * -nm_device_macvlan_new (const char *udi, - const char *iface, - const char *driver) +nm_device_macvlan_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Macvlan", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, NULL); diff --git a/src/devices/nm-device-macvlan.h b/src/devices/nm-device-macvlan.h index be6253f152..348ed2f96f 100644 --- a/src/devices/nm-device-macvlan.h +++ b/src/devices/nm-device-macvlan.h @@ -49,9 +49,7 @@ typedef struct { GType nm_device_macvlan_get_type (void); -NMDevice *nm_device_macvlan_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_macvlan_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-olpc-mesh.c b/src/devices/nm-device-olpc-mesh.c index 5d43dd7c37..2599cce5bc 100644 --- a/src/devices/nm-device-olpc-mesh.c +++ b/src/devices/nm-device-olpc-mesh.c @@ -707,18 +707,12 @@ state_changed (NMDevice *device, NMDeviceState new_state, NMDevice * -nm_device_olpc_mesh_new (const char *udi, - const char *iface, - const char *driver) +nm_device_olpc_mesh_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (driver != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_OLPC_MESH, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "802.11 OLPC Mesh", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_OLPC_MESH, NULL); diff --git a/src/devices/nm-device-olpc-mesh.h b/src/devices/nm-device-olpc-mesh.h index 5d6bfab832..c25dd8e53c 100644 --- a/src/devices/nm-device-olpc-mesh.h +++ b/src/devices/nm-device-olpc-mesh.h @@ -75,9 +75,7 @@ struct _NMDeviceOlpcMeshClass GType nm_device_olpc_mesh_get_type (void); -NMDevice *nm_device_olpc_mesh_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_olpc_mesh_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index 9e7d0d85e8..4c5393a196 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -26,6 +26,8 @@ /* This file should only be used by subclasses of NMDevice */ +#define NM_DEVICE_PLATFORM_DEVICE "platform-device" + enum NMActStageReturn { NM_ACT_STAGE_RETURN_FAILURE = 0, NM_ACT_STAGE_RETURN_SUCCESS, /* Activation stage done */ diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 1a31fdcd5e..86498cf859 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -24,6 +24,7 @@ #include #include "nm-device-tun.h" +#include "nm-device-private.h" #include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-platform.h" @@ -87,16 +88,12 @@ link_changed (NMDevice *device) /**************************************************************/ NMDevice * -nm_device_tun_new (const char *udi, - const char *iface, - const char *driver) +nm_device_tun_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_TUN, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Tun", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, NULL); diff --git a/src/devices/nm-device-tun.h b/src/devices/nm-device-tun.h index 336a9792ef..cfcf4d7be2 100644 --- a/src/devices/nm-device-tun.h +++ b/src/devices/nm-device-tun.h @@ -52,9 +52,7 @@ typedef struct { GType nm_device_tun_get_type (void); -NMDevice *nm_device_tun_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_tun_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 61935b562f..fdc44565e3 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -28,6 +28,7 @@ #include #include "nm-device-veth.h" +#include "nm-device-private.h" #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" @@ -96,16 +97,12 @@ get_peer (NMDeviceVeth *self) /**************************************************************/ NMDevice * -nm_device_veth_new (const char *udi, - const char *iface, - const char *driver) +nm_device_veth_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver ? driver : "veth", + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "Veth", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, NULL); diff --git a/src/devices/nm-device-veth.h b/src/devices/nm-device-veth.h index a1edba0224..bc8fedffde 100644 --- a/src/devices/nm-device-veth.h +++ b/src/devices/nm-device-veth.h @@ -47,9 +47,7 @@ typedef struct { GType nm_device_veth_get_type (void); -NMDevice *nm_device_veth_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_veth_new (NMPlatformLink *platform_device); G_END_DECLS diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index b83d0a467f..35667599ad 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -3504,18 +3504,12 @@ set_enabled (NMDevice *device, gboolean enabled) /********************************************************************/ NMDevice * -nm_device_wifi_new (const char *udi, - const char *iface, - const char *driver) +nm_device_wifi_new (NMPlatformLink *platform_device) { - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (driver != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_WIFI, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "802.11 WiFi", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_WIFI, NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WLAN, diff --git a/src/devices/nm-device-wifi.h b/src/devices/nm-device-wifi.h index 0326fa98fd..6ea303e773 100644 --- a/src/devices/nm-device-wifi.h +++ b/src/devices/nm-device-wifi.h @@ -89,9 +89,7 @@ struct _NMDeviceWifiClass GType nm_device_wifi_get_type (void); -NMDevice *nm_device_wifi_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_wifi_new (NMPlatformLink *platform_device); NMAccessPoint * nm_device_wifi_get_activation_ap (NMDeviceWifi *self); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 28295d486e..0d9eb345e8 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -107,6 +107,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; enum { PROP_0, + PROP_PLATFORM_DEVICE, PROP_UDI, PROP_IFACE, PROP_IP_IFACE, @@ -4702,34 +4703,51 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); + NMPlatformLink *platform_device; const char *hw_addr; int hw_addr_type; switch (prop_id) { - case PROP_UDI: - g_free (priv->udi); - priv->udi = g_strdup (g_value_get_string (value)); - break; - case PROP_IFACE: - g_free (priv->iface); - priv->ifindex = 0; - priv->iface = g_value_dup_string (value); - - /* Only look up the ifindex if it appears to be an actual kernel - * interface name. eg Bluetooth devices won't have one until we know - * the IP interface. - */ - if (priv->iface && !strchr (priv->iface, ':')) { - priv->ifindex = nm_platform_link_get_ifindex (priv->iface); - if (priv->ifindex <= 0) - nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", priv->iface); + case PROP_PLATFORM_DEVICE: + platform_device = g_value_get_pointer (value); + if (platform_device) { + g_free (priv->udi); + priv->udi = g_strdup (platform_device->udi); + g_free (priv->iface); + priv->iface = g_strdup (platform_device->name); + priv->ifindex = platform_device->ifindex; + g_free (priv->driver); + priv->driver = g_strdup (platform_device->driver); } break; - case PROP_IP_IFACE: + case PROP_UDI: + if (g_value_get_string (value)) { + g_free (priv->udi); + priv->udi = g_value_dup_string (value); + } + break; + case PROP_IFACE: + if (g_value_get_string (value)) { + g_free (priv->iface); + priv->ifindex = 0; + priv->iface = g_value_dup_string (value); + + /* Only look up the ifindex if it appears to be an actual kernel + * interface name. eg Bluetooth devices won't have one until we know + * the IP interface. + */ + if (priv->iface && !strchr (priv->iface, ':')) { + priv->ifindex = nm_platform_link_get_ifindex (priv->iface); + if (priv->ifindex <= 0) + nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", priv->iface); + } + } break; case PROP_DRIVER: - g_free (priv->driver); - priv->driver = g_strdup (g_value_get_string (value)); + if (g_value_get_string (value)) { + g_free (priv->driver); + priv->driver = g_value_dup_string (value); + } break; case PROP_DRIVER_VERSION: g_free (priv->driver_version); @@ -4958,6 +4976,13 @@ nm_device_class_init (NMDeviceClass *klass) klass->can_interrupt_activation = can_interrupt_activation; /* Properties */ + g_object_class_install_property + (object_class, PROP_PLATFORM_DEVICE, + g_param_spec_pointer (NM_DEVICE_PLATFORM_DEVICE, + "Platform Device", + "NMPlatform device object", + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (object_class, PROP_UDI, g_param_spec_string (NM_DEVICE_UDI, @@ -4980,7 +5005,7 @@ nm_device_class_init (NMDeviceClass *klass) "IP Interface", "IP Interface", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, PROP_DRIVER, diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index c2f6344978..71dc06a4d8 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -36,6 +36,7 @@ #include "nm-connection.h" #include "nm-rfkill-manager.h" #include "nm-connection-provider.h" +#include "nm-platform.h" /* Properties */ #define NM_DEVICE_UDI "udi" diff --git a/src/devices/wimax/Makefile.am b/src/devices/wimax/Makefile.am index a967e65be3..0f2b635b5f 100644 --- a/src/devices/wimax/Makefile.am +++ b/src/devices/wimax/Makefile.am @@ -3,6 +3,7 @@ INCLUDES = \ -I${top_builddir}/src \ -I${top_srcdir}/src/logging \ -I${top_srcdir}/src/devices \ + -I${top_srcdir}/src/platform \ -I${top_builddir}/include \ -I${top_srcdir}/include \ -I${top_builddir}/libnm-util \ diff --git a/src/devices/wimax/nm-device-wimax.c b/src/devices/wimax/nm-device-wimax.c index c055578be7..3e0d3eead9 100644 --- a/src/devices/wimax/nm-device-wimax.c +++ b/src/devices/wimax/nm-device-wimax.c @@ -1270,20 +1270,14 @@ wmx_new_sdk_cb (struct wmxsdk *sdk, void *user_data) /*************************************************************************/ NMDevice * -nm_device_wimax_new (const char *udi, - const char *iface, - const char *driver) +nm_device_wimax_new (NMPlatformLink *platform_device) { NMDevice *device; - g_return_val_if_fail (udi != NULL, NULL); - g_return_val_if_fail (iface != NULL, NULL); - g_return_val_if_fail (driver != NULL, NULL); + g_return_val_if_fail (platform_device != NULL, NULL); device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_WIMAX, - NM_DEVICE_UDI, udi, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, driver, + NM_DEVICE_PLATFORM_DEVICE, platform_device, NM_DEVICE_TYPE_DESC, "WiMAX", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_WIMAX, NM_DEVICE_RFKILL_TYPE, RFKILL_TYPE_WIMAX, @@ -1294,7 +1288,7 @@ nm_device_wimax_new (const char *udi, nm_wimax_util_sdk_ref (); /* See if the SDK already knows about this interface */ - sdk = iwmx_sdk_get_wmxsdk_for_iface (iface); + sdk = iwmx_sdk_get_wmxsdk_for_iface (platform_device->name); if (sdk) wmx_new_sdk_cb (sdk, device); diff --git a/src/devices/wimax/nm-device-wimax.h b/src/devices/wimax/nm-device-wimax.h index 4926edddd5..1baf5b2e9b 100644 --- a/src/devices/wimax/nm-device-wimax.h +++ b/src/devices/wimax/nm-device-wimax.h @@ -65,9 +65,7 @@ typedef struct { GType nm_device_wimax_get_type (void); -NMDevice *nm_device_wimax_new (const char *udi, - const char *iface, - const char *driver); +NMDevice *nm_device_wimax_new (NMPlatformLink *platform_device); NMWimaxNsp *nm_device_wimax_get_active_nsp (NMDeviceWimax *self); diff --git a/src/devices/wimax/nm-wimax-factory.c b/src/devices/wimax/nm-wimax-factory.c index 36fe934525..738c12eb31 100644 --- a/src/devices/wimax/nm-wimax-factory.c +++ b/src/devices/wimax/nm-wimax-factory.c @@ -24,18 +24,16 @@ #include "nm-device-wimax.h" G_MODULE_EXPORT GObject * -nm_device_factory_create_device (const char *devpath, - const char *ifname, - const char *driver, +nm_device_factory_create_device (NMPlatformLink *platform_device, GError **error) { /* FIXME: check udev 'DEVTYPE' instead; but since we only support Intel * WiMAX devices for now this is appropriate. */ - if (g_strcmp0 (driver, "i2400m_usb") != 0) + if (g_strcmp0 (platform_device->driver, "i2400m_usb") != 0) return NULL; /* unsupported */ - return (GObject *) nm_device_wimax_new (devpath, ifname, driver); + return (GObject *) nm_device_wimax_new (platform_device); } G_MODULE_EXPORT guint32 diff --git a/src/nm-manager.c b/src/nm-manager.c index 2d0bc19fac..9d6de6b457 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2199,7 +2199,7 @@ platform_link_added_cb (NMPlatform *platform, NMDeviceFactoryCreateFunc create_func = iter->data; g_clear_error (&error); - device = (NMDevice *) create_func (link->udi, link->name, link->driver, &error); + device = (NMDevice *) create_func (link, &error); if (device && NM_IS_DEVICE (device)) { g_assert_no_error (error); break; /* success! */ @@ -2221,16 +2221,16 @@ platform_link_added_cb (NMPlatform *platform, switch (link->type) { case NM_LINK_TYPE_ETHERNET: - device = nm_device_ethernet_new (link->udi, link->name, link->driver); + device = nm_device_ethernet_new (link); break; case NM_LINK_TYPE_INFINIBAND: - device = nm_device_infiniband_new (link->udi, link->name, link->driver); + device = nm_device_infiniband_new (link); break; case NM_LINK_TYPE_OLPC_MESH: - device = nm_device_olpc_mesh_new (link->udi, link->name, link->driver); + device = nm_device_olpc_mesh_new (link); break; case NM_LINK_TYPE_WIFI: - device = nm_device_wifi_new (link->udi, link->name, link->driver); + device = nm_device_wifi_new (link); break; case NM_LINK_TYPE_BOND: device = nm_device_bond_new (link->udi, link->name); @@ -2260,23 +2260,23 @@ platform_link_added_cb (NMPlatform *platform, nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", link->name); break; case NM_LINK_TYPE_VETH: - device = nm_device_veth_new (link->udi, link->name, link->driver); + device = nm_device_veth_new (link); break; case NM_LINK_TYPE_TUN: case NM_LINK_TYPE_TAP: - device = nm_device_tun_new (link->udi, link->name, link->driver); + device = nm_device_tun_new (link); break; case NM_LINK_TYPE_MACVLAN: case NM_LINK_TYPE_MACVTAP: - device = nm_device_macvlan_new (link->udi, link->name, link->driver); + device = nm_device_macvlan_new (link); break; case NM_LINK_TYPE_GRE: case NM_LINK_TYPE_GRETAP: - device = nm_device_gre_new (link->udi, link->name, link->driver); + device = nm_device_gre_new (link); break; default: - device = nm_device_generic_new (link->udi, link->name, link->driver); + device = nm_device_generic_new (link); break; } }