nvti.c File Reference

Implementation of API to handle NVT Info datasets. More...

`#include "nvti.h"`
`#include <stdio.h>`
`#include <string.h>`
`#include <strings.h>`
`#include <time.h>`

## Data Structures

struct | vtref
| The structure for a cross reference of a VT. More...
struct | vtseverity
| The structure for a severity of a VT. More...
struct | nvti
| The structure of a information record that corresponds to a NVT. More...
struct | nvtpref
| The structure for a preference of a NVT. More...

## Macros

#define | _XOPEN_SOURCE
#define | G_LOG_DOMAIN "libgvm base"
| GLib log domain. More...

## Typedefs

typedef struct vtref | vtref_t
| The structure for a cross reference of a VT. More...
typedef struct vtseverity | vtseverity_t
| The structure for a severity of a VT. More...
typedef struct nvti | nvti_t
| The structure of a information record that corresponds to a NVT. More...
typedef struct nvtpref | nvtpref_t
| The structure for a preference of a NVT. More...

## Functions

vtref_t * | vtref_new (const gchar *type, const gchar *ref_id, const gchar *ref_text)
| Create a new vtref structure filled with the given values. More...
void | vtref_free (vtref_t *ref)
| Free memory of a vtref structure. More...
const gchar * | vtref_type (const vtref_t *r)
| Get the type of a reference. More...
const gchar * | vtref_id (const vtref_t *r)
| Get the id of a reference. More...
const gchar * | vtref_text (const vtref_t *r)
| Get the text of a reference. More...
vtseverity_t * | vtseverity_new (const gchar *type, const gchar *origin, int date, double score, const gchar *value)
| Create a new vtseverity structure filled with the given values. More...
void | vtseverity_free (vtseverity_t *s)
| Free memory of a vtseverity structure. More...
const gchar * | vtseverity_type (const vtseverity_t *s)
| Get the type of a severity. More...
const gchar * | vtseverity_origin (const vtseverity_t *s)
| Get the origin of a severity. More...
const gchar * | vtseverity_value (const vtseverity_t *s)
| Get the value of a severity. More...
int | vtseverity_date (const vtseverity_t *s)
| Get the date of a severity. More...
double | vtseverity_score (const vtseverity_t *s)
| Get the score of a severity. More...
static time_t | parse_nvt_timestamp (const gchar *str_time)
| Try convert an NVT tag time string into epoch time or return 0 upon parse errors. More...
int | nvti_add_vtref (nvti_t *vt, vtref_t *ref)
| Add a reference to the VT Info. More...
int | nvti_add_vtseverity (nvti_t *vt, vtseverity_t *s)
| Add a severity to the VT Info. More...
nvtpref_t * | nvtpref_new (int id, gchar *name, gchar *type, gchar *dflt)
| Create a new nvtpref structure filled with the given values. More...
void | nvtpref_free (nvtpref_t *np)
| Free memory of a nvtpref structure. More...
int | nvtpref_id (const nvtpref_t *np)
| Get the ID of a NVT Preference. More...
gchar * | nvtpref_name (const nvtpref_t *np)
| Get the Name of a NVT Preference. More...
gchar * | nvtpref_type (const nvtpref_t *np)
| Get the Type of a NVT Preference. More...
gchar * | nvtpref_default (const nvtpref_t *np)
| Get the Default of a NVT Preference. More...
nvti_t * | nvti_new (void)
| Create a new (empty) nvti structure. More...
void | nvti_free (nvti_t *n)
| Free memory of a nvti structure. More...
gchar * | nvti_oid (const nvti_t *n)
| Get the OID string. More...
gchar * | nvti_name (const nvti_t *n)
| Get the name. More...
gchar * | nvti_summary (const nvti_t *n)
| Get the summary. More...
gchar * | nvti_insight (const nvti_t *n)
| Get the text about insight. More...
gchar * | nvti_affected (const nvti_t *n)
| Get the text about affected systems. More...
gchar * | nvti_impact (const nvti_t *n)
| Get the text about impact. More...
time_t | nvti_creation_time (const nvti_t *n)
| Get the creation time. More...
time_t | nvti_modification_time (const nvti_t *n)
| Get the modification time. More...
guint | nvti_vtref_len (const nvti_t *n)
| Get the number of references of the NVT. More...
vtref_t * | nvti_vtref (const nvti_t *n, guint p)
| Get the n'th reference of the NVT. More...
gchar * | nvti_refs (const nvti_t *n, const gchar *type, const gchar *exclude_types, guint use_types)
| Get references as string. More...
guint | nvti_vtseverities_len (const nvti_t *n)
| Get the number of severities of the NVT. More...
vtseverity_t * | nvti_vtseverity (const nvti_t *n, guint p)
| Get the n'th reference of the NVT. More...
double | nvti_severity_score (const nvti_t *n)
| Get the maximum severity score. More...
gchar * | nvti_solution (const nvti_t *n)
| Get the solution. More...
gchar * | nvti_solution_type (const nvti_t *n)
| Get the solution type. More...
gchar * | nvti_solution_method (const nvti_t *n)
| Get the solution method. More...
gchar * | nvti_tag (const nvti_t *n)
| Get the tags. More...
gchar * | nvti_get_tag (const nvti_t *n, const gchar *name)
| Get a tag value by a tag name. More...
gchar * | nvti_cvss_base (const nvti_t *n)
| Get the CVSS base. More...
gchar * | nvti_dependencies (const nvti_t *n)
| Get the dependencies list. More...
gchar * | nvti_required_keys (const nvti_t *n)
| Get the required keys list. More...
gchar * | nvti_mandatory_keys (const nvti_t *n)
| Get the mandatory keys list. More...
gchar * | nvti_excluded_keys (const nvti_t *n)
| Get the excluded keys list. More...
gchar * | nvti_required_ports (const nvti_t *n)
| Get the required ports list. More...
gchar * | nvti_required_udp_ports (const nvti_t *n)
| Get the required udp ports list. More...
gchar * | nvti_detection (const nvti_t *n)
| Get the text about detection. More...
gchar * | nvti_qod_type (const nvti_t *n)
| Get the QoD type. More...
gchar * | nvti_qod (const nvti_t *n)
| Get the QoD. More...
gchar * | nvti_family (const nvti_t *n)
| Get the family name. More...
guint | nvti_pref_len (const nvti_t *n)
| Get the number of preferences of the NVT. More...
const nvtpref_t * | nvti_pref (const nvti_t *n, guint p)
| Get the n'th preferences of the NVT. More...
gint | nvti_timeout (const nvti_t *n)
| Get the timeout for this NVT. More...
gint | nvti_category (const nvti_t *n)
| Get the category for this NVT. More...
int | nvti_set_oid (nvti_t *n, const gchar *oid)
| Set the OID of a NVT Info. More...
int | nvti_set_name (nvti_t *n, const gchar *name)
| Set the name of a NVT. More...
int | nvti_set_summary (nvti_t *n, const gchar *summary)
| Set the summary of a NVT. More...
int | nvti_set_insight (nvti_t *n, const gchar *insight)
| Set the insight text of a NVT. More...
int | nvti_set_affected (nvti_t *n, const gchar *affected)
| Set the affected text of a NVT. More...
int | nvti_set_impact (nvti_t *n, const gchar *impact)
| Set the impact text of a NVT. More...
int | nvti_set_creation_time (nvti_t *n, const time_t creation_time)
| Set the creation time of a NVT. More...
int | nvti_set_modification_time (nvti_t *n, const time_t modification_time)
| Set the modification time of a NVT. More...
int | nvti_set_solution (nvti_t *n, const gchar *solution)
| Set the solution of a NVT. More...
int | nvti_set_solution_type (nvti_t *n, const gchar *solution_type)
| Set the solution type of a NVT. More...
int | nvti_set_solution_method (nvti_t *n, const gchar *solution_method)
| Set the solution method of a NVT. More...
int | nvti_add_tag (nvti_t *n, const gchar *name, const gchar *value)
| Add a tag to the NVT tags. The tag names "severity_date", "last_modification" and "creation_date" are treated special: The value is expected to be a timestamp and it is being converted to seconds since epoch before added as a tag value. The tag name "cvss_base" will be ignored and not added. More...
int | nvti_set_tag (nvti_t *n, const gchar *tag)
| Set the tags of a NVT. More...
int | nvti_set_cvss_base (nvti_t *n, const gchar *cvss_base)
| Set the CVSS base of an NVT. More...
int | nvti_set_dependencies (nvti_t *n, const gchar *dependencies)
| Set the dependencies of a NVT. More...
int | nvti_set_required_keys (nvti_t *n, const gchar *required_keys)
| Set the required keys of a NVT. More...
int | nvti_set_mandatory_keys (nvti_t *n, const gchar *mandatory_keys)
| Set the mandatory keys of a NVT. More...
int | nvti_set_excluded_keys (nvti_t *n, const gchar *excluded_keys)
| Set the excluded keys of a NVT. More...
int | nvti_set_required_ports (nvti_t *n, const gchar *required_ports)
| Set the required ports of a NVT. More...
int | nvti_set_required_udp_ports (nvti_t *n, const gchar *required_udp_ports)
| Set the required udp ports of a NVT. More...
int | nvti_set_detection (nvti_t *n, const gchar *detection)
| Set the detection text of a NVT. More...
int | nvti_set_qod_type (nvti_t *n, const gchar *qod_type)
| Set the QoD type of a NVT. More...
int | nvti_set_qod (nvti_t *n, const gchar *qod)
| Set the QoD of a NVT. More...
int | nvti_set_family (nvti_t *n, const gchar *family)
| Set the family of a NVT. More...
int | nvti_set_timeout (nvti_t *n, const gint timeout)
| Set the timeout of a NVT Info. More...
int | nvti_set_category (nvti_t *n, const gint category)
| Set the category type of a NVT Info. More...
int | nvti_add_refs (nvti_t *n, const gchar *type, const gchar *ref_ids, const gchar *ref_text)
| Add many new vtref from a comma-separated list. More...
int | nvti_add_required_keys (nvti_t *n, const gchar *key)
| Add a required key of a NVT. More...
int | nvti_add_mandatory_keys (nvti_t *n, const gchar *key)
| Add a mandatory key of a NVT. More...
int | nvti_add_excluded_keys (nvti_t *n, const gchar *key)
| Add a excluded key of a NVT. More...
int | nvti_add_required_ports (nvti_t *n, const gchar *port)
| Add a required port of a NVT. More...
int | nvti_add_required_udp_ports (nvti_t *n, const gchar *port)
| Add a required udp port of a NVT. More...
int | nvti_add_pref (nvti_t *n, nvtpref_t *np)
| Add a preference to the NVT Info. More...
static void | free_nvti_for_hash_table (gpointer nvti)
| Free an NVT Info, for g_hash_table_destroy. More...
nvtis_t * | nvtis_new (void)
| Make a collection of NVT Infos. More...
void | nvtis_free (nvtis_t *nvtis)
| Free a collection of NVT Infos. More...
void | nvtis_add (nvtis_t *nvtis, nvti_t *nvti)
| Add an NVT Info to a collection of NVT Infos. More...
nvti_t * | nvtis_lookup (nvtis_t *nvtis, const char *oid)
| Add an NVT Info to a collection of NVT Infos. More...

## Detailed Description

Implementation of API to handle NVT Info datasets.

This file contains all methods to handle NVT Information datasets (nvti_t).

The module consequently uses glib datatypes and api for memory management etc.

## Macro Definition Documentation

## _XOPEN_SOURCE

#define _XOPEN_SOURCE

## G_LOG_DOMAIN

#define G_LOG_DOMAIN "libgvm base"

GLib log domain.

## Typedef Documentation

## nvti_t

typedef struct nvti nvti_t

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

## nvtpref_t

typedef struct nvtpref nvtpref_t

The structure for a preference of a NVT.

## vtref_t

typedef struct vtref vtref_t

The structure for a cross reference of a VT.

The elements of this structure should only be accessed by the respective functions.

## vtseverity_t

typedef struct vtseverity vtseverity_t

The structure for a severity of a VT.

VTs can have one or several severities.

## Function Documentation

## free_nvti_for_hash_table()

static void free_nvti_for_hash_table | ( | gpointer | nvti | ) |

static

Free an NVT Info, for g_hash_table_destroy.

Parameters

  nvti | The NVT Info.

## nvti_add_excluded_keys()

int nvti_add_excluded_keys | ( | nvti_t * | n,
|  | const gchar * | key
| ) |  |

Add a excluded key of a NVT.

Parameters

  n | The NVT Info structure.
  key | The excluded key to add. A copy will be created from this.

Returns
  0 for success. 1 if n was NULL. 2 if key was NULL.

## nvti_add_mandatory_keys()

int nvti_add_mandatory_keys | ( | nvti_t * | n,
|  | const gchar * | key
| ) |  |

Add a mandatory key of a NVT.

Parameters

  n | The NVT Info structure.
  key | The mandatory key to add. A copy will be created from this.

Returns
  0 for success. 1 if n was NULL. 2 if key was NULL.

## nvti_add_pref()

int nvti_add_pref | ( | nvti_t * | n,
|  | nvtpref_t * | np
| ) |  |

Add a preference to the NVT Info.

Parameters

  n | The NVT Info structure.
  np | The NVT preference to add.

Returns
  0 for success. Anything else indicates an error.

## nvti_add_refs()

int nvti_add_refs | ( | nvti_t * | n,
|  | const gchar * | type,
|  | const gchar * | ref_ids,
|  | const gchar * | ref_text
| ) |  |

Add many new vtref from a comma-separated list.

Parameters

  n | The NVTI where to add the references.
  type | The type for all references. If NULL, then for ref_ids a syntax is expected that includes the type like "type:id,type:id".
  ref_ids | A CSV of reference to be added.
  ref_text | The optional text accompanying all references.

Returns
  0 for success. 1 if n was NULL, 2 if ref_ids was NULL.

## nvti_add_required_keys()

int nvti_add_required_keys | ( | nvti_t * | n,
|  | const gchar * | key
| ) |  |

Add a required key of a NVT.

Parameters

  n | The NVT Info structure.
  key | The required key to add. A copy will be created from this.

Returns
  0 for success. 1 if n was NULL. 2 if key was NULL.

## nvti_add_required_ports()

int nvti_add_required_ports | ( | nvti_t * | n,
|  | const gchar * | port
| ) |  |

Add a required port of a NVT.

Parameters

  n | The NVT Info structure.
  port | The required port to add. A copy will be created from this.

Returns
  0 for success. 1 if n was NULL. 2 if port was NULL.

## nvti_add_required_udp_ports()

int nvti_add_required_udp_ports | ( | nvti_t * | n,
|  | const gchar * | port
| ) |  |

Add a required udp port of a NVT.

Parameters

  n | The NVT Info structure.
  port | The required udp port to add. A copy will be created from this.

Returns
  0 for success. 1 if n was NULL. 2 if port was NULL.

## nvti_add_tag()

int nvti_add_tag | ( | nvti_t * | n,
|  | const gchar * | name,
|  | const gchar * | value
| ) |  |

Add a tag to the NVT tags. The tag names "severity_date", "last_modification" and "creation_date" are treated special: The value is expected to be a timestamp and it is being converted to seconds since epoch before added as a tag value. The tag name "cvss_base" will be ignored and not added.

Parameters

  n | The NVT Info structure.
  name | The tag name. A copy will be created from this.
  value | The tag value. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_add_vtref()

int nvti_add_vtref | ( | nvti_t * | vt,
|  | vtref_t * | ref
| ) |  |

Add a reference to the VT Info.

Parameters

  vt | The VT Info structure.
  ref | The VT reference to add.

Returns
  0 for success. Anything else indicates an error.

## nvti_add_vtseverity()

int nvti_add_vtseverity | ( | nvti_t * | vt,
|  | vtseverity_t * | s
| ) |  |

Add a severity to the VT Info.

Parameters

  vt | The VT Info structure.
  ref | The VT severity to add.

Returns
  0 for success. Anything else indicates an error.

## nvti_affected()

gchar* nvti_affected | ( | const nvti_t * | n | ) |

Get the text about affected systems.

Parameters

  n | The NVT Info structure of which the affected description should be returned.

Returns
  The affected string. Don't free this.

## nvti_category()

gint nvti_category | ( | const nvti_t * | n | ) |

Get the category for this NVT.

Parameters

  n | The NVT Info structure of which the category should be returned.

Returns
  The category integer code. A value <= 0 indicates it is not set.

## nvti_creation_time()

time_t nvti_creation_time | ( | const nvti_t * | n | ) |

Get the creation time.

Parameters

  n | The NVT Info structure of which the creation time should be returned.

Returns
  The creation time in seconds since epoch.

## nvti_cvss_base()

gchar* nvti_cvss_base | ( | const nvti_t * | n | ) |

Get the CVSS base.

Parameters

  n | The NVT Info structure of which the CVSS base should be returned.

Returns
  The cvss_base string. Don't free this.

## nvti_dependencies()

gchar* nvti_dependencies | ( | const nvti_t * | n | ) |

Get the dependencies list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The dependencies string. Don't free this.

## nvti_detection()

gchar* nvti_detection | ( | const nvti_t * | n | ) |

Get the text about detection.

Parameters

  n | The NVT Info structure of which the detection should be returned.

Returns
  The detection string. Don't free this.

## nvti_excluded_keys()

gchar* nvti_excluded_keys | ( | const nvti_t * | n | ) |

Get the excluded keys list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The excluded keys string. Don't free this.

## nvti_family()

gchar* nvti_family | ( | const nvti_t * | n | ) |

Get the family name.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The family name string. Don't free this.

## nvti_free()

void nvti_free | ( | nvti_t * | n | ) |

Free memory of a nvti structure.

Parameters

  n | The structure to be freed.

## nvti_get_tag()

gchar* nvti_get_tag | ( | const nvti_t * | n,
|  | const gchar * | name
| ) |  |

Get a tag value by a tag name.

Parameters

  n | The NVT Info structure from where to search for the tag name.
  name | The name of the tag for which to return the value.

Returns
  The tag value string as a copy or NULL if not found. Needs to be free'd.

## nvti_impact()

gchar* nvti_impact | ( | const nvti_t * | n | ) |

Get the text about impact.

Parameters

  n | The NVT Info structure of which the impact description should be returned.

Returns
  The impact string. Don't free this.

## nvti_insight()

gchar* nvti_insight | ( | const nvti_t * | n | ) |

Get the text about insight.

Parameters

  n | The NVT Info structure of which the insight description should be returned.

Returns
  The insight string. Don't free this.

## nvti_mandatory_keys()

gchar* nvti_mandatory_keys | ( | const nvti_t * | n | ) |

Get the mandatory keys list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The mandatory keys string. Don't free this.

## nvti_modification_time()

time_t nvti_modification_time | ( | const nvti_t * | n | ) |

Get the modification time.

Parameters

  n | The NVT Info structure of which the modification time should be returned.

Returns
  The modification time in seconds since epoch.

## nvti_name()

gchar* nvti_name | ( | const nvti_t * | n | ) |

Get the name.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The name string. Don't free this.

## nvti_new()

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 initialized with 0's.

## nvti_oid()

gchar* nvti_oid | ( | const nvti_t * | n | ) |

Get the OID string.

Parameters

  n | The NVT Info structure of which the OID should be returned.

Returns
  The OID string. Don't free this.

## nvti_pref()

const nvtpref_t* nvti_pref | ( | const nvti_t * | n,
|  | guint | p
| ) |  |

Get the n'th preferences of the NVT.

Parameters

  n | The NVT Info structure.
  p | The position of the preference to return.

Returns
  The preference. NULL on error.

## nvti_pref_len()

guint nvti_pref_len | ( | const nvti_t * | n | ) |

Get the number of preferences of the NVT.

Parameters

  n | The NVT Info structure.

Returns
  The number of preferences.

## nvti_qod()

gchar* nvti_qod | ( | const nvti_t * | n | ) |

Get the QoD.

Parameters

  n | The NVT Info structure of which the QoD should be returned.

Returns
  The QoD as string. Don't free this.

## nvti_qod_type()

gchar* nvti_qod_type | ( | const nvti_t * | n | ) |

Get the QoD type.

Parameters

  n | The NVT Info structure of which the QoD type should be returned.

Returns
  The QoD type as string. Don't free this.

## nvti_refs()

gchar* nvti_refs | ( | const nvti_t * | n,
|  | const gchar * | type,
|  | const gchar * | exclude_types,
|  | guint | use_types
| ) |  |

Get references as string.

Parameters

  n | The NVT Info structure of which the references should be returned.
  type | Optional type to collect. If NULL, all types are collected.
  exclude_types | Optional CSC list of types to exclude from collection. If NULL, no types are excluded.
  use_types | If 0, then a simple comma separated list will be returned. If not 0, then for each reference the syntax "type:id" is applied.

Returns
  The references as string. This needs to be free'd. The format of the string depends on the "use_types" parameter. If use_types is 0 it is a comma-separated list "id, id, id" is returned. If use_types is not 0 a comma-separated list like "type:id, type:id, type:id" is returned. NULL is returned in case n is NULL.

## nvti_required_keys()

gchar* nvti_required_keys | ( | const nvti_t * | n | ) |

Get the required keys list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The required keys string. Don't free this.

## nvti_required_ports()

gchar* nvti_required_ports | ( | const nvti_t * | n | ) |

Get the required ports list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The required ports string. Don't free this.

## nvti_required_udp_ports()

gchar* nvti_required_udp_ports | ( | const nvti_t * | n | ) |

Get the required udp ports list.

Parameters

  n | The NVT Info structure of which the name should be returned.

Returns
  The required udp ports string. Don't free this.

## nvti_set_affected()

int nvti_set_affected | ( | nvti_t * | n,
|  | const gchar * | affected
| ) |  |

Set the affected text of a NVT.

Parameters

  n | The NVT Info structure.
  affected | The affected text to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_category()

int nvti_set_category | ( | nvti_t * | n,
|  | const gint | category
| ) |  |

Set the category type of a NVT Info.

Parameters

  n | The NVT Info structure.
  category | The category to set. Values <= 0 will indicate it is not set.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_creation_time()

int nvti_set_creation_time | ( | nvti_t * | n,
|  | const time_t | creation_time
| ) |  |

Set the creation time of a NVT.

Parameters

  n | The NVT Info structure.
  creation_time | The creation time to set.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_cvss_base()

int nvti_set_cvss_base | ( | nvti_t * | n,
|  | const gchar * | cvss_base
| ) |  |

Set the CVSS base of an NVT.

Parameters

  n | The NVT Info structure.
  cvss_base | The CVSS base to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_dependencies()

int nvti_set_dependencies | ( | nvti_t * | n,
|  | const gchar * | dependencies
| ) |  |

Set the dependencies of a NVT.

Parameters

  n | The NVT Info structure.
  dependencies | The dependencies to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_detection()

int nvti_set_detection | ( | nvti_t * | n,
|  | const gchar * | detection
| ) |  |

Set the detection text of a NVT.

Parameters

  n | The NVT Info structure.
  detection | The detection text to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_excluded_keys()

int nvti_set_excluded_keys | ( | nvti_t * | n,
|  | const gchar * | excluded_keys
| ) |  |

Set the excluded keys of a NVT.

Parameters

  n | The NVT Info structure.
  excluded_keys | The excluded keys to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_family()

int nvti_set_family | ( | nvti_t * | n,
|  | const gchar * | family
| ) |  |

Set the family of a NVT.

Parameters

  n | The NVT Info structure.
  family | The family to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_impact()

int nvti_set_impact | ( | nvti_t * | n,
|  | const gchar * | impact
| ) |  |

Set the impact text of a NVT.

Parameters

  n | The NVT Info structure.
  affected | The impact text to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_insight()

int nvti_set_insight | ( | nvti_t * | n,
|  | const gchar * | insight
| ) |  |

Set the insight text of a NVT.

Parameters

  n | The NVT Info structure.
  insight | The insight text to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_mandatory_keys()

int nvti_set_mandatory_keys | ( | nvti_t * | n,
|  | const gchar * | mandatory_keys
| ) |  |

Set the mandatory keys of a NVT.

Parameters

  n | The NVT Info structure.
  mandatory_keys | The mandatory keys to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_modification_time()

int nvti_set_modification_time | ( | nvti_t * | n,
|  | const time_t | modification_time
| ) |  |

Set the modification time of a NVT.

Parameters

  n | The NVT Info structure.
  modification_time | The modification time to set.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_name()

int nvti_set_name | ( | nvti_t * | n,
|  | const gchar * | name
| ) |  |

Set the name of a NVT.

Parameters

  n | The NVT Info structure.
  name | The name to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_oid()

int nvti_set_oid | ( | nvti_t * | n,
|  | const gchar * | oid
| ) |  |

Set the OID of a NVT Info.

Parameters

  n | The NVT Info structure.
  oid | The OID to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_qod()

int nvti_set_qod | ( | nvti_t * | n,
|  | const gchar * | qod
| ) |  |

Set the QoD of a NVT.

Parameters

  n | The NVT Info structure.
  qod | The QoD to set. A copy will be created from this. The string is not checked, any string is accepted as type.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_qod_type()

int nvti_set_qod_type | ( | nvti_t * | n,
|  | const gchar * | qod_type
| ) |  |

Set the QoD type of a NVT.

Parameters

  n | The NVT Info structure.
  qod_type | The QoD type to set. A copy will be created from this. The string is not checked, any string is accepted as type.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_required_keys()

int nvti_set_required_keys | ( | nvti_t * | n,
|  | const gchar * | required_keys
| ) |  |

Set the required keys of a NVT.

Parameters

  n | The NVT Info structure.
  required_keys | The required keys to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_required_ports()

int nvti_set_required_ports | ( | nvti_t * | n,
|  | const gchar * | required_ports
| ) |  |

Set the required ports of a NVT.

Parameters

  n | The NVT Info structure.
  required_ports | The required ports to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_required_udp_ports()

int nvti_set_required_udp_ports | ( | nvti_t * | n,
|  | const gchar * | required_udp_ports
| ) |  |

Set the required udp ports of a NVT.

Parameters

  n | The NVT Info structure.
  required_udp_ports | The required udp ports to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_solution()

int nvti_set_solution | ( | nvti_t * | n,
|  | const gchar * | solution
| ) |  |

Set the solution of a NVT.

Parameters

  n | The NVT Info structure.
  solution | The solution to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_solution_method()

int nvti_set_solution_method | ( | nvti_t * | n,
|  | const gchar * | solution_method
| ) |  |

Set the solution method of a NVT.

Parameters

  n | The NVT Info structure.
  solution_method | The solution method to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_solution_type()

int nvti_set_solution_type | ( | nvti_t * | n,
|  | const gchar * | solution_type
| ) |  |

Set the solution type of a NVT.

Parameters

  n | The NVT Info structure.
  solution_type | The solution type to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_summary()

int nvti_set_summary | ( | nvti_t * | n,
|  | const gchar * | summary
| ) |  |

Set the summary of a NVT.

Parameters

  n | The NVT Info structure.
  solution | The summary to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_tag()

int nvti_set_tag | ( | nvti_t * | n,
|  | const gchar * | tag
| ) |  |

Set the tags of a NVT.

Parameters

  n | The NVT Info structure.
  tag | The tags to set. A copy will be created from this.

Returns
  0 for success. Anything else indicates an error.

## nvti_set_timeout()

int nvti_set_timeout | ( | nvti_t * | n,
|  | const gint | timeout
| ) |  |

Set the timeout of a NVT Info.

Parameters

  n | The NVT Info structure.
  timeout | The timeout to set. Values <= 0 will indicate it is not set.

Returns
  0 for success. Anything else indicates an error.

## nvti_severity_score()

double nvti_severity_score | ( | const nvti_t * | n | ) |

Get the maximum severity score.

Parameters

  n | The NVT Info structure.

Returns
  The severity score, -1 indicates an error.

## nvti_solution()

gchar* nvti_solution | ( | const nvti_t * | n | ) |

Get the solution.

Parameters

  n | The NVT Info structure of which the solution should be returned.

Returns
  The solution string. Don't free this.

## nvti_solution_method()

gchar* nvti_solution_method | ( | const nvti_t * | n | ) |

Get the solution method.

Parameters

  n | The NVT Info structure of which the solution method should be returned.

Returns
  The solution method string. Don't free this.

## nvti_solution_type()

gchar* nvti_solution_type | ( | const nvti_t * | n | ) |

Get the solution type.

Parameters

  n | The NVT Info structure of which the solution type should be returned.

Returns
  The solution type string. Don't free this.

## nvti_summary()

gchar* nvti_summary | ( | const nvti_t * | n | ) |

Get the summary.

Parameters

  n | The NVT Info structure of which the summary should be returned.

Returns
  The summary string. Don't free this.

## nvti_tag()

gchar* nvti_tag | ( | const nvti_t * | n | ) |

Get the tags.

Parameters

  n | The NVT Info structure of which the tags should be returned.

Returns
  The tags string. Don't free this.

## nvti_timeout()

gint nvti_timeout | ( | const nvti_t * | n | ) |

Get the timeout for this NVT.

Parameters

  n | The NVT Info structure of which the timeout should be returned.

Returns
  The timeout integer number. A value <= 0 indicates it is not set.

## nvti_vtref()

vtref_t* nvti_vtref | ( | const nvti_t * | n,
|  | guint | p
| ) |  |

Get the n'th reference of the NVT.

Parameters

  n | The NVT Info structure.
  p | The position of the reference to return.

Returns
  The reference. NULL on error.

## nvti_vtref_len()

guint nvti_vtref_len | ( | const nvti_t * | n | ) |

Get the number of references of the NVT.

Parameters

  n | The NVT Info structure.

Returns
  The number of references.

## nvti_vtseverities_len()

guint nvti_vtseverities_len | ( | const nvti_t * | n | ) |

Get the number of severities of the NVT.

Parameters

  n | The NVT Info structure.

Returns
  The number of severities.

## nvti_vtseverity()

vtseverity_t* nvti_vtseverity | ( | const nvti_t * | n,
|  | guint | p
| ) |  |

Get the n'th reference of the NVT.

Parameters

  n | The NVT Info structure.
  p | The position of the reference to return.

Returns
  The reference. NULL on error.

## nvtis_add()

void nvtis_add | ( | nvtis_t * | nvtis,
|  | nvti_t * | nvti
| ) |  |

Add an NVT Info to a collection of NVT Infos.

Parameters

  nvtis | The collection of NVT Infos.
  nvti | The NVT Info to add.

## nvtis_free()

void nvtis_free | ( | nvtis_t * | nvtis | ) |

Free a collection of NVT Infos.

Parameters

  nvtis | The collection of NVT Infos.

## nvtis_lookup()

nvti_t* nvtis_lookup | ( | nvtis_t * | nvtis,
|  | const char * | oid
| ) |  |

Add an NVT Info to a collection of NVT Infos.

Parameters

  nvtis | The collection of NVT Infos.
  oid | The OID of the NVT.

Returns
  The NVT Info, if found, else NULL.

## nvtis_new()

nvtis_t* nvtis_new | ( | void |  | ) |

Make a collection of NVT Infos.

Returns
  An empty collection of NVT Infos.

## nvtpref_default()

gchar* nvtpref_default | ( | const nvtpref_t * | np | ) |

Get the Default of a NVT Preference.

Parameters

  np | The NVT Pref structure of which the Default should be returned.

Returns
  The default string. Don't free this.

## nvtpref_free()

void nvtpref_free | ( | nvtpref_t * | np | ) |

Free memory of a nvtpref structure.

Parameters

  np | The structure to be freed.

## nvtpref_id()

int nvtpref_id | ( | const nvtpref_t * | np | ) |

Get the ID of a NVT Preference.

Parameters

  np | The NVT Pref structure of which the Name should be returned.

Returns
  The ID value.

## nvtpref_name()

gchar* nvtpref_name | ( | const nvtpref_t * | np | ) |

Get the Name of a NVT Preference.

Parameters

  np | The NVT Pref structure of which the Name should be returned.

Returns
  The name string. Don't free this.

## nvtpref_new()

nvtpref_t* nvtpref_new | ( | int | id,
|  | gchar * | name,
|  | gchar * | type,
|  | gchar * | dflt
| ) |  |

Create a new nvtpref structure filled with the given values.

Parameters

  id | The ID to be set.
  name | The name to be set. A copy will created of this.
  type | The type to be set. A copy will created of this.
  dflt | The 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 .

## nvtpref_type()

gchar* nvtpref_type | ( | const nvtpref_t * | np | ) |

Get the Type of a NVT Preference.

Parameters

  np | The NVT Pref structure of which the Type should be returned.

Returns
  The type string. Don't free this.

## parse_nvt_timestamp()

static time_t parse_nvt_timestamp | ( | const gchar * | str_time | ) |

static

Try convert an NVT tag time string into epoch time or return 0 upon parse errors.

Parameters

  [in] | str_time | Time stamp as string in one of the forms used in NVTs.

Returns
  Time as seconds since the epoch.

## vtref_free()

void vtref_free | ( | vtref_t * | ref | ) |

Free memory of a vtref structure.

Parameters

  ref | The structure to be freed.

## vtref_id()

const gchar* vtref_id | ( | const vtref_t * | r | ) |

Get the id of a reference.

Parameters

  r | The VT Reference structure of which the id should be returned.

Returns
  The id string. Don't free this.

## vtref_new()

vtref_t* vtref_new | ( | const gchar * | type,
|  | const gchar * | ref_id,
|  | const gchar * | ref_text
| ) |  |

Create a new vtref structure filled with the given values.

Parameters

  type | The type to be set.
  ref_id | The actual reference to be set.
  ref_text | The optional text accompanying a reference.

Returns
  NULL in case the memory could not be allocated. Else a vtref structure which needs to be released using vtref_free .

## vtref_text()

const gchar* vtref_text | ( | const vtref_t * | r | ) |

Get the text of a reference.

Parameters

  r | The VT Reference structure of which the id should be returned.

Returns
  The id string. Don't free this.

## vtref_type()

const gchar* vtref_type | ( | const vtref_t * | r | ) |

Get the type of a reference.

Parameters

  r | The VT Reference structure of which the type should be returned.

Returns
  The type string. Don't free this.

## vtseverity_date()

int vtseverity_date | ( | const vtseverity_t * | s | ) |

Get the date of a severity.

Parameters

  s | The VT Severity structure of which the date should be returned.

Returns
  The date.

## vtseverity_free()

void vtseverity_free | ( | vtseverity_t * | s | ) |

Free memory of a vtseverity structure.

Parameters

  s | The structure to be freed.

## vtseverity_new()

vtseverity_t* vtseverity_new | ( | const gchar * | type,
|  | const gchar * | origin,
|  | int | date,
|  | double | score,
|  | const gchar * | value
| ) |  |

Create a new vtseverity structure filled with the given values.

Parameters

  [in] | type | The severity type to be set.
  [in] | origin | The origin reference to be set, can be NULL.
  [in] | date | The date to be set.
  [in] | score | The score to be set.
  [in] | value | The value corresponding to the type.

Returns
  NULL in case the memory could not be allocated. Else a vtref structure which needs to be released using vtref_free .

## vtseverity_origin()

const gchar* vtseverity_origin | ( | const vtseverity_t * | s | ) |

Get the origin of a severity.

Parameters

  s | The VT Severity structure of which the origin should be returned.

Returns
  The origin string. Don't free this.

## vtseverity_score()

double vtseverity_score | ( | const vtseverity_t * | s | ) |

Get the score of a severity.

Parameters

  s | The VT Severity structure of which the score should be returned.

Returns
  The score.

## vtseverity_type()

const gchar* vtseverity_type | ( | const vtseverity_t * | s | ) |

Get the type of a severity.

Parameters

  s | The VT Severity structure of which the type should be returned.

Returns
  The type string. Don't free this.

## vtseverity_value()

const gchar* vtseverity_value | ( | const vtseverity_t * | s | ) |

Get the value of a severity.

Parameters

  s | The VT Severity structure of which the value should be returned.

Returns
  The value string. Don't free this.