11 releases

new 0.3.1 Dec 5, 2025
0.3.0 Oct 14, 2025
0.2.7 Aug 15, 2025
0.2.6 May 28, 2025
0.1.0 Dec 1, 2022

#832 in Network programming

Download history 3511/week @ 2025-08-16 2268/week @ 2025-08-23 2626/week @ 2025-08-30 2786/week @ 2025-09-06 3131/week @ 2025-09-13 2267/week @ 2025-09-20 1742/week @ 2025-09-27 1516/week @ 2025-10-04 1202/week @ 2025-10-11 934/week @ 2025-10-18 982/week @ 2025-10-25 2017/week @ 2025-11-01 2211/week @ 2025-11-08 2008/week @ 2025-11-15 1700/week @ 2025-11-22 1550/week @ 2025-11-29

7,797 downloads per month
Used in 2 crates

Apache-2.0

250KB
6.5K SLoC

Mozim -- DHCP Client Library

Example code:

use mozim::{DhcpV4Client, DhcpV4Config, DhcpV4State};

const TEST_NIC: &str = "dhcpcli";

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut config = DhcpV4Config::new(TEST_NIC);
    config.set_host_name("mozim-test");
    config.use_host_name_as_client_id();
    config.set_timeout_sec(300);
    let mut cli = DhcpV4Client::init(config, None).await?;
    let mut got_lease = None;

    loop {
        let state = cli.run().await?;
        println!("DHCP state {state}");
        if let DhcpV4State::Done(lease) = state {
            println!("Got DHCPv4 lease {lease:?}");
            got_lease = Some(lease);
        } else {
            println!("DHCPv4 on {TEST_NIC} enter {state}");
        }
    }
}

Try out

# Below script will create veth eth1/eth1.ep.
# The `eth1.ep` is DHCP server interface running dnsmasq in `mozim` network
# namespace.
sudo ./utils/test_env_mozim &
cargo run --example mozim_dhcpv4
cargo run --example mozim_dhcpv6

Dependencies

~8–20MB
~256K SLoC