2 个版本
0.0.2-alphav1 | 2023年8月4日 |
---|---|
0.0.1 | 2023年8月4日 |
#18 in #ioctl
31KB
587 行代码(不包括注释)
Nic Port Info
该包提供了一种获取 NIC 链路信息的方法,包括端口类型、支持的模式。该包基于 ioctl 命令,因此只能在 Linux 上使用。
示例
列出所有 NIC 的端口信息。
use nic_port_info::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());
}
获取指定 NIC 的端口信息。
use nic_port_info::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());
}
通过 PortInfo 获取指定 NIC 的端口信息。
use nic_port_info::PortInfo;
let nic_port = PortInfo::from_name("eth0").unwrap();
println!("NIC: {}", nic_port.name());
println!("Port: {}", nic_port.port());
println!("Supported: {:?}", nic_port.supported());
依赖
~1.5MB
~35K SLoC