core: don't use generated glib enum for platform types

This commit is contained in:
Thomas Haller
2016-10-22 13:08:36 +02:00
parent 931a5b4f1c
commit 3bbc55fd9c
15 changed files with 79 additions and 48 deletions

View File

@@ -1133,7 +1133,6 @@ src_libNetworkManagerBase_la_LIBADD = \
src_libNetworkManager_la_CPPFLAGS = $(src_cppflags)
src_libNetworkManager_la_SOURCES_enum = \
src/platform/nm-platform.h \
src/nm-types.h \
$(NULL)
@@ -1220,6 +1219,7 @@ src_libNetworkManager_la_SOURCES = \
src/platform/nm-platform-utils.c \
src/platform/nm-platform-utils.h \
src/platform/nm-platform.c \
src/platform/nm-platform.h \
src/platform/nm-linux-platform.c \
src/platform/nm-linux-platform.h \
src/platform/wifi/wifi-utils-nl80211.c \

View File

@@ -235,12 +235,14 @@ error:
static void
link_changed_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
NMPlatformLink *info,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMDeviceAdsl *self)
{
const NMPlatformSignalChangeType change_type = change_type_i;
if (change_type == NM_PLATFORM_SIGNAL_REMOVED) {
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self);
NMDevice *device = NM_DEVICE (self);

View File

@@ -2003,12 +2003,13 @@ device_ip_link_changed (NMDevice *self)
static void
link_changed_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
NMPlatformLink *info,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMDevice *self)
{
const NMPlatformSignalChangeType change_type = change_type_i;
NMDevicePrivate *priv;
if (change_type != NM_PLATFORM_SIGNAL_CHANGED)
@@ -9719,12 +9720,14 @@ queued_ip6_config_change (gpointer user_data)
static void
device_ipx_changed (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
gpointer platform_object,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMDevice *self)
{
const NMPObjectType obj_type = obj_type_i;
const NMPlatformSignalChangeType change_type = change_type_i;
NMDevicePrivate *priv;
NMPlatformIP6Address *addr;

View File

@@ -1364,12 +1364,14 @@ _platform_ipx_route_changed_cb (const VTableIP *vtable,
static void
_platform_changed_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
gpointer platform_object,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMDefaultRouteManager *self)
{
const NMPObjectType obj_type = obj_type_i;
switch (obj_type) {
case NMP_OBJECT_TYPE_IP4_ADDRESS:
_platform_ipx_route_changed_cb (&vtable_ip4, self, NULL);

View File

@@ -333,12 +333,14 @@ do_early_setup (int *argc, char **argv[])
static void
ip6_address_changed (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int iface,
NMPlatformIP6Address *addr,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMRDisc *rdisc)
{
const NMPlatformSignalChangeType change_type = change_type_i;
if ( (change_type == NM_PLATFORM_SIGNAL_CHANGED && addr->n_ifa_flags & IFA_F_DADFAILED)
|| (change_type == NM_PLATFORM_SIGNAL_REMOVED && addr->n_ifa_flags & IFA_F_TENTATIVE))
nm_rdisc_dad_failed (rdisc, &addr->address);

View File

@@ -2225,12 +2225,13 @@ out:
static void
platform_link_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
NMPlatformLink *plink,
NMPlatformSignalChangeType change_type,
int change_type_i,
gpointer user_data)
{
const NMPlatformSignalChangeType change_type = change_type_i;
PlatformLinkCbData *data;
switch (change_type) {

View File

@@ -1027,12 +1027,13 @@ _ip4_device_routes_idle_cb (IP4DeviceRoutePurgeEntry *entry)
static void
_ip4_device_routes_ip4_route_changed (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
const NMPlatformIP4Route *route,
NMPlatformSignalChangeType change_type,
int change_type_i,
NMRouteManager *self)
{
const NMPlatformSignalChangeType change_type = change_type_i;
NMRouteManagerPrivate *priv;
NMPObject obj_needle;
IP4DeviceRoutePurgeEntry *entry;

View File

@@ -321,7 +321,7 @@ link_add (NMPlatform *platform,
new_device = &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1);
if (device.link.ifindex) {
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, NM_PLATFORM_SIGNAL_ADDED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, device.link.ifindex, &device, (int) NM_PLATFORM_SIGNAL_ADDED);
link_changed (platform, &g_array_index (priv->links, NMFakePlatformLink, priv->links->len - 1), FALSE);
}
@@ -373,7 +373,7 @@ link_delete (NMPlatform *platform, int ifindex)
memset (route, 0, sizeof (*route));
}
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, ifindex, &deleted_device, NM_PLATFORM_SIGNAL_REMOVED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, ifindex, &deleted_device, (int) NM_PLATFORM_SIGNAL_REMOVED);
return TRUE;
}
@@ -391,7 +391,7 @@ link_changed (NMPlatform *platform, NMFakePlatformLink *device, gboolean raise_s
int i;
if (raise_signal)
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, NMP_OBJECT_TYPE_LINK, device->link.ifindex, &device->link, NM_PLATFORM_SIGNAL_CHANGED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, (int) NMP_OBJECT_TYPE_LINK, device->link.ifindex, &device->link, (int) NM_PLATFORM_SIGNAL_CHANGED);
if (device->link.ifindex && !IN6_IS_ADDR_UNSPECIFIED (&device->ip6_lladdr)) {
if (device->link.connected)
@@ -947,12 +947,12 @@ ip4_address_add (NMPlatform *platform,
memcpy (item, &address, sizeof (address));
if (changed)
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_CHANGED);
return TRUE;
}
g_array_append_val (priv->ip4_addresses, address);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_ADDED);
return TRUE;
}
@@ -994,12 +994,12 @@ ip6_address_add (NMPlatform *platform,
memcpy (item, &address, sizeof (address));
if (changed)
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_CHANGED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_CHANGED);
return TRUE;
}
g_array_append_val (priv->ip6_addresses, address);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, NM_PLATFORM_SIGNAL_ADDED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &address, (int) NM_PLATFORM_SIGNAL_ADDED);
return TRUE;
}
@@ -1021,7 +1021,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, guint8 pl
memcpy (&deleted_address, address, sizeof (deleted_address));
memset (address, 0, sizeof (*address));
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ADDRESS, ifindex, &deleted_address, (int) NM_PLATFORM_SIGNAL_REMOVED);
return TRUE;
}
}
@@ -1045,7 +1045,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, gui
memcpy (&deleted_address, address, sizeof (deleted_address));
memset (address, 0, sizeof (*address));
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &deleted_address, NM_PLATFORM_SIGNAL_REMOVED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex, &deleted_address, (int) NM_PLATFORM_SIGNAL_REMOVED);
return TRUE;
}
}
@@ -1170,7 +1170,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, guint8 p
memcpy (&deleted_route, route, sizeof (deleted_route));
g_array_remove_index (priv->ip4_routes, i);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &deleted_route, (int) NM_PLATFORM_SIGNAL_REMOVED);
}
return TRUE;
@@ -1196,7 +1196,7 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, gu
memcpy (&deleted_route, route, sizeof (deleted_route));
g_array_remove_index (priv->ip6_routes, i);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &deleted_route, NM_PLATFORM_SIGNAL_REMOVED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &deleted_route, (int) NM_PLATFORM_SIGNAL_REMOVED);
}
return TRUE;
@@ -1260,12 +1260,12 @@ ip4_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
}
memcpy (item, &route, sizeof (route));
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_CHANGED);
return TRUE;
}
g_array_append_val (priv->ip4_routes, route);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP4_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_ADDED);
return TRUE;
}
@@ -1326,12 +1326,12 @@ ip6_route_add (NMPlatform *platform, int ifindex, NMIPConfigSource source,
}
memcpy (item, &route, sizeof (route));
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_CHANGED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_CHANGED);
return TRUE;
}
g_array_append_val (priv->ip6_routes, route);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, NM_PLATFORM_SIGNAL_ADDED);
g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, (int) NMP_OBJECT_TYPE_IP6_ROUTE, ifindex, &route, (int) NM_PLATFORM_SIGNAL_ADDED);
return TRUE;
}

View File

@@ -2807,10 +2807,10 @@ do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cach
g_signal_emit (platform,
_nm_platform_signal_id_get (klass->signal_type_id),
0,
klass->obj_type,
(int) klass->obj_type,
obj_clone.object.ifindex,
&obj_clone.object,
(NMPlatformSignalChangeType) cache_op);
(int) cache_op);
}
/*****************************************************************************/

View File

@@ -4295,7 +4295,12 @@ nm_platform_class_init (NMPlatformClass *platform_class)
G_SIGNAL_RUN_FIRST, \
G_CALLBACK (method), \
NULL, NULL, NULL, \
G_TYPE_NONE, 4, NM_TYPE_POBJECT_TYPE, G_TYPE_INT, G_TYPE_POINTER, NM_TYPE_PLATFORM_SIGNAL_CHANGE_TYPE); \
G_TYPE_NONE, 4, \
G_TYPE_INT, /* (int) NMPObjectType */ \
G_TYPE_INT, /* ifindex */ \
G_TYPE_POINTER /* const NMPObject * */, \
G_TYPE_INT /* (int) NMPlatformSignalChangeType */ \
); \
} G_STMT_END
/* Signals */

View File

@@ -149,12 +149,15 @@ _free_signal (const char *file, int line, const char *func, SignalData *data)
}
void
link_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, SignalData *data)
link_callback (NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, SignalData *data)
{
const NMPObjectType obj_type = obj_type_i;
const NMPlatformSignalChangeType change_type = change_type_i;
GArray *links;
NMPlatformLink *cached;
int i;
g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_LINK);
g_assert (received);
g_assert_cmpint (received->ifindex, ==, ifindex);
g_assert (data && data->name);
@@ -341,10 +344,10 @@ typedef struct {
static void
_wait_for_signal_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
NMPlatformLink *plink,
NMPlatformSignalChangeType change_type,
int change_type_i,
gpointer user_data)
{
WaitForSignalData *data = user_data;

View File

@@ -80,7 +80,7 @@ void _free_signal (const char *file, int line, const char *func, SignalData *dat
#define ensure_no_signal(data) _ensure_no_signal(__FILE__, __LINE__, G_STRFUNC, data)
#define free_signal(data) _free_signal(__FILE__, __LINE__, G_STRFUNC, data)
void link_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, NMPlatformLink *received, NMPlatformSignalChangeType change_type, SignalData *data);
void link_callback (NMPlatform *platform, int obj_type_i, int ifindex, NMPlatformLink *received, int change_type_i, SignalData *data);
/*****************************************************************************/

View File

@@ -157,12 +157,15 @@ software_add (NMLinkType link_type, const char *name)
static void
test_link_changed_signal_cb (NMPlatform *platform,
NMPObjectType obj_type,
int obj_type_i,
int ifindex,
const NMPlatformIP4Route *route,
NMPlatformSignalChangeType change_type,
int change_type_i,
gboolean *p_test_link_changed_signal_arg)
{
const NMPObjectType obj_type = obj_type_i;
const NMPlatformSignalChangeType change_type = change_type_i;
/* test invocation of platform signals with multiple listeners
* connected to the signal. Platform signals have enum-typed
* arguments and there seem to be an issue with invoking such

View File

@@ -30,8 +30,12 @@
#define DEVICE_NAME "nm-test-device"
static void
ip4_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformIP4Route *received, NMPlatformSignalChangeType change_type, SignalData *data)
ip4_route_callback (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP4Route *received, int change_type_i, SignalData *data)
{
const NMPObjectType obj_type = obj_type_i;
const NMPlatformSignalChangeType change_type = change_type_i;
g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_IP4_ROUTE);
g_assert (received);
g_assert_cmpint (received->ifindex, ==, ifindex);
g_assert (data && data->name);
@@ -50,8 +54,12 @@ ip4_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, c
}
static void
ip6_route_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformIP6Route *received, NMPlatformSignalChangeType change_type, SignalData *data)
ip6_route_callback (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformIP6Route *received, int change_type_i, SignalData *data)
{
const NMPObjectType obj_type = obj_type_i;
const NMPlatformSignalChangeType change_type = change_type_i;
g_assert_cmpint (obj_type, ==, NMP_OBJECT_TYPE_IP6_ROUTE);
g_assert (received);
g_assert_cmpint (received->ifindex, ==, ifindex);
g_assert (data && data->name);

View File

@@ -116,10 +116,11 @@ devtimeout_ready (gpointer user_data)
}
static void
link_changed (NMPlatform *platform, NMPObjectType obj_type, int ifindex, const NMPlatformLink *link,
NMPlatformSignalChangeType change_type,
link_changed (NMPlatform *platform, int obj_type_i, int ifindex, const NMPlatformLink *link,
int change_type_i,
NMConnection *self)
{
const NMPlatformSignalChangeType change_type = change_type_i;
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE ((NMIfcfgConnection *) self);
const char *ifname;