about summary refs log tree commit diff
path: root/libnm-glib/nm-device-bond.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib/nm-device-bond.c')
-rw-r--r--libnm-glib/nm-device-bond.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/libnm-glib/nm-device-bond.c b/libnm-glib/nm-device-bond.c
index d5e33e50..1d163c5e 100644
--- a/libnm-glib/nm-device-bond.c
+++ b/libnm-glib/nm-device-bond.c
@@ -33,6 +33,7 @@
 #include "nm-device-bond.h"
 #include "nm-device-private.h"
 #include "nm-object-private.h"
+#include "nm-types.h"
 
 G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE)
 
@@ -43,18 +44,21 @@ typedef struct {
 
 	char *hw_address;
 	gboolean carrier;
+	GPtrArray *slaves;
 } NMDeviceBondPrivate;
 
 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_bond_error_quark:
@@ -133,6 +137,27 @@ nm_device_bond_get_carrier (NMDeviceBond *device)
 	return NM_DEVICE_BOND_GET_PRIVATE (device)->carrier;
 }
 
+/**
+ * nm_device_bond_get_slaves:
+ * @device: a #NMDeviceBond
+ *
+ * Gets the devices currently slaved to @device.
+ *
+ * Returns: (element-type NMClient.Device): the #GPtrArray containing
+ * #NMDevice<!-- -->s that are slaves of @device. This is the internal
+ * copy used by the device, and must not be modified.
+ *
+ * Since: 0.9.6.4
+ **/
+const GPtrArray *
+nm_device_bond_get_slaves (NMDeviceBond *device)
+{
+	g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE);
+
+	_nm_object_ensure_inited (NM_OBJECT (device));
+	return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves);
+}
+
 static gboolean
 connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
 {
@@ -167,7 +192,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
 		return FALSE;
 	}
 
-	/* FIXME: check slaves? But we can't... */
+	/* FIXME: check slaves? */
 
 	return TRUE;
 }
@@ -187,6 +212,7 @@ register_properties (NMDeviceBond *device)
 	const NMPropertiesInfo property_info[] = {
 		{ NM_DEVICE_BOND_HW_ADDRESS, &priv->hw_address },
 		{ NM_DEVICE_BOND_CARRIER,    &priv->carrier },
+		{ NM_DEVICE_BOND_SLAVES,     &priv->slaves, NULL, NM_TYPE_DEVICE },
 		{ NULL },
 	};
 
@@ -219,6 +245,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_bond_parent_class)->dispose (object);
 }
 
@@ -249,6 +281,9 @@ get_property (GObject *object,
 	case PROP_CARRIER:
 		g_value_set_boolean (value, nm_device_bond_get_carrier (device));
 		break;
+	case PROP_SLAVES:
+		g_value_set_boxed (value, nm_device_bond_get_slaves (device));
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -298,4 +333,16 @@ nm_device_bond_class_init (NMDeviceBondClass *eth_class)
 		                       FALSE,
 		                       G_PARAM_READABLE));
 
+	/**
+	 * NMDeviceBond:slaves:
+	 *
+	 * The devices (#NMDevice) slaved to the bond device.
+	 **/
+	g_object_class_install_property
+		(object_class, PROP_SLAVES,
+		 g_param_spec_boxed (NM_DEVICE_BOND_SLAVES,
+		                     "Slaves",
+		                     "Slaves",
+		                     NM_TYPE_OBJECT_ARRAY,
+		                     G_PARAM_READABLE));
 }