8 releases

0.4.1 Jan 9, 2024
0.4.0 Jan 23, 2023
0.3.5 Jan 23, 2023
0.3.3 Jan 3, 2022
0.0.1 Jun 6, 2020

#188 in Network programming

Download history 72/week @ 2024-07-20 82/week @ 2024-07-27 59/week @ 2024-08-03 70/week @ 2024-08-10 46/week @ 2024-08-17 55/week @ 2024-08-24 88/week @ 2024-08-31 87/week @ 2024-09-07 76/week @ 2024-09-14 136/week @ 2024-09-21 126/week @ 2024-09-28 48/week @ 2024-10-05 54/week @ 2024-10-12 72/week @ 2024-10-19 55/week @ 2024-10-26 103/week @ 2024-11-02

288 downloads per month

MIT/Apache

245KB
6K SLoC

NetworkManager bindings for Rust

Crates.io docs.rs license CI

NetworkManager bindings for Rust using the D-Bus message bus system

Status

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

Usage

Add networkmanager and dbus to your Cargo.toml with:

[dependencies]
networkmanager = "0.4"
dbus = "0.9"

Example

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(())
}

Build prerequisites

  • Debian and its derivatives (e.g. Ubuntu)

    • network-manager
    • libdbus-1-dev
    • pkg-config
  • Fedora

    • NetworkManager
    • dbus-devel
    • pkg-config

Todo

  • 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
  • General
    • Improve Error handling
    • dbus::arg::Variants conversion

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~6MB
~132K SLoC