bonding: export path of master device property over DBUS
Adds a new "master" property to NMActiveConnection containing the path of the master NMDevice if the connection has a master. Signed-off-by: Thomas Graf <tgraf@redhat.com>
This commit is contained in:

committed by
Dan Williams

parent
93f289bc13
commit
1ba50e2f1b
@@ -37,6 +37,9 @@
|
|||||||
<property name="Vpn" type="b" access="read">
|
<property name="Vpn" type="b" access="read">
|
||||||
<tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>
|
<tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="Master" type="s" access="read">
|
||||||
|
<tp:docstring>The path to the master device if the connection is a slave.</tp:docstring>
|
||||||
|
</property>
|
||||||
|
|
||||||
<signal name="PropertiesChanged">
|
<signal name="PropertiesChanged">
|
||||||
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
|
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
|
||||||
|
@@ -23,6 +23,7 @@ global:
|
|||||||
nm_active_connection_get_default6;
|
nm_active_connection_get_default6;
|
||||||
nm_active_connection_get_default;
|
nm_active_connection_get_default;
|
||||||
nm_active_connection_get_devices;
|
nm_active_connection_get_devices;
|
||||||
|
nm_active_connection_get_master;
|
||||||
nm_active_connection_get_specific_object;
|
nm_active_connection_get_specific_object;
|
||||||
nm_active_connection_get_state;
|
nm_active_connection_get_state;
|
||||||
nm_active_connection_get_type;
|
nm_active_connection_get_type;
|
||||||
|
@@ -50,6 +50,7 @@ typedef struct {
|
|||||||
NMActiveConnectionState state;
|
NMActiveConnectionState state;
|
||||||
gboolean is_default;
|
gboolean is_default;
|
||||||
gboolean is_default6;
|
gboolean is_default6;
|
||||||
|
char *master;
|
||||||
} NMActiveConnectionPrivate;
|
} NMActiveConnectionPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -61,6 +62,7 @@ enum {
|
|||||||
PROP_STATE,
|
PROP_STATE,
|
||||||
PROP_DEFAULT,
|
PROP_DEFAULT,
|
||||||
PROP_DEFAULT6,
|
PROP_DEFAULT6,
|
||||||
|
PROP_MASTER,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
@@ -72,6 +74,7 @@ enum {
|
|||||||
#define DBUS_PROP_STATE "State"
|
#define DBUS_PROP_STATE "State"
|
||||||
#define DBUS_PROP_DEFAULT "Default"
|
#define DBUS_PROP_DEFAULT "Default"
|
||||||
#define DBUS_PROP_DEFAULT6 "Default6"
|
#define DBUS_PROP_DEFAULT6 "Default6"
|
||||||
|
#define DBUS_PROP_MASTER "Master"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_active_connection_new:
|
* nm_active_connection_new:
|
||||||
@@ -290,6 +293,33 @@ nm_active_connection_get_default6 (NMActiveConnection *connection)
|
|||||||
return priv->is_default6;
|
return priv->is_default6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nm_active_connection_get_master:
|
||||||
|
* @connection: a #NMActiveConnection
|
||||||
|
*
|
||||||
|
* Gets the path to the master #NMDevice of the connection.
|
||||||
|
*
|
||||||
|
* Returns: the path of the master #NMDevice of the #NMActiveConnection.
|
||||||
|
* This is the internal string used by the connection, and must not be modified.
|
||||||
|
**/
|
||||||
|
const char *
|
||||||
|
nm_active_connection_get_master (NMActiveConnection *connection)
|
||||||
|
{
|
||||||
|
NMActiveConnectionPrivate *priv;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL);
|
||||||
|
|
||||||
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
|
||||||
|
if (!priv->master) {
|
||||||
|
priv->master = _nm_object_get_string_property (NM_OBJECT (connection),
|
||||||
|
NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
|
||||||
|
DBUS_PROP_MASTER,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return priv->master;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_active_connection_init (NMActiveConnection *ap)
|
nm_active_connection_init (NMActiveConnection *ap)
|
||||||
{
|
{
|
||||||
@@ -324,6 +354,7 @@ finalize (GObject *object)
|
|||||||
g_free (priv->connection);
|
g_free (priv->connection);
|
||||||
g_free (priv->uuid);
|
g_free (priv->uuid);
|
||||||
g_free (priv->specific_object);
|
g_free (priv->specific_object);
|
||||||
|
g_free (priv->master);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_active_connection_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_active_connection_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@@ -355,6 +386,9 @@ get_property (GObject *object,
|
|||||||
case PROP_DEFAULT6:
|
case PROP_DEFAULT6:
|
||||||
g_value_set_boolean (value, nm_active_connection_get_default6 (self));
|
g_value_set_boolean (value, nm_active_connection_get_default6 (self));
|
||||||
break;
|
break;
|
||||||
|
case PROP_MASTER:
|
||||||
|
g_value_set_string (value, nm_active_connection_get_master (self));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -514,4 +548,17 @@ nm_active_connection_class_init (NMActiveConnectionClass *ap_class)
|
|||||||
"Is the default IPv6 active connection",
|
"Is the default IPv6 active connection",
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NMActiveConnection:master:
|
||||||
|
*
|
||||||
|
* The path of the master device if one exists.
|
||||||
|
**/
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_MASTER,
|
||||||
|
g_param_spec_string (NM_ACTIVE_CONNECTION_MASTER,
|
||||||
|
"Master",
|
||||||
|
"Path of the master device",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@ G_BEGIN_DECLS
|
|||||||
#define NM_ACTIVE_CONNECTION_STATE "state"
|
#define NM_ACTIVE_CONNECTION_STATE "state"
|
||||||
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
|
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
|
||||||
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
|
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
|
||||||
|
#define NM_ACTIVE_CONNECTION_MASTER "master"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMObject parent;
|
NMObject parent;
|
||||||
@@ -74,6 +75,7 @@ const GPtrArray *nm_active_connection_get_devices (NMActiveConnection *c
|
|||||||
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
|
NMActiveConnectionState nm_active_connection_get_state (NMActiveConnection *connection);
|
||||||
gboolean nm_active_connection_get_default (NMActiveConnection *connection);
|
gboolean nm_active_connection_get_default (NMActiveConnection *connection);
|
||||||
gboolean nm_active_connection_get_default6 (NMActiveConnection *connection);
|
gboolean nm_active_connection_get_default6 (NMActiveConnection *connection);
|
||||||
|
const char * nm_active_connection_get_master (NMActiveConnection *connection);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -91,6 +91,7 @@ enum {
|
|||||||
PROP_DEFAULT,
|
PROP_DEFAULT,
|
||||||
PROP_DEFAULT6,
|
PROP_DEFAULT6,
|
||||||
PROP_VPN,
|
PROP_VPN,
|
||||||
|
PROP_MASTER,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
@@ -558,6 +559,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_VPN:
|
case PROP_VPN:
|
||||||
g_value_set_boolean (value, FALSE);
|
g_value_set_boolean (value, FALSE);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MASTER:
|
||||||
|
g_value_set_string (value, nm_device_get_master_path (priv->device));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -632,7 +636,8 @@ nm_act_request_class_init (NMActRequestClass *req_class)
|
|||||||
PROP_STATE,
|
PROP_STATE,
|
||||||
PROP_DEFAULT,
|
PROP_DEFAULT,
|
||||||
PROP_DEFAULT6,
|
PROP_DEFAULT6,
|
||||||
PROP_VPN);
|
PROP_VPN,
|
||||||
|
PROP_MASTER);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
signals[PROPERTIES_CHANGED] =
|
signals[PROPERTIES_CHANGED] =
|
||||||
|
@@ -41,7 +41,8 @@ nm_active_connection_install_properties (GObjectClass *object_class,
|
|||||||
guint prop_state,
|
guint prop_state,
|
||||||
guint prop_default,
|
guint prop_default,
|
||||||
guint prop_default6,
|
guint prop_default6,
|
||||||
guint prop_vpn)
|
guint prop_vpn,
|
||||||
|
guint prop_master)
|
||||||
{
|
{
|
||||||
g_object_class_install_property (object_class, prop_connection,
|
g_object_class_install_property (object_class, prop_connection,
|
||||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
|
||||||
@@ -100,5 +101,12 @@ nm_active_connection_install_properties (GObjectClass *object_class,
|
|||||||
"Is a VPN connection",
|
"Is a VPN connection",
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, prop_master,
|
||||||
|
g_param_spec_string (NM_ACTIVE_CONNECTION_MASTER,
|
||||||
|
"Master",
|
||||||
|
"Path of master device",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
|
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
|
||||||
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
|
#define NM_ACTIVE_CONNECTION_DEFAULT6 "default6"
|
||||||
#define NM_ACTIVE_CONNECTION_VPN "vpn"
|
#define NM_ACTIVE_CONNECTION_VPN "vpn"
|
||||||
|
#define NM_ACTIVE_CONNECTION_MASTER "master"
|
||||||
|
|
||||||
char *nm_active_connection_get_next_object_path (void);
|
char *nm_active_connection_get_next_object_path (void);
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ void nm_active_connection_install_properties (GObjectClass *object_class,
|
|||||||
guint prop_state,
|
guint prop_state,
|
||||||
guint prop_default,
|
guint prop_default,
|
||||||
guint prop_default6,
|
guint prop_default6,
|
||||||
guint prop_vpn);
|
guint prop_vpn,
|
||||||
|
guint prop_master);
|
||||||
|
|
||||||
#endif /* NM_ACTIVE_CONNECTION_H */
|
#endif /* NM_ACTIVE_CONNECTION_H */
|
||||||
|
@@ -572,6 +572,17 @@ nm_device_get_master (NMDevice *self)
|
|||||||
return NM_DEVICE_GET_PRIVATE (self)->master;
|
return NM_DEVICE_GET_PRIVATE (self)->master;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_device_get_master_path (NMDevice *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (self != NULL, NULL);
|
||||||
|
|
||||||
|
if (NM_DEVICE_GET_PRIVATE (self)->master)
|
||||||
|
return nm_device_get_path (NM_DEVICE_GET_PRIVATE (self)->master);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_device_set_master (NMDevice *self, NMDevice *master)
|
nm_device_set_master (NMDevice *self, NMDevice *master)
|
||||||
{
|
{
|
||||||
@@ -580,6 +591,9 @@ nm_device_set_master (NMDevice *self, NMDevice *master)
|
|||||||
if (priv->master)
|
if (priv->master)
|
||||||
g_object_unref (priv->master);
|
g_object_unref (priv->master);
|
||||||
priv->master = master ? g_object_ref (master) : NULL;
|
priv->master = master ? g_object_ref (master) : NULL;
|
||||||
|
|
||||||
|
if (priv->act_request)
|
||||||
|
g_object_notify (G_OBJECT (priv->act_request), NM_ACTIVE_CONNECTION_MASTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -173,6 +173,7 @@ NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
|
|||||||
NMIP6Config * nm_device_get_ip6_config (NMDevice *dev);
|
NMIP6Config * nm_device_get_ip6_config (NMDevice *dev);
|
||||||
|
|
||||||
NMDevice * nm_device_get_master (NMDevice *self);
|
NMDevice * nm_device_get_master (NMDevice *self);
|
||||||
|
const char *nm_device_get_master_path (NMDevice *self);
|
||||||
void nm_device_set_master (NMDevice *self, NMDevice *master);
|
void nm_device_set_master (NMDevice *self, NMDevice *master);
|
||||||
|
|
||||||
NMActRequest * nm_device_get_act_request (NMDevice *dev);
|
NMActRequest * nm_device_get_act_request (NMDevice *dev);
|
||||||
|
@@ -52,6 +52,7 @@ enum {
|
|||||||
PROP_DEFAULT,
|
PROP_DEFAULT,
|
||||||
PROP_DEFAULT6,
|
PROP_DEFAULT6,
|
||||||
PROP_VPN,
|
PROP_VPN,
|
||||||
|
PROP_MASTER,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
@@ -175,6 +176,8 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case PROP_VPN:
|
case PROP_VPN:
|
||||||
g_value_set_boolean (value, TRUE);
|
g_value_set_boolean (value, TRUE);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MASTER:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -201,7 +204,8 @@ nm_vpn_connection_base_class_init (NMVpnConnectionBaseClass *vpn_class)
|
|||||||
PROP_STATE,
|
PROP_STATE,
|
||||||
PROP_DEFAULT,
|
PROP_DEFAULT,
|
||||||
PROP_DEFAULT6,
|
PROP_DEFAULT6,
|
||||||
PROP_VPN);
|
PROP_VPN,
|
||||||
|
PROP_MASTER);
|
||||||
|
|
||||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (vpn_class),
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (vpn_class),
|
||||||
&dbus_glib_nm_vpn_connection_base_object_info);
|
&dbus_glib_nm_vpn_connection_base_object_info);
|
||||||
|
Reference in New Issue
Block a user