mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 22:21:29 +00:00
Formatting in TargetGroup.{cc,h}.
astyle -a -p -H -s2 -m2 TargetGroup.cc TargetGroup.h
This commit is contained in:
@@ -166,7 +166,7 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
||||
} else
|
||||
netmask = 32;
|
||||
resolvedname = hostexp;
|
||||
for(i=0; hostexp[i] != '\0'; i++)
|
||||
for (i = 0; hostexp[i]; i++)
|
||||
if (isupper((int) (unsigned char) hostexp[i]) ||
|
||||
islower((int) (unsigned char) hostexp[i])) {
|
||||
namedhost = 1;
|
||||
@@ -223,8 +223,7 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
||||
fprintf(stderr, "Host specification invalid");
|
||||
free(hostexp);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
targets_type = IPV4_RANGES;
|
||||
i = 0;
|
||||
|
||||
@@ -232,8 +231,7 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
||||
if (*r == '.' && ++i < 4) {
|
||||
*r = '\0';
|
||||
addy[i] = r + 1;
|
||||
}
|
||||
else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int) (unsigned char) *r)) {
|
||||
} else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int) (unsigned char) *r)) {
|
||||
error("Invalid character in host specification: %s. Note in particular that square brackets [] are no longer allowed. They were redundant and can simply be removed.", target_expr);
|
||||
return 1;
|
||||
}
|
||||
@@ -249,13 +247,14 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
||||
do {
|
||||
s = strchr(addy[i], ',');
|
||||
if (s) *s = '\0';
|
||||
if (*addy[i] == '*') { start = 0; end = 255; }
|
||||
else if (*addy[i] == '-') {
|
||||
if (*addy[i] == '*') {
|
||||
start = 0;
|
||||
end = 255;
|
||||
} else if (*addy[i] == '-') {
|
||||
start = 0;
|
||||
if (*(addy[i] + 1) == '\0') end = 255;
|
||||
else end = atoi(addy[i] + 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
start = end = atoi(addy[i]);
|
||||
if ((r = strchr(addy[i], '-')) && *(r + 1) ) end = atoi(r + 1);
|
||||
else if (r && !*(r + 1)) end = 255;
|
||||
@@ -282,8 +281,7 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
||||
(unsigned long long) (last[1] + 1) *
|
||||
(unsigned long long) (last[2] + 1) *
|
||||
(unsigned long long) (last[3] + 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if HAVE_IPV6
|
||||
struct addrinfo *addrs, *addr;
|
||||
struct sockaddr_storage ss;
|
||||
@@ -383,8 +381,7 @@ int TargetGroup::skip_range(_octet_nums octet) {
|
||||
if (current[i] < last[i]) {
|
||||
current[i]++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
} else
|
||||
current[i] = 0;
|
||||
}
|
||||
|
||||
@@ -446,8 +443,7 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) {
|
||||
ipsleft = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (targets_type == IPV4_RANGES) {
|
||||
} else if (targets_type == IPV4_RANGES) {
|
||||
memset(sin, 0, sizeof(struct sockaddr_in));
|
||||
sin->sin_family = AF_INET;
|
||||
*sslen = sizeof(struct sockaddr_in);
|
||||
@@ -479,8 +475,10 @@ int TargetGroup::get_next_host(struct sockaddr_storage *ss, size_t *sslen) {
|
||||
assert(ipsleft == 1);
|
||||
/* So I set current to last with the very final octet up one ... */
|
||||
/* Note that this may make current[3] == 256 */
|
||||
current[0] = last[0]; current[1] = last[1];
|
||||
current[2] = last[2]; current[3] = last[3] + 1;
|
||||
current[0] = last[0];
|
||||
current[1] = last[1];
|
||||
current[2] = last[2];
|
||||
current[3] = last[3] + 1;
|
||||
} else {
|
||||
assert(ipsleft > 1); /* There must be at least one more IP left */
|
||||
}
|
||||
@@ -549,8 +547,7 @@ int TargetGroup::return_last_host() {
|
||||
/* Returns true iff the given address is the one that was resolved to create
|
||||
this target group; i.e., not one of the addresses derived from it with a
|
||||
netmask. */
|
||||
bool TargetGroup::is_resolved_address(const struct sockaddr_storage *ss)
|
||||
{
|
||||
bool TargetGroup::is_resolved_address(const struct sockaddr_storage *ss) {
|
||||
struct sockaddr_storage resolvedaddr;
|
||||
|
||||
if (resolvedaddrs.empty())
|
||||
@@ -565,15 +562,13 @@ bool TargetGroup::is_resolved_address(const struct sockaddr_storage *ss)
|
||||
}
|
||||
|
||||
/* Return a string of the name or address that was resolved for this group. */
|
||||
const char *TargetGroup::get_resolved_name(void)
|
||||
{
|
||||
const char *TargetGroup::get_resolved_name(void) {
|
||||
return resolvedname.c_str();
|
||||
}
|
||||
|
||||
/* Return the list of addresses that the name for this group resolved to, if
|
||||
it came from a name resolution. */
|
||||
const std::list<struct sockaddr_storage> &TargetGroup::get_resolved_addrs(void)
|
||||
{
|
||||
const std::list<struct sockaddr_storage> &TargetGroup::get_resolved_addrs(void) {
|
||||
return resolvedaddrs;
|
||||
}
|
||||
|
||||
@@ -611,12 +606,10 @@ unsigned long NewTargets::push (const char *target) {
|
||||
queue.push(tg);
|
||||
|
||||
if (o.debugging > 2)
|
||||
log_write(LOG_PLAIN, "New Targets: target %s pushed onto the queue.\n",
|
||||
tg.c_str());
|
||||
log_write(LOG_PLAIN, "New Targets: target %s pushed onto the queue.\n", tg.c_str());
|
||||
} else {
|
||||
if (o.debugging > 2)
|
||||
log_write(LOG_PLAIN, "New Targets: target %s is already in the queue.\n",
|
||||
tg.c_str());
|
||||
log_write(LOG_PLAIN, "New Targets: target %s is already in the queue.\n", tg.c_str());
|
||||
/* Return 1 when the target is already in the history cache,
|
||||
* this will prevent returning 0 when the target queue is
|
||||
* empty since no target was added. */
|
||||
|
||||
@@ -136,11 +136,17 @@ class TargetGroup {
|
||||
it came from a name resolution. */
|
||||
const std::list<struct sockaddr_storage> &get_resolved_addrs(void);
|
||||
/* return the target type */
|
||||
char get_targets_type() {return targets_type;};
|
||||
char get_targets_type() {
|
||||
return targets_type;
|
||||
};
|
||||
/* get the netmask */
|
||||
int get_mask() {return netmask;};
|
||||
int get_mask() {
|
||||
return netmask;
|
||||
};
|
||||
/* is the current expression a named host */
|
||||
int get_namedhost() {return namedhost;};
|
||||
int get_namedhost() {
|
||||
return namedhost;
|
||||
};
|
||||
/* Skip an octet in the range array */
|
||||
int skip_range(_octet_nums octet);
|
||||
private:
|
||||
@@ -166,11 +172,11 @@ class TargetGroup {
|
||||
unsigned int current[4];
|
||||
u8 last[4];
|
||||
|
||||
/* Number of IPs left in this structure -- set to 0 if
|
||||
the fields are not valid */
|
||||
/* Number of IPs left in this structure -- set to 0 if the fields are not
|
||||
valid */
|
||||
unsigned long long ipsleft;
|
||||
|
||||
// is the current target expression a named host
|
||||
/* is the current target expression a named host? */
|
||||
int namedhost;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user