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

Move TargetGroup class to TargetGroup files; make NetBlock class private

This commit is contained in:
dmiller
2017-08-06 03:20:40 +00:00
parent 675ae460b3
commit 817dd2a944
4 changed files with 125 additions and 124 deletions

View File

@@ -136,29 +136,39 @@
#define TARGETGROUP_H
#include <list>
#include <string>
class NetBlock {
class NetBlock;
class TargetGroup {
public:
virtual ~NetBlock() {}
std::string hostname;
std::list<struct sockaddr_storage> resolvedaddrs;
NetBlock *netblock;
/* Parses an expression such as 192.168.0.0/16, 10.1.0-5.1-254, or
fe80::202:e3ff:fe14:1102/112 and returns a newly allocated NetBlock. The af
parameter is AF_INET or AF_INET6. Returns NULL in case of error. */
static NetBlock *parse_expr(const char *target_expr, int af);
TargetGroup() {
this->netblock = NULL;
}
~TargetGroup();
/* Initializes (or reinitializes) the object with a new expression,
such as 192.168.0.0/16 , 10.1.0-5.1-254 , or
fe80::202:e3ff:fe14:1102 . The af parameter is AF_INET or
AF_INET6 Returns 0 for success */
int parse_expr(const char *target_expr, int af);
/* Grab the next host from this expression (if any). Returns 0 and
fills in ss if successful. ss must point to a pre-allocated
sockaddr_storage structure */
int get_next_host(struct sockaddr_storage *ss, size_t *sslen);
/* 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 is_resolved_address(const struct sockaddr_storage *ss) const;
/* For NetBlock subclasses that need to "resolve" themselves into a different
* NetBlock subclass, override this method. Otherwise, it's safe to reassign
* the return value to the pointer that this method was called through.
* On error, return NULL. */
virtual NetBlock *resolve() { return this; }
virtual bool next(struct sockaddr_storage *ss, size_t *sslen) = 0;
virtual void apply_netmask(int bits) = 0;
virtual std::string str() const = 0;
/* Return a string of the name or address that was resolved for this group. */
const char *get_resolved_name(void) const;
/* 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> &get_resolved_addrs(void) const;
/* is the current expression a named host */
int get_namedhost() const;
};
#endif /* TARGETGROUP_H */