OpenVAS Scanner  21.4.1
network.h
Go to the documentation of this file.
1 /* Portions Copyright (C) 2009-2021 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 */
53  OPENVAS_ENCAPS_TLScustom, /* SSL/TLS using custom priorities. */
56 
57 #define IS_ENCAPS_SSL(x) \
58  ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom)
59 
60 /* Plugin specific network functions */
61 int
62 open_sock_tcp (struct script_infos *, unsigned int, int);
63 
64 int
65 open_sock_option (struct script_infos *, unsigned int, int, int, int);
66 
67 int
68 recv_line (int, char *, size_t);
69 
70 int
71 nrecv (int, void *, int, int);
72 
73 int
74 socket_close (int);
75 
76 int
77 get_sock_infos (int sock, int *r_transport, void **r_tls_session);
78 
79 unsigned short *
80 getpts (char *, int *);
81 
82 int
83 open_stream_connection (struct script_infos *, unsigned int, int, int);
84 
85 int
86 open_stream_connection_ext (struct script_infos *, unsigned int, int, int,
87  const char *);
88 
89 int
90 open_stream_auto_encaps_ext (struct script_infos *, unsigned int port,
91  int timeout, int force);
92 
93 int
94 write_stream_connection (int, void *buf, int n);
95 
96 int
97 read_stream_connection (int, void *, int);
98 
99 int
100 read_stream_connection_min (int, void *, int, int);
101 
102 int
103 nsend (int, void *, int, int);
104 
105 void
107 
108 int
110 
111 const char *get_encaps_name (openvas_encaps_t);
112 
114 
115 /* Additional functions -- should not be used by the plugins */
116 int
117 open_sock_opt_hn (const char *, unsigned int, int, int, int);
118 
119 int
120 openvas_SSL_init (void);
121 
122 int
123 stream_set_buffer (int, int);
124 
125 int
127 
128 int
129 stream_get_err (int);
130 
131 int
132 openvas_register_connection (int s, void *ssl,
133  gnutls_certificate_credentials_t certcred,
134  openvas_encaps_t encaps);
135 int
137 
138 int
140 
141 gnutls_session_t
143 
144 int
145 stream_zero (fd_set *);
146 
147 int
148 stream_set (int, fd_set *);
149 
150 int
151 os_send (int, void *, int, int);
152 
153 int
154 os_recv (int, void *, int, int);
155 
156 int
157 fd_is_stream (int);
158 
159 int
160 stream_set_timeout (int, int);
161 
162 int
164 
165 void
166 socket_get_cert (int, void **, int *);
167 
168 int
170 
171 void
172 socket_get_ssl_session_id (int, void **, size_t *);
173 
174 int
176 
177 int
179 
180 #endif
const char * get_encaps_through(openvas_encaps_t)
Definition: network.c:1608
int openvas_SSL_init(void)
Initializes SSL support.
Definition: network.c:351
int openvas_get_socket_from_connection(int)
Definition: network.c:367
int stream_get_err(int)
Definition: network.c:145
int fd_is_stream(int)
Definition: network.c:1992
int read_stream_connection_min(int, void *, int, int)
Definition: network.c:1240
void add_close_stream_connection_hook(int(*)(int))
int stream_zero(fd_set *)
openvas_encaps
Definition: network.h:43
@ OPENVAS_ENCAPS_SSLv3
Definition: network.h:48
@ OPENVAS_ENCAPS_TLScustom
Definition: network.h:53
@ OPENVAS_ENCAPS_TLSv12
Definition: network.h:51
@ OPENVAS_ENCAPS_TLSv1
Definition: network.h:49
@ OPENVAS_ENCAPS_MAX
Definition: network.h:54
@ OPENVAS_ENCAPS_IP
Definition: network.h:45
@ OPENVAS_ENCAPS_TLSv13
Definition: network.h:52
@ OPENVAS_ENCAPS_SSLv2
Definition: network.h:47
@ OPENVAS_ENCAPS_SSLv23
Definition: network.h:46
@ OPENVAS_ENCAPS_TLSv11
Definition: network.h:50
@ OPENVAS_ENCAPS_AUTO
Definition: network.h:44
int nsend(int, void *, int, int)
Definition: network.c:1431
enum openvas_encaps openvas_encaps_t
int os_send(int, void *, int, int)
Definition: network.c:2056
int os_recv(int, void *, int, int)
Definition: network.c:2075
int openvas_register_connection(int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps)
Definition: network.c:244
void socket_get_ssl_session_id(int, void **, size_t *)
Definition: network.c:820
int get_sock_infos(int sock, int *r_transport, void **r_tls_session)
Definition: network.c:2096
unsigned short * getpts(char *, int *)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
Definition: network.c:2136
int open_stream_auto_encaps_ext(struct script_infos *, unsigned int port, int timeout, int force)
Definition: network.c:1029
int open_sock_option(struct script_infos *, unsigned int, int, int, int)
Definition: network.c:1835
int stream_get_buffer_sz(int)
Definition: network.c:1998
int recv_line(int, char *, size_t)
Reads a text from the socket stream into the argument buffer, always.
Definition: network.c:1879
int socket_get_ssl_compression(int)
int stream_set_buffer(int, int)
Definition: network.c:2008
int nrecv(int, void *, int, int)
Definition: network.c:1470
int socket_negotiate_ssl(int, openvas_encaps_t, struct script_infos *)
Definition: network.c:686
int socket_get_ssl_version(int)
Definition: network.c:777
int socket_get_ssl_ciphersuite(int)
Definition: network.c:860
gnutls_session_t ovas_get_tlssession_from_connection(int)
Definition: network.c:387
int open_stream_connection_ext(struct script_infos *, unsigned int, int, int, const char *)
Definition: network.c:899
int write_stream_connection(int, void *buf, int n)
Definition: network.c:1425
int open_stream_connection(struct script_infos *, unsigned int, int, int)
Definition: network.c:1019
int open_sock_tcp(struct script_infos *, unsigned int, int)
Definition: network.c:1761
void socket_get_cert(int, void **, int *)
Definition: network.c:741
int socket_close(int)
Definition: network.c:1982
int open_sock_opt_hn(const char *, unsigned int, int, int, int)
Definition: network.c:1732
int read_stream_connection(int, void *, int)
Definition: network.c:1300
const char * get_encaps_name(openvas_encaps_t)
Definition: network.c:1575
int close_stream_connection(int)
Definition: network.c:1547
int openvas_deregister_connection(int)
Definition: network.c:269
int stream_set_timeout(int, int)
Definition: network.c:1060
int stream_set(int, fd_set *)
Auxiliary structures for scanner.
Definition: scanneraux.h:42