Thanks to visit codestin.com
Credit goes to lib.rs

11 releases

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

#1133 in Network programming

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

5,077 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

~9–21MB
~250K SLoC