async fn compute_state(
    interface_info: &hal::Interface,
    routes: Option<Vec<hal::Route>>,
    pinger: &dyn Pinger,
) -> Option<ReachabilityInfo> {
    let port_type = port_type(interface_info);
    if port_type == PortType::Loopback {
        return None;
    }

    let ipv4_address = interface_info.get_address();

    let mut new_info = ReachabilityInfo {
        port_type,
        v4: NetworkInfo {
            is_default: false,
            is_l3: interface_info.dhcp_client_enabled || ipv4_address.is_some(),
            state: State::Down,
        },
        v6: NetworkInfo {
            is_default: false,
            is_l3: !interface_info.ipv6_addr.is_empty(),
            state: State::Down,
        },
    };

    let is_up = interface_info.state != hal::InterfaceState::Down;
    if !is_up {
        return Some(new_info);
    }

    new_info.v4.state = State::Up;
    new_info.v6.state = State::Up;

    // packet reception is network layer independent.
    if !packet_count_increases(interface_info.id) {
        // TODO(dpradilla): add active probing here.
        // No packets seen, but interface is up.
        return Some(new_info);
    }

    new_info.v4.state = State::LinkLayerUp;
    new_info.v6.state = State::LinkLayerUp;

    new_info.v4.state =
        network_layer_state(ipv4_address.into_iter(), &routes, &new_info.v4, &*pinger).await;

    // TODO(dpradilla): Add support for IPV6

    Some(new_info)
}
/// `compute_state` processes an event and computes the reachability based on the event and
/// system observations.
`compute_state` processes an event and computes the reachability based on the event and
system observations.
` compute_state ` processes an event and computes the reachability based on the event and system observations .
async fn compute_state(
    interface_info: &hal::Interface,
    routes: Option<Vec<hal::Route>>,
    pinger: &dyn Pinger,
) -> Option<ReachabilityInfo> {
    let port_type = port_type(interface_info);
    if port_type == PortType::Loopback {
        return None;
    }
    let ipv4_address = interface_info.get_address();
    let mut new_info = ReachabilityInfo {
        port_type,
        v4: NetworkInfo {
            is_default: false,
            is_l3: interface_info.dhcp_client_enabled || ipv4_address.is_some(),
            state: State::Down,
        },
        v6: NetworkInfo {
            is_default: false,
            is_l3: !interface_info.ipv6_addr.is_empty(),
            state: State::Down,
        },
    };
    let is_up = interface_info.state != hal::InterfaceState::Down;
    if !is_up {
        return Some(new_info);
    }
    new_info.v4.state = State::Up;
    new_info.v6.state = State::Up;
    // packet reception is network layer independent.
    if !packet_count_increases(interface_info.id) {
        // TODO(dpradilla): add active probing here.
        // No packets seen, but interface is up.
        return Some(new_info);
    }
    new_info.v4.state = State::LinkLayerUp;
    new_info.v6.state = State::LinkLayerUp;
    new_info.v4.state =
        network_layer_state(ipv4_address.into_iter(), &routes, &new_info.v4, &*pinger).await;
    // TODO(dpradilla): Add support for IPV6
    Some(new_info)
}
async fn compute_state ( interface_info : & hal :: Interface , routes : Option < Vec < hal :: Route > > , pinger : & dyn Pinger , ) -> Option < ReachabilityInfo > { let port_type = port_type ( interface_info ) ; if port_type == PortType :: Loopback { return None ; } let ipv4_address = interface_info . get_address ( ) ; let mut new_info = ReachabilityInfo { port_type , v4 : NetworkInfo { is_default : false , is_l3 : interface_info . dhcp_client_enabled || ipv4_address . is_some ( ) , state : State :: Down , } , v6 : NetworkInfo { is_default : false , is_l3 : ! interface_info . ipv6_addr . is_empty ( ) , state : State :: Down , } , } ; let is_up = interface_info . state != hal :: InterfaceState :: Down ; if ! is_up { return Some ( new_info ) ; } new_info . v4 . state = State :: Up ; new_info . v6 . state = State :: Up ; // packet reception is network layer independent. if ! packet_count_increases ( interface_info . id ) { // TODO(dpradilla): add active probing here. // No packets seen, but interface is up. return Some ( new_info ) ; } new_info . v4 . state = State :: LinkLayerUp ; new_info . v6 . state = State :: LinkLayerUp ; new_info . v4 . state = network_layer_state ( ipv4_address . into_iter ( ) , & routes , & new_info . v4 , & * pinger ) . await ; // TODO(dpradilla): Add support for IPV6 Some ( new_info ) }
`compute_state` processes an event and computes the reachability based on the event and
system observations.
` compute_state ` processes an event and computes the reachability based on the event and system observations .
interface_info
&hal::Interface
routes
Option<Vec<hal::Route>>
pinger
&dyn Pinger