OpenVAS Libraries
9.0.3
|
#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.
Data Structures | |
struct | host_info |
Macros | |
#define | IS_ENCAPS_SSL(x) ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom) |
Typedefs | |
typedef enum openvas_encaps | openvas_encaps_t |
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) |
struct host_info * | host_info_init (const char *name, const struct in6_addr *, const char *, const char *) |
Initializes a host_info. More... | |
void | host_info_free (struct host_info *) |
Free a host_info struct. More... | |
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) |
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) |
#define IS_ENCAPS_SSL | ( | x | ) | ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom) |
typedef enum openvas_encaps openvas_encaps_t |
enum openvas_encaps |
Definition at line 44 of file network.h.
void add_close_stream_connection_hook | ( | int(*)(int) | ) |
int close_stream_connection | ( | int | ) |
Definition at line 1699 of file network.c.
References log_legacy_write(), OPENVAS_STREAM, OVAS_CONNECTION_FROM_FD, openvas_connection::port, and socket_close().
Referenced by nasl_end_denial(), and nasl_start_denial().
int fd_is_stream | ( | int | ) |
Definition at line 2146 of file network.c.
References OPENVAS_STREAM.
Referenced by nasl_close_socket(), nasl_get_source_port(), nasl_recv(), nasl_recv_line(), nasl_send(), nasl_socket_get_error(), socket_get_cert(), socket_get_ssl_ciphersuite(), socket_get_ssl_compression(), socket_get_ssl_session_id(), socket_get_ssl_version(), and socket_negotiate_ssl().
const char* get_encaps_name | ( | openvas_encaps_t | ) |
Definition at line 1729 of file network.c.
References code, OPENVAS_ENCAPS_AUTO, OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, and OPENVAS_ENCAPS_TLSv12.
Referenced by get_port_transport(), and nasl_get_sock_info().
const char* get_encaps_through | ( | openvas_encaps_t | ) |
Definition at line 1759 of file network.c.
References code, OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, and OPENVAS_ENCAPS_TLSv12.
int get_sock_infos | ( | int | sock, |
int * | r_transport, | ||
void ** | r_tls_session | ||
) |
Definition at line 2376 of file network.c.
References OPENVAS_STREAM.
Referenced by nasl_get_sock_info().
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
Definition at line 2416 of file network.c.
Referenced by nasl_scanner_get_port(), and scan().
void host_info_free | ( | struct host_info * | hostinfo | ) |
Free a host_info struct.
[in] | hostinfo | Host info to free. |
Definition at line 2567 of file network.c.
References host_info::fqdn, host_info::ip, host_info::name, and host_info::vhosts.
struct host_info* host_info_init | ( | const char * | name, |
const struct in6_addr * | ip, | ||
const char * | vhosts, | ||
const char * | fqdn | ||
) |
Initializes a host_info.
[in] | name | Hostname. |
[in] | ip | IP address. |
[in] | vhosts | Vhosts list. |
[in] | fqdn | Fully qualified domain name. |
Definition at line 2544 of file network.c.
References host_info::fqdn, host_info::ip, host_info::name, name, and host_info::vhosts.
Referenced by init().
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. |
Definition at line 2318 of file network.c.
References INTERNAL_COMM_CTRL_ACK, INTERNAL_COMM_MSG_TYPE_CTRL, log_legacy_write(), os_recv(), and os_send().
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.
Definition at line 2263 of file network.c.
References INTERNAL_COMM_MSG_TYPE_CTRL, log_legacy_write(), os_recv(), and os_send().
int nrecv | ( | int | , |
void * | , | ||
int | , | ||
int | |||
) |
Definition at line 1618 of file network.c.
References log_legacy_write(), and OPENVAS_STREAM.
int nsend | ( | int | , |
void * | , | ||
int | , | ||
int | |||
) |
Definition at line 1577 of file network.c.
References OPENVAS_STREAM.
Referenced by nasl_end_denial().
int open_sock_opt_hn | ( | const char * | , |
unsigned int | , | ||
int | , | ||
int | , | ||
int | |||
) |
Definition at line 1888 of file network.c.
References openvas_resolve_as_addr6().
Referenced by nasl_open_sock_kdc().
int open_sock_option | ( | struct arglist * | , |
unsigned int | , | ||
int | , | ||
int | , | ||
int | |||
) |
Definition at line 1960 of file network.c.
References arg_dump(), host_get_port_state(), log_legacy_write(), and plug_get_host_ip().
Referenced by open_sock_tcp().
int open_sock_tcp | ( | struct arglist * | , |
unsigned int | , | ||
int | |||
) |
Definition at line 1918 of file network.c.
References open_sock_option(), plug_get_host_ip_str(), plug_get_kb(), and prefs_get().
Referenced by ids_open_sock_tcp().
int open_stream_auto_encaps_ext | ( | struct arglist * | args, |
unsigned int | port, | ||
int | timeout, | ||
int | force | ||
) |
Definition at line 1127 of file network.c.
References open_stream_connection(), OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_TLScustom, plug_get_port_transport(), and plug_set_port_transport().
int open_stream_connection | ( | struct arglist * | , |
unsigned int | , | ||
int | , | ||
int | |||
) |
Definition at line 1117 of file network.c.
References open_stream_connection_ext().
Referenced by nasl_end_denial(), nasl_start_denial(), and open_stream_auto_encaps_ext().
int open_stream_connection_ext | ( | struct arglist * | , |
unsigned int | , | ||
int | , | ||
int | , | ||
const char * | |||
) |
Definition at line 1004 of file network.c.
References log_legacy_write(), OPENVAS_ENCAPS_IP, OPENVAS_ENCAPS_SSLv2, OPENVAS_ENCAPS_SSLv23, OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLScustom, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, and TIMEOUT.
Referenced by open_stream_connection().
int openvas_deregister_connection | ( | int | ) |
int openvas_get_socket_from_connection | ( | int | ) |
Definition at line 395 of file network.c.
References log_legacy_fflush(), log_legacy_write(), and OPENVAS_STREAM.
Referenced by nasl_get_source_port(), and stream_set().
int openvas_register_connection | ( | int | soc, |
void * | ssl, | ||
gnutls_certificate_credentials_t | certcred, | ||
openvas_encaps_t | encaps | ||
) |
soc | Socket to use. |
Definition at line 267 of file network.c.
int openvas_SSL_init | ( | void | ) |
Initializes SSL support.
Definition at line 376 of file network.c.
References tlserror().
int os_recv | ( | int | , |
void * | , | ||
int | , | ||
int | |||
) |
Definition at line 2233 of file network.c.
Referenced by internal_recv(), and internal_send().
int os_send | ( | int | , |
void * | , | ||
int | , | ||
int | |||
) |
Definition at line 2214 of file network.c.
Referenced by internal_recv(), and internal_send().
gnutls_session_t ovas_get_tlssession_from_connection | ( | int | ) |
Definition at line 418 of file network.c.
References OPENVAS_STREAM.
Referenced by socket_get_cert(), socket_get_ssl_ciphersuite(), socket_get_ssl_compression(), socket_get_ssl_session_id(), and socket_get_ssl_version().
int read_stream_connection | ( | int | , |
void * | , | ||
int | |||
) |
Definition at line 1421 of file network.c.
References read_stream_connection_min().
Referenced by nasl_telnet_init().
int read_stream_connection_min | ( | int | , |
void * | , | ||
int | , | ||
int | |||
) |
Definition at line 1360 of file network.c.
References openvas_connection::buf, openvas_connection::bufcnt, openvas_connection::bufptr, openvas_connection::bufsz, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_recv_line(), nasl_telnet_init(), read_stream_connection(), and recv_line().
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. |
Definition at line 2017 of file network.c.
References OPENVAS_STREAM, and read_stream_connection_min().
Referenced by ftp_get_pasv_address().
int socket_close | ( | int | ) |
Definition at line 2120 of file network.c.
Referenced by close_stream_connection().
void socket_get_cert | ( | int | , |
void ** | , | ||
int * | |||
) |
Definition at line 813 of file network.c.
References fd_is_stream(), log_legacy_write(), and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_cert().
int socket_get_ssl_ciphersuite | ( | int | ) |
Definition at line 965 of file network.c.
References fd_is_stream(), log_legacy_write(), and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_ssl_ciphersuite().
int socket_get_ssl_compression | ( | int | ) |
Definition at line 930 of file network.c.
References fd_is_stream(), log_legacy_write(), and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_ssl_compression().
void socket_get_ssl_session_id | ( | int | , |
void ** | , | ||
size_t * | |||
) |
Definition at line 890 of file network.c.
References fd_is_stream(), log_legacy_write(), ovas_get_tlssession_from_connection(), and tlserror().
Referenced by nasl_socket_get_ssl_session_id().
int socket_get_ssl_version | ( | int | ) |
Definition at line 849 of file network.c.
References fd_is_stream(), log_legacy_write(), OPENVAS_ENCAPS_SSLv3, OPENVAS_ENCAPS_TLSv1, OPENVAS_ENCAPS_TLSv11, OPENVAS_ENCAPS_TLSv12, and ovas_get_tlssession_from_connection().
Referenced by nasl_socket_get_ssl_version().
int socket_negotiate_ssl | ( | int | , |
openvas_encaps_t | , | ||
struct arglist * | |||
) |
Definition at line 771 of file network.c.
References fd_is_stream(), log_legacy_write(), OVAS_CONNECTION_FROM_FD, and plug_get_kb().
Referenced by nasl_socket_negotiate_ssl().
int stream_get_buffer_sz | ( | int | ) |
Definition at line 2153 of file network.c.
References openvas_connection::bufsz, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_recv_line().
int stream_get_err | ( | int | ) |
Definition at line 161 of file network.c.
References openvas_connection::last_err, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_socket_get_error().
int stream_set | ( | int | , |
fd_set * | |||
) |
Definition at line 2137 of file network.c.
References openvas_get_socket_from_connection().
int stream_set_buffer | ( | int | , |
int | |||
) |
Definition at line 2163 of file network.c.
References openvas_connection::buf, openvas_connection::bufcnt, openvas_connection::bufptr, openvas_connection::bufsz, OPENVAS_STREAM, and OVAS_CONNECTION_FROM_FD.
Referenced by nasl_recv_line().
int stream_set_timeout | ( | int | , |
int | |||
) |
Definition at line 1158 of file network.c.
References OPENVAS_STREAM, OVAS_CONNECTION_FROM_FD, and openvas_connection::timeout.
int stream_zero | ( | fd_set * | ) |
int write_stream_connection | ( | int | , |
void * | buf, | ||
int | n | ||
) |
Definition at line 1571 of file network.c.
Referenced by ftp_get_pasv_address(), and nasl_telnet_init().