1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
//! NetworkManager Device interfaces.
use std::collections::HashMap;
use zbus::{
proxy,
zvariant::{OwnedObjectPath, OwnedValue},
};
pub mod adsl;
pub mod bluetooth;
pub mod bond;
pub mod bridge;
pub mod dummy;
pub mod generic;
pub mod hsr;
pub mod infiniband;
pub mod ip_tunnel;
pub mod ipvlan;
pub mod loopback;
pub mod lowpan;
pub mod macsec;
pub mod macvlan;
pub mod modem;
pub mod olpc_mesh;
pub mod ovs_bridge;
pub mod ovs_interface;
pub mod ovs_port;
pub mod ppp;
pub mod statistics;
pub mod team;
pub mod tun;
pub mod veth;
pub mod vlan;
pub mod vrf;
pub mod vxlan;
pub mod wifi_p2p;
pub mod wired;
pub mod wireguard;
pub mod wireless;
pub mod wpan;
type NMAppliedConnection = HashMap<String, HashMap<String, OwnedValue>>;
#[proxy(
default_service = "org.freedesktop.NetworkManager",
interface = "org.freedesktop.NetworkManager.Device"
)]
pub(crate) trait Device {
/// Attempts to update device with new connection settings and properties.
///
/// # Arguments
/// * `connection` - Optional connection settings
/// * `version_id` - Settings version id (0 for current)
/// * `flags` - Flags (none defined)
fn reapply(
&self,
connection: HashMap<String, HashMap<String, OwnedValue>>,
version_id: u64,
flags: u32,
) -> zbus::Result<()>;
/// Get the currently applied connection on the device.
///
/// # Arguments
/// * `flags` - Flags (none defined)
///
/// # Returns
/// * Connection settings
/// * Version id
fn get_applied_connection(&self, flags: u32) -> zbus::Result<(NMAppliedConnection, u64)>;
/// Disconnects a device and prevents the device from automatically activating further connections without user intervention.
fn disconnect(&self) -> zbus::Result<()>;
/// Deletes a software device from NetworkManager and removes the interface from the system.
fn delete(&self) -> zbus::Result<()>;
/// Sets the managed state of the device with optional persistence. Since: 1.58.
///
/// # Arguments
/// * `managed` - 0 = unmanaged, 1 = managed, 2 = reset to default
/// * `flags` - NMDeviceManagedFlags
#[zbus(name = "SetManaged")]
fn set_managed_ext(&self, managed: u32, flags: u32) -> zbus::Result<()>;
/// Operating-system specific transient device hardware identifier.
#[zbus(property)]
fn udi(&self) -> zbus::Result<String>;
/// The path of the device as exposed by the udev property ID_PATH.
#[zbus(property)]
fn path(&self) -> zbus::Result<String>;
/// The name of the device's control (and often data) interface.
#[zbus(property)]
fn interface(&self) -> zbus::Result<String>;
/// The name of the device's data interface when available.
#[zbus(property)]
fn ip_interface(&self) -> zbus::Result<String>;
/// The driver handling the device.
#[zbus(property)]
fn driver(&self) -> zbus::Result<String>;
/// The version of the driver handling the device.
#[zbus(property)]
fn driver_version(&self) -> zbus::Result<String>;
/// The firmware version for the device.
#[zbus(property)]
fn firmware_version(&self) -> zbus::Result<String>;
/// Flags describing the capabilities of the device.
#[zbus(property)]
fn capabilities(&self) -> zbus::Result<u32>;
/// The current state of the device.
#[zbus(property)]
fn state(&self) -> zbus::Result<u32>;
/// The current state and reason for that state.
#[zbus(property)]
fn state_reason(&self) -> zbus::Result<(u32, u32)>;
/// Object path of an ActiveConnection object that "owns" this device during activation.
#[zbus(property)]
fn active_connection(&self) -> zbus::Result<OwnedObjectPath>;
/// Object path of the Ip4Config object describing the configuration of the device.
#[zbus(property)]
fn ip4_config(&self) -> zbus::Result<OwnedObjectPath>;
/// Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server.
#[zbus(property)]
fn dhcp4_config(&self) -> zbus::Result<OwnedObjectPath>;
/// Object path of the Ip6Config object describing the configuration of the device.
#[zbus(property)]
fn ip6_config(&self) -> zbus::Result<OwnedObjectPath>;
/// Object path of the Dhcp6Config object describing the DHCP options returned by the DHCP server.
#[zbus(property)]
fn dhcp6_config(&self) -> zbus::Result<OwnedObjectPath>;
/// Whether or not this device is managed by NetworkManager.
#[zbus(property)]
fn managed(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_managed(&self, managed: bool) -> zbus::Result<()>;
/// If TRUE, indicates the device is allowed to autoconnect.
#[zbus(property)]
fn autoconnect(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_autoconnect(&self, autoconnect: bool) -> zbus::Result<()>;
/// If TRUE, indicates the device is likely missing firmware necessary for its operation.
#[zbus(property)]
fn firmware_missing(&self) -> zbus::Result<bool>;
/// If TRUE, indicates the NetworkManager plugin for the device is likely missing or misconfigured.
#[zbus(property)]
fn nm_plugin_missing(&self) -> zbus::Result<bool>;
/// The general type of the network device.
#[zbus(property)]
fn device_type(&self) -> zbus::Result<u32>;
/// An array of object paths of every configured connection that is currently 'available' through this device.
#[zbus(property)]
fn available_connections(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
/// If non-empty, an (opaque) indicator of the physical network port associated with the device.
#[zbus(property)]
fn physical_port_id(&self) -> zbus::Result<String>;
/// The MTU of the device.
#[zbus(property)]
fn mtu(&self) -> zbus::Result<u32>;
/// Whether the amount of traffic flowing through the device is subject to limitations.
#[zbus(property)]
fn metered(&self) -> zbus::Result<u32>;
/// Array of LLDP neighbors.
#[zbus(property)]
fn lldp_neighbors(&self) -> zbus::Result<Vec<HashMap<String, OwnedValue>>>;
/// True if the device exists, or False for placeholder devices.
#[zbus(property)]
fn real(&self) -> zbus::Result<bool>;
/// The result of the last IPv4 connectivity check.
#[zbus(property)]
fn ip4_connectivity(&self) -> zbus::Result<u32>;
/// The result of the last IPv6 connectivity check.
#[zbus(property)]
fn ip6_connectivity(&self) -> zbus::Result<u32>;
/// The flags of the network interface.
#[zbus(property)]
fn interface_flags(&self) -> zbus::Result<u32>;
/// The hardware address of the device.
#[zbus(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// The port devices of the controller device.
#[zbus(property)]
fn ports(&self) -> zbus::Result<Vec<OwnedObjectPath>>;
/// Emitted when the device's state changes.
#[zbus(signal, name = "StateChanged")]
fn device_state_changed(&self, new_state: u32, old_state: u32, reason: u32)
-> zbus::Result<()>;
}