OpenVAS Libraries  4.0+rc3.SVN
plugutils.h
1 /* OpenVAS
2  * $Id$
3  * Description: Header file for module plugutils.
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_PLUGUTILS_H
27 #define OPENVAS_PLUGUTILS_H
28 
29 #include "../misc/arglists.h"
30 
31 #include "../base/nvti.h"
32 
33 #define LEGACY_OID "1.3.6.1.4.1.25623.1.0."
34 
35 void scanner_add_port (struct arglist *, int, char *);
36 
37 
38 /*
39  * Arglist management at plugin-level
40  */
41 void plug_set_nvti (struct arglist *, nvti_t *);
42 nvti_t *plug_get_nvti (struct arglist *);
43 
44 void plug_set_name (struct arglist *, const char *);
45 char *plug_get_name (struct arglist *);
46 
47 void plug_set_path (struct arglist *, const char *);
48 char *plug_get_path (struct arglist *);
49 
50 void plug_set_version (struct arglist *, const char *);
51 char *plug_get_version (struct arglist *);
52 
53 void plug_set_timeout (struct arglist *, int);
54 int plug_get_timeout (struct arglist *);
55 
56 void plug_set_launch (struct arglist *, int);
57 int plug_get_launch (struct arglist *);
58 
59 void plug_set_summary (struct arglist *, const char *);
60 char *plug_get_summary (struct arglist *);
61 
62 void plug_set_description (struct arglist *, const char *);
63 char *plug_get_description (struct arglist *);
64 
65 void plug_set_category (struct arglist *, int);
66 int plug_get_category (struct arglist *);
67 
68 void plug_set_copyright (struct arglist *, const char *);
69 char *plug_get_copyright (struct arglist *);
70 
71 void plug_set_family (struct arglist *, const char *);
72 char *plug_get_family (struct arglist *);
73 
74 void plug_set_dep (struct arglist *, const char *);
75 struct arglist *plug_get_deps (struct arglist *);
76 
77 
78 void plug_set_id (struct arglist *, int);
79 int plug_get_id (struct arglist *);
80 
81 void plug_set_oid (struct arglist *, char *);
82 char *plug_get_oid (struct arglist *);
83 
84 void plug_set_cve_id (struct arglist *, char *);
85 char *plug_get_cve_id (struct arglist *);
86 
87 void plug_set_bugtraq_id (struct arglist *, char *);
88 char *plug_get_bugtraq_id (struct arglist *);
89 
90 void plug_set_xref (struct arglist *, char *, char *);
91 char *plug_get_xref (struct arglist *);
92 
93 void plug_set_tag (struct arglist *, char *, char *);
94 char *plug_get_tag (struct arglist *);
95 
96 void plug_set_sign_key_ids (struct arglist *, char *);
97 char *plug_get_sign_key_ids (struct arglist *);
98 
99 void plug_set_ssl_cert (struct arglist *, char *);
100 void plug_set_ssl_key (struct arglist *, char *);
101 void plug_set_ssl_pem_password (struct arglist *, char *);
102 void plug_set_ssl_CA_file (struct arglist *, char *);
103 
104 
105 const char *plug_get_hostname (struct arglist *);
106 const char *plug_get_host_fqdn (struct arglist *);
107 void plug_add_host (struct arglist *, struct arglist *);
108 unsigned int plug_get_host_open_port (struct arglist *desc);
109 
110 void plug_set_port_transport (struct arglist *, int, int);
111 
112 void plug_require_key (struct arglist *, const char *);
113 struct arglist *plug_get_required_keys (struct arglist *);
114 
115 void plug_mandatory_key (struct arglist *, const char *);
116 struct arglist *plug_get_mandatory_keys (struct arglist *);
117 
118 void plug_exclude_key (struct arglist *, const char *);
119 struct arglist *plug_get_excluded_keys (struct arglist *);
120 
121 void plug_require_port (struct arglist *, const char *);
122 struct arglist *plug_get_required_ports (struct arglist *);
123 
124 void plug_require_udp_port (struct arglist *, const char *);
125 struct arglist *plug_get_required_udp_ports (struct arglist *);
126 int plug_get_port_transport (struct arglist *, int);
127 
128 
129 /*
130  * Reporting functions
131  */
132 void proto_post_hole (struct arglist *, int, const char *, const char *);
133 void post_hole (struct arglist *, int, const char *);
134 void post_hole_udp (struct arglist *, int, const char *);
135 #define post_hole_tcp post_hole
136 
137 void proto_post_info (struct arglist *, int, const char *, const char *);
138 void post_info (struct arglist *, int, const char *);
139 void post_info_udp (struct arglist *, int, const char *);
140 #define post_info_tcp post_info
141 
142 void proto_post_note (struct arglist *, int, const char *, const char *);
143 void post_note (struct arglist *, int, const char *);
144 void post_note_udp (struct arglist *, int, const char *);
145 #define post_note_tcp post_note
146 
147 void proto_post_debug (struct arglist *, int, const char *, const char *);
148 void post_debug (struct arglist *, int, const char *);
149 void post_debug_udp (struct arglist *, int, const char *);
150 #define post_debug_tcp post_debug
151 
152 void proto_post_log (struct arglist *, int, const char *, const char *);
153 void post_log (struct arglist *, int, const char *);
154 void post_log_udp (struct arglist *, int, const char *);
155 #define post_log_tcp post_log
156 
157 
158 /*
159  * Management of the portlists
160  */
161 void host_add_port (struct arglist *, int, int);
162 void host_add_port_udp (struct arglist *, int, int);
163 int host_get_port_state (struct arglist *, int);
164 int host_get_port_state_udp (struct arglist *, int);
165 
166 /* Not implemented
167 char * host_get_port_banner(struct arglist *, int);
168 */
169 
170 
171 /*
172  * Inter Plugins Communication functions
173  */
174 void plug_set_key (struct arglist *, char *, int, void *);
175 void plug_replace_key (struct arglist *, char *, int, void *);
176 void *plug_get_fresh_key (struct arglist *, char *, int *);
177 struct kb_item **plug_get_kb (struct arglist *);
178 void *plug_get_key (struct arglist *, char *, int *);
179 
180 char *openvaslib_version ();
181 void openvas_lib_version (int *, int *, int *);
182 char *addslashes (char *);
183 char *rmslashes (char *);
184 
185 struct in6_addr *plug_get_host_ip (struct arglist *);
186 char *get_preference (struct arglist *, const char *);
187 void add_plugin_preference (struct arglist *, const char *, const char *,
188  const char *);
189 char *get_plugin_preference (struct arglist *, const char *);
190 const char *get_plugin_preference_fname (struct arglist *, const char *);
191 char *get_plugin_preference_file_content (struct arglist *, const char *);
192 const long get_plugin_preference_file_size (struct arglist *, const char *);
193 
194 char *find_in_path (char *, int);
195 
196 int shared_socket_register (struct arglist *, int, char *);
197 int shared_socket_acquire (struct arglist *, char *);
198 int shared_socket_release (struct arglist *, char *);
199 int shared_socket_destroy (struct arglist *, char *);
200 
205 #define INTERNAL_COMM_MSG_TYPE_CTRL (1 << 16)
206 #define INTERNAL_COMM_MSG_TYPE_KB (1 << 17)
207 #define INTERNAL_COMM_MSG_TYPE_DATA (1 << 18)
208 #define INTERNAL_COMM_MSG_SHARED_SOCKET (1 << 19)
209 
210 #define INTERNAL_COMM_KB_REPLACE 1
211 #define INTERNAL_COMM_KB_GET 2
212 #define INTERNAL_COMM_KB_SENDING_INT 4
213 #define INTERNAL_COMM_KB_SENDING_STR 8
214 #define INTERNAL_COMM_KB_ERROR 16
215 
216 
217 #define INTERNAL_COMM_CTRL_FINISHED 1
218 #define INTERNAL_COMM_CTRL_ACK 2
219 
220 #define INTERNAL_COMM_SHARED_SOCKET_REGISTER 1
221 #define INTERNAL_COMM_SHARED_SOCKET_ACQUIRE 2
222 #define INTERNAL_COMM_SHARED_SOCKET_RELEASE 4
223 #define INTERNAL_COMM_SHARED_SOCKET_DESTROY 8
224 
225 #define INTERNAL_COMM_SHARED_SOCKET_DORECVMSG 16
226 #define INTERNAL_COMM_SHARED_SOCKET_BUSY 32
227 #define INTERNAL_COMM_SHARED_SOCKET_ERROR 64
228 
229 /*
230  * Type of "transport layer", for encapsulated connections
231  * Only SSL is supported at this time.
232  * (Bad) examples of other layers could be SOCKS, httptunnel, icmptunnel,
233  * RMI over HTTP, DCOM over HTTP, TCP over TCP, etc.
234  */
235 #define OPENVAS_ENCAPS_IP 1
236 #define OPENVAS_ENCAPS_SSLv23 2 /* Ask for compatibility options */
237 #define OPENVAS_ENCAPS_SSLv2 3
238 #define OPENVAS_ENCAPS_SSLv3 4
239 #define OPENVAS_ENCAPS_TLSv1 5
240 
241 #define IS_ENCAPS_SSL(x) ((x) >= OPENVAS_ENCAPS_SSLv23 && (x) <= OPENVAS_ENCAPS_TLSv1)
242 
243 #endif