OpenVAS Libraries  8.0.3
Macros | Typedefs | Enumerations | Functions
network.h File Reference
#include <sys/select.h>
#include <netinet/in.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "arglists.h"
#include "../base/openvas_networking.h"

Go to the source code of this file.

Macros

#define IS_ENCAPS_SSL(x)   ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom)
 

Typedefs

typedef enum openvas_encaps openvas_encaps_t
 
typedef struct ovas_scanner_context_sovas_scanner_context_t
 

Enumerations

enum  openvas_encaps {
  OPENVAS_ENCAPS_AUTO = 0, OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv2,
  OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12,
  OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_MAX
}
 

Functions

int open_sock_tcp (struct arglist *, unsigned int, int)
 
int open_sock_option (struct arglist *, unsigned int, int, int, int)
 
int recv_line (int, char *, size_t)
 Reads a text from the socket stream into the argument buffer, always. More...
 
int nrecv (int, void *, int, int)
 
int socket_close (int)
 
int get_sock_infos (int sock, int *r_transport, void **r_tls_session)
 
unsigned short * getpts (char *, int *)
 Converts a string like "-100,200-1024,3000-4000,60000-" into an array. More...
 
int open_stream_connection (struct arglist *, unsigned int, int, int)
 
int open_stream_connection_ext (struct arglist *, unsigned int, int, int, const char *)
 
int open_stream_auto_encaps_ext (struct arglist *args, unsigned int port, int timeout, int force)
 
int write_stream_connection (int, void *buf, int n)
 
int read_stream_connection (int, void *, int)
 
int read_stream_connection_min (int, void *, int, int)
 
int nsend (int, void *, int, int)
 
void add_close_stream_connection_hook (int(*)(int))
 
int close_stream_connection (int)
 
const char * get_encaps_name (openvas_encaps_t)
 
const char * get_encaps_through (openvas_encaps_t)
 
int open_sock_opt_hn (const char *, unsigned int, int, int, int)
 
int openvas_SSL_init (void)
 Initializes SSL support. More...
 
int stream_set_buffer (int, int)
 
int stream_get_buffer_sz (int)
 
int stream_get_err (int)
 
ovas_scanner_context_t ovas_scanner_context_new (openvas_encaps_t, const char *, const char *, const char *, const char *, const char *, const char *)
 Creates a new ovas_scanner_context_t. More...
 
void ovas_scanner_context_free (ovas_scanner_context_t)
 Frees the ovas_scanner_context_t instance ctx. More...
 
int ovas_scanner_context_attach (ovas_scanner_context_t ctx, int soc)
 Sets up SSL/TLS on the socket soc and returns a openvas file. More...
 
int openvas_register_connection (int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps)
 
int openvas_deregister_connection (int)
 
int openvas_get_socket_from_connection (int)
 
gnutls_session_t ovas_get_tlssession_from_connection (int)
 
int stream_zero (fd_set *)
 
int stream_set (int, fd_set *)
 
int os_send (int, void *, int, int)
 
int os_recv (int, void *, int, int)
 
int internal_send (int, char *, int)
 
int internal_recv (int, char **, int *, int *)
 
int fd_is_stream (int)
 
int stream_set_timeout (int, int)
 
int socket_negotiate_ssl (int, openvas_encaps_t, struct arglist *)
 
void socket_get_cert (int, void **, int *)
 
int socket_get_ssl_version (int)
 
void socket_get_ssl_session_id (int, void **, size_t *)
 
int socket_get_ssl_compression (int)
 
int socket_get_ssl_ciphersuite (int)
 

Macro Definition Documentation

#define IS_ENCAPS_SSL (   x)    ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom)

Typedef Documentation

Enumeration Type Documentation

Enumerator
OPENVAS_ENCAPS_AUTO 
OPENVAS_ENCAPS_IP 
OPENVAS_ENCAPS_SSLv23 
OPENVAS_ENCAPS_SSLv2 
OPENVAS_ENCAPS_SSLv3 
OPENVAS_ENCAPS_TLSv1 
OPENVAS_ENCAPS_TLSv11 
OPENVAS_ENCAPS_TLSv12 
OPENVAS_ENCAPS_TLScustom 
OPENVAS_ENCAPS_MAX 

Function Documentation

void add_close_stream_connection_hook ( int(*)(int)  )
int close_stream_connection ( int  )
int fd_is_stream ( int  )
const char* get_encaps_name ( openvas_encaps_t  )
const char* get_encaps_through ( openvas_encaps_t  )
int get_sock_infos ( int  sock,
int *  r_transport,
void **  r_tls_session 
)
unsigned short* getpts ( char *  origexpr,
int *  len 
)

Converts a string like "-100,200-1024,3000-4000,60000-" into an array.

of port numbers

This function is (c) Fyodor fyodo.nosp@m.r@dh.nosp@m.p.com and was taken from his excellent and outstanding scanner Nmap See http://www.insecure.org/nmap/ for details about Nmap

int internal_recv ( int  soc,
char **  data,
int *  data_sz,
int *  msg_type 
)

internal_send() / internal_recv() :

When processes are passing messages to each other, the format is <length><msg>, with <length> being a long integer. The functions internal_send() and internal_recv() encapsulate and decapsulate the messages themselves.

Parameters
[in]socThe socket from which to receive message.
[out]dataWhere to allocate the reception buffer. Has to be set to NULL, and left untouched on failure or zero-length messages.
[out]data_szSize of the received message.
[out]msg_typeType of the message which was received.
Return values
Lengthof the received message on success (can be zero).
Negativevalue on error.
int internal_send ( int  soc,
char *  data,
int  msg_type 
)
Todo:
internal_send and internal_recv. could make an own module (ipc), in which the type constants could be moved, too.

internal_send() / internal_recv() :

When processes are passing messages to each other, the format is <length><msg>, with <length> being a long integer. The functions internal_send() and internal_recv() encapsulate and decapsulate the messages themselves.

int nrecv ( int  ,
void *  ,
int  ,
int   
)
int nsend ( int  ,
void *  ,
int  ,
int   
)
int open_sock_opt_hn ( const char *  ,
unsigned  int,
int  ,
int  ,
int   
)
int open_sock_option ( struct arglist ,
unsigned  int,
int  ,
int  ,
int   
)
int open_sock_tcp ( struct arglist ,
unsigned  int,
int   
)
int open_stream_auto_encaps_ext ( struct arglist args,
unsigned int  port,
int  timeout,
int  force 
)
int open_stream_connection ( struct arglist ,
unsigned  int,
int  ,
int   
)
int open_stream_connection_ext ( struct arglist ,
unsigned  int,
int  ,
int  ,
const char *   
)
int openvas_deregister_connection ( int  )
int openvas_get_socket_from_connection ( int  )
int openvas_register_connection ( int  soc,
void *  ssl,
gnutls_certificate_credentials_t  certcred,
openvas_encaps_t  encaps 
)
Todo:
TLS FIXME: migrate this to TLS
Todo:
Fix the voidness of the ssl parameter (problematic in 64bit env.) here or on caller-side
Parameters
socSocket to use.
int openvas_SSL_init ( void  )

Initializes SSL support.

int os_recv ( int  ,
void *  ,
int  ,
int   
)
int os_send ( int  ,
void *  ,
int  ,
int   
)
gnutls_session_t ovas_get_tlssession_from_connection ( int  )
int ovas_scanner_context_attach ( ovas_scanner_context_t  ctx,
int  soc 
)

Sets up SSL/TLS on the socket soc and returns a openvas file.

descriptor.

The parameters for the SSL/TLS layer are taken from ctx. Afterwards, the credentials of ctx are also referenced by the SSL/TLS objects associated with the openvas file descriptor. This means that the context ctx must not be freed until the openvas file descriptor is closed.

Returns
The openvas file descriptor on success and -1 on failure.
void ovas_scanner_context_free ( ovas_scanner_context_t  ctx)

Frees the ovas_scanner_context_t instance ctx.

If ctx is NULL, nothing is done.

Parameters
ctxovas_scanner_context_t to free.
ovas_scanner_context_t ovas_scanner_context_new ( openvas_encaps_t  encaps,
const char *  certfile,
const char *  keyfile,
const char *  passwd,
const char *  cafile,
const char *  priority,
const char *  dhparams 
)

Creates a new ovas_scanner_context_t.

If any of the SSL encapsulations are used, the parameters certfile, keyfile, and cafile should be the filenames of the scanner certificate and corresponding key and the CA certificate. The optional passwd parameter is used as the password to decrypt the keyfile if it is encrypted.

int read_stream_connection ( int  ,
void *  ,
int   
)
int read_stream_connection_min ( int  ,
void *  ,
int  ,
int   
)
int recv_line ( int  soc,
char *  buf,
size_t  bufsiz 
)

Reads a text from the socket stream into the argument buffer, always.

appending a '\0' byte.

Parameters
bufBuffer to read into.
Returns
Number of bytes read, without the trailing '\0'.
int socket_close ( int  )
void socket_get_cert ( int  ,
void **  ,
int *   
)
int socket_get_ssl_ciphersuite ( int  )
int socket_get_ssl_compression ( int  )
void socket_get_ssl_session_id ( int  ,
void **  ,
size_t *   
)
int socket_get_ssl_version ( int  )
int socket_negotiate_ssl ( int  ,
openvas_encaps_t  ,
struct arglist  
)
int stream_get_buffer_sz ( int  )
int stream_get_err ( int  )
int stream_set ( int  ,
fd_set *   
)
int stream_set_buffer ( int  ,
int   
)
int stream_set_timeout ( int  ,
int   
)
int stream_zero ( fd_set *  )
int write_stream_connection ( int  ,
void *  buf,
int  n 
)