async fn recv_loop(sock: Arc<UdpSocket>, e: events::Queue<DaemonEvent>) {
    loop {
        // fxb/90219 - disabled by default
        let is_enabled: bool = ffx_config::get("discovery.zedboot.enabled").await.unwrap_or(false);
        if !is_enabled {
            return;
        }

        let mut buf = &mut [0u8; 1500][..];
        let addr = match sock.recv_from(&mut buf).await {
            Ok((sz, addr)) => {
                buf = &mut buf[..sz];
                addr
            }
            Err(err) => {
                log::info!("listen socket recv error: {}, zedboot listener closed", err);
                return;
            }
        };

        let msg = match buf.parse::<NetbootPacket<_>>() {
            Ok(msg) => msg,
            Err(e) => {
                log::error!("failed to parse netboot packet {:?}", e);
                continue;
            }
        };

        // Note: important, otherwise non-local responders could add themselves.
        if !addr.ip().is_local_addr() {
            continue;
        }

        match ZedbootPacket(msg).try_into_target_info(addr) {
            Ok(info) => {
                log::trace!(
                    "zedboot packet from {} ({}) on {}",
                    addr,
                    info.nodename.clone().unwrap_or("<unknown>".to_string()),
                    sock.local_addr().unwrap()
                );
                e.push(DaemonEvent::WireTraffic(WireTrafficType::Zedboot(info))).unwrap_or_else(
                    |err| log::debug!("zedboot discovery was unable to publish: {}", err),
                );
            }
            Err(e) => log::error!("failed to extract zedboot target info {:?}", e),
        }
    }
}
// recv_loop reads packets from sock. If the packet is a Fuchsia zedboot packet, a
// corresponding zedboot event is published to the queue. All other packets are
// silently discarded.
recv_loop reads packets from sock. If the packet is a Fuchsia zedboot packet, a
corresponding zedboot event is published to the queue. All other packets are
silently discarded.
recv_loop reads packets from sock . If the packet is a Fuchsia zedboot packet a corresponding zedboot event is published to the queue . All other packets are silently discarded .
async fn recv_loop(sock: Arc<UdpSocket>, e: events::Queue<DaemonEvent>) {
    loop {
        // fxb/90219 - disabled by default
        let is_enabled: bool = ffx_config::get("discovery.zedboot.enabled").await.unwrap_or(false);
        if !is_enabled {
            return;
        }
        let mut buf = &mut [0u8; 1500][..];
        let addr = match sock.recv_from(&mut buf).await {
            Ok((sz, addr)) => {
                buf = &mut buf[..sz];
                addr
            }
            Err(err) => {
                log::info!("listen socket recv error: {}, zedboot listener closed", err);
                return;
            }
        };
        let msg = match buf.parse::<NetbootPacket<_>>() {
            Ok(msg) => msg,
            Err(e) => {
                log::error!("failed to parse netboot packet {:?}", e);
                continue;
            }
        };
        // Note: important, otherwise non-local responders could add themselves.
        if !addr.ip().is_local_addr() {
            continue;
        }
        match ZedbootPacket(msg).try_into_target_info(addr) {
            Ok(info) => {
                log::trace!(
                    "zedboot packet from {} ({}) on {}",
                    addr,
                    info.nodename.clone().unwrap_or("<unknown>".to_string()),
                    sock.local_addr().unwrap()
                );
                e.push(DaemonEvent::WireTraffic(WireTrafficType::Zedboot(info))).unwrap_or_else(
                    |err| log::debug!("zedboot discovery was unable to publish: {}", err),
                );
            }
            Err(e) => log::error!("failed to extract zedboot target info {:?}", e),
        }
    }
}
async fn recv_loop ( sock : Arc < UdpSocket > , e : events :: Queue < DaemonEvent > ) { loop { // fxb/90219 - disabled by default let is_enabled : bool = ffx_config :: get ( " " ) . await . unwrap_or ( false ) ; if ! is_enabled { return ; } let mut buf = & mut [ 0u8 ; 1500 ] [ .. ] ; let addr = match sock . recv_from ( & mut buf ) . await { Ok ( ( sz , addr ) ) => { buf = & mut buf [ .. sz ] ; addr } Err ( err ) => { log :: info ! ( " " err ) ; return ; } } ; let msg = match buf . parse :: < NetbootPacket < _ > > ( ) { Ok ( msg ) => msg , Err ( e ) => { log :: error ! ( " " e ) ; continue ; } } ; // Note: important, otherwise non-local responders could add themselves. if ! addr . ip ( ) . is_local_addr ( ) { continue ; } match ZedbootPacket ( msg ) . try_into_target_info ( addr ) { Ok ( info ) => { log :: trace ! ( " " addr info nodename clone ( ) unwrap_or ( " " to_string ( ) ) sock local_addr ( ) unwrap ( ) ) ; e . push ( DaemonEvent :: WireTraffic ( WireTrafficType :: Zedboot ( info ) ) ) . unwrap_or_else ( | err | log :: debug ! ( " " err ) , ) ; } Err ( e ) => log :: error ! ( " " e ) , } } }
recv_loop reads packets from sock.
recv_loop reads packets from sock .
sock
Arc<UdpSocket>
e
events::Queue<DaemonEvent>
sock
Arc<UdpSocket>
e
events::Queue<DaemonEvent>