netdev 0.41.0

Cross-platform library for enumerating network interfaces with metadata.
Documentation
1
2
3
4
5
6
7
8
9
10
use crate::interface::types::InterfaceType;

pub fn get_interface_type(addr_ref: &libc::ifaddrs) -> InterfaceType {
    if !addr_ref.ifa_data.is_null() {
        let if_data = unsafe { &*(addr_ref.ifa_data as *const libc::if_data) };
        InterfaceType::try_from(if_data.ifi_type as u32).unwrap_or(InterfaceType::Unknown)
    } else {
        InterfaceType::Unknown
    }
}