Index: NmapOps.cc =================================================================== --- NmapOps.cc (revision 32984) +++ NmapOps.cc (working copy) @@ -339,6 +339,7 @@ memset(logfd, 0, sizeof(FILE *) * LOG_NUM_FILES); ttl = -1; badsum = 0; + forget_after = 0; /* Unset. */ nmap_stdout = stdout; gettimeofday(&start_time, NULL); pTrace = vTrace = false; Index: NmapOps.h =================================================================== --- NmapOps.h (revision 32984) +++ NmapOps.h (working copy) @@ -340,6 +340,7 @@ FILE *nmap_stdout; /* Nmap standard output */ int ttl; // Time to live int badsum; + int forget_after; char *datadir; /* A map from abstract data file names like "nmap-services" and "nmap-os-db" to paths which have been requested by the user. nmap_fetchfile will return Index: nmap.cc =================================================================== --- nmap.cc (revision 32984) +++ nmap.cc (working copy) @@ -307,6 +307,7 @@ " --ttl : Set IP time-to-live field\n" " --spoof-mac : Spoof your MAC address\n" " --badsum: Send packets with a bogus TCP/UDP/SCTP checksum\n" + " --forget-after : Stops scanning a host after num ports are found open (EXPERIMENTAL)\n" "OUTPUT:\n" " -oN/-oX/-oS/-oG : Output scan in normal, XML, s|ports.getStateCounts(PORT_OPEN) + /* TODO: Check if I should add count of openfiltered (or anything else) here */ + >= o.forget_after) + return true; + /* If there are probes active or awaiting retransmission, we are not done. */ if (num_probes_active != 0 || num_probes_waiting_retransmit != 0 || !probe_bench.empty() || !retry_stack.empty()) {