OpenVAS Libraries  4.0+rc3.SVN
Macros | Functions
hg_add_hosts.c File Reference
#include <arpa/inet.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "network.h"
#include "hosts_gatherer.h"
#include "hg_utils.h"
#include "hg_filter.h"
#include "hg_add_hosts.h"
#include "hg_subnet.h"

Macros

#define OCTETRANGE   "%3d%*1[-]%3d"
#define OCTET   "%3d"
#define DOT   "%*1[.]"
#define COMP   "%7[0-9-]"
#define REMINDER   "%s"

Functions

int hg_add_comma_delimited_hosts (struct hg_globals *globals, int limit)
void hg_add_ipv6host_with_options (struct hg_globals *globals, char *hostname, struct in6_addr *ip, int alive, int netmask, int use_max, struct in6_addr *ip_max)
void hg_add_host_with_options (struct hg_globals *globals, char *hostname, struct in_addr ip, int alive, int netmask, int use_max, struct in_addr *ip_max)
 Appends a new hg_host to the hg_globals hostlist.
void hg_add_domain (struct hg_globals *globals, char *domain)
void hg_add_subnet (struct hg_globals *globals, struct in_addr ip, int netmask)

Detailed Description

Functions to add hosts to a hg_globals host list.

Possible input values for host/hostname:

'hostname' or 'xx.xx.xx.xx' or 'hostname/netmask' or 'xx.xx.xx.xx/netmask' or '[xx|xx-xx].[xx|xx-xx].[xx|xx-xx].[xx|xx-xx]' (by Alex Butcher, Articon-Integralis AG)


Macro Definition Documentation

#define OCTETRANGE   "%3d%*1[-]%3d"
Todo:
Document what kind of input for ipv6 adresses is acceppted, move description of valid "hostnames" to a better place (this is really interesting for a user), document how to list multiple hosts (space, comma, semicolon- separated?).

Function Documentation

int hg_add_comma_delimited_hosts ( struct hg_globals globals,
int  limit 
)

Add hosts of the form :

host1/nm,host2/nm,xxx.xxx.xxx.xxx/xxx, ....

, progressing the "marker" of the globals argument. Hosts can be separated by comma or semicolons.

Parameters:
[in,out]globalshg_globals to add hosts to.
[in]limitMaximum number of hosts to resolve, might well break before. Smaller or equal to 0 means "no limit".
Returns:
0 if all or limit hosts have been added, -1 on errors.
void hg_add_host_with_options ( struct hg_globals globals,
char *  hostname,
struct in_addr  ip,
int  alive,
int  netmask,
int  use_max,
struct in_addr *  ip_max 
)

Appends a new hg_host to the hg_globals hostlist.

Parameters:
[in,out]globalshg_globals to add host to.
[in]hostnamehostname.
Todo:
consider const for hostname parameter
void hg_add_ipv6host_with_options ( struct hg_globals globals,
char *  hostname,
struct in6_addr *  ip,
int  alive,
int  netmask,
int  use_max,
struct in6_addr *  ip_max 
)
Parameters:
ip_maxIgnored.
Todo:
We will probably segfault sooner or later if inet_ntop fails.