OpenVAS Libraries  4.0+rc3.SVN
Data Structures | Defines | Typedefs | Functions
base/nvti.h File Reference

Protos and data structures for NVT Information data sets. More...

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  nvtpref
 The structure for a preference of a NVT. More...
struct  nvti
 The structure of a information record that corresponds to a NVT. More...

Defines

#define nvtis_find   g_hash_table_find

Typedefs

typedef struct nvtpref nvtpref_t
 The structure for a preference of a NVT.
typedef struct nvti nvti_t
 The structure of a information record that corresponds to a NVT.
typedef GHashTable nvtis_t
 A collection of information records corresponding to NVTs.

Functions

nvtpref_tnvtpref_new (gchar *, gchar *, gchar *)
 Create a new nvtpref structure filled with the given values.
void nvtpref_free (nvtpref_t *)
 Free memory of a nvtpref structure.
gchar * nvtpref_name (const nvtpref_t *)
 Get the Name of a NVT Preference.
gchar * nvtpref_type (const nvtpref_t *)
 Get the Type of a NVT Preference.
gchar * nvtpref_default (const nvtpref_t *)
 Get the Default of a NVT Preference.
nvti_tnvti_new (void)
 Create a new (empty) nvti structure.
void nvti_free (nvti_t *)
 Free memory of a nvti structure.
gchar * nvti_oid (const nvti_t *)
 Get the OID string.
gchar * nvti_version (const nvti_t *)
 Get the version.
gchar * nvti_name (const nvti_t *)
 Get the name.
gchar * nvti_summary (const nvti_t *)
 Get the summary.
gchar * nvti_description (const nvti_t *)
 Get the description.
gchar * nvti_copyright (const nvti_t *)
 Get the copyright notice.
gchar * nvti_cve (const nvti_t *)
 Get the CVE references.
gchar * nvti_bid (const nvti_t *)
 Get the bid references.
gchar * nvti_xref (const nvti_t *)
 Get the xref's.
gchar * nvti_tag (const nvti_t *)
 Get the tag.
gchar * nvti_cvss_base (const nvti_t *)
 Get the CVSS base.
gchar * nvti_risk_factor (const nvti_t *)
 Get the risk factor.
gchar * nvti_dependencies (const nvti_t *)
 Get the dependencies list.
gchar * nvti_required_keys (const nvti_t *)
 Get the required keys list.
gchar * nvti_mandatory_keys (const nvti_t *)
 Get the mandatory keys list.
gchar * nvti_excluded_keys (const nvti_t *)
 Get the excluded keys list.
gchar * nvti_required_ports (const nvti_t *)
 Get the required ports list.
gchar * nvti_required_udp_ports (const nvti_t *)
 Get the required udp ports list.
gchar * nvti_sign_key_ids (const nvti_t *)
 Get the sign key ids (fingerptints) list.
gchar * nvti_src (const nvti_t *)
 Get the source URI of a NVT Info.
gint nvti_timeout (const nvti_t *)
 Get the timeout for this NVT.
gint nvti_category (const nvti_t *)
 Get the category for this NVT.
gchar * nvti_family (const nvti_t *)
 Get the family name.
guint nvti_pref_len (const nvti_t *)
 Get the number of preferences of the NVT.
nvtpref_tnvti_pref (const nvti_t *, guint)
 Get the n'th preferences of the NVT.
int nvti_set_oid (nvti_t *, const gchar *)
 Set the OID of a NVT Info.
int nvti_set_version (nvti_t *, const gchar *)
 Set the version of a NVT.
int nvti_set_name (nvti_t *, const gchar *)
 Set the name of a NVT.
int nvti_set_summary (nvti_t *, const gchar *)
 Set the summary of a NVT.
int nvti_set_description (nvti_t *, const gchar *)
 Set the description of a NVT.
int nvti_set_copyright (nvti_t *, const gchar *)
 Set the copyright of a NVT.
int nvti_set_cve (nvti_t *, const gchar *)
 Set the CVE references of a NVT.
int nvti_set_bid (nvti_t *, const gchar *)
 Set the bid references of a NVT.
int nvti_set_xref (nvti_t *, const gchar *)
 Set the xrefs of a NVT.
int nvti_set_tag (nvti_t *, const gchar *)
 Set the tags of a NVT.
int nvti_set_cvss_base (nvti_t *, const gchar *)
 Set the CVSS base of an NVT.
int nvti_set_risk_factor (nvti_t *, const gchar *)
 Set the risk factor of an NVT.
int nvti_set_dependencies (nvti_t *, const gchar *)
 Set the dependencies of a NVT.
int nvti_set_required_keys (nvti_t *, const gchar *)
 Set the required keys of a NVT.
int nvti_set_mandatory_keys (nvti_t *, const gchar *)
 Set the mandatory keys of a NVT.
int nvti_set_excluded_keys (nvti_t *, const gchar *)
 Set the excluded keys of a NVT.
int nvti_set_required_ports (nvti_t *, const gchar *)
 Set the required ports of a NVT.
int nvti_set_required_udp_ports (nvti_t *, const gchar *)
 Set the required udp ports of a NVT.
int nvti_set_sign_key_ids (nvti_t *, const gchar *)
 Set the sign key ids of a NVT.
int nvti_set_src (nvti_t *, const gchar *)
 Set the source identifier for the acutal NVT.
int nvti_set_timeout (nvti_t *, const gint)
 Set the timout of a NVT Info.
int nvti_set_category (nvti_t *, const gint)
 Set the category type of a NVT Info.
int nvti_set_family (nvti_t *, const gchar *)
 Set the family of a NVT.
int nvti_add_pref (nvti_t *, nvtpref_t *)
 Add a preference to the NVT Info.
gchar * nvti_as_text (const nvti_t *)
 Create a human readable text representation of a NVT Info. This is mainly for debug purposes.
gchar * nvti_as_openvas_nvt_cache_entry (const nvti_t *)
 Create a single line representation of a NVT Info as used in "openvas_nvt_cache" files of OpenVAS-Client.
nvti_tnvti_from_keyfile (const gchar *)
 Read NVT Info from a keyfile.
int nvti_to_keyfile (const nvti_t *, const gchar *)
 Store NVT Info into a keyfile.
nvtis_tnvtis_new ()
 Make a collection of NVT Infos.
void nvtis_free (nvtis_t *)
 Free a collection of NVT Infos.
guint nvtis_size (nvtis_t *)
 Get the size of a collection of NVT Infos.
void nvtis_add (nvtis_t *, nvti_t *)
 Add an NVT Info to a collection of NVT Infos.
nvti_tnvtis_lookup (nvtis_t *, const char *)
 Add an NVT Info to a collection of NVT Infos.

Detailed Description

Protos and data structures for NVT Information data sets.

This file contains the protos for nvti.c


Typedef Documentation

typedef struct nvti nvti_t

The structure of a information record that corresponds to a NVT.

The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.

typedef struct nvtpref nvtpref_t

The structure for a preference of a NVT.

The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.


Function Documentation

int nvti_add_pref ( nvti_t n,
nvtpref_t np 
)

Add a preference to the NVT Info.

Parameters:
nThe NVT Info structure.
npThe NVT preference to add.
Returns:
0 for success. Anything else indicates an error.
gchar* nvti_as_openvas_nvt_cache_entry ( const nvti_t n)

Create a single line representation of a NVT Info as used in "openvas_nvt_cache" files of OpenVAS-Client.

Parameters:
nThe NVT Info structure.
Returns:
NULL (not implemented yet).
Todo:
return A newly allocated string The string needs to be freed with g_free().
gchar* nvti_as_text ( const nvti_t n)

Create a human readable text representation of a NVT Info. This is mainly for debug purposes.

Parameters:
nThe NVT Info structure.
Returns:
A newly allocated string with multi-line text. The string needs to be freed with g_free().
gchar* nvti_bid ( const nvti_t n)

Get the bid references.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The bid list as string. Don't free this.
gint nvti_category ( const nvti_t n)

Get the category for this NVT.

Parameters:
nThe NVT Info structure of which the category should be returned.
Returns:
The category integer code. A value <= 0 indicates it is not set.
gchar* nvti_copyright ( const nvti_t n)

Get the copyright notice.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The copyright string. Don't free this.
gchar* nvti_cve ( const nvti_t n)

Get the CVE references.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The CVE list as string. Don't free this.
gchar* nvti_cvss_base ( const nvti_t n)

Get the CVSS base.

Parameters:
nThe NVT Info structure of which the CVSS base should be returned.
Returns:
The cvss_bas string. Don't free this.
gchar* nvti_dependencies ( const nvti_t n)

Get the dependencies list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The dependencies string. Don't free this.
gchar* nvti_description ( const nvti_t n)

Get the description.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The description string. Don't free this.
gchar* nvti_excluded_keys ( const nvti_t n)

Get the excluded keys list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The excluded keys string. Don't free this.
gchar* nvti_family ( const nvti_t n)

Get the family name.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The family name string. Don't free this.
void nvti_free ( nvti_t n)

Free memory of a nvti structure.

Parameters:
nThe structure to be freed.
nvti_t* nvti_from_keyfile ( const gchar *  fn)

Read NVT Info from a keyfile.

Parameters:
fnThe filename to read from.
Returns:
A newly allocated nvti_t object. The nvti_t needs to be freed with nvti_free().
gchar* nvti_mandatory_keys ( const nvti_t n)

Get the mandatory keys list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The mandatory keys string. Don't free this.
gchar* nvti_name ( const nvti_t n)

Get the name.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The name string. Don't free this.
nvti_t* nvti_new ( void  )

Create a new (empty) nvti structure.

Returns:
NULL in case the memory could not be allocated. Else an empty nvti structure which needs to be released using nvti_free . The whole struct is initalized with 0's.
gchar* nvti_oid ( const nvti_t n)

Get the OID string.

Parameters:
nThe NVT Info structure of which the OID should be returned.
Returns:
The OID string. Don't free this.
nvtpref_t* nvti_pref ( const nvti_t n,
guint  p 
)

Get the n'th preferences of the NVT.

Parameters:
nThe NVT Info structure.
pThe position of the preference to return.
Returns:
The number of preferences. NULL if
guint nvti_pref_len ( const nvti_t n)

Get the number of preferences of the NVT.

Parameters:
nThe NVT Info structure.
Returns:
The number of preferences.
gchar* nvti_required_keys ( const nvti_t n)

Get the required keys list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The required keys string. Don't free this.
gchar* nvti_required_ports ( const nvti_t n)

Get the required ports list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The required ports string. Don't free this.
gchar* nvti_required_udp_ports ( const nvti_t n)

Get the required udp ports list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The required udp ports string. Don't free this.
gchar* nvti_risk_factor ( const nvti_t n)

Get the risk factor.

Parameters:
nThe NVT Info structure of which the risk factor should be returned.
Returns:
The risk_factors string. Don't free this.
int nvti_set_bid ( nvti_t n,
const gchar *  bid 
)

Set the bid references of a NVT.

Parameters:
nThe NVT Info structure.
bidThe bid to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_category ( nvti_t n,
const gint  category 
)

Set the category type of a NVT Info.

Parameters:
nThe NVT Info structure.
categoryThe category to set. Values <= 0 will indicate it is not set.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_copyright ( nvti_t n,
const gchar *  copyright 
)

Set the copyright of a NVT.

Parameters:
nThe NVT Info structure.
copyrightThe copyright to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_cve ( nvti_t n,
const gchar *  cve 
)

Set the CVE references of a NVT.

Parameters:
nThe NVT Info structure.
cveThe cve list to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_cvss_base ( nvti_t n,
const gchar *  cvss_base 
)

Set the CVSS base of an NVT.

Parameters:
nThe NVT Info structure.
tagThe CVSS base to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_dependencies ( nvti_t n,
const gchar *  dependencies 
)

Set the dependencies of a NVT.

Parameters:
nThe NVT Info structure.
dependenciesThe dependencies to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_description ( nvti_t n,
const gchar *  description 
)

Set the description of a NVT.

Parameters:
nThe NVT Info structure.
descriptionThe description to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_excluded_keys ( nvti_t n,
const gchar *  excluded_keys 
)

Set the excluded keys of a NVT.

Parameters:
nThe NVT Info structure.
excluded_keysThe excluded keys to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_family ( nvti_t n,
const gchar *  family 
)

Set the family of a NVT.

Parameters:
nThe NVT Info structure.
familyThe family to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_mandatory_keys ( nvti_t n,
const gchar *  mandatory_keys 
)

Set the mandatory keys of a NVT.

Parameters:
nThe NVT Info structure.
mandatory_keysThe mandatory keys to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_name ( nvti_t n,
const gchar *  name 
)

Set the name of a NVT.

Parameters:
nThe NVT Info structure.
nameThe name to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_oid ( nvti_t n,
const gchar *  oid 
)

Set the OID of a NVT Info.

Parameters:
nThe NVT Info structure.
oidThe OID to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_required_keys ( nvti_t n,
const gchar *  required_keys 
)

Set the required keys of a NVT.

Parameters:
nThe NVT Info structure.
required_keysThe required keys to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_required_ports ( nvti_t n,
const gchar *  required_ports 
)

Set the required ports of a NVT.

Parameters:
nThe NVT Info structure.
required_portsThe required ports to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_required_udp_ports ( nvti_t n,
const gchar *  required_udp_ports 
)

Set the required udp ports of a NVT.

Parameters:
nThe NVT Info structure.
required_udp_portsThe required udp ports to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_risk_factor ( nvti_t n,
const gchar *  risk_factor 
)

Set the risk factor of an NVT.

Parameters:
nThe NVT Info structure.
tagThe risk factor to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_sign_key_ids ( nvti_t n,
const gchar *  sign_key_ids 
)

Set the sign key ids of a NVT.

Parameters:
nThe NVT Info structure.
sign_key_idsThe sign key ids to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_src ( nvti_t n,
const gchar *  src 
)

Set the source identifier for the acutal NVT.

Parameters:
nThe NVT Info structure.
srcThe URI to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_summary ( nvti_t n,
const gchar *  summary 
)

Set the summary of a NVT.

Parameters:
nThe NVT Info structure.
summaryThe summary to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_tag ( nvti_t n,
const gchar *  tag 
)

Set the tags of a NVT.

Parameters:
nThe NVT Info structure.
tagThe tags to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_timeout ( nvti_t n,
const gint  timeout 
)

Set the timout of a NVT Info.

Parameters:
nThe NVT Info structure.
timoutThe timeout to set. Values <= 0 will indicate it is not set.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_version ( nvti_t n,
const gchar *  version 
)

Set the version of a NVT.

Parameters:
nThe NVT Info structure.
versionThe version to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
int nvti_set_xref ( nvti_t n,
const gchar *  xref 
)

Set the xrefs of a NVT.

Parameters:
nThe NVT Info structure.
xrefThe xrefs to set. A copy will be created from this.
Returns:
0 for success. Anything else indicates an error.
gchar* nvti_sign_key_ids ( const nvti_t n)

Get the sign key ids (fingerptints) list.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The sign key ids string. Don't free this.
gchar* nvti_src ( const nvti_t n)

Get the source URI of a NVT Info.

Parameters:
nThe NVT Info structure of which the source URI should be returned.
Returns:
The source URI string. This can be NULL if the NVT Info was created in memory. It can also be a file path. Don't free this.
gchar* nvti_summary ( const nvti_t n)

Get the summary.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The summary string. Don't free this.
gchar* nvti_tag ( const nvti_t n)

Get the tag.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The tags string. Don't free this.
gint nvti_timeout ( const nvti_t n)

Get the timeout for this NVT.

Parameters:
nThe NVT Info structure of which the timeout should be returned.
Returns:
The timeout integer number. A value <= 0 indicates it is not set.
int nvti_to_keyfile ( const nvti_t n,
const gchar *  fn 
)

Store NVT Info into a keyfile.

Parameters:
nThe NVT Info object to store.
fnThe filename to write to.
Returns:
0 on success.
Todo:
Anything else indicates an error.
gchar* nvti_version ( const nvti_t n)

Get the version.

Parameters:
nThe NVT Info structure of which the OID should be returned.
Returns:
The version string. Don't free this.
gchar* nvti_xref ( const nvti_t n)

Get the xref's.

Parameters:
nThe NVT Info structure of which the name should be returned.
Returns:
The xref string. Don't free this.
void nvtis_add ( nvtis_t nvtis,
nvti_t nvti 
)

Add an NVT Info to a collection of NVT Infos.

Parameters:
nvtisThe collection of NVT Infos.
nvtiThe NVT Info to add.
void nvtis_free ( nvtis_t nvtis)

Free a collection of NVT Infos.

Parameters:
nvtisThe collection of NVT Infos.
nvti_t* nvtis_lookup ( nvtis_t nvtis,
const char *  oid 
)

Add an NVT Info to a collection of NVT Infos.

Parameters:
nvtisThe collection of NVT Infos.
oidThe OID of the NVT.
Returns:
The NVT Info, if found, else NULL.
guint nvtis_size ( nvtis_t nvtis)

Get the size of a collection of NVT Infos.

Returns:
The number of entries in the collection.
gchar* nvtpref_default ( const nvtpref_t np)

Get the Default of a NVT Preference.

Parameters:
npThe NVT Pref structure of which the Default should be returned.
Returns:
The default string. Don't free this.
void nvtpref_free ( nvtpref_t np)

Free memory of a nvtpref structure.

Parameters:
nThe structure to be freed.
gchar* nvtpref_name ( const nvtpref_t np)

Get the Name of a NVT Preference.

Parameters:
npThe NVT Pref structure of which the Name should be returned.
Returns:
The name string. Don't free this.
nvtpref_t* nvtpref_new ( gchar *  name,
gchar *  type,
gchar *  dflt 
)

Create a new nvtpref structure filled with the given values.

Parameters:
nameThe name to be set. A copy will created of this.
typeThe type to be set. A copy will created of this.
dfltThe default to be set. A copy will created of this.
Returns:
NULL in case the memory could not be allocated. Else a nvtpref structure which needs to be released using nvtpref_free .
gchar* nvtpref_type ( const nvtpref_t np)

Get the Type of a NVT Preference.

Parameters:
npThe NVT Pref structure of which the Type should be returned.
Returns:
The type string. Don't free this.