diff options
author | Dan Williams <dcbw@redhat.com> | 2014-09-10 10:59:40 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-09-11 12:50:16 -0500 |
commit | 2a55c450bdfdf92ee76002443fc919bf28aabbc9 (patch) | |
tree | 546b18494bbdb15aacfacd613fe127e2bffa996e | |
parent | 388e53b1808ad49809392784899809631f372d4c (diff) |
ethernet: port to internal device factory
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.c | 36 | ||||
-rw-r--r-- | src/devices/nm-device-ethernet.h | 14 | ||||
-rw-r--r-- | src/nm-manager.c | 4 | ||||
-rw-r--r-- | src/tests/Makefile.am | 2 |
5 files changed, 28 insertions, 30 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bc961bb524..c2880b5cae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,6 +63,7 @@ NetworkManager_LDADD = libNetworkManager.la noinst_LTLIBRARIES = libNetworkManager.la nm_device_sources = \ + devices/nm-device-ethernet.c \ devices/nm-device-veth.c \ $(NULL) @@ -84,7 +85,6 @@ nm_sources = \ devices/nm-device.h \ devices/nm-device-bond.c \ devices/nm-device-bridge.c \ - devices/nm-device-ethernet.c \ devices/nm-device-ethernet-utils.c \ devices/nm-device-ethernet-utils.h \ devices/nm-device-factory.c \ diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 44159320c9..92d0b3dc7d 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -58,6 +58,7 @@ #include "nm-config.h" #include "nm-device-ethernet-utils.h" #include "nm-connection-provider.h" +#include "nm-device-factory.h" #include "nm-device-ethernet-glue.h" @@ -322,18 +323,6 @@ nm_device_ethernet_init (NMDeviceEthernet *self) priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } -NMDevice * -nm_device_ethernet_new (NMPlatformLink *platform_device) -{ - g_return_val_if_fail (platform_device != NULL, NULL); - - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET, - NM_DEVICE_PLATFORM_DEVICE, platform_device, - NM_DEVICE_TYPE_DESC, "Ethernet", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, - NULL); -} - static void update_permanent_hw_address (NMDevice *dev) { @@ -1761,3 +1750,26 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) dbus_g_error_domain_register (NM_ETHERNET_ERROR, NULL, NM_TYPE_ETHERNET_ERROR); } + +/*************************************************************/ + +#define NM_TYPE_ETHERNET_FACTORY (nm_ethernet_factory_get_type ()) +#define NM_ETHERNET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ETHERNET_FACTORY, NMEthernetFactory)) + +static NMDevice * +new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) +{ + if (plink->type == NM_LINK_TYPE_ETHERNET) { + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET, + NM_DEVICE_PLATFORM_DEVICE, plink, + NM_DEVICE_TYPE_DESC, "Ethernet", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET, + NULL); + } + return NULL; +} + +DEFINE_DEVICE_FACTORY_INTERNAL(ETHERNET, Ethernet, ethernet, \ + factory_iface->new_link = new_link; \ + ) + diff --git a/src/devices/nm-device-ethernet.h b/src/devices/nm-device-ethernet.h index c0ad7f2e24..ff21bcad99 100644 --- a/src/devices/nm-device-ethernet.h +++ b/src/devices/nm-device-ethernet.h @@ -45,21 +45,11 @@ typedef enum #define NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS "perm-hw-address" #define NM_DEVICE_ETHERNET_SPEED "speed" -typedef struct { - NMDevice parent; -} NMDeviceEthernet; - -typedef struct { - NMDeviceClass parent; - -} NMDeviceEthernetClass; - +typedef NMDevice NMDeviceEthernet; +typedef NMDeviceClass NMDeviceEthernetClass; GType nm_device_ethernet_get_type (void); - -NMDevice *nm_device_ethernet_new (NMPlatformLink *platform_device); - G_END_DECLS #endif /* NM_DEVICE_ETHERNET_H */ diff --git a/src/nm-manager.c b/src/nm-manager.c index 57d60d1891..1e278f0dfa 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -39,7 +39,6 @@ #include "nm-dbus-manager.h" #include "nm-vpn-manager.h" #include "nm-device.h" -#include "nm-device-ethernet.h" #include "nm-device-infiniband.h" #include "nm-device-bond.h" #include "nm-device-bridge.h" @@ -2127,9 +2126,6 @@ platform_link_added (NMManager *self, NMDevice *parent; switch (plink->type) { - case NM_LINK_TYPE_ETHERNET: - device = nm_device_ethernet_new (plink); - break; case NM_LINK_TYPE_INFINIBAND: device = nm_device_infiniband_new (plink); break; diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index fe76e402ad..70797b6229 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -99,7 +99,7 @@ TESTS = \ if ENABLE_TESTS check-local: - @for t in veth; do \ + @for t in ethernet veth; do \ # Ensure the device subclass factory registration constructors exist \ # which could inadvertently break if src/Makefile.am gets changed \ if ! LC_ALL=C nm $(top_builddir)/src/NetworkManager | LC_ALL=C grep -q "register_device_factory_internal_$$t" ; then \ |