OpenVAS Scanner  7.0.0~git
hosts.h File Reference

hosts.c header. More...

Include dependency graph for hosts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int hosts_init (int)
 
int hosts_new (char *, kb_t)
 
int hosts_set_pid (char *, pid_t)
 
int hosts_read (void)
 Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise. More...
 
void hosts_stop_all (void)
 

Detailed Description

hosts.c header.

Definition in file hosts.h.

Function Documentation

◆ hosts_init()

int hosts_init ( int  )

Definition at line 137 of file hosts.c.

138 {
139  g_max_hosts = max_hosts;
140  return 0;
141 }

References g_max_hosts.

Referenced by attack_network().

Here is the caller graph for this function:

◆ hosts_new()

int hosts_new ( char *  ,
kb_t   
)

Definition at line 144 of file hosts.c.

145 {
146  struct host *h;
147 
148  while (hosts_num () >= g_max_hosts)
149  {
150  if (hosts_read () < 0)
151  return -1;
152  }
153  if (global_scan_stop)
154  return 0;
155 
156  h = g_malloc0 (sizeof (struct host));
157  h->name = g_strdup (name);
158  h->pid = 0;
159  h->host_kb = kb;
160  if (hosts != NULL)
161  hosts->prev = h;
162  h->next = hosts;
163  h->prev = NULL;
164  hosts = h;
165  return 0;
166 }

References g_max_hosts, global_scan_stop, host::host_kb, hosts, hosts_num(), hosts_read(), host::name, name, host::next, host::pid, and host::prev.

Referenced by attack_network().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hosts_read()

int hosts_read ( void  )

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

Definition at line 250 of file hosts.c.

251 {
252  if (hosts == NULL)
253  return -1;
254 
255  hosts_read_data ();
256  usleep (500000);
257 
258  return 0;
259 }

References hosts, and hosts_read_data().

Referenced by attack_network(), and hosts_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hosts_set_pid()

int hosts_set_pid ( char *  ,
pid_t   
)

Definition at line 169 of file hosts.c.

170 {
171  struct host *h = hosts_get (name);
172  if (h == NULL)
173  {
174  g_debug ("host_set_pid() failed!\n");
175  return -1;
176  }
177 
178  h->pid = pid;
179  return 0;
180 }

References hosts_get(), name, host::pid, and pid.

Referenced by attack_network().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hosts_stop_all()

void hosts_stop_all ( void  )

Definition at line 196 of file hosts.c.

197 {
198  struct host *host = hosts;
199 
200  global_scan_stop = 1;
201  while (host)
202  {
204  host = host->next;
205  }
206 }

References global_scan_stop, hosts, hosts_stop_host(), and host::next.

Referenced by handle_stop_all_scans_signal().

Here is the call graph for this function:
Here is the caller graph for this function:
hosts_read
int hosts_read(void)
Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise.
Definition: hosts.c:250
host::pid
pid_t pid
Definition: hosts.c:50
pid
static pid_t pid
Definition: nasl_builtin_nmap.c:499
hosts_get
static struct host * hosts_get(char *name)
Retrieves a host specified by its name from the global host list.
Definition: hosts.c:124
hosts_read_data
static void hosts_read_data(void)
Definition: hosts.c:211
name
const char * name
Definition: nasl_init.c:377
g_max_hosts
static int g_max_hosts
Definition: hosts.c:59
global_scan_stop
int global_scan_stop
Definition: attack.c:224
host::prev
struct host * prev
Definition: hosts.c:53
hosts_stop_host
static int hosts_stop_host(struct host *h)
Definition: hosts.c:184
host::name
char * name
Definition: hosts.c:48
host
Host information, implemented as doubly linked list.
Definition: hosts.c:46
hosts_num
static int hosts_num(void)
Returns the number of entries in the global hosts list.
Definition: hosts.c:109
host::host_kb
kb_t host_kb
Definition: hosts.c:51
hosts
static struct host * hosts
Definition: hosts.c:58
host::next
struct host * next
Definition: hosts.c:52