Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
NetworkManager
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
147
Issues
147
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NetworkManager
NetworkManager
Commits
ad74379c
Commit
ad74379c
authored
Oct 17, 2012
by
Dan Winship
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, libnm-glib: expose "slaves" property on NMDeviceBond
https://bugzilla.gnome.org/show_bug.cgi?id=686367
parent
439fefd2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
3 deletions
+84
-3
introspection/nm-device-bond.xml
introspection/nm-device-bond.xml
+7
-0
libnm-glib/libnm-glib.ver
libnm-glib/libnm-glib.ver
+1
-0
libnm-glib/nm-device-bond.c
libnm-glib/nm-device-bond.c
+46
-1
libnm-glib/nm-device-bond.h
libnm-glib/nm-device-bond.h
+4
-2
src/nm-device-bond.c
src/nm-device-bond.c
+25
-0
src/nm-device-bond.h
src/nm-device-bond.h
+1
-0
No files found.
introspection/nm-device-bond.xml
View file @
ad74379c
...
...
@@ -15,6 +15,13 @@
</tp:docstring>
</property>
<property
name=
"Slaves"
type=
"ao"
access=
"read"
>
<tp:docstring>
Array of object paths representing devices which are currently
slaved to this device.
</tp:docstring>
</property>
<signal
name=
"PropertiesChanged"
>
<arg
name=
"properties"
type=
"a{sv}"
tp:type=
"String_Variant_Map"
>
<tp:docstring>
...
...
libnm-glib/libnm-glib.ver
View file @
ad74379c
...
...
@@ -67,6 +67,7 @@ global:
nm_device_bond_error_quark;
nm_device_bond_get_carrier;
nm_device_bond_get_hw_address;
nm_device_bond_get_slaves;
nm_device_bond_get_type;
nm_device_bond_new;
nm_device_bt_error_get_type;
...
...
libnm-glib/nm-device-bond.c
View file @
ad74379c
...
...
@@ -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,25 @@ 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.
**/
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 +190,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 +210,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 +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_bond_parent_class
)
->
dispose
(
object
);
}
...
...
@@ -249,6 +279,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 +331,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
));
}
libnm-glib/nm-device-bond.h
View file @
ad74379c
...
...
@@ -53,6 +53,7 @@ GQuark nm_device_bond_error_quark (void);
#define NM_DEVICE_BOND_HW_ADDRESS "hw-address"
#define NM_DEVICE_BOND_CARRIER "carrier"
#define NM_DEVICE_BOND_SLAVES "slaves"
typedef
struct
{
NMDevice
parent
;
...
...
@@ -74,8 +75,9 @@ GType nm_device_bond_get_type (void);
GObject
*
nm_device_bond_new
(
DBusGConnection
*
connection
,
const
char
*
path
);
const
char
*
nm_device_bond_get_hw_address
(
NMDeviceBond
*
device
);
gboolean
nm_device_bond_get_carrier
(
NMDeviceBond
*
device
);
const
char
*
nm_device_bond_get_hw_address
(
NMDeviceBond
*
device
);
gboolean
nm_device_bond_get_carrier
(
NMDeviceBond
*
device
);
const
GPtrArray
*
nm_device_bond_get_slaves
(
NMDeviceBond
*
device
);
G_END_DECLS
...
...
src/nm-device-bond.c
View file @
ad74379c
...
...
@@ -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
};
...
...
@@ -401,6 +403,7 @@ enslave_slave (NMDevice *device, NMDevice *slave)
nm_log_dbg
(
LOGD_DEVICE
,
"(%s): enslaved bond slave %s"
,
nm_device_get_ip_iface
(
device
),
nm_device_get_ip_iface
(
slave
));
g_object_notify
(
G_OBJECT
(
device
),
"slaves"
);
}
nm_device_hw_bring_up
(
slave
,
TRUE
,
&
no_firmware
);
...
...
@@ -430,6 +433,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
),
"slaves"
);
return
success
;
}
...
...
@@ -469,7 +473,12 @@ static void
get_property
(
GObject
*
object
,
guint
prop_id
,
GValue
*
value
,
GParamSpec
*
pspec
)
{
NMDeviceBond
*
self
=
NM_DEVICE_BOND
(
object
);
NMDeviceBondPrivate
*
priv
=
NM_DEVICE_BOND_GET_PRIVATE
(
self
);
const
guint8
*
current_addr
;
GPtrArray
*
slaves
;
GSList
*
iter
;
SlaveInfo
*
info
;
switch
(
prop_id
)
{
case
PROP_HW_ADDRESS
:
...
...
@@ -479,6 +488,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
;
...
...
@@ -557,6 +574,14 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
FALSE
,
G_PARAM_READABLE
));
g_object_class_install_property
(
object_class
,
PROP_SLAVES
,
g_param_spec_boxed
(
NM_DEVICE_BOND_SLAVES
,
"Slaves"
,
"Slaves"
,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH
,
G_PARAM_READABLE
));
/* Signals */
signals
[
PROPERTIES_CHANGED
]
=
nm_properties_changed_signal_new
(
object_class
,
...
...
src/nm-device-bond.h
View file @
ad74379c
...
...
@@ -42,6 +42,7 @@ typedef enum {
#define NM_DEVICE_BOND_HW_ADDRESS "hw-address"
#define NM_DEVICE_BOND_CARRIER "carrier"
#define NM_DEVICE_BOND_SLAVES "slaves"
typedef
struct
{
NMDeviceWired
parent
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment