nm_rs/auto/device_tun.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5#![allow(deprecated)]
6
7use crate::{ffi,Device,Object};
8use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
9use std::{boxed::Box as Box_};
10
11glib::wrapper! {
12 ///
13 ///
14 /// ## Properties
15 ///
16 ///
17 /// #### `group`
18 /// The gid of the tunnel group, or -1 if it has no owner.
19 ///
20 /// Readable
21 ///
22 ///
23 /// #### `mode`
24 /// The tunnel mode, either "tun" or "tap".
25 ///
26 /// Readable
27 ///
28 ///
29 /// #### `multi-queue`
30 /// The tunnel's "TUN_TAP_MQ" flag; true if callers can connect to
31 /// the tap device multiple times, for multiple send/receive
32 /// queues.
33 ///
34 /// Readable
35 ///
36 ///
37 /// #### `no-pi`
38 /// The tunnel's "TUN_NO_PI" flag; true if no protocol info is
39 /// prepended to the tunnel packets.
40 ///
41 /// Readable
42 ///
43 ///
44 /// #### `owner`
45 /// The uid of the tunnel owner, or -1 if it has no owner.
46 ///
47 /// Readable
48 ///
49 ///
50 /// #### `vnet-hdr`
51 /// The tunnel's "TUN_VNET_HDR" flag; true if the tunnel packets
52 /// include a virtio network header.
53 ///
54 /// Readable
55 /// <details><summary><h4>Device</h4></summary>
56 ///
57 ///
58 /// #### `active-connection`
59 /// The #NMActiveConnection object that "owns" this device during activation.
60 ///
61 /// Readable
62 ///
63 ///
64 /// #### `autoconnect`
65 /// Whether the device can auto-activate a connection.
66 ///
67 /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
68 ///
69 /// Readable | Writeable
70 ///
71 ///
72 /// #### `available-connections`
73 /// The available connections of the device
74 ///
75 /// Readable
76 ///
77 ///
78 /// #### `capabilities`
79 /// The capabilities of the device.
80 ///
81 /// Readable
82 ///
83 ///
84 /// #### `device-type`
85 /// The numeric type of the device.
86 ///
87 /// Readable
88 ///
89 ///
90 /// #### `dhcp4-config`
91 /// The IPv4 #NMDhcpConfig of the device.
92 ///
93 /// Readable
94 ///
95 ///
96 /// #### `dhcp6-config`
97 /// The IPv6 #NMDhcpConfig of the device.
98 ///
99 /// Readable
100 ///
101 ///
102 /// #### `driver`
103 /// The driver of the device.
104 ///
105 /// Readable
106 ///
107 ///
108 /// #### `driver-version`
109 /// The version of the device driver.
110 ///
111 /// Readable
112 ///
113 ///
114 /// #### `firmware-missing`
115 /// When [`true`] indicates the device is likely missing firmware required
116 /// for its operation.
117 ///
118 /// Readable
119 ///
120 ///
121 /// #### `firmware-version`
122 /// The firmware version of the device.
123 ///
124 /// Readable
125 ///
126 ///
127 /// #### `hw-address`
128 /// The hardware address of the device.
129 ///
130 /// Readable
131 ///
132 ///
133 /// #### `interface`
134 /// The interface of the device.
135 ///
136 /// Readable
137 ///
138 ///
139 /// #### `interface-flags`
140 /// The interface flags.
141 ///
142 /// Readable
143 ///
144 ///
145 /// #### `ip-interface`
146 /// The IP interface of the device which should be used for all IP-related
147 /// operations like addressing and routing.
148 ///
149 /// Readable
150 ///
151 ///
152 /// #### `ip4-config`
153 /// The #NMIP4Config of the device.
154 ///
155 /// Readable
156 ///
157 ///
158 /// #### `ip4-connectivity`
159 /// The IPv4 connectivity state of the device.
160 ///
161 /// Readable
162 ///
163 ///
164 /// #### `ip6-config`
165 /// The IPv6 #NMIPConfig of the device.
166 ///
167 /// Readable
168 ///
169 ///
170 /// #### `ip6-connectivity`
171 /// The IPv6 connectivity state of the device.
172 ///
173 /// Readable
174 ///
175 ///
176 /// #### `lldp-neighbors`
177 /// The LLDP neighbors.
178 ///
179 /// Readable
180 ///
181 ///
182 /// #### `managed`
183 /// Whether the device is managed by NetworkManager.
184 ///
185 /// Readable
186 ///
187 ///
188 /// #### `metered`
189 /// Whether the device is metered.
190 ///
191 /// Readable
192 ///
193 ///
194 /// #### `mtu`
195 /// The MTU of the device.
196 ///
197 /// Readable
198 ///
199 ///
200 /// #### `nm-plugin-missing`
201 /// When [`true`] indicates that the NetworkManager plugin for the device
202 /// is not installed.
203 ///
204 /// Readable
205 ///
206 ///
207 /// #### `path`
208 /// The device path as exposed by the udev property ID_PATH.
209 ///
210 /// The string is backslash escaped (C escaping) for invalid
211 /// characters. The escaping can be reverted with g_strcompress(),
212 /// however the result may not be valid UTF-8.
213 ///
214 /// Readable
215 ///
216 ///
217 /// #### `physical-port-id`
218 /// The physical port ID of the device. (See
219 /// nm_device_get_physical_port_id().)
220 ///
221 /// Readable
222 ///
223 ///
224 /// #### `ports`
225 /// The port devices of the controller device. For devices that cannot be
226 /// controllers this is likely to be always empty.
227 ///
228 /// Readable
229 ///
230 ///
231 /// #### `product`
232 /// The product string of the device.
233 ///
234 /// Readable
235 ///
236 ///
237 /// #### `real`
238 /// Whether the device is real or is a placeholder device that could
239 /// be created automatically by NetworkManager if one of its
240 /// #NMDevice:available-connections was activated.
241 ///
242 /// Readable
243 ///
244 ///
245 /// #### `state`
246 /// The state of the device.
247 ///
248 /// Readable
249 ///
250 ///
251 /// #### `state-reason`
252 /// The reason for the device state.
253 ///
254 /// Readable
255 ///
256 ///
257 /// #### `udi`
258 /// An operating-system specific device hardware identifier; this is not
259 /// unique to a specific hardware device across reboots or hotplugs. It
260 /// is an opaque string which for some device types (Bluetooth, Modem)
261 /// contains an identifier provided by the underlying hardware service daemon
262 /// such as Bluez or ModemManager, and clients can use this property to
263 /// request more information about the device from those services.
264 ///
265 /// Readable
266 ///
267 ///
268 /// #### `vendor`
269 /// The vendor string of the device.
270 ///
271 /// Readable
272 /// </details>
273 /// <details><summary><h4>Object</h4></summary>
274 ///
275 ///
276 /// #### `client`
277 /// The NMClient instance as returned by nm_object_get_client().
278 ///
279 /// When an NMObject gets removed from the NMClient cache,
280 /// the NMObject:path property stays unchanged, but this client
281 /// instance gets reset to [`None`]. You can use this property to
282 /// track removal of the object from the cache.
283 ///
284 /// Readable
285 ///
286 ///
287 /// #### `path`
288 /// The D-Bus object path.
289 ///
290 /// The D-Bus path of an object instance never changes, even if the object
291 /// gets removed from the cache. To see whether the object is still in the
292 /// cache, check NMObject:client.
293 ///
294 /// Readable
295 /// </details>
296 ///
297 /// # Implements
298 ///
299 /// [`DeviceExt`][trait@crate::prelude::DeviceExt], [`ObjectExt`][trait@crate::prelude::ObjectExt]
300 #[doc(alias = "NMDeviceTun")]
301 pub struct DeviceTun(Object<ffi::NMDeviceTun, ffi::NMDeviceTunClass>) @extends Device, Object;
302
303 match fn {
304 type_ => || ffi::nm_device_tun_get_type(),
305 }
306}
307
308impl DeviceTun {
309 // rustdoc-stripper-ignore-next
310 /// Creates a new builder-pattern struct instance to construct [`DeviceTun`] objects.
311 ///
312 /// This method returns an instance of [`DeviceTunBuilder`](crate::builders::DeviceTunBuilder) which can be used to create [`DeviceTun`] objects.
313 pub fn builder() -> DeviceTunBuilder {
314 DeviceTunBuilder::new()
315 }
316
317
318 /// Gets the tunnel group.
319 ///
320 /// # Returns
321 ///
322 /// the gid of the tunnel group, or -1 if it has no owner.
323 #[doc(alias = "nm_device_tun_get_group")]
324 #[doc(alias = "get_group")]
325 pub fn group(&self) -> i64 {
326 unsafe {
327 ffi::nm_device_tun_get_group(self.to_glib_none().0)
328 }
329 }
330
331 /// Gets the hardware (MAC) address of the #NMDeviceTun
332 ///
333 /// # Deprecated since 1.24
334 ///
335 /// Use nm_device_get_hw_address() instead.
336 ///
337 /// # Returns
338 ///
339 /// the hardware address. This is the internal string used by the
340 /// device, and must not be modified.
341 #[cfg_attr(feature = "v1_24", deprecated = "Since 1.24")]
342 #[allow(deprecated)]
343 #[doc(alias = "nm_device_tun_get_hw_address")]
344 #[doc(alias = "get_hw_address")]
345 pub fn hw_address(&self) -> glib::GString {
346 unsafe {
347 from_glib_none(ffi::nm_device_tun_get_hw_address(self.to_glib_none().0))
348 }
349 }
350
351 /// Returns the TUN/TAP mode for the device.
352 ///
353 /// # Returns
354 ///
355 /// 'tun' or 'tap'
356 #[doc(alias = "nm_device_tun_get_mode")]
357 #[doc(alias = "get_mode")]
358 pub fn mode(&self) -> glib::GString {
359 unsafe {
360 from_glib_none(ffi::nm_device_tun_get_mode(self.to_glib_none().0))
361 }
362 }
363
364 /// Returns whether the #NMDeviceTun has the IFF_MULTI_QUEUE flag.
365 ///
366 /// # Returns
367 ///
368 /// [`true`] if the device doesn't have the flag, [`false`] otherwise
369 #[doc(alias = "nm_device_tun_get_multi_queue")]
370 #[doc(alias = "get_multi_queue")]
371 #[doc(alias = "multi-queue")]
372 pub fn is_multi_queue(&self) -> bool {
373 unsafe {
374 from_glib(ffi::nm_device_tun_get_multi_queue(self.to_glib_none().0))
375 }
376 }
377
378 /// Returns whether the #NMDeviceTun has the IFF_NO_PI flag.
379 ///
380 /// # Returns
381 ///
382 /// [`true`] if the device has the flag, [`false`] otherwise
383 #[doc(alias = "nm_device_tun_get_no_pi")]
384 #[doc(alias = "get_no_pi")]
385 #[doc(alias = "no-pi")]
386 pub fn is_no_pi(&self) -> bool {
387 unsafe {
388 from_glib(ffi::nm_device_tun_get_no_pi(self.to_glib_none().0))
389 }
390 }
391
392 /// Gets the tunnel owner.
393 ///
394 /// # Returns
395 ///
396 /// the uid of the tunnel owner, or -1 if it has no owner.
397 #[doc(alias = "nm_device_tun_get_owner")]
398 #[doc(alias = "get_owner")]
399 pub fn owner(&self) -> i64 {
400 unsafe {
401 ffi::nm_device_tun_get_owner(self.to_glib_none().0)
402 }
403 }
404
405 /// Returns whether the #NMDeviceTun has the IFF_VNET_HDR flag.
406 ///
407 /// # Returns
408 ///
409 /// [`true`] if the device has the flag, [`false`] otherwise
410 #[doc(alias = "nm_device_tun_get_vnet_hdr")]
411 #[doc(alias = "get_vnet_hdr")]
412 #[doc(alias = "vnet-hdr")]
413 pub fn is_vnet_hdr(&self) -> bool {
414 unsafe {
415 from_glib(ffi::nm_device_tun_get_vnet_hdr(self.to_glib_none().0))
416 }
417 }
418
419 #[cfg(feature = "v1_2")]
420 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
421 #[doc(alias = "group")]
422 pub fn connect_group_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
423 unsafe extern "C" fn notify_group_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
424 let f: &F = &*(f as *const F);
425 f(&from_glib_borrow(this))
426 }
427 unsafe {
428 let f: Box_<F> = Box_::new(f);
429 connect_raw(self.as_ptr() as *mut _, c"notify::group".as_ptr() as *const _,
430 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_group_trampoline::<F> as *const ())), Box_::into_raw(f))
431 }
432 }
433
434 #[cfg(feature = "v1_2")]
435 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
436 #[doc(alias = "mode")]
437 pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
438 unsafe extern "C" fn notify_mode_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
439 let f: &F = &*(f as *const F);
440 f(&from_glib_borrow(this))
441 }
442 unsafe {
443 let f: Box_<F> = Box_::new(f);
444 connect_raw(self.as_ptr() as *mut _, c"notify::mode".as_ptr() as *const _,
445 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_mode_trampoline::<F> as *const ())), Box_::into_raw(f))
446 }
447 }
448
449 #[cfg(feature = "v1_2")]
450 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
451 #[doc(alias = "multi-queue")]
452 pub fn connect_multi_queue_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
453 unsafe extern "C" fn notify_multi_queue_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
454 let f: &F = &*(f as *const F);
455 f(&from_glib_borrow(this))
456 }
457 unsafe {
458 let f: Box_<F> = Box_::new(f);
459 connect_raw(self.as_ptr() as *mut _, c"notify::multi-queue".as_ptr() as *const _,
460 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_multi_queue_trampoline::<F> as *const ())), Box_::into_raw(f))
461 }
462 }
463
464 #[cfg(feature = "v1_2")]
465 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
466 #[doc(alias = "no-pi")]
467 pub fn connect_no_pi_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
468 unsafe extern "C" fn notify_no_pi_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
469 let f: &F = &*(f as *const F);
470 f(&from_glib_borrow(this))
471 }
472 unsafe {
473 let f: Box_<F> = Box_::new(f);
474 connect_raw(self.as_ptr() as *mut _, c"notify::no-pi".as_ptr() as *const _,
475 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_no_pi_trampoline::<F> as *const ())), Box_::into_raw(f))
476 }
477 }
478
479 #[cfg(feature = "v1_2")]
480 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
481 #[doc(alias = "owner")]
482 pub fn connect_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
483 unsafe extern "C" fn notify_owner_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
484 let f: &F = &*(f as *const F);
485 f(&from_glib_borrow(this))
486 }
487 unsafe {
488 let f: Box_<F> = Box_::new(f);
489 connect_raw(self.as_ptr() as *mut _, c"notify::owner".as_ptr() as *const _,
490 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_owner_trampoline::<F> as *const ())), Box_::into_raw(f))
491 }
492 }
493
494 #[cfg(feature = "v1_2")]
495 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
496 #[doc(alias = "vnet-hdr")]
497 pub fn connect_vnet_hdr_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
498 unsafe extern "C" fn notify_vnet_hdr_trampoline<F: Fn(&DeviceTun) + 'static>(this: *mut ffi::NMDeviceTun, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
499 let f: &F = &*(f as *const F);
500 f(&from_glib_borrow(this))
501 }
502 unsafe {
503 let f: Box_<F> = Box_::new(f);
504 connect_raw(self.as_ptr() as *mut _, c"notify::vnet-hdr".as_ptr() as *const _,
505 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_vnet_hdr_trampoline::<F> as *const ())), Box_::into_raw(f))
506 }
507 }
508}
509
510// rustdoc-stripper-ignore-next
511 /// A [builder-pattern] type to construct [`DeviceTun`] objects.
512 ///
513 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
514#[must_use = "The builder must be built to be used"]
515pub struct DeviceTunBuilder {
516 builder: glib::object::ObjectBuilder<'static, DeviceTun>,
517 }
518
519 impl DeviceTunBuilder {
520 fn new() -> Self {
521 Self { builder: glib::object::Object::builder() }
522 }
523
524 /// Whether the device can auto-activate a connection.
525 ///
526 /// The property setter is a synchronous D-Bus call. This is deprecated since 1.22.
527 pub fn autoconnect(self, autoconnect: bool) -> Self {
528 Self { builder: self.builder.property("autoconnect", autoconnect), }
529 }
530
531 // rustdoc-stripper-ignore-next
532 /// Build the [`DeviceTun`].
533 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
534 pub fn build(self) -> DeviceTun {
535assert_initialized_main_thread!();
536 self.builder.build() }
537}