diff options
Diffstat (limited to 'src/devices/nm-device-veth.c')
| -rw-r--r-- | src/devices/nm-device-veth.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index df107523..db29c00d 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -33,9 +33,13 @@ #include "nm-manager.h" #include "nm-platform.h" #include "nm-dbus-manager.h" +#include "nm-device-factory.h" #include "nm-device-veth-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceVeth); + G_DEFINE_TYPE (NMDeviceVeth, nm_device_veth, NM_TYPE_DEVICE_ETHERNET) #define NM_DEVICE_VETH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VETH, NMDeviceVethPrivate)) @@ -79,8 +83,7 @@ get_peer (NMDeviceVeth *self) return priv->peer; if (!nm_platform_veth_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read veth properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read veth properties"); return NULL; } @@ -96,18 +99,6 @@ get_peer (NMDeviceVeth *self) /**************************************************************/ -NMDevice * -nm_device_veth_new (NMPlatformLink *platform_device) -{ - g_return_val_if_fail (platform_device != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH, - NM_DEVICE_PLATFORM_DEVICE, platform_device, - NM_DEVICE_TYPE_DESC, "Veth", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, - NULL); -} - static void nm_device_veth_init (NMDeviceVeth *self) { @@ -159,13 +150,35 @@ nm_device_veth_class_init (NMDeviceVethClass *klass) /* properties */ g_object_class_install_property (object_class, PROP_PEER, - g_param_spec_boxed (NM_DEVICE_VETH_PEER, - "Peer", - "Peer device", + g_param_spec_boxed (NM_DEVICE_VETH_PEER, "", "", DBUS_TYPE_G_OBJECT_PATH, - G_PARAM_READABLE)); + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), G_TYPE_FROM_CLASS (klass), &dbus_glib_nm_device_veth_object_info); } + +/*************************************************************/ + +#define NM_TYPE_VETH_FACTORY (nm_veth_factory_get_type ()) +#define NM_VETH_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VETH_FACTORY, NMVethFactory)) + +static NMDevice * +new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) +{ + if (plink->type == NM_LINK_TYPE_VETH) { + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH, + NM_DEVICE_PLATFORM_DEVICE, plink, + NM_DEVICE_TYPE_DESC, "Veth", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, + NULL); + } + return NULL; +} + +DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(VETH, Veth, veth, ETHERNET, \ + factory_iface->new_link = new_link; \ + ) + |