OpenVAS Libraries  4.0+rc3.SVN
network.h
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 
45 int open_stream_connection (struct arglist *, unsigned int, int, int);
46 int open_stream_connection_unknown_encaps (struct arglist *, unsigned int, int,
47  int *);
48 int open_stream_connection_unknown_encaps5 (struct arglist *, unsigned int, int,
49  int *, int *);
50 int open_stream_auto_encaps (struct arglist *, unsigned int, int);
51 
52 int write_stream_connection (int, void *buf, int n);
53 int read_stream_connection (int, void *, int);
54 int read_stream_connection_min (int, void *, int, int);
55 int nsend (int, void *, int, int);
56 int close_stream_connection (int);
57 const char *get_encaps_name (int);
58 const char *get_encaps_through (int);
59 
60 /* Additional functions -- should not be used by the plugins */
61 int open_sock_tcp_hn (const char *, unsigned int);
62 int open_sock_opt_hn (const char *, unsigned int, int, int, int);
63 
64 #ifdef __GNUC__
65 void auth_printf (struct arglist *, char *, ...) __attribute__ ((format (printf, 2, 3))); /* RATS: ignore */
66 #else
67 void auth_printf (struct arglist *, char *, ...);
68 #endif
69 
70 void auth_send (struct arglist *, char *);
71 char *auth_gets (struct arglist *, char *, size_t);
72 
73 int openvas_SSL_init ();
74 
75 int stream_set_buffer (int, int);
76 int stream_get_buffer_sz (int);
77 int stream_get_err (int);
78 
79 void *stream_get_ssl (int);
80 
83 
84 ovas_scanner_context_t ovas_scanner_context_new (int encaps,
85  const char *certfile,
86  const char *keyfile,
87  const char *passwd,
88  const char *cacertfile,
89  int force_pubkey_auth);
90 
91 void ovas_scanner_context_free (ovas_scanner_context_t);
92 int ovas_scanner_context_attach (ovas_scanner_context_t ctx, int soc);
93 
94 int openvas_register_connection (int s, void *ssl,
95  gnutls_certificate_credentials_t certcred);
96 int openvas_deregister_connection (int);
97 int openvas_get_socket_from_connection (int);
98 gnutls_session_t *ovas_get_tlssession_from_connection (int);
99 
100 int stream_zero (fd_set *);
101 int stream_set (int, fd_set *);
102 int stream_isset (int, fd_set *);
103 
104 struct in_addr socket_get_next_source_addr ();
105 struct in6_addr socket_get_next_source_v4_addr ();
106 struct in6_addr socket_get_next_source_v6_addr ();
107 int set_socket_source_addr (int, int, int);
108 void socket_source_init (struct in6_addr *, int family);
109 
110 int os_send (int, void *, int, int);
111 int os_recv (int, void *, int, int);
112 
113 int internal_send (int, char *, int);
114 int internal_recv (int, char **, int *, int *);
115 
116 int fd_is_stream (int);
117 int stream_pending (int);
118 
119 int stream_set_timeout (int, int);
120 int stream_set_options (int, int, int);
121 
122 void convipv4toipv4mappedaddr (struct in_addr, struct in6_addr *);
123 
124 #endif