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:
@@ -141,6 +141,14 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <errno.h>
|
#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 BITVECTOR_BITS (sizeof(bitvector_t) * CHAR_BIT)
|
||||||
#define BIT_SET(v, n) ((v)[(n) / BITVECTOR_BITS] |= 1UL << ((n) % BITVECTOR_BITS))
|
#define BIT_SET(v, n) ((v)[(n) / BITVECTOR_BITS] |= 1UL << ((n) % BITVECTOR_BITS))
|
||||||
@@ -148,6 +156,49 @@
|
|||||||
|
|
||||||
extern NmapOps o;
|
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;
|
NewTargets *NewTargets::new_targets;
|
||||||
|
|
||||||
/* Return a newly allocated string containing the part of expr up to the last
|
/* Return a newly allocated string containing the part of expr up to the last
|
||||||
|
|||||||
@@ -135,20 +135,11 @@
|
|||||||
#ifndef TARGETGROUP_H
|
#ifndef TARGETGROUP_H
|
||||||
#define TARGETGROUP_H
|
#define TARGETGROUP_H
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/* 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];
|
|
||||||
|
|
||||||
class NetBlock {
|
class NetBlock {
|
||||||
public:
|
public:
|
||||||
virtual ~NetBlock() {}
|
virtual ~NetBlock() {}
|
||||||
@@ -172,49 +163,6 @@ public:
|
|||||||
virtual std::string str() const = 0;
|
virtual std::string str() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Adding new targets is for NSE scripts */
|
/* Adding new targets is for NSE scripts */
|
||||||
class NewTargets {
|
class NewTargets {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user