Skip to content

Commit

Permalink
Straighten out some headers and the (struct) addrset type
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Nov 1, 2018
1 parent c223ec5 commit 27807aa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
3 changes: 2 additions & 1 deletion TargetGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
#define TARGETGROUP_H

#include <list>
#include <cstddef>

class NetBlock;

Expand All @@ -157,7 +158,7 @@ class TargetGroup {
/* 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);
int get_next_host(struct sockaddr_storage *ss, std::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. */
Expand Down
12 changes: 1 addition & 11 deletions nbase/nbase_addrset.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,7 @@
#define _NBASE_ADDRSET_H

//#define HAVE_IPV6 1
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#ifndef WIN32
#include <sys/socket.h>
#endif

#include "nbase.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
Expand Down
2 changes: 1 addition & 1 deletion nmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ int nmap_main(int argc, char *argv[]) {
struct hostent *target = NULL;
time_t timep;
char mytime[128];
addrset exclude_group;
struct addrset exclude_group;
#ifndef NOLUA
/* Only NSE scripts can add targets */
NewTargets *new_targets = NULL;
Expand Down
14 changes: 7 additions & 7 deletions targets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void returnhost(HostGroupState *hs) {
/* Is the host passed as Target to be excluded? Much of this logic had
to be rewritten from wam's original code to allow for the objects */
static int hostInExclude(struct sockaddr *checksock, size_t checksocklen,
const addrset *exclude_group) {
const struct addrset *exclude_group) {
if (exclude_group == NULL)
return 0;

Expand All @@ -219,7 +219,7 @@ static int hostInExclude(struct sockaddr *checksock, size_t checksocklen,
}

/* Load an exclude list from a file for --excludefile. */
int load_exclude_file(addrset *excludelist, FILE *fp) {
int load_exclude_file(struct addrset *excludelist, FILE *fp) {
char host_spec[1024];
size_t n;

Expand All @@ -236,7 +236,7 @@ int load_exclude_file(addrset *excludelist, FILE *fp) {

/* Load a comma-separated exclude list from a string, the argument to
--exclude. */
int load_exclude_string(addrset *excludelist, const char *s) {
int load_exclude_string(struct addrset *excludelist, const char *s) {
const char *begin, *p;

p = s;
Expand All @@ -259,7 +259,7 @@ int load_exclude_string(addrset *excludelist, const char *s) {

/* A debug routine to dump some information to stdout. Invoked if debugging is
set to 4 or higher. */
int dumpExclude(addrset *exclude_group) {
int dumpExclude(struct addrset *exclude_group) {
const struct addrset_elem *elem;

for (elem = exclude_group->head; elem != NULL; elem = elem->next)
Expand Down Expand Up @@ -495,7 +495,7 @@ static Target *setup_target(const HostGroupState *hs,
return NULL;
}

static Target *next_target(HostGroupState *hs, const addrset *exclude_group,
static Target *next_target(HostGroupState *hs, const struct addrset *exclude_group,
struct scan_lists *ports, int pingtype) {
struct sockaddr_storage ss;
size_t sslen;
Expand Down Expand Up @@ -548,7 +548,7 @@ static Target *next_target(HostGroupState *hs, const addrset *exclude_group,
return t;
}

static void refresh_hostbatch(HostGroupState *hs, const addrset *exclude_group,
static void refresh_hostbatch(HostGroupState *hs, const struct addrset *exclude_group,
struct scan_lists *ports, int pingtype) {
int i;
bool arpping_done = false;
Expand Down Expand Up @@ -642,7 +642,7 @@ static void refresh_hostbatch(HostGroupState *hs, const addrset *exclude_group,
nmap_mass_rdns(hs->hostbatch, hs->current_batch_sz);
}

Target *nexthost(HostGroupState *hs, const addrset *exclude_group,
Target *nexthost(HostGroupState *hs, const struct addrset *exclude_group,
struct scan_lists *ports, int pingtype) {
if (hs->next_batch_no >= hs->current_batch_sz)
refresh_hostbatch(hs, exclude_group, ports, pingtype);
Expand Down
11 changes: 6 additions & 5 deletions targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@
#ifndef TARGETS_H
#define TARGETS_H

#include <list>
#include "TargetGroup.h"
#include <list>
#include <nbase.h>
class Target;

class HostGroupState {
Expand Down Expand Up @@ -173,12 +174,12 @@ class HostGroupState {
};

/* ports is used to pass information about what ports to use for host discovery */
Target *nexthost(HostGroupState *hs,const addrset *exclude_group,
Target *nexthost(HostGroupState *hs,const struct addrset *exclude_group,
struct scan_lists *ports, int pingtype);
int load_exclude_file(addrset *exclude_group, FILE *fp);
int load_exclude_string(addrset *exclude_group, const char *s);
int load_exclude_file(struct addrset *exclude_group, FILE *fp);
int load_exclude_string(struct addrset *exclude_group, const char *s);
/* a debugging routine to dump an exclude list to stdout. */
int dumpExclude(addrset *exclude_group);
int dumpExclude(struct addrset *exclude_group);
/* Returns the last host obtained by nexthost. It will be given again the next
time you call nexthost(). */
void returnhost(HostGroupState *hs);
Expand Down

0 comments on commit 27807aa

Please sign in to comment.