Expand description
The crate provides a way to get the link information of the NIC, including the port type, supported modes. The crate is based on the ioctl command, so it can only be used on Linux.
§Examples
List all the NICs’ port information.
use ethtool::get_nic_port_info;
let nics_port = get_nic_port_info(None);
for nic_port in nics_port {
println!("NIC: {}", nic_port.name());
println!("Port: {}", nic_port.port());
println!("Supported: {:?}", nic_port.supported());
}Get the port information of the specified NIC.
use ethtool::get_nic_port_info;
let nics_port = get_nic_port_info(Some("eth0"));
for nic_port in nics_port {
println!("NIC: {}", nic_port.name());
println!("Port: {}", nic_port.port());
println!("Supported: {:?}", nic_port.supported());
}Get the port information of the specified NIC by PortInfo.
use ethtool::PortInfo;
let nic_port = PortInfo::from_name("eth0").unwrap();
println!("NIC: {}", nic_port.name());
println!("Port: {}", nic_port.port());
println!("Supported: {:?}", nic_port.supported());Structs§
- Ethtool
Error - Port
Info - The port information includes the port type, supported modes.
Functions§
- get_
nic_ port_ info - Get the port information of the NIC If devname is None, get all the NICs’ port information. If devname is Some(&str), get the specified NIC’s port information.