Greenbone Vulnerability Manager  8.0.0~git
Functions
scanner.h File Reference

Module for Greenbone Vulnerability Manager: Scanner Connection API. More...

#include <gnutls/gnutls.h>

Go to the source code of this file.

Functions

int openvas_scanner_read ()
 Read as much from the server as the from_scanner buffer will. More...
 
int openvas_scanner_write (int)
 Write as much as possible from the to_scanner buffer to the scanner. More...
 
int openvas_scanner_close ()
 Finish the connection to the Scanner and free internal buffers. More...
 
void openvas_scanner_fork ()
 Reset Scanner variables after a fork. More...
 
int openvas_scanner_connect ()
 Create a new connection to the scanner and set it as current scanner. More...
 
void openvas_scanner_free ()
 Free the scanner allocated data. Doesn't close socket and terminate the session.
 
int openvas_scanner_fd_isset (fd_set *)
 Check if connected to Scanner is set in an fd_set. More...
 
void openvas_scanner_fd_set (fd_set *)
 Add connected to Scanner's socket to an fd_set. More...
 
int openvas_scanner_peek ()
 Check if there is any data to receive from connected Scanner socket. More...
 
int openvas_scanner_get_nfds (int)
 Get the nfds value to use for a select() call. More...
 
int openvas_scanner_session_peek ()
 Check if there is any data to receive from connected Scanner session. More...
 
int openvas_scanner_full ()
 Check whether the buffer for data from Scanner is full. More...
 
int openvas_scanner_realloc ()
 Reallocates the from_scanner buffer to a higher size. More...
 
int openvas_scanner_connected ()
 Whether we have started a connection to the Scanner using openvas_scanner_connect(). More...
 
int openvas_scanner_init (int)
 Initializes the already setup connection with the Scanner. More...
 
int openvas_scanner_is_loading ()
 Checks whether the connected to OpenVAS Scanner is still loading plugins. To be called right after openvas_scanner_init(). More...
 
int openvas_scanner_set_address (const char *, int)
 Set the scanner's address and port. Will try to resolve addr if it is a hostname. More...
 
int openvas_scanner_set_unix (const char *)
 Set the scanner's unix socket path. More...
 
void openvas_scanner_set_certs (const char *, const char *, const char *)
 Set the scanner's CA Certificate, and public/private key pair. More...
 

Detailed Description

Module for Greenbone Vulnerability Manager: Scanner Connection API.

Function Documentation

◆ openvas_scanner_close()

int openvas_scanner_close ( )

Finish the connection to the Scanner and free internal buffers.

Returns
-1 if error, 0 if success.

◆ openvas_scanner_connect()

int openvas_scanner_connect ( )

Create a new connection to the scanner and set it as current scanner.

Returns
0 on success, -1 on error.

◆ openvas_scanner_connected()

int openvas_scanner_connected ( )

Whether we have started a connection to the Scanner using openvas_scanner_connect().

Returns
1 if connected, 0 otherwise.

◆ openvas_scanner_fd_isset()

int openvas_scanner_fd_isset ( fd_set *  fd)

Check if connected to Scanner is set in an fd_set.

Parameters
[in]fdFile descriptor set.
Returns
1 if scanner socket in fd_set, 0 if not connected or or not set.

◆ openvas_scanner_fd_set()

void openvas_scanner_fd_set ( fd_set *  fd)

Add connected to Scanner's socket to an fd_set.

Parameters
[in]fdFile Descriptor set.

◆ openvas_scanner_fork()

void openvas_scanner_fork ( )

Reset Scanner variables after a fork.

This other side of the fork will do the actual cleanup.

◆ openvas_scanner_full()

int openvas_scanner_full ( )

Check whether the buffer for data from Scanner is full.

Returns
1 if full, 0 otherwise.

◆ openvas_scanner_get_nfds()

int openvas_scanner_get_nfds ( int  socket)

Get the nfds value to use for a select() call.

Parameters
[in]socketSocket to compare to.
Returns
socket + 1 if socket value is higher then scanner's or not connected to a scanner, scanner socket + 1 otherwise.

◆ openvas_scanner_init()

int openvas_scanner_init ( int  cache_mode)

Initializes the already setup connection with the Scanner.

Parameters
[in]cache_modeNVT Cache mode if true, which means sending NVT_INFO command to scanner in initial negotiation.
Returns
0 success, -1 error.

◆ openvas_scanner_is_loading()

int openvas_scanner_is_loading ( )

Checks whether the connected to OpenVAS Scanner is still loading plugins. To be called right after openvas_scanner_init().

Returns
1 if loading, 0 if not loading or error.

◆ openvas_scanner_peek()

int openvas_scanner_peek ( )

Check if there is any data to receive from connected Scanner socket.

Returns
1 if there is data in socket buffer, 0 if no data or not connected to a scanner.

◆ openvas_scanner_read()

int openvas_scanner_read ( )

Read as much from the server as the from_scanner buffer will.

hold.

Returns
0 on reading everything available, -1 on error, -2 if from_scanner buffer is full or -3 on reaching end of file.
Todo:
Rehandshake.

◆ openvas_scanner_realloc()

int openvas_scanner_realloc ( )

Reallocates the from_scanner buffer to a higher size.

Returns
1 if max size reached, 0 otherwise.

◆ openvas_scanner_session_peek()

int openvas_scanner_session_peek ( )

Check if there is any data to receive from connected Scanner session.

Returns
1 if there is data in session buffer, 0 if no data or not connected to a scanner.

◆ openvas_scanner_set_address()

int openvas_scanner_set_address ( const char *  addr,
int  port 
)

Set the scanner's address and port. Will try to resolve addr if it is a hostname.

Parameters
[in]addrScanner address string.
[in]portScanner port.
Returns
0 success, -1 error.

◆ openvas_scanner_set_certs()

void openvas_scanner_set_certs ( const char *  ca_pub,
const char *  key_pub,
const char *  key_priv 
)

Set the scanner's CA Certificate, and public/private key pair.

Parameters
[in]ca_pubCA Certificate.
[in]key_pubScanner Certificate.
[in]key_privScanner private key.

◆ openvas_scanner_set_unix()

int openvas_scanner_set_unix ( const char *  path)

Set the scanner's unix socket path.

Parameters
[in]pathPath to scanner unix socket.
Returns
0 success, -1 error.

◆ openvas_scanner_write()

int openvas_scanner_write ( int  nvt_cache_mode)

Write as much as possible from the to_scanner buffer to the scanner.

Parameters
[in]nvt_cache_modeNVT cache mode.
Returns
0 wrote everything, -1 error, -2 wrote as much as scanner accepted, -3 did an initialisation step.