sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::InterfaceOperationalState;

impl InterfaceOperationalState {
    pub(crate) fn from_flag(flags: core::ffi::c_int, link_state: core::ffi::c_int) -> Self {
        // https://github.com/freebsd/freebsd-src/blob/7e7d4e711ff94d114c93fd522d4125aa9bd9f5cd/contrib/bsnmp/snmp_mibII/mibII_interfaces.c#L283-L298
        if (flags & libc::IFF_RUNNING) != 0 {
            if link_state != libc::LINK_STATE_UP {
                InterfaceOperationalState::Dormant
            } else {
                InterfaceOperationalState::Up
            }
        } else {
            InterfaceOperationalState::Down
        }
    }
}