1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

a few more consts

This commit is contained in:
dmiller
2021-04-26 15:04:47 +00:00
parent 1fd272f8dd
commit d142d1f808
8 changed files with 23 additions and 25 deletions

View File

@@ -800,7 +800,7 @@ static double vectorize_isr(std::map<std::string, FPPacket>& resps) {
const char *probe_name; const char *probe_name;
const FPPacket *fp; const FPPacket *fp;
const TCPHeader *tcp; const TCPHeader *tcp;
std::map<std::string, FPPacket>::iterator it; std::map<std::string, FPPacket>::const_iterator it;
probe_name = SEQ_PROBE_NAMES[i]; probe_name = SEQ_PROBE_NAMES[i];
it = resps.find(probe_name); it = resps.find(probe_name);

View File

@@ -2102,8 +2102,6 @@ void printserviceinfooutput(Target *currenths) {
hostname_tbl[i][0] = ostype_tbl[i][0] = devicetype_tbl[i][0] = cpe_tbl[i][0] = '\0'; hostname_tbl[i][0] = ostype_tbl[i][0] = devicetype_tbl[i][0] = cpe_tbl[i][0] = '\0';
while ((p = currenths->ports.nextPort(p, &port, TCPANDUDPANDSCTP, PORT_OPEN))) { while ((p = currenths->ports.nextPort(p, &port, TCPANDUDPANDSCTP, PORT_OPEN))) {
std::vector<char *>::iterator it;
// The following 2 lines (from portlist.h) tell us that we don't need to // The following 2 lines (from portlist.h) tell us that we don't need to
// worry about free()ing anything in the serviceDeductions struct. pass in // worry about free()ing anything in the serviceDeductions struct. pass in
// an allocated struct serviceDeductions (don't worry about initializing, and // an allocated struct serviceDeductions (don't worry about initializing, and
@@ -2149,7 +2147,7 @@ void printserviceinfooutput(Target *currenths) {
} }
} }
for (it = sd.cpe.begin(); it != sd.cpe.end(); it++) { for (std::vector<char *>::const_iterator it = sd.cpe.begin(); it != sd.cpe.end(); it++) {
for (i = 0; i < MAX_SERVICE_INFO_FIELDS; i++) { for (i = 0; i < MAX_SERVICE_INFO_FIELDS; i++) {
if (cpe_tbl[i][0] && !strcmp(&cpe_tbl[i][0], *it)) if (cpe_tbl[i][0] && !strcmp(&cpe_tbl[i][0], *it))
break; break;
@@ -2221,7 +2219,7 @@ void printserviceinfooutput(Target *currenths) {
#ifndef NOLUA #ifndef NOLUA
void printscriptresults(ScriptResults *scriptResults, stype scantype) { void printscriptresults(ScriptResults *scriptResults, stype scantype) {
ScriptResults::iterator iter; ScriptResults::const_iterator iter;
char *script_output; char *script_output;
if (scriptResults->size() > 0) { if (scriptResults->size() > 0) {
@@ -2246,7 +2244,7 @@ void printscriptresults(ScriptResults *scriptResults, stype scantype) {
} }
void printhostscriptresults(Target *currenths) { void printhostscriptresults(Target *currenths) {
ScriptResults::iterator iter; ScriptResults::const_iterator iter;
char *script_output; char *script_output;
if (currenths->scriptResults.size() > 0) { if (currenths->scriptResults.size() > 0) {
@@ -2274,7 +2272,7 @@ static void printtraceroute_normal(Target *currenths) {
static const int HOP_COL = 0, RTT_COL = 1, HOST_COL = 2; static const int HOP_COL = 0, RTT_COL = 1, HOST_COL = 2;
NmapOutputTable Tbl(currenths->traceroute_hops.size() + 1, 3); NmapOutputTable Tbl(currenths->traceroute_hops.size() + 1, 3);
struct probespec probe; struct probespec probe;
std::list<TracerouteHop>::iterator it; std::list<TracerouteHop>::const_iterator it;
int row; int row;
/* No trace, must be localhost. */ /* No trace, must be localhost. */
@@ -2314,7 +2312,7 @@ static void printtraceroute_normal(Target *currenths) {
if (!o.debugging) { if (!o.debugging) {
/* Consolidate shared hops. */ /* Consolidate shared hops. */
TracerouteHop *shared_hop = NULL; const TracerouteHop *shared_hop = NULL;
struct sockaddr_storage addr; struct sockaddr_storage addr;
size_t sslen; size_t sslen;
@@ -2381,7 +2379,7 @@ static void printtraceroute_normal(Target *currenths) {
static void printtraceroute_xml(Target *currenths) { static void printtraceroute_xml(Target *currenths) {
struct probespec probe; struct probespec probe;
std::list<TracerouteHop>::iterator it; std::list<TracerouteHop>::const_iterator it;
/* No trace, must be localhost. */ /* No trace, must be localhost. */
if (currenths->traceroute_hops.size() == 0) if (currenths->traceroute_hops.size() == 0)
@@ -2401,7 +2399,7 @@ static void printtraceroute_xml(Target *currenths) {
xml_attribute("port", "%d", probe.pd.sctp.dport); xml_attribute("port", "%d", probe.pd.sctp.dport);
xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto)); xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto));
} else if (probe.type == PS_ICMP || probe.type == PS_PROTO) { } else if (probe.type == PS_ICMP || probe.type == PS_PROTO) {
struct protoent *proto = nmap_getprotbynum(probe.proto); const struct protoent *proto = nmap_getprotbynum(probe.proto);
if (proto == NULL) if (proto == NULL)
xml_attribute("proto", "%d", probe.proto); xml_attribute("proto", "%d", probe.proto);
else else
@@ -2608,8 +2606,8 @@ struct data_file_record {
were found. */ were found. */
void printdatafilepaths() { void printdatafilepaths() {
std::list<struct data_file_record> df; std::list<struct data_file_record> df;
std::list<struct data_file_record>::iterator iter; std::list<struct data_file_record>::const_iterator iter;
std::map<std::string, std::string>::iterator map_iter; std::map<std::string, std::string>::const_iterator map_iter;
std::string dir; std::string dir;
unsigned int num_dirs; unsigned int num_dirs;

View File

@@ -157,7 +157,7 @@ reason_map_type reason_map;
/* Function to Translate ICMP codes and types to * /* Function to Translate ICMP codes and types to *
* Reason Codes */ * Reason Codes */
static const reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) { static reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) {
switch(icmp_type){ switch(icmp_type){
@@ -200,7 +200,7 @@ static const reason_codes icmpv4_to_reason(int icmp_type, int icmp_code) {
return ER_UNKNOWN; return ER_UNKNOWN;
}; };
static const reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) { static reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) {
switch(icmp_type){ switch(icmp_type){
@@ -235,7 +235,7 @@ static const reason_codes icmpv6_to_reason(int icmp_type, int icmp_code) {
return ER_UNKNOWN; return ER_UNKNOWN;
}; };
const reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code) { reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code) {
if (proto == IPPROTO_ICMP) if (proto == IPPROTO_ICMP)
return icmpv4_to_reason(icmp_type, icmp_code); return icmpv4_to_reason(icmp_type, icmp_code);
else if (proto == IPPROTO_ICMPV6) else if (proto == IPPROTO_ICMPV6)

View File

@@ -146,7 +146,7 @@ public:
}; };
/* Function to translate ICMP code and typ to reason code */ /* Function to translate ICMP code and typ to reason code */
const reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code); reason_codes icmp_to_reason(u8 proto, int icmp_type, int icmp_code);
/* Passed to reason_str to determine if string should be in /* Passed to reason_str to determine if string should be in
* plural of singular form */ * plural of singular form */

View File

@@ -208,7 +208,7 @@ static int nmap_services_init() {
ps.proto = proto; ps.proto = proto;
/* Now we make sure our service table doesn't have duplicates */ /* Now we make sure our service table doesn't have duplicates */
std::map<port_spec, service_node>::iterator i; std::map<port_spec, service_node>::const_iterator i;
i = service_table.find(ps); i = service_table.find(ps);
if (i != service_table.end()) { if (i != service_table.end()) {
if (o.debugging) if (o.debugging)
@@ -270,15 +270,15 @@ void free_services() {
* Returns the number of ports added in total. * Returns the number of ports added in total.
*/ */
int addportsfromservmask(char *mask, u8 *porttbl, int range_type) { int addportsfromservmask(const char *mask, u8 *porttbl, int range_type) {
std::map<port_spec, service_node>::iterator i; std::map<port_spec, service_node>::const_iterator i;
int t = 0; int t = 0;
if (!services_initialized && nmap_services_init() == -1) if (!services_initialized && nmap_services_init() == -1)
fatal("%s: Couldn't get port numbers", __func__); fatal("%s: Couldn't get port numbers", __func__);
for (i = service_table.begin(); i != service_table.end(); i++) { for (i = service_table.begin(); i != service_table.end(); i++) {
service_node& current = i->second; const service_node& current = i->second;
if (wildtest(mask, current.s_name)) { if (wildtest(mask, current.s_name)) {
if ((range_type & SCAN_TCP_PORT) && strcmp(current.s_proto, "tcp") == 0) { if ((range_type & SCAN_TCP_PORT) && strcmp(current.s_proto, "tcp") == 0) {
porttbl[current.s_port] |= SCAN_TCP_PORT; porttbl[current.s_port] |= SCAN_TCP_PORT;
@@ -368,7 +368,7 @@ static bool is_port_member(const struct scan_lists *ptsdata, const struct servic
// This function doesn't support IP protocol scan so only call this // This function doesn't support IP protocol scan so only call this
// function if o.TCPScan() || o.UDPScan() || o.SCTPScan() // function if o.TCPScan() || o.UDPScan() || o.SCTPScan()
void gettoppts(double level, char *portlist, struct scan_lists * ports, char *exclude_ports) { void gettoppts(double level, const char *portlist, struct scan_lists * ports, const char *exclude_ports) {
int ti=0, ui=0, si=0; int ti=0, ui=0, si=0;
struct scan_lists ptsdata = { 0 }; struct scan_lists ptsdata = { 0 };
bool ptsdata_initialized = false; bool ptsdata_initialized = false;

View File

@@ -74,9 +74,9 @@
#define SERVICE_TABLE_SIZE 1024 #define SERVICE_TABLE_SIZE 1024
int addportsfromservmask(char *mask, u8 *porttbl, int range_type); int addportsfromservmask(const char *mask, u8 *porttbl, int range_type);
struct servent *nmap_getservbyport(int port, const char *proto); struct servent *nmap_getservbyport(int port, const char *proto);
void gettoppts(double level, char *portlist, struct scan_lists * ports, char *exclude_list = NULL); void gettoppts(double level, const char *portlist, struct scan_lists * ports, const char *exclude_list = NULL);
void free_services(); void free_services();

View File

@@ -80,7 +80,7 @@ extern NmapOps o;
/* Test a wildcard mask against a test string. Wildcard mask can include '*' and /* Test a wildcard mask against a test string. Wildcard mask can include '*' and
'?' which work the same as they do in /bin/sh (except it's case insensitive). '?' which work the same as they do in /bin/sh (except it's case insensitive).
Return val of 1 means it DID match. 0 means it DIDN'T. - Doug Hoyte, 2005 */ Return val of 1 means it DID match. 0 means it DIDN'T. - Doug Hoyte, 2005 */
int wildtest(char *wild, char *test) { int wildtest(const char *wild, const char *test) {
int i; int i;
while (*wild != '\0' || *test != '\0') { while (*wild != '\0' || *test != '\0') {

View File

@@ -100,7 +100,7 @@ template<class T> T box(T bmin, T bmax, T bnum) {
return bnum; return bnum;
} }
int wildtest(char *wild, char *test); int wildtest(const char *wild, const char *test);
void nmap_hexdump(const unsigned char *cp, unsigned int length); void nmap_hexdump(const unsigned char *cp, unsigned int length);