OpenVAS Libraries  6.0+beta5
nvti.h
Go to the documentation of this file.
1 /* openvas-libraries/base
2  * $Id$
3  * Description: API (structs and protos) for NVT Info datasets
4  *
5  * Authors:
6  * Jan-Oliver Wagner <jan-oliver.wagner@greenbone.net>
7  * Matthew Mundell <matthew.mundell@greenbone.net>
8  *
9  * Copyright:
10  * Copyright (C) 2009, 2011 Greenbone Networks GmbH
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2,
14  * or, at your option, any later version as published by the Free
15  * Software Foundation
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26 
34 #ifndef _NVTI_H
35 #define _NVTI_H
36 
37 #include <glib.h>
38 
45 typedef struct nvtpref
46 {
47  gchar *type;
48  gchar *name;
49  gchar *dflt;
50 } nvtpref_t;
51 
52 nvtpref_t *nvtpref_new (gchar *, gchar *, gchar *);
53 void nvtpref_free (nvtpref_t *);
54 gchar *nvtpref_name (const nvtpref_t *);
55 gchar *nvtpref_type (const nvtpref_t *);
56 gchar *nvtpref_default (const nvtpref_t *);
57 
64 typedef struct nvti
65 {
66  gchar *oid;
67  gchar *version;
68  gchar *name;
69  gchar *summary;
70  gchar *description;
71  gchar *copyright;
73  gchar *cve;
74  gchar *bid;
76  gchar *xref;
78  gchar *tag;
79  gchar *cvss_base;
81  gchar *dependencies;
82  gchar *required_keys;
83  gchar *mandatory_keys;
84  gchar *excluded_keys;
85  gchar *required_ports;
88  gchar *sign_key_ids;
91  gchar *src;
94  GSList *prefs;
96  // The following are not settled yet.
97  gint timeout;
98  gint category;
99  gchar *family;
100 } nvti_t;
101 
102 nvti_t *nvti_new (void);
103 void nvti_free (nvti_t *);
104 void nvti_shrink (nvti_t *);
105 
106 gchar *nvti_oid (const nvti_t *);
107 gchar *nvti_version (const nvti_t *);
108 gchar *nvti_name (const nvti_t *);
109 gchar *nvti_summary (const nvti_t *);
110 gchar *nvti_description (const nvti_t *);
111 gchar *nvti_copyright (const nvti_t *);
112 gchar *nvti_cve (const nvti_t *);
113 gchar *nvti_bid (const nvti_t *);
114 gchar *nvti_xref (const nvti_t *);
115 gchar *nvti_tag (const nvti_t *);
116 double nvti_cvss (const nvti_t *);
117 gchar *nvti_cvss_base (const nvti_t *);
118 gchar *nvti_cvss_base_vector (const nvti_t *);
119 gchar *nvti_risk_factor (const nvti_t *);
120 gchar *nvti_dependencies (const nvti_t *);
121 gchar *nvti_required_keys (const nvti_t *);
122 gchar *nvti_mandatory_keys (const nvti_t *);
123 gchar *nvti_excluded_keys (const nvti_t *);
124 gchar *nvti_required_ports (const nvti_t *);
125 gchar *nvti_required_udp_ports (const nvti_t *);
126 gchar *nvti_sign_key_ids (const nvti_t *);
127 gchar *nvti_src (const nvti_t *);
128 gint nvti_timeout (const nvti_t *);
129 gint nvti_category (const nvti_t *);
130 gchar *nvti_family (const nvti_t *);
131 guint nvti_pref_len (const nvti_t *);
132 nvtpref_t *nvti_pref (const nvti_t *, guint);
133 
134 int nvti_set_oid (nvti_t *, const gchar *);
135 int nvti_set_version (nvti_t *, const gchar *);
136 int nvti_set_name (nvti_t *, const gchar *);
137 int nvti_set_summary (nvti_t *, const gchar *);
138 int nvti_set_description (nvti_t *, const gchar *);
139 int nvti_set_copyright (nvti_t *, const gchar *);
140 int nvti_set_cve (nvti_t *, const gchar *);
141 int nvti_set_bid (nvti_t *, const gchar *);
142 int nvti_set_xref (nvti_t *, const gchar *);
143 int nvti_set_tag (nvti_t *, const gchar *);
144 int nvti_set_cvss_base (nvti_t *, const gchar *);
145 int nvti_set_dependencies (nvti_t *, const gchar *);
146 int nvti_set_required_keys (nvti_t *, const gchar *);
147 int nvti_set_mandatory_keys (nvti_t *, const gchar *);
148 int nvti_set_excluded_keys (nvti_t *, const gchar *);
149 int nvti_set_required_ports (nvti_t *, const gchar *);
150 int nvti_set_required_udp_ports (nvti_t *, const gchar *);
151 int nvti_set_sign_key_ids (nvti_t *, const gchar *);
152 int nvti_set_src (nvti_t *, const gchar *);
153 int nvti_set_timeout (nvti_t *, const gint);
154 int nvti_set_category (nvti_t *, const gint);
155 int nvti_set_family (nvti_t *, const gchar *);
156 
157 int nvti_add_cve (nvti_t *, const gchar *);
158 int nvti_add_bid (nvti_t *, const gchar *);
159 int nvti_add_required_keys (nvti_t *, const gchar *);
160 int nvti_add_mandatory_keys (nvti_t *, const gchar *);
161 int nvti_add_excluded_keys (nvti_t *, const gchar *);
162 int nvti_add_required_ports (nvti_t *, const gchar *);
163 int nvti_add_required_udp_ports (nvti_t *, const gchar *);
164 int nvti_add_sign_key_id (nvti_t *, const gchar *);
165 int nvti_add_pref (nvti_t *, nvtpref_t *);
166 
167 gchar *nvti_as_text (const nvti_t *);
168 gchar *nvti_as_openvas_nvt_cache_entry (const nvti_t *);
169 
170 nvti_t *nvti_from_keyfile (const gchar *);
171 int nvti_to_keyfile (const nvti_t *, const gchar *);
172 
173 nvti_t * nvti_clone (const nvti_t *);
174 
175 /* Collections of NVT Infos. */
176 
180 typedef GHashTable nvtis_t;
181 
182 nvtis_t *nvtis_new ();
183 
184 void nvtis_free (nvtis_t *);
185 
186 guint nvtis_size (nvtis_t *);
187 
188 void nvtis_add (nvtis_t *, nvti_t *);
189 
190 nvti_t *nvtis_lookup (nvtis_t *, const char *);
191 
192 #define nvtis_find g_hash_table_find
193 
194 #endif /* not _NVTI_H */