OpenVAS Libraries
9.0.1
|
Implementation of an API to handle Hosts objects. More...
#include "openvas_hosts.h"
Functions | |
int | openvas_get_host_type (const gchar *str_stripped) |
Determines the host type in a buffer. More... | |
openvas_hosts_t * | openvas_hosts_new_with_max (const gchar *hosts_str, unsigned int max_hosts) |
Creates a new openvas_hosts_t structure and the associated hosts objects from the provided hosts_str. More... | |
openvas_hosts_t * | openvas_hosts_new (const gchar *hosts_str) |
Creates a new openvas_hosts_t structure and the associated hosts objects from the provided hosts_str. More... | |
openvas_host_t * | openvas_hosts_next (openvas_hosts_t *hosts) |
Gets the next openvas_host_t from a openvas_hosts_t structure. The state of iteration is kept internally within the openvas_hosts structure. More... | |
void | openvas_hosts_free (openvas_hosts_t *hosts) |
Frees memory occupied by an openvas_hosts_t structure. More... | |
void | openvas_hosts_shuffle (openvas_hosts_t *hosts) |
Randomizes the order of the hosts objects in the collection. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
void | openvas_hosts_reverse (openvas_hosts_t *hosts) |
Reverses the order of the hosts objects in the collection. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
void | openvas_hosts_resolve (openvas_hosts_t *hosts) |
Resolves host objects of type name in a hosts collection, replacing hostnames with IPv4 values. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
int | openvas_hosts_exclude (openvas_hosts_t *hosts, const char *excluded_str, int resolve) |
Excludes a set of hosts provided as a string from a hosts collection. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
char * | openvas_host_reverse_lookup (openvas_host_t *host) |
Checks for a host object reverse dns lookup existence. More... | |
int | openvas_hosts_reverse_lookup_only (openvas_hosts_t *hosts) |
Removes hosts that don't reverse-lookup from the hosts collection. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
int | openvas_hosts_reverse_lookup_unify (openvas_hosts_t *hosts) |
Removes hosts duplicates that reverse-lookup to the same value. Not to be used while iterating over the single hosts as it resets the iterator. More... | |
unsigned int | openvas_hosts_count (const openvas_hosts_t *hosts) |
Gets the count of single hosts objects in a hosts collection. More... | |
unsigned int | openvas_hosts_removed (const openvas_hosts_t *hosts) |
Gets the count of single values in hosts string that were removed (duplicates / excluded.) More... | |
int | openvas_host_in_hosts (const openvas_host_t *host, const struct in6_addr *addr, const openvas_hosts_t *hosts) |
Returns whether a host has an equal host in a hosts collection. eg. 192.168.10.1 has an equal in list created from "192.168.10.1-5, 192.168.10.10-20" string while 192.168.10.7 doesn't. More... | |
enum host_type | openvas_host_type (const openvas_host_t *host) |
Gets a host object's type. More... | |
gchar * | openvas_host_type_str (const openvas_host_t *host) |
Gets a host's type in printable format. More... | |
gchar * | openvas_host_value_str (const openvas_host_t *host) |
Gets a host's value in printable format. More... | |
int | openvas_host_resolve (const openvas_host_t *host, void *dst, int family) |
Resolves a host object's name to an IPv4 or IPv6 address. Host object should be of type HOST_TYPE_NAME. More... | |
int | openvas_host_get_addr6 (const openvas_host_t *host, struct in6_addr *ip6) |
Gives a host object's value as an IPv6 address. If the host type is hostname, it resolves the IPv4 address then gives an IPv4-mapped IPv6 address (eg. ::ffff:192.168.1.1 .) If the host type is IPv4, it gives an IPv4-mapped IPv6 address. If the host's type is IPv6, it gives the value directly. More... | |
Variables | |
gchar * | host_type_str [HOST_TYPE_MAX] |
Implementation of an API to handle Hosts objects.
This file contains all methods to handle Hosts collections (openvas_hosts_t) and single hosts objects (openvas_host_t.)
The module consequently uses glib datatypes.
int openvas_get_host_type | ( | const gchar * | str_stripped | ) |
Determines the host type in a buffer.
[in] | str_stripped | Buffer that contains host definition, could a be hostname, single IPv4 or IPv6, CIDR-expressed block etc,. |
int openvas_host_get_addr6 | ( | const openvas_host_t * | host, |
struct in6_addr * | ip6 | ||
) |
Gives a host object's value as an IPv6 address. If the host type is hostname, it resolves the IPv4 address then gives an IPv4-mapped IPv6 address (eg. ::ffff:192.168.1.1 .) If the host type is IPv4, it gives an IPv4-mapped IPv6 address. If the host's type is IPv6, it gives the value directly.
[in] | host | The host object whose value to get as IPv6. |
[out] | ip6 | Buffer to store the IPv6 address. |
int openvas_host_in_hosts | ( | const openvas_host_t * | host, |
const struct in6_addr * | addr, | ||
const openvas_hosts_t * | hosts | ||
) |
Returns whether a host has an equal host in a hosts collection. eg. 192.168.10.1 has an equal in list created from "192.168.10.1-5, 192.168.10.10-20" string while 192.168.10.7 doesn't.
[in] | host | The host object. |
[in] | addr | Optional pointer to ip address. Could be used so that host isn't resolved multiple times when type is HOST_TYPE_NAME. |
[in] | hosts | Hosts collection. |
int openvas_host_resolve | ( | const openvas_host_t * | host, |
void * | dst, | ||
int | family | ||
) |
Resolves a host object's name to an IPv4 or IPv6 address. Host object should be of type HOST_TYPE_NAME.
[in] | host | The host object whose name to resolve. |
[out] | dst | Buffer to store resolved address. Size must be at least 4 bytes for AF_INET and 16 bytes for AF_INET6. |
[in] | family | Either AF_INET or AF_INET6. |
char* openvas_host_reverse_lookup | ( | openvas_host_t * | host | ) |
Checks for a host object reverse dns lookup existence.
[in] | host | The host to reverse-lookup. |
enum host_type openvas_host_type | ( | const openvas_host_t * | host | ) |
Gets a host object's type.
[in] | host | The host object. |
gchar* openvas_host_type_str | ( | const openvas_host_t * | host | ) |
Gets a host's type in printable format.
[in] | host | The host object. |
gchar* openvas_host_value_str | ( | const openvas_host_t * | host | ) |
Gets a host's value in printable format.
[in] | host | The host object. |
unsigned int openvas_hosts_count | ( | const openvas_hosts_t * | hosts | ) |
Gets the count of single hosts objects in a hosts collection.
[in] | hosts | The hosts collection to count hosts of. |
int openvas_hosts_exclude | ( | openvas_hosts_t * | hosts, |
const char * | excluded_str, | ||
int | resolve | ||
) |
Excludes a set of hosts provided as a string from a hosts collection. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection from which to exclude. |
[in] | excluded_str | String of hosts to exclude. |
[in] | resolve | Boolean. Whether to also resolve hostnames when excluding. |
Uses a hash table in order to exclude hosts in O(N+M) time.
void openvas_hosts_free | ( | openvas_hosts_t * | hosts | ) |
Frees memory occupied by an openvas_hosts_t structure.
[in] | hosts | The hosts collection to free. |
openvas_hosts_t* openvas_hosts_new | ( | const gchar * | hosts_str | ) |
Creates a new openvas_hosts_t structure and the associated hosts objects from the provided hosts_str.
[in] | hosts_str | The hosts string. A copy will be created of this within the returned struct. |
openvas_hosts_t* openvas_hosts_new_with_max | ( | const gchar * | hosts_str, |
unsigned int | max_hosts | ||
) |
Creates a new openvas_hosts_t structure and the associated hosts objects from the provided hosts_str.
[in] | hosts_str | The hosts string. A copy will be created of this within the returned struct. |
[in] | max_hosts | Max number of hosts in hosts_str. 0 means unlimited. |
openvas_host_t* openvas_hosts_next | ( | openvas_hosts_t * | hosts | ) |
Gets the next openvas_host_t from a openvas_hosts_t structure. The state of iteration is kept internally within the openvas_hosts structure.
[in] | hosts | openvas_hosts_t structure to get next host from. |
unsigned int openvas_hosts_removed | ( | const openvas_hosts_t * | hosts | ) |
Gets the count of single values in hosts string that were removed (duplicates / excluded.)
[in] | hosts | The hosts collection. |
void openvas_hosts_resolve | ( | openvas_hosts_t * | hosts | ) |
Resolves host objects of type name in a hosts collection, replacing hostnames with IPv4 values. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection from which to exclude. |
void openvas_hosts_reverse | ( | openvas_hosts_t * | hosts | ) |
Reverses the order of the hosts objects in the collection. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection to reverse. |
int openvas_hosts_reverse_lookup_only | ( | openvas_hosts_t * | hosts | ) |
Removes hosts that don't reverse-lookup from the hosts collection. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection to filter. |
int openvas_hosts_reverse_lookup_unify | ( | openvas_hosts_t * | hosts | ) |
Removes hosts duplicates that reverse-lookup to the same value. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection to filter. |
Uses a hash table in order to unify the hosts list in O(N) time.
void openvas_hosts_shuffle | ( | openvas_hosts_t * | hosts | ) |
Randomizes the order of the hosts objects in the collection. Not to be used while iterating over the single hosts as it resets the iterator.
[in] | hosts | The hosts collection to shuffle. |
gchar* host_type_str[HOST_TYPE_MAX] |