OpenVAS Scanner  21.4.1
Data Structures | Macros | Functions | Variables
hosts.c File Reference

Basically creates a new process for each tested host. More...

#include "hosts.h"
#include "../misc/network.h"
#include "utils.h"
#include <errno.h>
#include <glib.h>
#include <gvm/base/networking.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>

Data Structures

struct  host
 Host information, implemented as doubly linked list. More...
 

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain. More...
 

Functions

void host_set_time (kb_t kb, char *ip, char *type)
 Add star_scan and end_scan results to the main kb. More...
 
static void host_rm (struct host *h)
 
static int hosts_num (void)
 Returns the number of entries in the global hosts list. More...
 
static struct hosthosts_get (char *name)
 Retrieves a host specified by its name from the global host list. More...
 
int hosts_init (int max_hosts)
 
int hosts_new (char *name, kb_t kb, kb_t main_kb)
 
int hosts_set_pid (char *name, pid_t pid)
 
static int hosts_stop_host (struct host *h)
 
void hosts_stop_all (void)
 
static void hosts_read_data (void)
 
int hosts_read (void)
 Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise. More...
 
int host_is_currently_scanned (gvm_host_t *host_to_check)
 Returns 1 if the host is being scanned. 0 otherwise. More...
 

Variables

static struct hosthosts = NULL
 
static int g_max_hosts = 15
 
int global_scan_stop
 

Detailed Description

Basically creates a new process for each tested host.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

Function Documentation

◆ host_is_currently_scanned()

int host_is_currently_scanned ( gvm_host_t *  host_to_check)

Returns 1 if the host is being scanned. 0 otherwise.

It checks not only the main IP of the host, but also the ips that a dns-lookup returns.

◆ host_rm()

static void host_rm ( struct host h)
static

◆ host_set_time()

void host_set_time ( kb_t  kb,
char *  ip,
char *  type 
)

Add star_scan and end_scan results to the main kb.

Parameters
[in]kbMain KB where results are stored.
[in]ipList of vhosts to add new vhosts to.
[in]typeIf it is start or end message.

◆ hosts_get()

static struct host* hosts_get ( char *  name)
static

Retrieves a host specified by its name from the global host list.

◆ hosts_init()

int hosts_init ( int  max_hosts)

◆ hosts_new()

int hosts_new ( char *  name,
kb_t  kb,
kb_t  main_kb 
)

◆ hosts_num()

static int hosts_num ( void  )
static

Returns the number of entries in the global hosts list.

◆ hosts_read()

int hosts_read ( void  )

Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise.

◆ hosts_read_data()

static void hosts_read_data ( void  )
static

◆ hosts_set_pid()

int hosts_set_pid ( char *  name,
pid_t  pid 
)

◆ hosts_stop_all()

void hosts_stop_all ( void  )

◆ hosts_stop_host()

static int hosts_stop_host ( struct host h)
static

Variable Documentation

◆ g_max_hosts

int g_max_hosts = 15
static

◆ global_scan_stop

int global_scan_stop
extern

◆ hosts

struct host* hosts = NULL
static
Todo:
struct hosts could be stripped down and put in a g_list, or, as a g_hash_table (name -> [soc,pid]), see hosts_get.