1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Move some private classes to TargetGroup.cc from TargetGroup.h

This commit is contained in:
dmiller
2017-08-05 20:49:54 +00:00
parent 0ef9cc7f83
commit f5d29c490f
2 changed files with 51 additions and 52 deletions

View File

@@ -141,6 +141,14 @@
#include <sstream>
#include <errno.h>
#include <limits.h> // CHAR_BIT
/* We use bit vectors to represent what values are allowed in an IPv4 octet.
Each vector is built up of an array of bitvector_t (any convenient integer
type). */
typedef unsigned long bitvector_t;
/* A 256-element bit vector, representing legal values for one octet. */
typedef bitvector_t octet_bitvector[(256 - 1) / (sizeof(unsigned long) * CHAR_BIT) + 1];
#define BITVECTOR_BITS (sizeof(bitvector_t) * CHAR_BIT)
#define BIT_SET(v, n) ((v)[(n) / BITVECTOR_BITS] |= 1UL << ((n) % BITVECTOR_BITS))
@@ -148,6 +156,49 @@
extern NmapOps o;
class NetBlockIPv4Ranges : public NetBlock {
public:
octet_bitvector octets[4];
NetBlockIPv4Ranges();
bool next(struct sockaddr_storage *ss, size_t *sslen);
void apply_netmask(int bits);
std::string str() const;
private:
unsigned int counter[4];
};
class NetBlockIPv6Netmask : public NetBlock {
public:
void set_addr(const struct sockaddr_in6 *addr);
bool next(struct sockaddr_storage *ss, size_t *sslen);
void apply_netmask(int bits);
std::string str() const;
private:
bool exhausted;
struct sockaddr_in6 addr;
struct in6_addr start;
struct in6_addr cur;
struct in6_addr end;
};
class NetBlockHostname : public NetBlock {
public:
NetBlockHostname(const char *hostname, int af);
int af;
int bits;
NetBlock *resolve();
bool next(struct sockaddr_storage *ss, size_t *sslen);
void apply_netmask(int bits);
std::string str() const;
};
NewTargets *NewTargets::new_targets;
/* Return a newly allocated string containing the part of expr up to the last