OpenVAS Scanner  7.0.0~git
network.h
Go to the documentation of this file.
1 /* Portions Copyright (C) 2009-2019 Greenbone Networks GmbH
2  * Based on work Copyright (C) 1998 - 2007 Tenable Network Security, Inc.
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
26 #ifndef OPENVAS_NETWORK_H
27 #define OPENVAS_NETWORK_H
28 
29 #include "scanneraux.h"
30 
31 #include <gnutls/gnutls.h>
32 #include <gnutls/x509.h>
33 #include <netinet/in.h> /* struct in_addr, struct in6_addr */
34 #include <sys/select.h> /* at least for fd_set */
35 
36 /*
37  * Type of "transport layer", for encapsulated connections
38  * Only SSL is supported at this time.
39  * (Bad) examples of other layers could be SOCKS, httptunnel, icmptunnel,
40  * RMI over HTTP, DCOM over HTTP, TCP over TCP, etc.
41  */
42 typedef enum openvas_encaps
43 {
44  OPENVAS_ENCAPS_AUTO = 0, /* Request auto detection. */
46  OPENVAS_ENCAPS_SSLv23, /* Ask for compatibility options */
52  OPENVAS_ENCAPS_TLScustom, /* SSL/TLS using custom priorities. */
55 
56 #define IS_ENCAPS_SSL(x) \
57  ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom)
58 
59 /* Plugin specific network functions */
60 int
61 open_sock_tcp (struct script_infos *, unsigned int, int);
62 
63 int
64 open_sock_option (struct script_infos *, unsigned int, int, int, int);
65 
66 int
67 recv_line (int, char *, size_t);
68 
69 int
70 nrecv (int, void *, int, int);
71 
72 int
73 socket_close (int);
74 
75 int
76 get_sock_infos (int sock, int *r_transport, void **r_tls_session);
77 
78 unsigned short *
79 getpts (char *, int *);
80 
81 int
82 open_stream_connection (struct script_infos *, unsigned int, int, int);
83 
84 int
85 open_stream_connection_ext (struct script_infos *, unsigned int, int, int,
86  const char *);
87 
88 int
89 open_stream_auto_encaps_ext (struct script_infos *, unsigned int port,
90  int timeout, int force);
91 
92 int
93 write_stream_connection (int, void *buf, int n);
94 
95 int
96 read_stream_connection (int, void *, int);
97 
98 int
99 read_stream_connection_min (int, void *, int, int);
100 
101 int
102 nsend (int, void *, int, int);
103 
104 void
105 add_close_stream_connection_hook (int (*) (int));
106 
107 int
109 
110 const char *get_encaps_name (openvas_encaps_t);
111 
113 
114 /* Additional functions -- should not be used by the plugins */
115 int
116 open_sock_opt_hn (const char *, unsigned int, int, int, int);
117 
118 int
119 openvas_SSL_init (void);
120 
121 int
122 stream_set_buffer (int, int);
123 
124 int
126 
127 int
128 stream_get_err (int);
129 
130 int
131 openvas_register_connection (int s, void *ssl,
132  gnutls_certificate_credentials_t certcred,
133  openvas_encaps_t encaps);
134 int
136 
137 int
139 
140 gnutls_session_t
142 
143 int
144 stream_zero (fd_set *);
145 
146 int
147 stream_set (int, fd_set *);
148 
149 int
150 os_send (int, void *, int, int);
151 
152 int
153 os_recv (int, void *, int, int);
154 
155 int
156 fd_is_stream (int);
157 
158 int
159 stream_set_timeout (int, int);
160 
161 int
163 
164 void
165 socket_get_cert (int, void **, int *);
166 
167 int
169 
170 void
171 socket_get_ssl_session_id (int, void **, size_t *);
172 
173 int
175 
176 int
178 
179 #endif
openvas_deregister_connection
int openvas_deregister_connection(int)
Definition: network.c:269
nsend
int nsend(int, void *, int, int)
Definition: network.c:1402
open_sock_option
int open_sock_option(struct script_infos *, unsigned int, int, int, int)
Definition: network.c:1802
script_infos
Definition: scanneraux.h:43
read_stream_connection_min
int read_stream_connection_min(int, void *, int, int)
Definition: network.c:1212
open_stream_connection_ext
int open_stream_connection_ext(struct script_infos *, unsigned int, int, int, const char *)
Definition: network.c:886
OPENVAS_ENCAPS_IP
@ OPENVAS_ENCAPS_IP
Definition: network.h:45
get_encaps_through
const char * get_encaps_through(openvas_encaps_t)
Definition: network.c:1577
getpts
unsigned short * getpts(char *, int *)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
Definition: network.c:2103
stream_set_timeout
int stream_set_timeout(int, int)
Definition: network.c:1033
socket_negotiate_ssl
int socket_negotiate_ssl(int, openvas_encaps_t, struct script_infos *)
Definition: network.c:683
stream_get_buffer_sz
int stream_get_buffer_sz(int)
Definition: network.c:1965
recv_line
int recv_line(int, char *, size_t)
Reads a text from the socket stream into the argument buffer, always.
Definition: network.c:1846
socket_close
int socket_close(int)
Definition: network.c:1949
nrecv
int nrecv(int, void *, int, int)
Definition: network.c:1441
openvas_register_connection
int openvas_register_connection(int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps)
Definition: network.c:244
read_stream_connection
int read_stream_connection(int, void *, int)
Definition: network.c:1272
stream_get_err
int stream_get_err(int)
Definition: network.c:145
close_stream_connection
int close_stream_connection(int)
Definition: network.c:1518
OPENVAS_ENCAPS_MAX
@ OPENVAS_ENCAPS_MAX
Definition: network.h:53
OPENVAS_ENCAPS_TLScustom
@ OPENVAS_ENCAPS_TLScustom
Definition: network.h:52
stream_zero
int stream_zero(fd_set *)
open_stream_auto_encaps_ext
int open_stream_auto_encaps_ext(struct script_infos *, unsigned int port, int timeout, int force)
Definition: network.c:1002
open_sock_tcp
int open_sock_tcp(struct script_infos *, unsigned int, int)
Definition: network.c:1729
socket_get_cert
void socket_get_cert(int, void **, int *)
Definition: network.c:730
get_sock_infos
int get_sock_infos(int sock, int *r_transport, void **r_tls_session)
Definition: network.c:2063
scanneraux.h
Auxiliary structures for scanner.
OPENVAS_ENCAPS_SSLv2
@ OPENVAS_ENCAPS_SSLv2
Definition: network.h:47
openvas_encaps_t
enum openvas_encaps openvas_encaps_t
stream_set_buffer
int stream_set_buffer(int, int)
Definition: network.c:1975
openvas_SSL_init
int openvas_SSL_init(void)
Initializes SSL support.
Definition: network.c:351
open_sock_opt_hn
int open_sock_opt_hn(const char *, unsigned int, int, int, int)
Definition: network.c:1700
open_stream_connection
int open_stream_connection(struct script_infos *, unsigned int, int, int)
Definition: network.c:992
socket_get_ssl_ciphersuite
int socket_get_ssl_ciphersuite(int)
Definition: network.c:847
OPENVAS_ENCAPS_TLSv1
@ OPENVAS_ENCAPS_TLSv1
Definition: network.h:49
write_stream_connection
int write_stream_connection(int, void *buf, int n)
Definition: network.c:1396
ovas_get_tlssession_from_connection
gnutls_session_t ovas_get_tlssession_from_connection(int)
Definition: network.c:387
stream_set
int stream_set(int, fd_set *)
socket_get_ssl_version
int socket_get_ssl_version(int)
Definition: network.c:766
os_send
int os_send(int, void *, int, int)
Definition: network.c:2023
openvas_get_socket_from_connection
int openvas_get_socket_from_connection(int)
Definition: network.c:367
OPENVAS_ENCAPS_SSLv3
@ OPENVAS_ENCAPS_SSLv3
Definition: network.h:48
socket_get_ssl_session_id
void socket_get_ssl_session_id(int, void **, size_t *)
Definition: network.c:807
openvas_encaps
openvas_encaps
Definition: network.h:42
socket_get_ssl_compression
int socket_get_ssl_compression(int)
os_recv
int os_recv(int, void *, int, int)
Definition: network.c:2042
OPENVAS_ENCAPS_TLSv11
@ OPENVAS_ENCAPS_TLSv11
Definition: network.h:50
OPENVAS_ENCAPS_TLSv12
@ OPENVAS_ENCAPS_TLSv12
Definition: network.h:51
get_encaps_name
const char * get_encaps_name(openvas_encaps_t)
Definition: network.c:1546
add_close_stream_connection_hook
void add_close_stream_connection_hook(int(*)(int))
fd_is_stream
int fd_is_stream(int)
Definition: network.c:1959
OPENVAS_ENCAPS_AUTO
@ OPENVAS_ENCAPS_AUTO
Definition: network.h:44
OPENVAS_ENCAPS_SSLv23
@ OPENVAS_ENCAPS_SSLv23
Definition: network.h:46