1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-17 13:09:02 +00:00

Moar const

This commit is contained in:
dmiller
2024-03-01 19:29:54 +00:00
parent b862961cdb
commit 938c3c7081
2 changed files with 23 additions and 23 deletions

View File

@@ -108,7 +108,7 @@ int HssPredicate::operator() (const HostScanStats *lhs, const HostScanStats *rhs
rss = (rhs) ? rhs->target->TargetSockAddr() : ss; rss = (rhs) ? rhs->target->TargetSockAddr() : ss;
return 0 > sockaddr_storage_cmp(lss, rss); return 0 > sockaddr_storage_cmp(lss, rss);
} }
struct sockaddr_storage *HssPredicate::ss = NULL; const struct sockaddr_storage *HssPredicate::ss = NULL;
void UltraScanInfo::log_overall_rates(int logt) const { void UltraScanInfo::log_overall_rates(int logt) const {
log_write(logt, "Overall sending rates: %.2f packets / s", send_rate_meter.getOverallPacketRate(&now)); log_write(logt, "Overall sending rates: %.2f packets / s", send_rate_meter.getOverallPacketRate(&now));
@@ -165,8 +165,8 @@ const char *pspectype2ascii(int type) {
static void init_ultra_timing_vals(ultra_timing_vals *timing, static void init_ultra_timing_vals(ultra_timing_vals *timing,
enum ultra_timing_type utt, enum ultra_timing_type utt,
int num_hosts_in_group, int num_hosts_in_group,
struct ultra_scan_performance_vars *perf, const struct ultra_scan_performance_vars *perf,
struct timeval *now); const struct timeval *now);
/* Take a buffer, buf, of size bufsz (64 bytes is sufficient) and /* Take a buffer, buf, of size bufsz (64 bytes is sufficient) and
writes a short description of the probe (arg1) into buf. It also returns writes a short description of the probe (arg1) into buf. It also returns
@@ -1098,7 +1098,7 @@ bool UltraScanInfo::sendOK(struct timeval *when) const {
/* Find a HostScanStats by its IP address in the incomplete and completed lists. /* Find a HostScanStats by its IP address in the incomplete and completed lists.
Returns NULL if none are found. */ Returns NULL if none are found. */
HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) const { HostScanStats *UltraScanInfo::findHost(const struct sockaddr_storage *ss) const {
std::multiset<HostScanStats *, HssPredicate>::const_iterator hss; std::multiset<HostScanStats *, HssPredicate>::const_iterator hss;
HssPredicate::ss = ss; HssPredicate::ss = ss;
@@ -1272,8 +1272,8 @@ int determineScanGroupSize(int hosts_scanned_so_far,
static void init_ultra_timing_vals(ultra_timing_vals *timing, static void init_ultra_timing_vals(ultra_timing_vals *timing,
enum ultra_timing_type utt, enum ultra_timing_type utt,
int num_hosts_in_group, int num_hosts_in_group,
struct ultra_scan_performance_vars *perf, const struct ultra_scan_performance_vars *perf,
struct timeval *now) { const struct timeval *now) {
timing->cwnd = (utt == TIMING_HOST) ? perf->host_initial_cwnd : perf->group_initial_cwnd; timing->cwnd = (utt == TIMING_HOST) ? perf->host_initial_cwnd : perf->group_initial_cwnd;
timing->ssthresh = perf->initial_ssthresh; /* Will be reduced if any packets are dropped anyway */ timing->ssthresh = perf->initial_ssthresh; /* Will be reduced if any packets are dropped anyway */
timing->num_replies_expected = 0; timing->num_replies_expected = 0;
@@ -1288,7 +1288,7 @@ static void init_ultra_timing_vals(ultra_timing_vals *timing,
different types of probes (see probespec structure). Returns 0 and different types of probes (see probespec structure). Returns 0 and
fills in pspec if there is a new probe, -1 if there are none fills in pspec if there is a new probe, -1 if there are none
left. */ left. */
static int get_next_target_probe(UltraScanInfo *USI, HostScanStats *hss, static int get_next_target_probe(const UltraScanInfo *USI, HostScanStats *hss,
probespec *pspec) { probespec *pspec) {
assert(pspec); assert(pspec);
@@ -1607,8 +1607,8 @@ void HostScanStats::destroyAllOutstandingProbes() {
not called when a response is not useful for adjusting other timing not called when a response is not useful for adjusting other timing
variables. */ variables. */
static void ultrascan_adjust_timeouts(UltraScanInfo *USI, HostScanStats *hss, static void ultrascan_adjust_timeouts(UltraScanInfo *USI, HostScanStats *hss,
UltraProbe *probe, const UltraProbe *probe,
struct timeval *rcvdtime) { const struct timeval *rcvdtime) {
if (rcvdtime == NULL) if (rcvdtime == NULL)
return; return;
@@ -1836,13 +1836,13 @@ static bool pingprobe_is_better(const probespec *new_probe, int new_state,
return pingprobe_score(new_probe, new_state) > pingprobe_score(old_probe, old_state); return pingprobe_score(new_probe, new_state) > pingprobe_score(old_probe, old_state);
} }
static bool ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss, static bool ultrascan_host_pspec_update(const UltraScanInfo *USI, HostScanStats *hss,
const probespec *pspec, int newstate); const probespec *pspec, int newstate);
/* Like ultrascan_port_probe_update(), except it is called with just a /* Like ultrascan_port_probe_update(), except it is called with just a
probespec rather than a whole UltraProbe. Returns true if the port probespec rather than a whole UltraProbe. Returns true if the port
was added or at least the state was changed. */ was added or at least the state was changed. */
static bool ultrascan_port_pspec_update(UltraScanInfo *USI, static bool ultrascan_port_pspec_update(const UltraScanInfo *USI,
HostScanStats *hss, HostScanStats *hss,
const probespec *pspec, const probespec *pspec,
int newstate) { int newstate) {
@@ -1983,7 +1983,7 @@ void HostScanStats::moveProbeToBench(std::list<UltraProbe *>::iterator probeI) {
stats are not updated. */ stats are not updated. */
void ultrascan_ping_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_ping_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
struct timeval *rcvdtime, const struct timeval *rcvdtime,
bool adjust_timing) { bool adjust_timing) {
ultrascan_adjust_timeouts(USI, hss, *probeI, rcvdtime); ultrascan_adjust_timeouts(USI, hss, *probeI, rcvdtime);
if (adjust_timing) if (adjust_timing)
@@ -2008,7 +2008,7 @@ static const char *readhoststate(int state) {
/* Update state of the host in hss based on its current state and newstate. /* Update state of the host in hss based on its current state and newstate.
Returns true if the state was changed. */ Returns true if the state was changed. */
static bool ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss, static bool ultrascan_host_pspec_update(const UltraScanInfo *USI, HostScanStats *hss,
const probespec *pspec, int newstate) { const probespec *pspec, int newstate) {
int oldstate = hss->target->flags; int oldstate = hss->target->flags;
/* If the host is already up, ignore any further updates. */ /* If the host is already up, ignore any further updates. */
@@ -2026,7 +2026,7 @@ static bool ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss,
return hss->target->flags != oldstate; return hss->target->flags != oldstate;
} }
static void ultrascan_host_timeout_init(UltraScanInfo *USI, HostScanStats *hss) { static void ultrascan_host_timeout_init(const UltraScanInfo *USI, HostScanStats *hss) {
// Don't count host discovery time against host timeout clock. For large // Don't count host discovery time against host timeout clock. For large
// numbers of targets, we might be busy sending lots of new probes to new // numbers of targets, we might be busy sending lots of new probes to new
// targets, and that time shouldn't count against the individual target. // targets, and that time shouldn't count against the individual target.
@@ -2045,9 +2045,9 @@ static void ultrascan_host_timeout_init(UltraScanInfo *USI, HostScanStats *hss)
adjust_timing_hint is false, packet stats are not updated. */ adjust_timing_hint is false, packet stats are not updated. */
void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
int newstate, struct timeval *rcvdtime, int newstate, const struct timeval *rcvdtime,
bool adjust_timing_hint) { bool adjust_timing_hint) {
UltraProbe *probe = *probeI; const UltraProbe *probe = *probeI;
if (o.debugging > 1) { if (o.debugging > 1) {
struct timeval tv; struct timeval tv;
@@ -2108,9 +2108,9 @@ void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
updated. */ updated. */
void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
int newstate, struct timeval *rcvdtime, int newstate, const struct timeval *rcvdtime,
bool adjust_timing_hint) { bool adjust_timing_hint) {
UltraProbe *probe = *probeI; const UltraProbe *probe = *probeI;
const probespec *pspec = probe->pspec(); const probespec *pspec = probe->pspec();
ultrascan_port_pspec_update(USI, hss, pspec, newstate); ultrascan_port_pspec_update(USI, hss, pspec, newstate);

View File

@@ -526,7 +526,7 @@ struct ultra_scan_performance_vars : public scan_performance_vars {
struct HssPredicate { struct HssPredicate {
public: public:
int operator() (const HostScanStats *lhs, const HostScanStats *rhs) const; int operator() (const HostScanStats *lhs, const HostScanStats *rhs) const;
static struct sockaddr_storage *ss; static const struct sockaddr_storage *ss;
}; };
class UltraScanInfo { class UltraScanInfo {
@@ -587,7 +587,7 @@ public:
int removeCompletedHosts(); int removeCompletedHosts();
/* Find a HostScanStats by its IP address in the incomplete and completed /* Find a HostScanStats by its IP address in the incomplete and completed
lists. Returns NULL if none are found. */ lists. Returns NULL if none are found. */
HostScanStats *findHost(struct sockaddr_storage *ss) const; HostScanStats *findHost(const struct sockaddr_storage *ss) const;
double getCompletionFraction() const; double getCompletionFraction() const;
@@ -675,17 +675,17 @@ const char *pspectype2ascii(int type);
void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
int newstate, struct timeval *rcvdtime, int newstate, const struct timeval *rcvdtime,
bool adjust_timing_hint = true); bool adjust_timing_hint = true);
void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
int newstate, struct timeval *rcvdtime, int newstate, const struct timeval *rcvdtime,
bool adjust_timing_hint = true); bool adjust_timing_hint = true);
void ultrascan_ping_update(UltraScanInfo *USI, HostScanStats *hss, void ultrascan_ping_update(UltraScanInfo *USI, HostScanStats *hss,
std::list<UltraProbe *>::iterator probeI, std::list<UltraProbe *>::iterator probeI,
struct timeval *rcvdtime, const struct timeval *rcvdtime,
bool adjust_timing = true); bool adjust_timing = true);
#endif /* SCAN_ENGINE_H */ #endif /* SCAN_ENGINE_H */