OpenVAS Scanner  6.0.0~git
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 "ntp.h"
#include "utils.h"
#include <errno.h>
#include <glib.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

static int send_to_client (int out, char *buf)
 
static int forward_status (struct host *h, int out)
 
static int forward (struct host *h, int out)
 
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 soc, int max_hosts)
 
int hosts_new (struct scan_globals *globals, char *name, kb_t 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)
 
static int hosts_read_client (struct scan_globals *globals)
 
int hosts_read (struct scan_globals *globals)
 Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise. More...
 

Variables

static struct hosthosts = NULL
 
static int g_soc = -1
 
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

◆ forward()

static int forward ( struct host h,
int  out 
)
static

◆ forward_status()

static int forward_status ( struct host h,
int  out 
)
static

◆ host_rm()

static void host_rm ( struct host h)
static

◆ 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  soc,
int  max_hosts 
)

◆ hosts_new()

int hosts_new ( struct scan_globals globals,
char *  name,
kb_t  kb 
)

◆ hosts_num()

static int hosts_num ( void  )
static

Returns the number of entries in the global hosts list.

◆ hosts_read()

int hosts_read ( struct scan_globals globals)

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

◆ hosts_read_client()

static int hosts_read_client ( struct scan_globals globals)
static

Returns -1 if no socket, error or client asked to stop tests, 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

◆ send_to_client()

static int send_to_client ( int  out,
char *  buf 
)
static

Variable Documentation

◆ g_max_hosts

int g_max_hosts = 15
static

◆ g_soc

int g_soc = -1
static

◆ global_scan_stop

int global_scan_stop

◆ 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.