diff --git a/osscan2.cc b/osscan2.cc index 261af04e9..1d32061b9 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -534,7 +534,7 @@ static void doSeqTests(OsScanInfo *OSI, HostOsScan *HOS) { for (hostI = OSI->incompleteHosts.begin(); hostI != OSI->incompleteHosts.end(); hostI++) { if (HOS->nextTimeout((*hostI)->hss, &tmptv)) { - if (TIMEVAL_SUBTRACT(tmptv, stime) < 0) + if (TIMEVAL_BEFORE(tmptv, stime)) stime = tmptv; } } @@ -548,7 +548,7 @@ static void doSeqTests(OsScanInfo *OSI, HostOsScan *HOS) { break; } - if (!foundgood || TIMEVAL_SUBTRACT(tmptv, stime) < 0) { + if (!foundgood || TIMEVAL_BEFORE(tmptv, stime)) { stime = tmptv; foundgood = true; } @@ -567,7 +567,7 @@ static void doSeqTests(OsScanInfo *OSI, HostOsScan *HOS) { gettimeofday(&now, NULL); - if (!ip && TIMEVAL_SUBTRACT(stime, now) < 0) { + if (!ip && TIMEVAL_BEFORE(stime, now)) { timedout = true; break; } else if (!ip) { @@ -705,7 +705,7 @@ static void doTUITests(OsScanInfo *OSI, HostOsScan *HOS) { for (hostI = OSI->incompleteHosts.begin(); hostI != OSI->incompleteHosts.end(); hostI++) { if (HOS->nextTimeout((*hostI)->hss, &tmptv)) { - if (TIMEVAL_SUBTRACT(tmptv, stime) < 0) + if (TIMEVAL_BEFORE(tmptv, stime)) stime = tmptv; } } @@ -720,7 +720,7 @@ static void doTUITests(OsScanInfo *OSI, HostOsScan *HOS) { break; } - if (!foundgood || TIMEVAL_SUBTRACT(tmptv, stime) < 0) { + if (!foundgood || TIMEVAL_BEFORE(tmptv, stime)) { stime = tmptv; foundgood = true; } @@ -738,7 +738,7 @@ static void doTUITests(OsScanInfo *OSI, HostOsScan *HOS) { gettimeofday(&now, NULL); - if (!ip && TIMEVAL_SUBTRACT(stime, now) < 0) { + if (!ip && TIMEVAL_BEFORE(stime, now)) { timedout = true; break; } else if (!ip) { @@ -1277,7 +1277,7 @@ bool HostOsScan::nextTimeout(HostOsScanStats *hss, struct timeval *when) const { for (probeI = hss->probesActive.begin(); probeI != hss->probesActive.end(); probeI++) { TIMEVAL_ADD(probe_to, (*probeI)->sent, timeProbeTimeout(hss)); - if (firstgood || TIMEVAL_SUBTRACT(probe_to, earliest_to) < 0) { + if (firstgood || TIMEVAL_BEFORE(probe_to, earliest_to)) { earliest_to = probe_to; firstgood = false; } @@ -1580,7 +1580,7 @@ bool HostOsScan::hostSendOK(HostOsScanStats *hss, struct timeval *when) const { /* Any timeouts coming up? */ for (probeI = hss->probesActive.begin(); probeI != hss->probesActive.end(); probeI++) { TIMEVAL_MSEC_ADD(probe_to, (*probeI)->sent, timeProbeTimeout(hss) / 1000); - if (TIMEVAL_SUBTRACT(probe_to, earliest_to) < 0) { + if (TIMEVAL_BEFORE(probe_to, earliest_to)) { earliest_to = probe_to; } } @@ -1588,7 +1588,7 @@ bool HostOsScan::hostSendOK(HostOsScanStats *hss, struct timeval *when) const { // Will any scan delay affect this? if (hss->sendDelayMs > 0) { TIMEVAL_MSEC_ADD(sendTime, hss->lastProbeSent, hss->sendDelayMs); - if (TIMEVAL_MSEC_SUBTRACT(sendTime, now) < 0) + if (TIMEVAL_BEFORE(sendTime, now)) sendTime = now; tdiff = TIMEVAL_MSEC_SUBTRACT(earliest_to, sendTime); @@ -1653,13 +1653,13 @@ bool HostOsScan::hostSeqSendOK(HostOsScanStats *hss, struct timeval *when) const /* Any timeouts coming up? */ for (probeI = hss->probesActive.begin(); probeI != hss->probesActive.end(); probeI++) { TIMEVAL_MSEC_ADD(probe_to, (*probeI)->sent, timeProbeTimeout(hss) / 1000); - if (TIMEVAL_SUBTRACT(probe_to, earliest_to) < 0) { + if (TIMEVAL_BEFORE(probe_to, earliest_to)) { earliest_to = probe_to; } } TIMEVAL_ADD(sendTime, hss->lastProbeSent, maxWait); - if (TIMEVAL_SUBTRACT(sendTime, now) < 0) + if (TIMEVAL_BEFORE(sendTime, now)) sendTime = now; tdiff = TIMEVAL_SUBTRACT(earliest_to, sendTime); diff --git a/scan_engine.cc b/scan_engine.cc index fa15c0b26..ca3249b3a 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -307,7 +307,7 @@ void GroupScanStats::probeSent(unsigned int nbytes) { connection is capable of the maximum. */ if (o.min_packet_send_rate != 0.0) { - if (TIMEVAL_SUBTRACT(send_no_later_than, USI->now) > 0) { + if (TIMEVAL_AFTER(send_no_later_than, USI->now)) { /* The next scheduled send is in the future. That means there's slack time during which the sending rate could drop. Pull the time back to the present to prevent that. */ @@ -346,7 +346,7 @@ bool GroupScanStats::sendOK(struct timeval *when) const { return false. If not, mark now as a good time to send and allow the congestion control to override it. */ if (o.max_packet_send_rate != 0.0) { - if (TIMEVAL_SUBTRACT(send_no_earlier_than, USI->now) > 0) { + if (TIMEVAL_AFTER(send_no_earlier_than, USI->now)) { if (when) *when = send_no_earlier_than; return false; @@ -361,7 +361,7 @@ bool GroupScanStats::sendOK(struct timeval *when) const { control. If we're behind schedule, return true to indicate that we need to send right now. */ if (o.min_packet_send_rate != 0.0) { - if (TIMEVAL_SUBTRACT(send_no_later_than, USI->now) > 0) { + if (TIMEVAL_AFTER(send_no_later_than, USI->now)) { if (when) *when = send_no_later_than; } else { @@ -548,7 +548,7 @@ bool HostScanStats::sendOK(struct timeval *when) const { /* If the group stats say we need to send a probe to enforce a minimum scanning rate, then we need to step up and send a probe. */ if (o.min_packet_send_rate != 0.0) { - if (TIMEVAL_SUBTRACT(USI->gstats->send_no_later_than, USI->now) <= 0) { + if (!TIMEVAL_AFTER(USI->gstats->send_no_later_than, USI->now)) { if (when) *when = USI->now; return true; @@ -594,7 +594,7 @@ bool HostScanStats::sendOK(struct timeval *when) const { probeI++) { if (!(*probeI)->timedout) { TIMEVAL_MSEC_ADD(probe_to, (*probeI)->sent, probeTimeout() / 1000); - if (TIMEVAL_SUBTRACT(probe_to, earliest_to) < 0) { + if (TIMEVAL_BEFORE(probe_to, earliest_to)) { earliest_to = probe_to; } } @@ -1049,7 +1049,7 @@ bool UltraScanInfo::sendOK(struct timeval *when) const { for (host = incompleteHosts.begin(); host != incompleteHosts.end(); host++) { if ((*host)->nextTimeout(&tmptv)) { - if (TIMEVAL_SUBTRACT(tmptv, lowhtime) < 0) + if (TIMEVAL_BEFORE(tmptv, lowhtime)) lowhtime = tmptv; } } @@ -1064,7 +1064,7 @@ bool UltraScanInfo::sendOK(struct timeval *when) const { break; } - if (!foundgood || TIMEVAL_SUBTRACT(lowhtime, tmptv) > 0) { + if (!foundgood || TIMEVAL_AFTER(lowhtime, tmptv)) { lowhtime = tmptv; foundgood = true; } @@ -1076,11 +1076,11 @@ bool UltraScanInfo::sendOK(struct timeval *when) const { /* Defer to the group stats if they need a shorter delay to enforce a minimum packet sending rate. */ if (o.min_packet_send_rate != 0.0) { - if (TIMEVAL_MSEC_SUBTRACT(gstats->send_no_later_than, lowhtime) < 0) + if (TIMEVAL_BEFORE(gstats->send_no_later_than, lowhtime)) lowhtime = gstats->send_no_later_than; } - if (TIMEVAL_MSEC_SUBTRACT(lowhtime, now) < 0) + if (TIMEVAL_BEFORE(lowhtime, now)) lowhtime = now; if (when) diff --git a/scan_engine_raw.cc b/scan_engine_raw.cc index b8af542ab..964145804 100644 --- a/scan_engine_raw.cc +++ b/scan_engine_raw.cc @@ -415,7 +415,7 @@ int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) { &linkhdr, true); gettimeofday(&USI->now, NULL); if (!ip_tmp) { - if (TIMEVAL_SUBTRACT(*stime, USI->now) < 0) { + if (TIMEVAL_BEFORE(*stime, USI->now)) { timedout = true; break; } else { @@ -1433,7 +1433,7 @@ bool get_arp_result(UltraScanInfo *USI, struct timeval *stime) { if (rc == -1) fatal("Received -1 response from read_arp_reply_pcap"); if (rc == 0) { - if (TIMEVAL_SUBTRACT(*stime, USI->now) < 0) { + if (TIMEVAL_BEFORE(*stime, USI->now)) { timedout = true; break; } else { @@ -1512,7 +1512,7 @@ bool get_ns_result(UltraScanInfo *USI, struct timeval *stime) { if (rc == -1) fatal("Received -1 response from read_arp_reply_pcap"); if (rc == 0) { - if (TIMEVAL_SUBTRACT(*stime, USI->now) < 0) { + if (TIMEVAL_BEFORE(*stime, USI->now)) { timedout = true; break; } else { @@ -1610,7 +1610,7 @@ bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) { to_usec = 2000; ip_tmp = (struct ip *) readip_pcap(USI->pd, &bytes, to_usec, &rcvdtime, &linkhdr, true); gettimeofday(&USI->now, NULL); - if (!ip_tmp && TIMEVAL_SUBTRACT(*stime, USI->now) < 0) { + if (!ip_tmp && TIMEVAL_BEFORE(*stime, USI->now)) { timedout = true; break; } else if (!ip_tmp)