OpenVAS Scanner  6.0.1
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
int socket_close(int)
Definition: network.c:1971
int read_stream_connection(int, void *, int)
Definition: network.c:1294
int openvas_register_connection(int s, void *ssl, gnutls_certificate_credentials_t certcred, openvas_encaps_t encaps)
Definition: network.c:265
const char * get_encaps_through(openvas_encaps_t)
Definition: network.c:1599
unsigned short * getpts(char *, int *)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
Definition: network.c:2125
int stream_zero(fd_set *)
int read_stream_connection_min(int, void *, int, int)
Definition: network.c:1234
int open_stream_auto_encaps_ext(struct script_infos *, unsigned int port, int timeout, int force)
Definition: network.c:1024
int recv_line(int, char *, size_t)
Reads a text from the socket stream into the argument buffer, always.
Definition: network.c:1868
int stream_get_err(int)
Definition: network.c:166
Definition: network.h:49
Definition: network.h:46
enum openvas_encaps openvas_encaps_t
int socket_negotiate_ssl(int, openvas_encaps_t, struct script_infos *)
Definition: network.c:704
int stream_set_buffer(int, int)
Definition: network.c:1997
int nrecv(int, void *, int, int)
Definition: network.c:1463
Definition: network.h:51
int get_sock_infos(int sock, int *r_transport, void **r_tls_session)
Definition: network.c:2085
gnutls_session_t ovas_get_tlssession_from_connection(int)
Definition: network.c:408
int close_stream_connection(int)
Definition: network.c:1540
Definition: network.h:50
int openvas_SSL_init(void)
Initializes SSL support.
Definition: network.c:372
int open_sock_tcp(struct script_infos *, unsigned int, int)
Definition: network.c:1751
int os_send(int, void *, int, int)
Definition: network.c:2045
void socket_get_cert(int, void **, int *)
Definition: network.c:751
Definition: network.h:53
int socket_get_ssl_version(int)
Definition: network.c:787
openvas_encaps
Definition: network.h:42
int open_sock_opt_hn(const char *, unsigned int, int, int, int)
Definition: network.c:1722
int stream_set(int, fd_set *)
Definition: network.h:45
const char * get_encaps_name(openvas_encaps_t)
Definition: network.c:1568
Auxiliary structures for scanner.
int socket_get_ssl_ciphersuite(int)
Definition: network.c:868
int open_stream_connection(struct script_infos *, unsigned int, int, int)
Definition: network.c:1014
int write_stream_connection(int, void *buf, int n)
Definition: network.c:1418
void socket_get_ssl_session_id(int, void **, size_t *)
Definition: network.c:828
Definition: network.h:47
Definition: network.h:48
int openvas_deregister_connection(int)
Definition: network.c:290
int nsend(int, void *, int, int)
Definition: network.c:1424
int openvas_get_socket_from_connection(int)
Definition: network.c:388
int open_sock_option(struct script_infos *, unsigned int, int, int, int)
Definition: network.c:1824
int open_stream_connection_ext(struct script_infos *, unsigned int, int, int, const char *)
Definition: network.c:907
Definition: scanneraux.h:44
int os_recv(int, void *, int, int)
Definition: network.c:2064
void add_close_stream_connection_hook(int(*)(int))
int socket_get_ssl_compression(int)
int stream_get_buffer_sz(int)
Definition: network.c:1987
int fd_is_stream(int)
Definition: network.c:1981
Definition: network.h:52
int stream_set_timeout(int, int)
Definition: network.c:1055
Definition: network.h:44