platform: add ifindex arg to NMPlatform signals
In some cases, callers don't need to distinguish, eg, ip4-address-added from ip6-address-added, but just need to know what device the event occurred on. Make this simpler by including the ifindex as a separate explicit argument, allowing callers to just ignore the struct part.
This commit is contained in:
@@ -22,7 +22,8 @@ nm_daemon_all_sources = \
|
||||
$(top_srcdir)/src/modem-manager/*.[ch] \
|
||||
$(top_srcdir)/src/bluez-manager/*.[ch] \
|
||||
$(top_srcdir)/src/firewall-manager/*.[ch] \
|
||||
$(top_srcdir)/src/settings/*.[ch]
|
||||
$(top_srcdir)/src/settings/*.[ch] \
|
||||
$(top_srcdir)/src/platform/*.[ch]
|
||||
|
||||
if WITH_WIMAX
|
||||
nm_daemon_all_sources += $(top_srcdir)/src/wimax/*.[ch]
|
||||
@@ -68,6 +69,7 @@ INCLUDES = \
|
||||
-I$(top_srcdir)/src/bluez-manager \
|
||||
-I$(top_srcdir)/src/firewall-manager \
|
||||
-I$(top_srcdir)/src/settings \
|
||||
-I$(top_srcdir)/src/platform \
|
||||
-I$(top_srcdir)/src/wifi \
|
||||
-I$(top_srcdir)/libnm-util
|
||||
|
||||
|
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
|
||||
-I${top_srcdir} \
|
||||
-I${top_srcdir}/src \
|
||||
-I${top_srcdir}/src/logging \
|
||||
-I${top_srcdir}/src/generated \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-DKERNEL_HACKS=1
|
||||
|
||||
@@ -26,5 +27,6 @@ libnm_platform_la_CPPFLAGS = \
|
||||
|
||||
libnm_platform_la_LIBADD = \
|
||||
$(top_builddir)/src/logging/libnm-logging.la \
|
||||
$(top_builddir)/src/generated/libnm-generated.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(LIBNL_LIBS)
|
||||
|
@@ -133,7 +133,7 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type)
|
||||
g_array_append_val (priv->links, device);
|
||||
|
||||
if (device.ifindex)
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_ADDED, &device);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_ADDED, device.ifindex, &device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ link_delete (NMPlatform *platform, int ifindex)
|
||||
memcpy (&deleted_device, device, sizeof (deleted_device));
|
||||
memset (device, 0, sizeof (*device));
|
||||
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_REMOVED, &deleted_device);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_LINK_REMOVED, ifindex, &deleted_device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ link_changed (NMPlatform *platform, NMPlatformLink *device)
|
||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||
int i;
|
||||
|
||||
g_signal_emit_by_name (platform, "link-changed", device);
|
||||
g_signal_emit_by_name (platform, "link-changed", device->ifindex, device);
|
||||
|
||||
if (device->master) {
|
||||
NMPlatformLink *master = link_get (platform, device->master);
|
||||
@@ -491,7 +491,7 @@ ip4_address_add (NMPlatform *platform, int ifindex, in_addr_t addr, int plen)
|
||||
|
||||
g_array_append_val (priv->ip4_addresses, address);
|
||||
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_ADDED, &address);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_ADDED, ifindex, &address);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -509,7 +509,7 @@ ip6_address_add (NMPlatform *platform, int ifindex, struct in6_addr addr, int pl
|
||||
|
||||
g_array_append_val (priv->ip6_addresses, address);
|
||||
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_ADDED, &address);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_ADDED, ifindex, &address);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen)
|
||||
|
||||
memcpy (&deleted_address, address, sizeof (deleted_address));
|
||||
memset (address, 0, sizeof (*address));
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_REMOVED, &deleted_address);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ADDRESS_REMOVED, ifindex, &deleted_address);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -551,7 +551,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
|
||||
|
||||
memcpy (&deleted_address, address, sizeof (deleted_address));
|
||||
memset (address, 0, sizeof (*address));
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_REMOVED, &deleted_address);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ADDRESS_REMOVED, ifindex, &deleted_address);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -664,7 +664,7 @@ ip4_route_add (NMPlatform *platform, int ifindex, in_addr_t network, int plen,
|
||||
|
||||
g_array_append_val (priv->ip4_routes, route);
|
||||
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_ADDED, &route);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_ADDED, ifindex, &route);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -685,7 +685,7 @@ ip6_route_add (NMPlatform *platform, int ifindex, struct in6_addr network, int p
|
||||
|
||||
g_array_append_val (priv->ip6_routes, route);
|
||||
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_ADDED, &route);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_ADDED, ifindex, &route);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -743,7 +743,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen
|
||||
|
||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||
memset (route, 0, sizeof (*route));
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_REMOVED, &deleted_route);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_REMOVED, ifindex, &deleted_route);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -759,7 +759,7 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, in
|
||||
|
||||
memcpy (&deleted_route, route, sizeof (deleted_route));
|
||||
memset (route, 0, sizeof (*route));
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_REMOVED, &deleted_route);
|
||||
g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_REMOVED, ifindex, &deleted_route);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -483,7 +483,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
||||
NMPlatformLink device;
|
||||
|
||||
link_init (&device, (struct rtnl_link *) object);
|
||||
g_signal_emit_by_name (platform, sig, &device);
|
||||
g_signal_emit_by_name (platform, sig, device.ifindex, &device);
|
||||
}
|
||||
return;
|
||||
case IP4_ADDRESS:
|
||||
@@ -491,7 +491,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
||||
NMPlatformIP4Address address;
|
||||
|
||||
init_ip4_address (&address, (struct rtnl_addr *) object);
|
||||
g_signal_emit_by_name (platform, sig, &address);
|
||||
g_signal_emit_by_name (platform, sig, address.ifindex, &address);
|
||||
}
|
||||
return;
|
||||
case IP6_ADDRESS:
|
||||
@@ -499,7 +499,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
||||
NMPlatformIP6Address address;
|
||||
|
||||
init_ip6_address (&address, (struct rtnl_addr *) object);
|
||||
g_signal_emit_by_name (platform, sig, &address);
|
||||
g_signal_emit_by_name (platform, sig, address.ifindex, &address);
|
||||
}
|
||||
return;
|
||||
case IP4_ROUTE:
|
||||
@@ -507,7 +507,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
||||
NMPlatformIP4Route route;
|
||||
|
||||
init_ip4_route (&route, (struct rtnl_route *) object);
|
||||
g_signal_emit_by_name (platform, sig, &route);
|
||||
g_signal_emit_by_name (platform, sig, route.ifindex, &route);
|
||||
}
|
||||
return;
|
||||
case IP6_ROUTE:
|
||||
@@ -515,7 +515,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
|
||||
NMPlatformIP6Route route;
|
||||
|
||||
init_ip6_route (&route, (struct rtnl_route *) object);
|
||||
g_signal_emit_by_name (platform, sig, &route);
|
||||
g_signal_emit_by_name (platform, sig, route.ifindex, &route);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "nm-platform.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-marshal.h"
|
||||
|
||||
#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__)
|
||||
|
||||
@@ -974,21 +975,21 @@ nm_platform_ip6_route_exists (int ifindex,
|
||||
/******************************************************************/
|
||||
|
||||
static void
|
||||
log_link_added (NMPlatform *p, NMPlatformLink *info, gpointer user_data)
|
||||
log_link_added (NMPlatform *p, int ifindex, NMPlatformLink *info, gpointer user_data)
|
||||
{
|
||||
debug ("signal: link address: '%s' (%d)", info->name, info->ifindex);
|
||||
debug ("signal: link address: '%s' (%d)", info->name, ifindex);
|
||||
}
|
||||
|
||||
static void
|
||||
log_link_changed (NMPlatform *p, NMPlatformLink *info, gpointer user_data)
|
||||
log_link_changed (NMPlatform *p, int ifindex, NMPlatformLink *info, gpointer user_data)
|
||||
{
|
||||
debug ("signal: link changed: '%s' (%d)", info->name, info->ifindex);
|
||||
debug ("signal: link changed: '%s' (%d)", info->name, ifindex);
|
||||
}
|
||||
|
||||
static void
|
||||
log_link_removed (NMPlatform *p, NMPlatformLink *info, gpointer user_data)
|
||||
log_link_removed (NMPlatform *p, int ifindex, NMPlatformLink *info, gpointer user_data)
|
||||
{
|
||||
debug ("signal: link removed: '%s' (%d)", info->name, info->ifindex);
|
||||
debug ("signal: link removed: '%s' (%d)", info->name, ifindex);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1004,19 +1005,19 @@ log_ip4_address (NMPlatformIP4Address *address, const char *change_type)
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_address_added (NMPlatform *p, NMPlatformIP4Address *address, gpointer user_data)
|
||||
log_ip4_address_added (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip4_address (address, "added");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_address_changed (NMPlatform *p, NMPlatformIP4Address *address, gpointer user_data)
|
||||
log_ip4_address_changed (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip4_address (address, "changed");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_address_removed (NMPlatform *p, NMPlatformIP4Address *address, gpointer user_data)
|
||||
log_ip4_address_removed (NMPlatform *p, int ifindex, NMPlatformIP4Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip4_address (address, "removed");
|
||||
}
|
||||
@@ -1034,19 +1035,19 @@ log_ip6_address (NMPlatformIP6Address *address, const char *change_type)
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_address_added (NMPlatform *p, NMPlatformIP6Address *address, gpointer user_data)
|
||||
log_ip6_address_added (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip6_address (address, "added");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_address_changed (NMPlatform *p, NMPlatformIP6Address *address, gpointer user_data)
|
||||
log_ip6_address_changed (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip6_address (address, "changed");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_address_removed (NMPlatform *p, NMPlatformIP6Address *address, gpointer user_data)
|
||||
log_ip6_address_removed (NMPlatform *p, int ifindex, NMPlatformIP6Address *address, gpointer user_data)
|
||||
{
|
||||
log_ip6_address (address, "removed");
|
||||
}
|
||||
@@ -1066,19 +1067,19 @@ log_ip4_route (NMPlatformIP4Route *route, const char *change_type)
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_route_added (NMPlatform *p, NMPlatformIP4Route *route, gpointer user_data)
|
||||
log_ip4_route_added (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip4_route (route, "added");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_route_changed (NMPlatform *p, NMPlatformIP4Route *route, gpointer user_data)
|
||||
log_ip4_route_changed (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip4_route (route, "changed");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip4_route_removed (NMPlatform *p, NMPlatformIP4Route *route, gpointer user_data)
|
||||
log_ip4_route_removed (NMPlatform *p, int ifindex, NMPlatformIP4Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip4_route (route, "removed");
|
||||
}
|
||||
@@ -1098,19 +1099,19 @@ log_ip6_route (NMPlatformIP6Route *route, const char *change_type)
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_route_added (NMPlatform *p, NMPlatformIP6Route *route, gpointer user_data)
|
||||
log_ip6_route_added (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip6_route (route, "added");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_route_changed (NMPlatform *p, NMPlatformIP6Route *route, gpointer user_data)
|
||||
log_ip6_route_changed (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip6_route (route, "changed");
|
||||
}
|
||||
|
||||
static void
|
||||
log_ip6_route_removed (NMPlatform *p, NMPlatformIP6Route *route, gpointer user_data)
|
||||
log_ip6_route_removed (NMPlatform *p, int ifindex, NMPlatformIP6Route *route, gpointer user_data)
|
||||
{
|
||||
log_ip6_route (route, "removed");
|
||||
}
|
||||
@@ -1128,8 +1129,8 @@ nm_platform_init (NMPlatform *object)
|
||||
G_SIGNAL_RUN_FIRST, \
|
||||
G_CALLBACK (method), \
|
||||
NULL, NULL, \
|
||||
g_cclosure_marshal_VOID__POINTER, \
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER); \
|
||||
_nm_marshal_VOID__INT_POINTER, \
|
||||
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_POINTER); \
|
||||
|
||||
static void
|
||||
nm_platform_class_init (NMPlatformClass *platform_class)
|
||||
|
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
|
||||
-I${top_srcdir} \
|
||||
-I${top_srcdir}/src \
|
||||
-I${top_srcdir}/src/logging \
|
||||
-I${top_srcdir}/src/generated \
|
||||
-I${top_srcdir}/libnm-util \
|
||||
-I${srcdir}/.. \
|
||||
$(GLIB_CFLAGS) \
|
||||
@@ -11,7 +12,9 @@ AM_CPPFLAGS = \
|
||||
|
||||
AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
|
||||
AM_LDFLAGS = $(GLIB_LIBS) $(LIBNL_LIBS) $(CODE_COVERAGE_LDFLAGS)
|
||||
COMMON_LDADD = $(top_builddir)/src/logging/libnm-logging.la
|
||||
COMMON_LDADD = \
|
||||
$(top_builddir)/src/logging/libnm-logging.la \
|
||||
$(top_builddir)/src/generated/libnm-generated.la
|
||||
PLATFORM_LDADD = $(COMMON_LDADD) $(top_builddir)/src/platform/libnm-platform.la
|
||||
|
||||
@GNOME_CODE_COVERAGE_RULES@
|
||||
|
@@ -7,9 +7,10 @@
|
||||
#define IP6_PLEN 64
|
||||
|
||||
static void
|
||||
ip4_address_callback (NMPlatform *platform, NMPlatformIP4Address *received, SignalData *data)
|
||||
ip4_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Address *received, SignalData *data)
|
||||
{
|
||||
g_assert (received);
|
||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
@@ -24,9 +25,10 @@ ip4_address_callback (NMPlatform *platform, NMPlatformIP4Address *received, Sign
|
||||
}
|
||||
|
||||
static void
|
||||
ip6_address_callback (NMPlatform *platform, NMPlatformIP6Address *received, SignalData *data)
|
||||
ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *received, SignalData *data)
|
||||
{
|
||||
g_assert (received);
|
||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#define SLAVE_NAME "nm-test-slave"
|
||||
|
||||
static void
|
||||
link_callback (NMPlatform *platform, NMPlatformLink *received, SignalData *data)
|
||||
link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, SignalData *data)
|
||||
{
|
||||
|
||||
GArray *links;
|
||||
@@ -17,6 +17,7 @@ link_callback (NMPlatform *platform, NMPlatformLink *received, SignalData *data)
|
||||
int i;
|
||||
|
||||
g_assert (received);
|
||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
|
@@ -3,9 +3,10 @@
|
||||
#define DEVICE_NAME "nm-test-device"
|
||||
|
||||
static void
|
||||
ip4_route_callback (NMPlatform *platform, NMPlatformIP4Route *received, SignalData *data)
|
||||
ip4_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP4Route *received, SignalData *data)
|
||||
{
|
||||
g_assert (received);
|
||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
@@ -20,9 +21,10 @@ ip4_route_callback (NMPlatform *platform, NMPlatformIP4Route *received, SignalDa
|
||||
}
|
||||
|
||||
static void
|
||||
ip6_route_callback (NMPlatform *platform, NMPlatformIP6Route *received, SignalData *data)
|
||||
ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *received, SignalData *data)
|
||||
{
|
||||
g_assert (received);
|
||||
g_assert_cmpint (received->ifindex, ==, ifindex);
|
||||
|
||||
if (data->ifindex && data->ifindex != received->ifindex)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user