#networking #enumerate #local #interface #cross-platform #utility #ipv6

netifs

Cross-platform utility library to enumerate local network interfaces

3 releases (breaking)

0.3.0 Jun 12, 2020
0.2.0 Jun 6, 2020
0.1.0 Jun 5, 2020

#8 in #enumerate

Apache-2.0

40KB
956 lines

netifs

This is a simple rust wrapper on top of libc/winapi to enumerate network interfaces. On Windows, an MSVC toolchain is necessary to build.

Loopback interface and IPv6 support is present in both platform specific implementations.

Usage

An small example program is provided in netifs-cli:

use netifs::get_interfaces;

fn main() {
    for interface in get_interfaces().expect("Getting interfaces failed") {
        println!("{}", interface.display_name);
        if let Some(mac) = interface.mac_address {
            println!("\tMAC: {}", mac.to_hex_string());
        }
        for ip in interface.ip_addresses {
            println!("\tIP: {}", ip);
        }
    }
}

lib.rs:

Utility create to enumerate local network interfaces.

This crate was tested on Windows 10 and Ubuntu 19.10

Example

use netifs::get_interfaces;

fn main() {
    for interface in get_interfaces().expect("Getting interfaces failed") {
        println!("{}", interface.name);
        if let Some(mac) = interface.mac_address {
            println!("\tMAC: {}", mac.to_hex_string());
        }
        for ip in interface.ip_addresses {
            println!("\tIP: {}", ip);
        }
    }
}

Dependencies

~1–1.4MB
~24K SLoC