Commit fa325dca authored by Jiří Klimeš's avatar Jiří Klimeš

vlan: export parent device for VLANs as D-Bus property

and use the internal construct-time parent property for VLAN creation.
parent 5b75e00d
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
</tp:docstring> </tp:docstring>
</property> </property>
<property name="Parent" type="o" access="read">
<tp:docstring>
Object path of the parent device of this VLAN device.
</tp:docstring>
</property>
<property name="VlanId" type="u" access="read"> <property name="VlanId" type="u" access="read">
<tp:docstring> <tp:docstring>
The VLAN ID of this VLAN interface. The VLAN ID of this VLAN interface.
......
...@@ -67,6 +67,8 @@ enum { ...@@ -67,6 +67,8 @@ enum {
PROP_PARENT, PROP_PARENT,
PROP_VLAN_ID, PROP_VLAN_ID,
PROP_INT_PARENT_DEVICE,
LAST_PROP LAST_PROP
}; };
...@@ -477,6 +479,12 @@ get_property (GObject *object, guint prop_id, ...@@ -477,6 +479,12 @@ get_property (GObject *object, guint prop_id,
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
switch (prop_id) { switch (prop_id) {
case PROP_PARENT:
g_value_set_boxed (value, priv->parent ? nm_device_get_path (priv->parent) : "/");
break;
case PROP_INT_PARENT_DEVICE:
g_value_set_object (value, priv->parent);
break;
case PROP_VLAN_ID: case PROP_VLAN_ID:
g_value_set_uint (value, priv->vlan_id); g_value_set_uint (value, priv->vlan_id);
break; break;
...@@ -493,7 +501,7 @@ set_property (GObject *object, guint prop_id, ...@@ -493,7 +501,7 @@ set_property (GObject *object, guint prop_id,
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (object);
switch (prop_id) { switch (prop_id) {
case PROP_PARENT: case PROP_INT_PARENT_DEVICE:
nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), g_value_get_object (value)); nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), g_value_get_object (value));
break; break;
case PROP_VLAN_ID: case PROP_VLAN_ID:
...@@ -564,10 +572,10 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) ...@@ -564,10 +572,10 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
/* properties */ /* properties */
g_object_class_install_property g_object_class_install_property
(object_class, PROP_PARENT, (object_class, PROP_PARENT,
g_param_spec_object (NM_DEVICE_VLAN_PARENT, "", "", g_param_spec_boxed (NM_DEVICE_VLAN_PARENT, "", "",
NM_TYPE_DEVICE, DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
g_object_class_install_property g_object_class_install_property
(object_class, PROP_VLAN_ID, (object_class, PROP_VLAN_ID,
g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "", g_param_spec_uint (NM_DEVICE_VLAN_ID, "", "",
...@@ -575,6 +583,14 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) ...@@ -575,6 +583,14 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/* Internal properties */
g_object_class_install_property
(object_class, PROP_INT_PARENT_DEVICE,
g_param_spec_object (NM_DEVICE_VLAN_INT_PARENT_DEVICE, "", "",
NM_TYPE_DEVICE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (), nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_vlan_object_info); &dbus_glib_nm_device_vlan_object_info);
...@@ -613,7 +629,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) ...@@ -613,7 +629,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN, device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN,
NM_DEVICE_PLATFORM_DEVICE, plink, NM_DEVICE_PLATFORM_DEVICE, plink,
NM_DEVICE_VLAN_PARENT, parent, NM_DEVICE_VLAN_INT_PARENT_DEVICE, parent,
NM_DEVICE_DRIVER, "8021q", NM_DEVICE_DRIVER, "8021q",
NM_DEVICE_TYPE_DESC, "VLAN", NM_DEVICE_TYPE_DESC, "VLAN",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN, NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN,
...@@ -663,7 +679,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, ...@@ -663,7 +679,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN, device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN,
NM_DEVICE_IFACE, iface, NM_DEVICE_IFACE, iface,
NM_DEVICE_VLAN_PARENT, parent, NM_DEVICE_VLAN_INT_PARENT_DEVICE, parent,
NM_DEVICE_DRIVER, "8021q", NM_DEVICE_DRIVER, "8021q",
NM_DEVICE_TYPE_DESC, "VLAN", NM_DEVICE_TYPE_DESC, "VLAN",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN, NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_VLAN,
......
...@@ -40,9 +40,13 @@ typedef enum { ...@@ -40,9 +40,13 @@ typedef enum {
NM_VLAN_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/ NM_VLAN_ERROR_CONNECTION_INCOMPATIBLE, /*< nick=ConnectionIncompatible >*/
} NMVlanError; } NMVlanError;
/* D-Bus exported properties */
#define NM_DEVICE_VLAN_PARENT "parent" #define NM_DEVICE_VLAN_PARENT "parent"
#define NM_DEVICE_VLAN_ID "vlan-id" #define NM_DEVICE_VLAN_ID "vlan-id"
/* Internal non-exported properties */
#define NM_DEVICE_VLAN_INT_PARENT_DEVICE "int-parent-device"
typedef NMDevice NMDeviceVlan; typedef NMDevice NMDeviceVlan;
typedef NMDeviceClass NMDeviceVlanClass; typedef NMDeviceClass NMDeviceVlanClass;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment