OpenVAS Libraries  6.0+beta5
network.h
Go to the documentation of this file.
1 /* OpenVAS
2  * $Id$
3  * Description: Header file for module network.
4  *
5  * Authors:
6  * Renaud Deraison <deraison@nessus.org> (Original pre-fork development)
7  *
8  * Copyright:
9  * Based on work Copyright (C) 1998 - 2007 Tenable Network Security, Inc.
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef OPENVAS_NETWORK_H
27 #define OPENVAS_NETWORK_H
28 
29 #include <sys/select.h> /* at least for fd_set */
30 #include <netinet/in.h> /* struct in_addr, struct in6_addr */
31 
32 #include <gnutls/gnutls.h>
33 #include <gnutls/x509.h>
34 
35 #include "arglists.h"
36 
37 /* Plugin specific network functions */
38 int open_sock_tcp (struct arglist *, unsigned int, int);
39 int open_sock_udp (struct arglist *, unsigned int);
40 int open_sock_option (struct arglist *, unsigned int, int, int, int);
41 int recv_line (int, char *, size_t);
42 int nrecv (int, void *, int, int);
43 int socket_close (int);
44 int get_sock_infos (int sock, int *r_transport, void **r_tls_session);
45 
46 int open_stream_connection (struct arglist *, unsigned int, int, int);
47 int open_stream_connection_ext (struct arglist *, unsigned int, int, int,
48  const char *);
49 int open_stream_connection_unknown_encaps (struct arglist *, unsigned int, int,
50  int *);
51 int open_stream_connection_unknown_encaps5 (struct arglist *, unsigned int, int,
52  int *, int *);
53 int open_stream_auto_encaps_ext (struct arglist *args, unsigned int port,
54  int timeout, int force);
55 int open_stream_auto_encaps (struct arglist *, unsigned int, int);
56 
57 int write_stream_connection (int, void *buf, int n);
58 int read_stream_connection (int, void *, int);
59 int read_stream_connection_min (int, void *, int, int);
60 int nsend (int, void *, int, int);
61 int close_stream_connection (int);
62 
63 const char *get_encaps_name (int);
64 const char *get_encaps_through (int);
65 
66 /* Additional functions -- should not be used by the plugins */
67 int open_sock_tcp_hn (const char *, unsigned int);
68 int open_sock_opt_hn (const char *, unsigned int, int, int, int);
69 
70 #ifdef __GNUC__
71 void auth_printf (struct arglist *, char *, ...) __attribute__ ((format (printf, 2, 3))); /* RATS: ignore */
72 #else
73 void auth_printf (struct arglist *, char *, ...);
74 #endif
75 
76 void auth_send (struct arglist *, char *);
77 char *auth_gets (struct arglist *, char *, size_t);
78 
79 int openvas_SSL_init ();
80 
81 int stream_set_buffer (int, int);
82 int stream_get_buffer_sz (int);
83 int stream_get_err (int);
84 
85 void *stream_get_ssl (int);
86 
89 
90 ovas_scanner_context_t ovas_scanner_context_new (int encaps,
91  const char *certfile,
92  const char *keyfile,
93  const char *passwd,
94  const char *cacertfile,
95  int force_pubkey_auth);
96 
97 void ovas_scanner_context_free (ovas_scanner_context_t);
98 int ovas_scanner_context_attach (ovas_scanner_context_t ctx, int soc);
99 
100 int openvas_register_connection (int s, void *ssl,
101  gnutls_certificate_credentials_t certcred);
104 gnutls_session_t *ovas_get_tlssession_from_connection (int);
105 
106 int stream_zero (fd_set *);
107 int stream_set (int, fd_set *);
108 int stream_isset (int, fd_set *);
109 
110 struct in_addr socket_get_next_source_addr ();
111 struct in6_addr socket_get_next_source_v4_addr ();
112 struct in6_addr socket_get_next_source_v6_addr ();
113 int set_socket_source_addr (int, int, int);
114 void socket_source_init (struct in6_addr *, int family);
115 
116 int os_send (int, void *, int, int);
117 int os_recv (int, void *, int, int);
118 
119 int internal_send (int, char *, int);
120 int internal_recv (int, char **, int *, int *);
121 
122 int fd_is_stream (int);
123 int stream_pending (int);
124 
125 int stream_set_timeout (int, int);
126 int stream_set_options (int, int, int);
127 
128 void convipv4toipv4mappedaddr (struct in_addr, struct in6_addr *);
129 
130 #endif