mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
const all the things!
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
class Target;
|
||||
|
||||
/* 3rd generation Nmap scanning function. Handles most Nmap port scan types */
|
||||
void ultra_scan(std::vector<Target *> &Targets, struct scan_lists *ports,
|
||||
void ultra_scan(std::vector<Target *> &Targets, const struct scan_lists *ports,
|
||||
stype scantype, struct timeout_info *to = NULL);
|
||||
|
||||
/* Determines an ideal number of hosts to be scanned (port scan, os
|
||||
@@ -93,7 +93,7 @@ void ultra_scan(std::vector<Target *> &Targets, struct scan_lists *ports,
|
||||
number of hosts scanned in parallel, though rarely to significant
|
||||
levels. */
|
||||
int determineScanGroupSize(int hosts_scanned_so_far,
|
||||
struct scan_lists *ports);
|
||||
const struct scan_lists *ports);
|
||||
|
||||
class UltraScanInfo;
|
||||
|
||||
@@ -152,13 +152,13 @@ public:
|
||||
internal IPProbe. The relevant probespec is necessary for setIP
|
||||
because pspec.type is ambiguous with just the ippacket (e.g. a
|
||||
tcp packet could be PS_PROTO or PS_TCP). */
|
||||
void setIP(u8 *ippacket, u32 iplen, const probespec *pspec);
|
||||
void setIP(const u8 *ippacket, u32 iplen, const probespec *pspec);
|
||||
/* Sets this UltraProbe as type UP_CONNECT, preparing to connect to given
|
||||
port number*/
|
||||
void setConnect(u16 portno);
|
||||
/* Pass an arp packet, including ethernet header. Must be 42bytes */
|
||||
void setARP(u8 *arppkt, u32 arplen);
|
||||
void setND(u8 *ndpkt, u32 ndlen);
|
||||
void setARP(const u8 *arppkt, u32 arplen);
|
||||
void setND(const u8 *ndpkt, u32 ndlen);
|
||||
// The 4 accessors below all return in HOST BYTE ORDER
|
||||
// source port used if TCP, UDP or SCTP
|
||||
u16 sport() const;
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
u8 protocol() const {
|
||||
return mypspec.proto;
|
||||
}
|
||||
ConnectProbe *CP() {
|
||||
ConnectProbe *CP() const {
|
||||
return probes.CP; // if type == UP_CONNECT
|
||||
}
|
||||
// Arpprobe removed because not used.
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
struct timeval sent;
|
||||
/* Time the previous probe was sent, if this is a retransmit (tryno > 0) */
|
||||
struct timeval prevSent;
|
||||
bool isPing() {
|
||||
bool isPing() const {
|
||||
return pingseq > 0;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
~GroupScanStats();
|
||||
void probeSent(unsigned int nbytes);
|
||||
/* Returns true if the GLOBAL system says that sending is OK. */
|
||||
bool sendOK(struct timeval *when);
|
||||
bool sendOK(struct timeval *when) const;
|
||||
/* Total # of probes outstanding (active) for all Hosts */
|
||||
int num_probes_active;
|
||||
UltraScanInfo *USI; /* The USI which contains this GSS. Use for at least
|
||||
@@ -318,8 +318,8 @@ public:
|
||||
Target *target; /* A copy of the Target that these stats refer to. */
|
||||
HostScanStats(Target *t, UltraScanInfo *UltraSI);
|
||||
~HostScanStats();
|
||||
bool freshPortsLeft(); /* Returns true if there are ports remaining to probe */
|
||||
int numFreshPortsLeft(); /* Returns the number of ports remaining to probe */
|
||||
bool freshPortsLeft() const; /* Returns true if there are ports remaining to probe */
|
||||
int numFreshPortsLeft() const; /* Returns the number of ports remaining to probe */
|
||||
int next_portidx; /* Index of the next port to probe in the relevant
|
||||
ports array in USI.ports */
|
||||
bool sent_arp; /* Has an ARP probe been sent for the target yet? */
|
||||
@@ -357,25 +357,25 @@ public:
|
||||
before considering it timed out. Uses the host values from
|
||||
target if they are available, otherwise from gstats. Results
|
||||
returned in MICROseconds. */
|
||||
unsigned long probeTimeout();
|
||||
unsigned long probeTimeout() const;
|
||||
|
||||
/* How long I'll wait until completely giving up on a probe.
|
||||
Timedout probes are often marked as such (and sometimes
|
||||
considered a drop), but kept in the list juts in case they come
|
||||
really late. But after probeExpireTime(), I don't waste time
|
||||
keeping them around. Give in MICROseconds */
|
||||
unsigned long probeExpireTime(const UltraProbe *probe);
|
||||
unsigned long probeExpireTime(const UltraProbe *probe) const;
|
||||
/* Returns OK if sending a new probe to this host is OK (to avoid
|
||||
flooding). If when is non-NULL, fills it with the time that sending
|
||||
will be OK assuming no pending probes are resolved by responses
|
||||
(call it again if they do). when will become now if it returns
|
||||
true. */
|
||||
bool sendOK(struct timeval *when);
|
||||
bool sendOK(struct timeval *when) const;
|
||||
|
||||
/* If there are pending probe timeouts, fills in when with the time of
|
||||
the earliest one and returns true. Otherwise returns false and
|
||||
puts now in when. */
|
||||
bool nextTimeout(struct timeval *when);
|
||||
bool nextTimeout(struct timeval *when) const;
|
||||
UltraScanInfo *USI; /* The USI which contains this HSS */
|
||||
|
||||
/* Removes a probe from probes_outstanding, adjusts HSS and USS
|
||||
@@ -407,7 +407,7 @@ public:
|
||||
necessary. Note that probes on probe_bench are not included
|
||||
in this value. */
|
||||
unsigned int num_probes_waiting_retransmit;
|
||||
unsigned int num_probes_outstanding() {
|
||||
unsigned int num_probes_outstanding() const {
|
||||
return probes_outstanding.size();
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ public:
|
||||
/* Move all members of bench to retry_stack for probe retransmission */
|
||||
void retransmitBench();
|
||||
|
||||
bool completed(); /* Whether or not the scan of this Target has completed */
|
||||
bool completed() const; /* Whether or not the scan of this Target has completed */
|
||||
struct timeval completiontime; /* When this Target completed */
|
||||
|
||||
/* This function provides the proper cwnd and ssthresh to use. It
|
||||
@@ -446,7 +446,7 @@ public:
|
||||
responses have been received for this host, may look at others in
|
||||
the group. For CHANGING this host's timing, use the timing
|
||||
memberval instead. */
|
||||
void getTiming(struct ultra_timing_vals *tmng);
|
||||
void getTiming(struct ultra_timing_vals *tmng) const;
|
||||
struct ultra_timing_vals timing;
|
||||
/* The most recently received probe response time -- initialized to scan start time. */
|
||||
struct timeval lastrcvd;
|
||||
@@ -466,7 +466,7 @@ public:
|
||||
appropriate. If mayincrease is non-NULL, it is set to whether
|
||||
the allowedTryno may increase again. If it is false, any probes
|
||||
which have reached the given limit may be dealt with. */
|
||||
unsigned int allowedTryno(bool *capped, bool *mayincrease);
|
||||
unsigned int allowedTryno(bool *capped, bool *mayincrease) const;
|
||||
|
||||
|
||||
/* Provides the next ping sequence number. This starts at one, goes
|
||||
@@ -520,21 +520,21 @@ public:
|
||||
class UltraScanInfo {
|
||||
public:
|
||||
UltraScanInfo();
|
||||
UltraScanInfo(std::vector<Target *> &Targets, struct scan_lists *pts, stype scantype) {
|
||||
UltraScanInfo(std::vector<Target *> &Targets, const struct scan_lists *pts, stype scantype) {
|
||||
Init(Targets, pts, scantype);
|
||||
}
|
||||
~UltraScanInfo();
|
||||
/* Must call Init if you create object with default constructor */
|
||||
void Init(std::vector<Target *> &Targets, struct scan_lists *pts, stype scantp);
|
||||
void Init(std::vector<Target *> &Targets, const struct scan_lists *pts, stype scantp);
|
||||
|
||||
unsigned int numProbesPerHost();
|
||||
unsigned int numProbesPerHost() const;
|
||||
|
||||
/* Consults with the group stats, and the hstats for every
|
||||
incomplete hosts to determine whether any probes may be sent.
|
||||
Returns true if they can be sent immediately. If when is non-NULL,
|
||||
it is filled with the next possible time that probes can be sent
|
||||
(which will be now, if the function returns true */
|
||||
bool sendOK(struct timeval *tv);
|
||||
bool sendOK(struct timeval *tv) const;
|
||||
stype scantype;
|
||||
bool tcp_scan; /* scantype is a type of TCP scan */
|
||||
bool udp_scan;
|
||||
@@ -558,7 +558,7 @@ public:
|
||||
rawprotoscan: 1;
|
||||
} ptech;
|
||||
|
||||
bool isRawScan();
|
||||
bool isRawScan() const;
|
||||
|
||||
struct timeval now; /* Updated after potentially meaningful delays. This can
|
||||
be used to save a call to gettimeofday() */
|
||||
@@ -575,25 +575,25 @@ public:
|
||||
int removeCompletedHosts();
|
||||
/* Find a HostScanStats by its IP address in the incomplete and completed
|
||||
lists. Returns NULL if none are found. */
|
||||
HostScanStats *findHost(struct sockaddr_storage *ss);
|
||||
HostScanStats *findHost(struct sockaddr_storage *ss) const;
|
||||
|
||||
double getCompletionFraction();
|
||||
double getCompletionFraction() const;
|
||||
|
||||
unsigned int numIncompleteHosts() {
|
||||
unsigned int numIncompleteHosts() const {
|
||||
return incompleteHosts.size();
|
||||
}
|
||||
/* Call this instead of checking for numIncompleteHosts() == 0 because it
|
||||
avoids a potential traversal of the list to find the size. */
|
||||
bool incompleteHostsEmpty() {
|
||||
bool incompleteHostsEmpty() const {
|
||||
return incompleteHosts.empty();
|
||||
}
|
||||
bool numIncompleteHostsLessThan(unsigned int n);
|
||||
bool numIncompleteHostsLessThan(unsigned int n) const;
|
||||
|
||||
unsigned int numInitialHosts() {
|
||||
unsigned int numInitialHosts() const {
|
||||
return numInitialTargets;
|
||||
}
|
||||
|
||||
void log_overall_rates(int logt);
|
||||
void log_overall_rates(int logt) const;
|
||||
void log_current_rates(int logt, bool update = true);
|
||||
|
||||
/* Any function which messes with (removes elements from)
|
||||
@@ -610,7 +610,7 @@ public:
|
||||
|
||||
ScanProgressMeter *SPM;
|
||||
PacketRateMeter send_rate_meter;
|
||||
struct scan_lists *ports;
|
||||
const struct scan_lists *ports;
|
||||
int rawsd; /* raw socket descriptor */
|
||||
pcap_t *pd;
|
||||
eth_t *ethsd;
|
||||
|
||||
Reference in New Issue
Block a user