File: network.h

package info (click to toggle)
openvas-scanner 23.35.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,416 kB
  • sloc: ansic: 41,615; xml: 6,251; pascal: 3,723; yacc: 1,250; sh: 1,068; makefile: 333; sql: 273; javascript: 12
file content (179 lines) | stat: -rw-r--r-- 3,738 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/* SPDX-FileCopyrightText: 2023 Greenbone AG
 * SPDX-FileCopyrightText: 1998-2007 Tenable Network Security, Inc.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/**
 * @file network.h
 * @brief Header file for module network.
 */

#ifndef MISC_NETWORK_H
#define MISC_NETWORK_H

#include "scanneraux.h"

#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <netinet/in.h> /* struct in_addr, struct in6_addr */
#include <sys/select.h> /* at least for fd_set */

/*
 * Type of "transport layer", for encapsulated connections
 * Only SSL is supported at this time.
 * (Bad) examples of other layers could be SOCKS, httptunnel, icmptunnel,
 * RMI over HTTP, DCOM over HTTP, TCP over TCP, etc.
 */
typedef enum openvas_encaps
{
  OPENVAS_ENCAPS_AUTO = 0, /* Request auto detection.  */
  OPENVAS_ENCAPS_IP,
  OPENVAS_ENCAPS_SSLv23, /* Ask for compatibility options */
  OPENVAS_ENCAPS_SSLv2,
  OPENVAS_ENCAPS_SSLv3,
  OPENVAS_ENCAPS_TLSv1,
  OPENVAS_ENCAPS_TLSv11,
  OPENVAS_ENCAPS_TLSv12,
  OPENVAS_ENCAPS_TLSv13,
  OPENVAS_ENCAPS_TLScustom, /* SSL/TLS using custom priorities.  */
  OPENVAS_ENCAPS_MAX,
} openvas_encaps_t;

#define IS_ENCAPS_SSL(x) \
  ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLScustom)

/* Define FLAGS for setting other priorities in
   open_stream_connection_ext */
#define NO_PRIORITY_FLAGS 0
#define INSECURE_DH_PRIME_BITS (1 << 0) // 1

/* Plugin specific network functions */
int
open_sock_tcp (struct script_infos *, unsigned int, int);

int
open_sock_option (struct script_infos *, unsigned int, int, int, int);

int
recv_line (int, char *, size_t);

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 *);

void
open_stream_tls_default_priorities (const char *p, const int pflag);

int
open_stream_connection (struct script_infos *, unsigned int, int, int);

int
open_stream_connection_ext (struct script_infos *, unsigned int, int, int,
                            const char *, int);

int
open_stream_auto_encaps_ext (struct script_infos *, 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);

/* Additional functions -- should not be used by the plugins */
int
open_sock_opt_hn (const char *, unsigned int, int, int, int);

int
openvas_SSL_init (void);

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
fd_is_stream (int);

int
stream_set_timeout (int, int);

int
socket_ssl_safe_renegotiation_status (int);
int
socket_ssl_do_handshake (int);

int
socket_negotiate_ssl (int, openvas_encaps_t, struct script_infos *);

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);

#endif