fork of https://github.com/shellrow/default-net/tree/v0.16.2 fixes an unsafe bug in sockaddr_to_network_addr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
default-net/examples/list_interfaces.rs

26 lines
879 B

use default_net;
fn main(){
let interfaces = default_net::get_interfaces();
for interface in interfaces {
println!("Interface");
println!("\tIndex: {}", interface.index);
println!("\tName: {}", interface.name);
println!("\tDescription: {:?}", interface.description);
if let Some(mac_addr) = interface.mac_addr {
println!("\tMAC: {}", mac_addr);
}else{
println!("\tMAC: (Failed to get mac address)");
}
println!("\tIPv4: {:?}", interface.ipv4);
println!("\tIPv6: {:?}", interface.ipv6);
if let Some(gateway) = interface.gateway {
println!("Gateway");
println!("\tMAC: {}", gateway.mac_addr);
println!("\tIP: {}", gateway.ip_addr);
}else {
println!("Gateway: (Not found)");
}
println!();
}
}