diff options
| author | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
| commit | 2c032d8f1c6292c1338a615e6ec40252889ba85c (patch) | |
| tree | 1f77182220b2b0264288ba4a476ab47e5bc48716 /src/devices/nm-device-macvlan.c | |
| parent | 33491bc4279481db8ae47213e34a6d695a0e8830 (diff) | |
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/devices/nm-device-macvlan.c')
| -rw-r--r-- | src/devices/nm-device-macvlan.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 22848fe7..bcd38617 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -28,9 +28,13 @@ #include "nm-logging.h" #include "nm-manager.h" #include "nm-platform.h" +#include "nm-device-factory.h" #include "nm-device-macvlan-glue.h" +#include "nm-device-logging.h" +_LOG_DECLARE_SELF(NMDeviceMacvlan); + G_DEFINE_TYPE (NMDeviceMacvlan, nm_device_macvlan, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlanPrivate)) @@ -55,13 +59,13 @@ enum { static void update_properties (NMDevice *device) { + NMDeviceMacvlan *self = NM_DEVICE_MACVLAN (device); NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (device); GObject *object = G_OBJECT (device); NMPlatformMacvlanProperties props; if (!nm_platform_macvlan_get_properties (nm_device_get_ifindex (device), &props)) { - nm_log_warn (LOGD_HW, "(%s): could not read macvlan properties", - nm_device_get_iface (device)); + _LOGW (LOGD_HW, "could not read macvlan properties"); return; } @@ -88,18 +92,6 @@ link_changed (NMDevice *device, NMPlatformLink *info) /**************************************************************/ -NMDevice * -nm_device_macvlan_new (NMPlatformLink *platform_device) -{ - g_return_val_if_fail (platform_device != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN, - NM_DEVICE_PLATFORM_DEVICE, platform_device, - NM_DEVICE_TYPE_DESC, "Macvlan", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, - NULL); -} - static void nm_device_macvlan_init (NMDeviceMacvlan *self) { @@ -153,29 +145,49 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) /* properties */ g_object_class_install_property (object_class, PROP_PARENT, - g_param_spec_boxed (NM_DEVICE_MACVLAN_PARENT, - "Parent", - "Parent device", + g_param_spec_boxed (NM_DEVICE_MACVLAN_PARENT, "", "", DBUS_TYPE_G_OBJECT_PATH, - G_PARAM_READABLE)); + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_MODE, - g_param_spec_string (NM_DEVICE_MACVLAN_MODE, - "Mode", - "Mode: 'private', 'vepa', 'bridge', or 'passthru'", + g_param_spec_string (NM_DEVICE_MACVLAN_MODE, "", "", NULL, - G_PARAM_READABLE)); + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_NO_PROMISC, - g_param_spec_boolean (NM_DEVICE_MACVLAN_NO_PROMISC, - "No-promisc", - "No promiscuous mode", + g_param_spec_boolean (NM_DEVICE_MACVLAN_NO_PROMISC, "", "", FALSE, - 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_macvlan_object_info); } + +/*************************************************************/ + +#define NM_TYPE_MACVLAN_FACTORY (nm_macvlan_factory_get_type ()) +#define NM_MACVLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACVLAN_FACTORY, NMMacvlanFactory)) + +static NMDevice * +new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) +{ + if (plink->type == NM_LINK_TYPE_MACVLAN || plink->type == NM_LINK_TYPE_MACVTAP) { + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN, + NM_DEVICE_PLATFORM_DEVICE, plink, + NM_DEVICE_TYPE_DESC, "Macvlan", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC, + NULL); + } + return NULL; +} + +DEFINE_DEVICE_FACTORY_INTERNAL_WITH_DEVTYPE(MACVLAN, Macvlan, macvlan, ETHERNET, \ + factory_iface->new_link = new_link; \ + ) + |