diff --git a/introspection/nm-device-bridge.xml b/introspection/nm-device-bridge.xml
index 67ce419af0..f3b25602f0 100644
--- a/introspection/nm-device-bridge.xml
+++ b/introspection/nm-device-bridge.xml
@@ -15,6 +15,13 @@
+
+
+ Array of object paths representing devices which are currently
+ slaved to this device.
+
+
+
diff --git a/libnm-glib/libnm-glib.ver b/libnm-glib/libnm-glib.ver
index 4ea2489587..8e04b3019b 100644
--- a/libnm-glib/libnm-glib.ver
+++ b/libnm-glib/libnm-glib.ver
@@ -74,6 +74,7 @@ global:
nm_device_bridge_error_quark;
nm_device_bridge_get_carrier;
nm_device_bridge_get_hw_address;
+ nm_device_bridge_get_slaves;
nm_device_bridge_get_type;
nm_device_bridge_new;
nm_device_bt_error_get_type;
diff --git a/libnm-glib/nm-device-bridge.c b/libnm-glib/nm-device-bridge.c
index ec0264f807..34e02d6d96 100644
--- a/libnm-glib/nm-device-bridge.c
+++ b/libnm-glib/nm-device-bridge.c
@@ -33,6 +33,7 @@
#include "nm-device-bridge.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
+#include "nm-types.h"
G_DEFINE_TYPE (NMDeviceBridge, nm_device_bridge, NM_TYPE_DEVICE)
@@ -43,18 +44,21 @@ typedef struct {
char *hw_address;
gboolean carrier;
+ GPtrArray *slaves;
} NMDeviceBridgePrivate;
enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_CARRIER,
+ PROP_SLAVES,
LAST_PROP
};
#define DBUS_PROP_HW_ADDRESS "HwAddress"
#define DBUS_PROP_CARRIER "Carrier"
+#define DBUS_PROP_SLAVES "Slaves"
/**
* nm_device_bridge_error_quark:
@@ -133,6 +137,25 @@ nm_device_bridge_get_carrier (NMDeviceBridge *device)
return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->carrier;
}
+/**
+ * nm_device_bridge_get_slaves:
+ * @device: a #NMDeviceBridge
+ *
+ * Gets the devices currently slaved to @device.
+ *
+ * Returns: (element-type NMClient.Device): the #GPtrArray containing
+ * #NMDevices that are slaves of @device. This is the internal
+ * copy used by the device, and must not be modified.
+ **/
+const GPtrArray *
+nm_device_bridge_get_slaves (NMDeviceBridge *device)
+{
+ g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE);
+
+ _nm_object_ensure_inited (NM_OBJECT (device));
+ return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves);
+}
+
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
@@ -187,6 +210,7 @@ register_properties (NMDeviceBridge *device)
const NMPropertiesInfo property_info[] = {
{ NM_DEVICE_BRIDGE_HW_ADDRESS, &priv->hw_address },
{ NM_DEVICE_BRIDGE_CARRIER, &priv->carrier },
+ { NM_DEVICE_BRIDGE_SLAVES, &priv->slaves, NULL, NM_TYPE_DEVICE },
{ NULL },
};
@@ -219,6 +243,12 @@ dispose (GObject *object)
g_clear_object (&priv->proxy);
+ if (priv->slaves) {
+ g_ptr_array_foreach (priv->slaves, (GFunc) g_object_unref, NULL);
+ g_ptr_array_free (priv->slaves, TRUE);
+ priv->slaves = NULL;
+ }
+
G_OBJECT_CLASS (nm_device_bridge_parent_class)->dispose (object);
}
@@ -249,6 +279,9 @@ get_property (GObject *object,
case PROP_CARRIER:
g_value_set_boolean (value, nm_device_bridge_get_carrier (device));
break;
+ case PROP_SLAVES:
+ g_value_set_boxed (value, nm_device_bridge_get_slaves (device));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -298,4 +331,16 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *bridge_class)
FALSE,
G_PARAM_READABLE));
+ /**
+ * NMDeviceBridge:slaves:
+ *
+ * The devices (#NMDevice) slaved to the bridge device.
+ **/
+ g_object_class_install_property
+ (object_class, PROP_SLAVES,
+ g_param_spec_boxed (NM_DEVICE_BRIDGE_SLAVES,
+ "Slaves",
+ "Slaves",
+ NM_TYPE_OBJECT_ARRAY,
+ G_PARAM_READABLE));
}
diff --git a/libnm-glib/nm-device-bridge.h b/libnm-glib/nm-device-bridge.h
index f138922ae8..3462063d27 100644
--- a/libnm-glib/nm-device-bridge.h
+++ b/libnm-glib/nm-device-bridge.h
@@ -53,6 +53,7 @@ GQuark nm_device_bridge_error_quark (void);
#define NM_DEVICE_BRIDGE_HW_ADDRESS "hw-address"
#define NM_DEVICE_BRIDGE_CARRIER "carrier"
+#define NM_DEVICE_BRIDGE_SLAVES "slaves"
typedef struct {
NMDevice parent;
@@ -74,8 +75,9 @@ GType nm_device_bridge_get_type (void);
GObject * nm_device_bridge_new (DBusGConnection *connection, const char *path);
-const char * nm_device_bridge_get_hw_address (NMDeviceBridge *device);
-gboolean nm_device_bridge_get_carrier (NMDeviceBridge *device);
+const char *nm_device_bridge_get_hw_address (NMDeviceBridge *device);
+gboolean nm_device_bridge_get_carrier (NMDeviceBridge *device);
+const GPtrArray *nm_device_bridge_get_slaves (NMDeviceBridge *device);
G_END_DECLS
diff --git a/src/nm-device-bridge.c b/src/nm-device-bridge.c
index f4de9a8a6a..3c54cb0004 100644
--- a/src/nm-device-bridge.c
+++ b/src/nm-device-bridge.c
@@ -32,6 +32,7 @@
#include "NetworkManagerUtils.h"
#include "nm-device-private.h"
#include "nm-netlink-monitor.h"
+#include "nm-dbus-glib-types.h"
#include "nm-enum-types.h"
#include "nm-system.h"
@@ -60,6 +61,7 @@ enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_CARRIER,
+ PROP_SLAVES,
LAST_PROP
};
@@ -465,6 +467,8 @@ enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection)
nm_device_get_ip_iface (device),
nm_device_get_ip_iface (slave));
+ g_object_notify (G_OBJECT (device), NM_DEVICE_BRIDGE_SLAVES);
+
/* Set port properties */
s_port = nm_connection_get_setting_bridge_port (connection);
if (s_port) {
@@ -499,6 +503,7 @@ release_slave (NMDevice *device, NMDevice *slave)
success);
priv->slaves = g_slist_remove (priv->slaves, sinfo);
free_slave_info (sinfo);
+ g_object_notify (G_OBJECT (device), NM_DEVICE_BRIDGE_SLAVES);
return success;
}
@@ -538,7 +543,12 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
+ NMDeviceBridge *self = NM_DEVICE_BRIDGE (object);
+ NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (self);
const guint8 *current_addr;
+ GPtrArray *slaves;
+ GSList *iter;
+ SlaveInfo *info;
switch (prop_id) {
case PROP_HW_ADDRESS:
@@ -548,6 +558,14 @@ get_property (GObject *object, guint prop_id,
case PROP_CARRIER:
g_value_set_boolean (value, nm_device_wired_get_carrier (NM_DEVICE_WIRED (object)));
break;
+ case PROP_SLAVES:
+ slaves = g_ptr_array_new ();
+ for (iter = priv->slaves; iter; iter = iter->next) {
+ info = iter->data;
+ g_ptr_array_add (slaves, g_strdup (nm_device_get_path (info->slave)));
+ }
+ g_value_take_boxed (value, slaves);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -627,6 +645,14 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
FALSE,
G_PARAM_READABLE));
+ g_object_class_install_property
+ (object_class, PROP_SLAVES,
+ g_param_spec_boxed (NM_DEVICE_BRIDGE_SLAVES,
+ "Slaves",
+ "Slaves",
+ DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
+ G_PARAM_READABLE));
+
/* Signals */
signals[PROPERTIES_CHANGED] =
nm_properties_changed_signal_new (object_class,
diff --git a/src/nm-device-bridge.h b/src/nm-device-bridge.h
index 0ab07758b7..bf0ed01e8d 100644
--- a/src/nm-device-bridge.h
+++ b/src/nm-device-bridge.h
@@ -42,6 +42,7 @@ typedef enum {
#define NM_DEVICE_BRIDGE_HW_ADDRESS "hw-address"
#define NM_DEVICE_BRIDGE_CARRIER "carrier"
+#define NM_DEVICE_BRIDGE_SLAVES "slaves"
typedef struct {
NMDeviceWired parent;