fn find_open_ports_in_network(
    pc: pcap::ThreadingContext,
    device: &EthernetDevice,
    ports: &PortCollection) -> Result<ScanReport> {
    let mut report = ScanReport::new();

    for (mac, ip) in try!(Ipv4ArpScanner::scan_device(pc.clone(), device)) {
        report.add_host(mac, IpAddr::V4(ip), HINFO_FLAG_ARP);
    }

    for (mac, ip) in try!(IcmpScanner::scan_device(pc.clone(), device)) {
        report.add_host(mac, IpAddr::V4(ip), HINFO_FLAG_ICMP);
    }

    let open_ports = {
        let hosts = report.hosts()
            .map(|host| (host.mac_addr, host.ip_addr));

        try!(find_open_ports(pc, device, hosts, ports))
    };

    for (mac, addr) in open_ports {
        report.add_port(mac, addr.ip(), addr.port());
    }

    Ok(report)
}
/// Find open ports on all available hosts within a given network and port
/// range.
Find open ports on all available hosts within a given network and port
range.
Find open ports on all available hosts within a given network and port range .
fn find_open_ports_in_network(
    pc: pcap::ThreadingContext,
    device: &EthernetDevice,
    ports: &PortCollection) -> Result<ScanReport> {
    let mut report = ScanReport::new();
    for (mac, ip) in try!(Ipv4ArpScanner::scan_device(pc.clone(), device)) {
        report.add_host(mac, IpAddr::V4(ip), HINFO_FLAG_ARP);
    }
    for (mac, ip) in try!(IcmpScanner::scan_device(pc.clone(), device)) {
        report.add_host(mac, IpAddr::V4(ip), HINFO_FLAG_ICMP);
    }
    let open_ports = {
        let hosts = report.hosts()
            .map(|host| (host.mac_addr, host.ip_addr));
        try!(find_open_ports(pc, device, hosts, ports))
    };
    for (mac, addr) in open_ports {
        report.add_port(mac, addr.ip(), addr.port());
    }
    Ok(report)
}
fn find_open_ports_in_network ( pc : pcap :: ThreadingContext , device : & EthernetDevice , ports : & PortCollection ) -> Result < ScanReport > { let mut report = ScanReport :: new ( ) ; for ( mac , ip ) in try ! ( Ipv4ArpScanner scan_device ( pc clone ( ) device ) ) { report . add_host ( mac , IpAddr :: V4 ( ip ) , HINFO_FLAG_ARP ) ; } for ( mac , ip ) in try ! ( IcmpScanner scan_device ( pc clone ( ) device ) ) { report . add_host ( mac , IpAddr :: V4 ( ip ) , HINFO_FLAG_ICMP ) ; } let open_ports = { let hosts = report . hosts ( ) . map ( | host | ( host . mac_addr , host . ip_addr ) ) ; try ! ( find_open_ports ( pc device hosts ports ) ) } ; for ( mac , addr ) in open_ports { report . add_port ( mac , addr . ip ( ) , addr . port ( ) ) ; } Ok ( report ) }
Find open ports on all available hosts within a given network and port
range.
Find open ports on all available hosts within a given network and port range .
pc
pcap::ThreadingContext
device
&EthernetDevice
ports
&PortCollection
pc
pcap::ThreadingContext
device
&EthernetDevice
ports
&PortCollection