Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions base/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ is_hostname (const char *str)
*
* @return 1 if valid IPv6 CIDR-expressed block, 0 otherwise.
*/
static int
is_cidr6_block (const char *str)
int
gvm_is_cidr6_block (const char *str)
{
long block;
char *addr6_str, *block_str, *p;
Expand Down Expand Up @@ -512,8 +512,8 @@ is_cidr6_block (const char *str)
*
* @return -1 if error, 0 otherwise.
*/
static int
cidr6_get_block (const char *str, unsigned int *block)
int
gvm_cidr6_get_block (const char *str, unsigned int *block)
{
if (str == NULL || block == NULL)
return -1;
Expand All @@ -533,8 +533,8 @@ cidr6_get_block (const char *str, unsigned int *block)
*
* @return -1 if error, 0 otherwise.
*/
static int
cidr6_get_ip (const char *str, struct in6_addr *addr6)
int
gvm_cidr6_get_ip (const char *str, struct in6_addr *addr6)
{
gchar *addr6_str, *tmp;

Expand Down Expand Up @@ -568,8 +568,9 @@ cidr6_get_ip (const char *str, struct in6_addr *addr6)
*
* @return -1 if error, 0 else.
*/
static int
cidr6_block_ips (const char *str, struct in6_addr *first, struct in6_addr *last)
int
gvm_cidr6_block_ips (const char *str, struct in6_addr *first,
struct in6_addr *last)
{
unsigned int block;
int i, j;
Expand All @@ -578,9 +579,9 @@ cidr6_block_ips (const char *str, struct in6_addr *first, struct in6_addr *last)
return -1;

/* Get IP and block values. */
if (cidr6_get_block (str, &block) == -1)
if (gvm_cidr6_get_block (str, &block) == -1)
return -1;
if (cidr6_get_ip (str, first) == -1)
if (gvm_cidr6_get_ip (str, first) == -1)
return -1;
memcpy (&last->s6_addr, &first->s6_addr, 16);

Expand Down Expand Up @@ -844,7 +845,7 @@ gvm_get_host_type (const gchar *str_stripped)
return HOST_TYPE_RANGE_LONG;

/* Check for regular IPv6 CIDR-expressed block like "2620:0:2d0:200::7/120" */
if (is_cidr6_block (str_stripped))
if (gvm_is_cidr6_block (str_stripped))
return HOST_TYPE_CIDR6_BLOCK;

/* Check for short range-expressed networks "::1-ef12" */
Expand Down Expand Up @@ -1216,7 +1217,7 @@ gvm_hosts_new_with_max (const gchar *hosts_str, unsigned int max_hosts)
struct in6_addr *);

if (host_type == HOST_TYPE_CIDR6_BLOCK)
ips_func = cidr6_block_ips;
ips_func = gvm_cidr6_block_ips;
else if (host_type == HOST_TYPE_RANGE6_SHORT)
ips_func = short_range6_network_ips;
else
Expand Down
13 changes: 13 additions & 0 deletions base/hosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,17 @@ gvm_vhost_new (char *, char *);
int
gvm_get_host_type (const gchar *);

int
gvm_is_cidr6_block (const char *);

int
gvm_cidr6_get_block (const char *, unsigned int *);

int
gvm_cidr6_get_ip (const char *, struct in6_addr *);

int
gvm_cidr6_block_ips (const char *str, struct in6_addr *first,
struct in6_addr *last);

#endif /* not _GVM_BASE_HOSTS_H */
12 changes: 11 additions & 1 deletion boreas/alivedetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ start_alive_detection (void *);

typedef struct hosts_data hosts_data_t;
typedef struct scan_restrictions scan_restrictions_t;
typedef struct ipv6_net_data ipv6_net_data_t;

/**
* @brief The scanner struct holds data which is used frequently by the alive
Expand All @@ -62,13 +63,21 @@ struct scanner
/* pcap handle */
pcap_t *pcap_handle;
hosts_data_t *hosts_data;
ipv6_net_data_t *ipv6_net;
scan_restrictions_t *scan_restrictions;
/* 0 do not print in stdout, 1 print in stdout used for cmd line cli. */
int print_results;
int host_discovery;
};

typedef struct scanner scanner_t;

struct ipv6_net_data
{
char *net;
struct in6_addr src;
};

/**
* @brief The hosts_data struct holds the alive hosts and target hosts in
* separate hashtables.
Expand Down Expand Up @@ -108,7 +117,8 @@ typedef enum
ALIVE_TEST_ICMP = 2,
ALIVE_TEST_ARP = 4,
ALIVE_TEST_CONSIDER_ALIVE = 8,
ALIVE_TEST_TCP_SYN_SERVICE = 16
ALIVE_TEST_TCP_SYN_SERVICE = 16,
ALIVE_TEST_IPV6_HOST_DISCOVERY = 32
} alive_test_t;

/**
Expand Down
3 changes: 3 additions & 0 deletions boreas/boreas_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ str_boreas_error (boreas_error_t boreas_error)
msg = "Boreas was not able to determine a source address for the given "
"destination.";
break;
case BOREAS_INVALID_IPV6_NETWORK:
msg = "Invalid IPv6 Network. Not possible to run an Host Discovery";
break;
case NO_ERROR:
msg = "No error was encountered by Boreas";
break;
Expand Down
2 changes: 2 additions & 0 deletions boreas/boreas_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ typedef enum
{
BOREAS_OPENING_SOCKET_FAILED = -100,
BOREAS_SETTING_SOCKET_OPTION_FAILED,
BOREAS_BIND_SOCKET_FAILED,
BOREAS_NO_VALID_ALIVE_TEST_SPECIFIED,
BOREAS_CLEANUP_ERROR,
BOREAS_NO_SRC_ADDR_FOUND,
BOREAS_INVALID_IPV6_NETWORK,
NO_ERROR = 0,
} boreas_error_t;

Expand Down
Loading
Loading