Add wrappers for TUN/TAP devices and WireGuard devices

This commit is contained in:
Lucy 2022-02-08 12:27:35 -05:00
parent 4704a1672d
commit 8bdccc1f18
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
7 changed files with 194 additions and 2 deletions

View file

@ -21,7 +21,9 @@
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
pub mod bluetooth;
pub mod tun;
pub mod wired;
pub mod wireguard;
pub mod wireless;
use zbus::dbus_proxy;

View file

@ -0,0 +1,48 @@
// SPDX-License-Identifier: MPL-2.0
//! # DBus interface proxy for: `org.freedesktop.NetworkManager.Device.Tun`
//!
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
//! Source: `org.freedesktop.NetworkManager.Device.Tun.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
//! More information can be found in the
//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
//! section of the zbus documentation.
//!
use zbus::dbus_proxy;
#[dbus_proxy(
interface = "org.freedesktop.NetworkManager.Device.Tun",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait TunDevice {
/// Group property
#[dbus_proxy(property)]
fn group(&self) -> zbus::Result<i64>;
/// HwAddress property
#[dbus_proxy(property)]
fn hw_address(&self) -> zbus::Result<String>;
/// Mode property
#[dbus_proxy(property)]
fn mode(&self) -> zbus::Result<String>;
/// MultiQueue property
#[dbus_proxy(property)]
fn multi_queue(&self) -> zbus::Result<bool>;
/// NoPi property
#[dbus_proxy(property)]
fn no_pi(&self) -> zbus::Result<bool>;
/// Owner property
#[dbus_proxy(property)]
fn owner(&self) -> zbus::Result<i64>;
/// VnetHdr property
#[dbus_proxy(property)]
fn vnet_hdr(&self) -> zbus::Result<bool>;
}

View file

@ -0,0 +1,32 @@
// SPDX-License-Identifier: MPL-2.0
//! # DBus interface proxy for: `org.freedesktop.NetworkManager.Device.WireGuard`
//!
//! This code was generated by `zbus-xmlgen` `2.0.1` from DBus introspection data.
//! Source: `org.freedesktop.NetworkManager.Device.WireGuard.xml`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
//! More information can be found in the
//! [Writing a client proxy](https://dbus.pages.freedesktop.org/zbus/client.html)
//! section of the zbus documentation.
//!
use zbus::dbus_proxy;
#[dbus_proxy(
interface = "org.freedesktop.NetworkManager.Device.WireGuard",
default_service = "org.freedesktop.NetworkManager"
)]
pub trait WireGuardDevice {
/// FwMark property
#[dbus_proxy(property)]
fn fw_mark(&self) -> zbus::Result<u32>;
/// ListenPort property
#[dbus_proxy(property)]
fn listen_port(&self) -> zbus::Result<u16>;
/// PublicKey property
#[dbus_proxy(property)]
fn public_key(&self) -> zbus::Result<Vec<u8>>;
}

View file

@ -51,6 +51,8 @@ pub enum DeviceType {
Ethernet,
Wifi,
Bluetooth,
TunTap,
WireGuard,
Generic,
Other,
Unknown,
@ -63,6 +65,8 @@ impl From<u32> for DeviceType {
2 => DeviceType::Wifi,
5 => DeviceType::Bluetooth,
14 => DeviceType::Generic,
16 => DeviceType::TunTap,
29 => DeviceType::WireGuard,
3..=32 => DeviceType::Other,
_ => DeviceType::Unknown,
}