OpenVAS Scanner  7.0.1~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 153 of file hosts.c.

References g_max_hosts.

Referenced by attack_network().

154 {
155  g_max_hosts = max_hosts;
156  return 0;
157 }
static int g_max_hosts
Definition: hosts.c:60
Here is the caller graph for this function:

◆ hosts_new()

int hosts_new ( char *  ,
kb_t   
)

Definition at line 160 of file hosts.c.

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().

161 {
162  struct host *h;
163 
164  while (hosts_num () >= g_max_hosts)
165  {
166  if (hosts_read () < 0)
167  return -1;
168  }
169  if (global_scan_stop)
170  return 0;
171 
172  h = g_malloc0 (sizeof (struct host));
173  h->name = g_strdup (name);
174  h->pid = 0;
175  h->host_kb = kb;
176  if (hosts != NULL)
177  hosts->prev = h;
178  h->next = hosts;
179  h->prev = NULL;
180  hosts = h;
181  return 0;
182 }
static struct host * hosts
Definition: hosts.c:59
static int g_max_hosts
Definition: hosts.c:60
int hosts_read(void)
Returns -1 if client asked to stop all tests or connection was lost or error. 0 otherwise.
Definition: hosts.c:271
Host information, implemented as doubly linked list.
Definition: hosts.c:47
struct host * prev
Definition: hosts.c:54
const char * name
Definition: nasl_init.c:377
static int hosts_num(void)
Returns the number of entries in the global hosts list.
Definition: hosts.c:125
int global_scan_stop
Definition: attack.c:224
char * name
Definition: hosts.c:49
kb_t host_kb
Definition: hosts.c:52
pid_t pid
Definition: hosts.c:51
struct host * next
Definition: hosts.c:53
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 271 of file hosts.c.

References hosts, and hosts_read_data().

Referenced by attack_network(), and hosts_new().

272 {
273  if (hosts == NULL)
274  return -1;
275 
276  hosts_read_data ();
277  usleep (500000);
278 
279  return 0;
280 }
static struct host * hosts
Definition: hosts.c:59
static void hosts_read_data(void)
Definition: hosts.c:226
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 185 of file hosts.c.

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

Referenced by attack_network().

186 {
187  struct host *h = hosts_get (name);
188  if (h == NULL)
189  {
190  g_debug ("host_set_pid() failed!\n");
191  return -1;
192  }
193 
194  h->pid = pid;
195  return 0;
196 }
static struct host * hosts_get(char *name)
Retrieves a host specified by its name from the global host list.
Definition: hosts.c:140
static pid_t pid
Host information, implemented as doubly linked list.
Definition: hosts.c:47
const char * name
Definition: nasl_init.c:377
pid_t pid
Definition: hosts.c:51
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 211 of file hosts.c.

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

Referenced by handle_scan_stop_signal().

212 {
213  struct host *host = hosts;
214 
215  global_scan_stop = 1;
216  while (host)
217  {
219  host = host->next;
220  }
221 }
static int hosts_stop_host(struct host *h)
Definition: hosts.c:200
static struct host * hosts
Definition: hosts.c:59
Host information, implemented as doubly linked list.
Definition: hosts.c:47
int global_scan_stop
Definition: attack.c:224
struct host * next
Definition: hosts.c:53
Here is the call graph for this function:
Here is the caller graph for this function: