OpenVAS Libraries
9.0.1
|
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <sys/time.h>
#include <glib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include "network.h"
#include "../base/kb.h"
#include "ids_send.h"
#include "prefs.h"
#include "plugutils.h"
#include "internal_com.h"
#include "support.h"
#include "openvas_logging.h"
#include "openvas_server.h"
Data Structures | |
struct | openvas_connection |
struct | csc_hook_s |
Object to store a list of hooks for close_stream_connection. More... | |
Macros | |
#define | TIMEOUT 20 |
#define | INADDR_NONE 0xffffffff |
#define | OPENVAS_FD_MAX 1024 |
#define | OPENVAS_FD_OFF 1000000 |
#define | OPENVAS_STREAM(x) (((x - OPENVAS_FD_OFF) < OPENVAS_FD_MAX) && ((x - OPENVAS_FD_OFF) >=0)) |
#define | OVAS_CONNECTION_FROM_FD(fd) (connections + ((fd) - OPENVAS_FD_OFF)) |
#define | INCR_TIMEOUT 1 |
Functions | |
int | stream_get_err (int fd) |
int | openvas_register_connection (int soc, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps) |
int | openvas_deregister_connection (int fd) |
void | tlserror (char *txt, int err) |
int | openvas_SSL_init () |
Initializes SSL support. More... | |
int | openvas_get_socket_from_connection (int fd) |
gnutls_session_t | ovas_get_tlssession_from_connection (int fd) |
int | socket_negotiate_ssl (int fd, openvas_encaps_t transport, struct arglist *args) |
void | socket_get_cert (int fd, void **cert, int *certlen) |
int | socket_get_ssl_version (int fd) |
void | socket_get_ssl_session_id (int fd, void **sid, size_t *ssize) |
int | socket_get_ssl_compression (int fd) |
int | socket_get_ssl_ciphersuite (int fd) |
int | open_stream_connection_ext (struct arglist *args, unsigned int port, int transport, int timeout, const char *priority) |
int | open_stream_connection (struct arglist *args, unsigned int port, int transport, int timeout) |
int | open_stream_auto_encaps_ext (struct arglist *args, unsigned int port, int timeout, int force) |
int | stream_set_timeout (int fd, int timeout) |
int | read_stream_connection_min (int fd, void *buf0, int min_len, int max_len) |
int | read_stream_connection (int fd, void *buf0, int len) |
int | write_stream_connection (int fd, void *buf0, int n) |
int | nsend (int fd, void *data, int length, int i_opt) |
int | nrecv (int fd, void *data, int length, int i_opt) |
void | add_close_stream_connection_hook (int(*fnc)(int fd)) |
Register a hook function for close_stream_connection. More... | |
int | close_stream_connection (int fd) |
const char * | get_encaps_name (openvas_encaps_t code) |
const char * | get_encaps_through (openvas_encaps_t code) |
int | open_sock_opt_hn (const char *hostname, unsigned int port, int type, int protocol, int timeout) |
int | open_sock_tcp (struct arglist *args, unsigned int port, int timeout) |
int | open_sock_option (struct arglist *args, unsigned int port, int type, int protocol, int timeout) |
int | recv_line (int soc, char *buf, size_t bufsiz) |
Reads a text from the socket stream into the argument buffer, always. More... | |
int | socket_close (int soc) |
int | stream_zero (fd_set *set) |
int | stream_set (int fd, fd_set *set) |
int | fd_is_stream (int fd) |
int | stream_get_buffer_sz (int fd) |
int | stream_set_buffer (int fd, int sz) |
int | os_send (int soc, void *buf, int len, int opt) |
int | os_recv (int soc, void *buf, int len, int opt) |
int | internal_send (int soc, char *data, int msg_type) |
int | internal_recv (int soc, char **data, int *data_sz, int *msg_type) |
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. More... | |
struct host_info * | host_info_init (const char *name, const struct in6_addr *ip, const char *vhosts, const char *fqdn) |
Initializes a host_info. More... | |
void | host_info_free (struct host_info *hostinfo) |
Free a host_info struct. More... | |
#define INADDR_NONE 0xffffffff |
#define INCR_TIMEOUT 1 |
#define OPENVAS_FD_MAX 1024 |
The role of this offset is:
#define OPENVAS_FD_OFF 1000000 |
#define OPENVAS_STREAM | ( | x | ) | (((x - OPENVAS_FD_OFF) < OPENVAS_FD_MAX) && ((x - OPENVAS_FD_OFF) >=0)) |
OPENVAS_STREAM(x) is TRUE if <x> is a OpenVAS-ified fd
#define OVAS_CONNECTION_FROM_FD | ( | fd | ) | (connections + ((fd) - OPENVAS_FD_OFF)) |
determine the openvas_connection* from the openvas fd
#define TIMEOUT 20 |
void add_close_stream_connection_hook | ( | int(*)(int fd) | fnc | ) |
Register a hook function for close_stream_connection.
The function adds the given hook function to the list of hooks to be run by close_stream_connection. These hooks are intended to test whether they need to close the stream them self. See argument to the hook function is the file descriptor of the stream. The hook shall return 0 if it has taken over control of that file descriptor. The same function is only aded once to the list of hooks.
fnc | The hook function. See above for details. |
int close_stream_connection | ( | int | fd | ) |
int fd_is_stream | ( | int | fd | ) |
const char* get_encaps_name | ( | openvas_encaps_t | code | ) |
const char* get_encaps_through | ( | openvas_encaps_t | code | ) |
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 and was taken from his excellent and outstanding scanner Nmap See r@dh p.comhttp://www.insecure.org/nmap/ for details about Nmap
void host_info_free | ( | struct host_info * | hostinfo | ) |
Free a host_info struct.
[in] | hostinfo | Host info to free. |
struct host_info* host_info_init | ( | const char * | name, |
const struct in6_addr * | ip, | ||
const char * | vhosts, | ||
const char * | fqdn | ||
) |
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.
[in] | soc | The socket from which to receive message. |
[out] | data | Where to allocate the reception buffer. Has to be set to NULL, and left untouched on failure or zero-length messages. |
[out] | data_sz | Size of the received message. |
[out] | msg_type | Type of the message which was received. |
Length | of the received message on success (can be zero). |
Negative | value on error. |
int internal_send | ( | int | soc, |
char * | data, | ||
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.
int nrecv | ( | int | fd, |
void * | data, | ||
int | length, | ||
int | i_opt | ||
) |
int nsend | ( | int | fd, |
void * | data, | ||
int | length, | ||
int | i_opt | ||
) |
int open_sock_opt_hn | ( | const char * | hostname, |
unsigned int | port, | ||
int | type, | ||
int | protocol, | ||
int | timeout | ||
) |
int open_sock_option | ( | struct arglist * | args, |
unsigned int | port, | ||
int | type, | ||
int | protocol, | ||
int | timeout | ||
) |
int open_sock_tcp | ( | struct arglist * | args, |
unsigned int | port, | ||
int | timeout | ||
) |
int open_stream_auto_encaps_ext | ( | struct arglist * | args, |
unsigned int | port, | ||
int | timeout, | ||
int | force | ||
) |
int open_stream_connection | ( | struct arglist * | args, |
unsigned int | port, | ||
int | transport, | ||
int | timeout | ||
) |
int open_stream_connection_ext | ( | struct arglist * | args, |
unsigned int | port, | ||
int | transport, | ||
int | timeout, | ||
const char * | priority | ||
) |
int openvas_deregister_connection | ( | int | fd | ) |
int openvas_get_socket_from_connection | ( | int | fd | ) |
int openvas_register_connection | ( | int | soc, |
void * | ssl, | ||
gnutls_certificate_credentials_t | certcred, | ||
openvas_encaps_t | encaps | ||
) |
int openvas_SSL_init | ( | void | ) |
Initializes SSL support.
int os_recv | ( | int | soc, |
void * | buf, | ||
int | len, | ||
int | opt | ||
) |
int os_send | ( | int | soc, |
void * | buf, | ||
int | len, | ||
int | opt | ||
) |
gnutls_session_t ovas_get_tlssession_from_connection | ( | int | fd | ) |
int read_stream_connection | ( | int | fd, |
void * | buf0, | ||
int | len | ||
) |
int read_stream_connection_min | ( | int | fd, |
void * | buf0, | ||
int | min_len, | ||
int | max_len | ||
) |
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.
buf | Buffer to read into. |
int socket_close | ( | int | soc | ) |
void socket_get_cert | ( | int | fd, |
void ** | cert, | ||
int * | certlen | ||
) |
int socket_get_ssl_ciphersuite | ( | int | fd | ) |
int socket_get_ssl_compression | ( | int | fd | ) |
void socket_get_ssl_session_id | ( | int | fd, |
void ** | sid, | ||
size_t * | ssize | ||
) |
int socket_get_ssl_version | ( | int | fd | ) |
int socket_negotiate_ssl | ( | int | fd, |
openvas_encaps_t | transport, | ||
struct arglist * | args | ||
) |
int stream_get_buffer_sz | ( | int | fd | ) |
int stream_get_err | ( | int | fd | ) |
int stream_set | ( | int | fd, |
fd_set * | set | ||
) |
int stream_set_buffer | ( | int | fd, |
int | sz | ||
) |
int stream_set_timeout | ( | int | fd, |
int | timeout | ||
) |
int stream_zero | ( | fd_set * | set | ) |
void tlserror | ( | char * | txt, |
int | err | ||
) |
int write_stream_connection | ( | int | fd, |
void * | buf0, | ||
int | n | ||
) |