Skip to content

Commit 70eea63

Browse files
committed
Add feature macro for backward compatibility
1 parent f4ded91 commit 70eea63

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

base/hosts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ gvm_is_cidr6_block (const char *str)
509509
return is_cidr6_block (str);
510510
}
511511

512-
513512
/**
514513
* @brief Gets the network block value from a CIDR-expressed block string.
515514
* For "192.168.1.1/24" it is 24.
@@ -652,7 +651,8 @@ cidr6_block_ips (const char *str, struct in6_addr *first, struct in6_addr *last)
652651
}
653652

654653
int
655-
gvm_cidr6_block_ips (const char *str, struct in6_addr *first, struct in6_addr *last)
654+
gvm_cidr6_block_ips (const char *str, struct in6_addr *first,
655+
struct in6_addr *last)
656656
{
657657
return cidr6_block_ips (str, first, last);
658658
}

base/hosts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,6 @@ gvm_cidr6_get_ip (const char *, struct in6_addr *);
219219

220220
int
221221
gvm_cidr6_block_ips (const char *str, struct in6_addr *first,
222-
struct in6_addr *last);
222+
struct in6_addr *last);
223223

224224
#endif /* not _GVM_BASE_HOSTS_H */

boreas/cli.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ create_host_list (gpointer key, gpointer value, gpointer *userdata)
269269
GString *host_str = (GString *) *userdata;
270270
g_string_append (host_str, key);
271271
g_string_append (host_str, ",");
272-
273-
274272
}
275273
/**
276274
* @brief
@@ -281,15 +279,15 @@ create_host_list (gpointer key, gpointer value, gpointer *userdata)
281279
* @return NO_ERROR (0) on success, boreas_error_t on error.
282280
*/
283281
boreas_error_t
284-
run_cli_for_ipv6_network (const char *net, char **hosts_found )
282+
run_cli_for_ipv6_network (const char *net, char **hosts_found,
283+
int print_results)
285284
{
286285
unsigned int block;
287286
struct in6_addr target;
288287
scanner_t scanner = {0};
289288
boreas_error_t init_err;
290289
boreas_error_t run_err;
291290
boreas_error_t free_err;
292-
int print_results = 1;
293291

294292
if (net == NULL || gvm_get_host_type (net) != HOST_TYPE_CIDR6_BLOCK)
295293
return BOREAS_INVALID_IPV6_NETWORK;
@@ -311,13 +309,17 @@ run_cli_for_ipv6_network (const char *net, char **hosts_found )
311309
printf ("Error while running the scan.\n");
312310
return run_err;
313311
}
314-
315-
GString *host_str = g_string_new("");
316-
g_hash_table_foreach (scanner.hosts_data->alivehosts, (GHFunc) create_host_list, (gpointer) &host_str);
317312

318-
*hosts_found = g_strdup (host_str->str);
319-
g_string_free (host_str, TRUE);
320-
313+
if (hosts_found != NULL)
314+
{
315+
GString *host_str = g_string_new ("");
316+
g_hash_table_foreach (scanner.hosts_data->alivehosts,
317+
(GHFunc) create_host_list, (gpointer) &host_str);
318+
319+
*hosts_found = g_strdup (host_str->str);
320+
g_string_free (host_str, TRUE);
321+
}
322+
321323
free_err = free_cli (&scanner, ALIVE_TEST_IPV6_HOST_DISCOVERY);
322324
if (free_err)
323325
{
@@ -326,8 +328,6 @@ run_cli_for_ipv6_network (const char *net, char **hosts_found )
326328
}
327329

328330
return NO_ERROR;
329-
330-
return 0;
331331
}
332332

333333
/**

boreas/cli.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "alivedetection.h"
1010
#include "boreas_error.h"
1111

12+
#define FEATURE_HOST_DISCOVERY_IPV6
13+
1214
boreas_error_t
1315
run_cli_extended (gvm_hosts_t *, alive_test_t, const gchar *,
1416
const unsigned int);
@@ -17,7 +19,7 @@ boreas_error_t
1719
run_cli (gvm_hosts_t *, alive_test_t, const gchar *);
1820

1921
boreas_error_t
20-
run_cli_for_ipv6_network (const char *, char **);
22+
run_cli_for_ipv6_network (const char *, char **, int);
2123

2224
boreas_error_t
2325
is_host_alive (const char *, int *);

boreas/sniffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ got_packet (u_char *user_data,
181181
&& (g_hash_table_add (hosts_data->alivehosts, g_strdup (addr_str))))
182182
|| ((scanner->host_discovery == 1)
183183
&& (g_hash_table_add (hosts_data->alivehosts, g_strdup (addr_str)))
184-
&& (g_hash_table_add (hosts_data->targethosts, g_strdup (addr_str))) ))
184+
&& (g_hash_table_add (hosts_data->targethosts, g_strdup (addr_str)))))
185185
{
186186
/* handle max_scan_hosts related restrictions. */
187187
handle_scan_restrictions (scanner, addr_str);

0 commit comments

Comments
 (0)