ethernet: port to internal device factory

This commit is contained in:
Dan Williams 2014-09-10 10:59:40 -05:00
parent 388e53b180
commit 2a55c450bd
5 changed files with 28 additions and 30 deletions

View file

@ -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 \

View file

@ -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; \
)

View file

@ -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 */

View file

@ -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;

View file

@ -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 \