1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Replace nested MAX/MIN macros with box() function

This commit is contained in:
dmiller
2024-06-27 19:36:05 +00:00
parent dcb4ba569e
commit 1ec9caea3b
4 changed files with 7 additions and 5 deletions

View File

@@ -267,7 +267,7 @@ GroupScanStats::GroupScanStats(UltraScanInfo *UltraSI) {
initialize_timeout_info(&to);
/* Default timout should be much lower for arp */
if (USI->ping_scan_arp)
to.timeout = MAX(o.minRttTimeout(), MIN(o.initialRttTimeout(), INITIAL_ARP_RTT_TIMEOUT)) * 1000;
to.timeout = box(o.minRttTimeout(), o.initialRttTimeout(), INITIAL_ARP_RTT_TIMEOUT) * 1000;
num_probes_active = 0;
numtargets = USI->numIncompleteHosts(); // They are all incomplete at the beginning
numprobes = USI->numProbesPerHost();

View File

@@ -91,10 +91,11 @@ static void arpping(Target *hostbatch[], int num_hosts) {
int targetno;
targets.reserve(num_hosts);
/* Default timout should be much lower for arp */
int default_to = box(o.minRttTimeout(), o.initialRttTimeout(), INITIAL_ARP_RTT_TIMEOUT) * 1000;
for (targetno = 0; targetno < num_hosts; targetno++) {
initialize_timeout_info(&hostbatch[targetno]->to);
/* Default timout should be much lower for arp */
hostbatch[targetno]->to.timeout = MAX(o.minRttTimeout(), MIN(o.initialRttTimeout(), INITIAL_ARP_RTT_TIMEOUT)) * 1000;
hostbatch[targetno]->to.timeout = default_to;
if (!hostbatch[targetno]->SrcMACAddress()) {
bool islocal = islocalhost(hostbatch[targetno]->TargetSockAddr());
if (islocal) {

View File

@@ -121,7 +121,7 @@ void adjust_timeouts2(const struct timeval *sent,
if (to->srtt == -1 && to->rttvar == -1) {
/* We need to initialize the sucker ... */
to->srtt = delta;
to->rttvar = MAX(5000, MIN(to->srtt, 2000000));
to->rttvar = box(5000, 2000000, to->srtt);
to->timeout = to->srtt + (to->rttvar << 2);
} else {
long rttdelta;

View File

@@ -108,6 +108,7 @@ individually.
#include "NmapOps.h"
#include "Target.h"
#include "tcpip.h"
#include "utils.h"
#include "struct_ip.h"
@@ -313,7 +314,7 @@ static unsigned int hop_cache_size();
HostState::HostState(Target *target) : sent_ttls(MAX_TTL + 1, false) {
this->target = target;
current_ttl = MIN(MAX(1, HostState::distance_guess(target)), MAX_TTL);
current_ttl = box(1, MAX_TTL, (int)HostState::distance_guess(target));
state = HostState::COUNTING_DOWN;
reached_target = 0;
pspec = HostState::get_probe(target);