NetworkManager bindings for Rust using the D-Bus message bus system
NOTE: At the moment i dont have any time to take care of this project. Contributors welcome!!
This project is still under development. Currently implemented parts can be found in the docs.
- NetworkManager D-Bus API >= v1.24.2
Add networkmanager and dbus to your Cargo.toml
with:
[dependencies]
networkmanager = "0.4"
dbus = "0.9"
use networkmanager::devices::{Any, Device, Wired, Wireless};
use networkmanager::{Error, NetworkManager};
use dbus::blocking::Connection;
fn main() -> Result<(), Error> {
let dbus_connection = Connection::new_system()?;
let nm = NetworkManager::new(&dbus_connection);
for dev in nm.get_devices()? {
match dev {
Device::Ethernet(x) => {
println!("Is autoconnected: {:?}", x.autoconnect()?);
println!("Speed: {:?}", x.speed()?);
println!("S390 Subchannels: {:?}", x.s390_subchannels()?);
println!("Carrier: {:?}", x.carrier()?);
}
Device::WiFi(x) => {
println!("Access Point: {:?}", x.access_points()?);
}
_ => {}
}
}
let enp0s2 = nm.get_device_by_ip_iface("enp0s2")?;
match enp0s2 {
Device::Ethernet(x) => {
// NetworkManager >= 1.24
// println!("Hardware Address: {:?}", Any::hw_address(&x)?);
// NetworkManager < 1.24
// println!("Hardware Address: {:?}", Wired::hw_address(&x)?);
println!("Speed: {:?}", x.speed()?);
}
_ => {}
}
Ok(())
}
-
- network-manager
- libdbus-1-dev
- pkg-config
-
- NetworkManager
- dbus-devel
- pkg-config
- Implementations
- Devices
- Any
- Generic
- Wireless
- Wired
- ADSL
- Bluetooth
- Bond
- Bridge
- Dummy
- Infiniband
- IpTunnel
- Lowpan
- Macsec
- MacVLAN
- Modem
- OLPCMesh
- OVSBridge
- OVSInterface
- OVSPort
- PPP
- Statistics
- Team
- TUN/TAP
- VETH
- VLAN
- VRF
- VXLAN
- WifiP2P
- WiMax
- Wireguard
- Wpan
- Configs
- IP4
- IP6
- DHCP4
- DHCP6
- Accesspoint
- ConnectionActive
- NetworkManager (partially implemented)
- AgentManager
- Checkpoint
- DNSManager
- PPP
- SecretAgent
- Settings
- Settings Connection
- VPN Connection
- VPN Plugin
- WifiP2P
- Wimax NSP
- Devices
- General
- Improve Error handling
- dbus::arg::Variants conversion
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.