14#ifndef _GVM_BASE_HOSTS_H
15#define _GVM_BASE_HOSTS_H
20#define FEATURE_HOSTS_ALLOWED_ONLY 1
26#define FEATURE_REVERSE_LOOKUP_EXCLUDED 1
29#include <netinet/in.h>
66 struct in6_addr
addr6;
222 struct in6_addr *last);
void gvm_hosts_add(gvm_hosts_t *hosts, gvm_host_t *host)
Inserts a host object at the end of a hosts collection.
int gvm_host_in_hosts(const gvm_host_t *host, const struct in6_addr *addr, const gvm_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...
gvm_hosts_t * gvm_hosts_reverse_lookup_unify_excluded(gvm_hosts_t *hosts)
Removes hosts duplicates that reverse-lookup to the same value. Not to be used while iterating over t...
int gvm_hosts_reverse_lookup_only(gvm_hosts_t *hosts)
Removes hosts that don't reverse-lookup from the hosts collection. Not to be used while iterating ove...
gchar * gvm_host_value_str(const gvm_host_t *host)
Gets a host's value in printable format.
int gvm_host_resolve(const gvm_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_NAM...
gvm_hosts_t * gvm_hosts_reverse_lookup_only_excluded(gvm_hosts_t *hosts)
Removes hosts that don't reverse-lookup from the hosts collection. Not to be used while iterating ove...
char * gvm_host_reverse_lookup(gvm_host_t *host)
Checks for a host object reverse dns lookup existence.
gvm_host_t * gvm_duplicate_host(gvm_host_t *host)
Creates a deep copy of a host. gvm_host_free has to be called on it.
gvm_vhost_t * gvm_vhost_new(char *value, char *source)
Creates a new gvm_vhost_t object.
gvm_hosts_t * gvm_hosts_new(const gchar *hosts_str)
Creates a new gvm_hosts_t structure and the associated hosts objects from the provided hosts_str.
gvm_host_t * gvm_hosts_next(gvm_hosts_t *hosts)
Gets the next gvm_host_t from a gvm_hosts_t structure. The state of iteration is kept internally with...
GSList * gvm_hosts_allowed_only(gvm_hosts_t *hosts, const char *deny_hosts_str, const char *allow_hosts_str)
Returns a list of hosts after a host authorization check.
void gvm_host_free(gpointer host)
Frees the memory occupied by an gvm_host_t object.
unsigned int gvm_hosts_removed(const gvm_hosts_t *hosts)
Gets the count of single values in hosts string that were removed (duplicates / excluded....
gchar * gvm_host_type_str(const gvm_host_t *host)
Gets a host's type in printable format.
void gvm_host_add_reverse_lookup(gvm_host_t *host)
Add a host's reverse-lookup name to the vhosts list.
gvm_hosts_t * gvm_hosts_new_with_max(const gchar *hosts_str, unsigned int max_hosts)
Creates a new gvm_hosts_t structure and the associated hosts objects from the provided hosts_str.
int gvm_cidr6_block_ips(const char *str, struct in6_addr *first, struct in6_addr *last)
Gets the first and last usable IPv4 addresses from a CIDR-expressed block. eg. "192....
void gvm_hosts_reverse(gvm_hosts_t *hosts)
Reverses the order of the hosts objects in the collection. Not to be used while iterating over the si...
void gvm_hosts_shuffle(gvm_hosts_t *hosts)
Randomizes the order of the hosts objects in the collection. Not to be used while iterating over the ...
unsigned int gvm_hosts_duplicated(const gvm_hosts_t *hosts)
Gets the count of single values in hosts string that were duplicated and therefore removed from the l...
gvm_host_t * gvm_host_from_str(const gchar *host_str)
Creates a new gvm_host_t from a host string.
int gvm_cidr6_get_block(const char *str, unsigned int *block)
Gets the network block value from a CIDR-expressed block string. For "192.168.1.1/24" it is 24.
int gvm_cidr6_get_ip(const char *str, struct in6_addr *addr6)
Gets the IPv4 value from a CIDR-expressed block. eg. For "192.168.1.10/24" it is "192....
int gvm_host_get_addr6(const gvm_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 ad...
void gvm_hosts_move_current_host_to_end(gvm_hosts_t *hosts)
Move the current gvm_host_t from a gvm_hosts_t structure to the end of the hosts list.
int gvm_vhosts_exclude(gvm_host_t *host, const char *excluded_str)
Exclude a list of vhosts from a host's vhosts list.
int gvm_hosts_exclude_with_max(gvm_hosts_t *hosts, const char *excluded_str, unsigned int max_hosts)
Excludes a set of hosts provided as a string from a hosts collection. Not to be used while iterating ...
GSList * gvm_hosts_resolve(gvm_hosts_t *hosts)
Resolves host objects of type name in a hosts collection, replacing hostnames with IPv4 values....
enum host_type gvm_host_type(const gvm_host_t *host)
Gets a host object's type.
gpointer gvm_duplicate_vhost(gconstpointer vhost, gpointer data)
Creates a deep copy of a gvm_vhost_t object.
gvm_host_t * gvm_host_find_in_hosts(const gvm_host_t *host, const struct in6_addr *addr, const gvm_hosts_t *hosts)
Find the gvm_host_t from a gvm_hosts_t structure.
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
unsigned int gvm_hosts_count(const gvm_hosts_t *hosts)
Gets the count of single hosts objects in a hosts collection.
void gvm_hosts_free(gvm_hosts_t *hosts)
Frees memory occupied by an gvm_hosts_t structure.
int gvm_hosts_exclude(gvm_hosts_t *hosts, const char *excluded_str)
Excludes a set of hosts provided as a string from a hosts collection. Not to be used while iterating ...
int gvm_is_cidr6_block(const char *str)
Checks if a buffer points to an IPv6 CIDR-expressed block. "2620:0:2d0:200::7/120" is valid,...
int gvm_hosts_reverse_lookup_unify(gvm_hosts_t *hosts)
Removes hosts duplicates that reverse-lookup to the same value. Not to be used while iterating over t...
struct gvm_host gvm_host_t
struct gvm_vhost gvm_vhost_t
struct gvm_hosts gvm_hosts_t
The structure for a single host object.
The structure for Hosts collection.
The structure for a single vhost object.