/// Scan a given device and return list of all active hosts.
Scan a given device and return list of all active hosts.
Scan a given device and return list of all active hosts .
fn scan(&mut self) -> pcap::Result<Vec<(MacAddr, Ipv4Addr)>> {
            let mut gen    = Ipv4ArpScannerPacketGenerator::new(&self.device);
            let filter     = format!("arp and ether dst {}", 
                                self.device.mac_addr);
            let packets    = try!(self.scanner.sr(&filter, 
                                &mut gen, 1000000000));
            let mut hosts  = Vec::new();
            for p in packets {
                if let Ok(ep) = EtherPacket::<ArpPacket>::parse(&p) {
                    let sha = MacAddr::from_slice(&ep.body.sha);
                    let spa = raw::utils::slice_to_ipv4addr(&ep.body.spa);
                    hosts.push((sha, spa));
                }
            }
            Ok(hosts)
        }
fn scan ( & mut self ) -> pcap :: Result < Vec < ( MacAddr , Ipv4Addr ) > > { let mut gen = Ipv4ArpScannerPacketGenerator :: new ( & self . device ) ; let filter = format ! ( " " self device mac_addr ) ; let packets = try ! ( self scanner sr ( filter mut gen 1000000000 ) ) ; let mut hosts = Vec :: new ( ) ; for p in packets { if let Ok ( ep ) = EtherPacket :: < ArpPacket > :: parse ( & p ) { let sha = MacAddr :: from_slice ( & ep . body . sha ) ; let spa = raw :: utils :: slice_to_ipv4addr ( & ep . body . spa ) ; hosts . push ( ( sha , spa ) ) ; } } Ok ( hosts ) }
Scan a given device and return list of all active hosts.
Scan a given device and return list of all active hosts .
&mut self