mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Replace nested MAX/MIN macros with box() function
This commit is contained in:
@@ -267,7 +267,7 @@ GroupScanStats::GroupScanStats(UltraScanInfo *UltraSI) {
|
|||||||
initialize_timeout_info(&to);
|
initialize_timeout_info(&to);
|
||||||
/* Default timout should be much lower for arp */
|
/* Default timout should be much lower for arp */
|
||||||
if (USI->ping_scan_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;
|
num_probes_active = 0;
|
||||||
numtargets = USI->numIncompleteHosts(); // They are all incomplete at the beginning
|
numtargets = USI->numIncompleteHosts(); // They are all incomplete at the beginning
|
||||||
numprobes = USI->numProbesPerHost();
|
numprobes = USI->numProbesPerHost();
|
||||||
|
|||||||
@@ -91,10 +91,11 @@ static void arpping(Target *hostbatch[], int num_hosts) {
|
|||||||
int targetno;
|
int targetno;
|
||||||
targets.reserve(num_hosts);
|
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++) {
|
for (targetno = 0; targetno < num_hosts; targetno++) {
|
||||||
initialize_timeout_info(&hostbatch[targetno]->to);
|
initialize_timeout_info(&hostbatch[targetno]->to);
|
||||||
/* Default timout should be much lower for arp */
|
hostbatch[targetno]->to.timeout = default_to;
|
||||||
hostbatch[targetno]->to.timeout = MAX(o.minRttTimeout(), MIN(o.initialRttTimeout(), INITIAL_ARP_RTT_TIMEOUT)) * 1000;
|
|
||||||
if (!hostbatch[targetno]->SrcMACAddress()) {
|
if (!hostbatch[targetno]->SrcMACAddress()) {
|
||||||
bool islocal = islocalhost(hostbatch[targetno]->TargetSockAddr());
|
bool islocal = islocalhost(hostbatch[targetno]->TargetSockAddr());
|
||||||
if (islocal) {
|
if (islocal) {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void adjust_timeouts2(const struct timeval *sent,
|
|||||||
if (to->srtt == -1 && to->rttvar == -1) {
|
if (to->srtt == -1 && to->rttvar == -1) {
|
||||||
/* We need to initialize the sucker ... */
|
/* We need to initialize the sucker ... */
|
||||||
to->srtt = delta;
|
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);
|
to->timeout = to->srtt + (to->rttvar << 2);
|
||||||
} else {
|
} else {
|
||||||
long rttdelta;
|
long rttdelta;
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ individually.
|
|||||||
#include "NmapOps.h"
|
#include "NmapOps.h"
|
||||||
#include "Target.h"
|
#include "Target.h"
|
||||||
#include "tcpip.h"
|
#include "tcpip.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include "struct_ip.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) {
|
HostState::HostState(Target *target) : sent_ttls(MAX_TTL + 1, false) {
|
||||||
this->target = target;
|
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;
|
state = HostState::COUNTING_DOWN;
|
||||||
reached_target = 0;
|
reached_target = 0;
|
||||||
pspec = HostState::get_probe(target);
|
pspec = HostState::get_probe(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user