/// 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 = IcmpPacketGenerator::new(&self.device);
            let filter  = format!("icmp and icmp[icmptype] = icmp-echoreply \
                                    and ip dst {}", self.device.ip_addr);
            let packets = try!(self.scanner.sr(&filter, &mut gen, 1000000000));
            let mut hosts = Vec::new();
            for p in packets {
                if let Ok(ep) = ParsePacketType::parse(&p) {
                    let iph = &ep.body.header;
                    let sha = ep.header.src;
                    let spa = iph.src;
                    let nwa = raw::utils::ipv4addr_to_u32(&spa) & self.mask;
                    // check if the received packet is from the same subnet
                    if nwa == self.network {
                        hosts.push((sha, spa));
                    }
                }
            }
            Ok(hosts)
        }
fn scan ( & mut self ) -> pcap :: Result < Vec < ( MacAddr , Ipv4Addr ) > > { let mut gen = IcmpPacketGenerator :: new ( & self . device ) ; let filter = format ! ( " \
 " self device ip_addr ) ; let packets = try ! ( self scanner sr ( filter mut gen 1000000000 ) ) ; let mut hosts = Vec :: new ( ) ; for p in packets { if let Ok ( ep ) = ParsePacketType :: parse ( & p ) { let iph = & ep . body . header ; let sha = ep . header . src ; let spa = iph . src ; let nwa = raw :: utils :: ipv4addr_to_u32 ( & spa ) & self . mask ; // check if the received packet is from the same subnet if nwa == self . network { 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