nvticache.h File Reference

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

`#include "../base/nvti.h"`
`#include "kb.h"`
`#include <glib.h>`

Go to the source code of this file.

## Macros

#define | NVTICACHE_STR "nvticache"

## Functions

int | nvticache_init (const char *, const char *)
| Initializes the nvti cache. More...
void | nvticache_reset ()
| Reset connection to KB. To be called after a fork(). More...
kb_t | nvticache_get_kb ()
| Return the nvticache kb. More...
void | nvticache_save ()
| Save the nvticache to disk. More...
int | nvticache_initialized (void)
| Return whether the nvt cache is initialized. More...
int | nvticache_check (const gchar *)
| Check if the nvt for the given filename exists in cache. More...
int | nvticache_add (const nvti_t *, const char *)
| Add a NVT Information to the cache. More...
char * | nvticache_get_src (const char *)
| Get the full source filename of an OID. More...
char * | nvticache_get_oid (const char *)
| Get the OID from a plugin filename. More...
char * | nvticache_get_name (const char *)
| Get the name from a plugin OID. More...
char * | nvticache_get_tags (const char *)
| Get the tags from a plugin OID. More...
GSList * | nvticache_get_prefs (const char *)
| Get the prefs from a plugin OID. More...
char * | nvticache_get_cves (const char *)
| Get the cves from a plugin OID. More...
char * | nvticache_get_bids (const char *)
| Get the bids from a plugin OID. More...
char * | nvticache_get_xrefs (const char *)
| Get the xrefs from a plugin OID. More...
char * | nvticache_get_family (const char *)
| Get the family from a plugin OID. More...
char * | nvticache_get_filename (const char *)
| Get the filename from a plugin OID. More...
char * | nvticache_get_required_keys (const char *)
| Get the Required Keys from a plugin OID. More...
char * | nvticache_get_mandatory_keys (const char *)
| Get the Mandatory Keys from a plugin OID. More...
char * | nvticache_get_excluded_keys (const char *)
| Get the Excluded Keys from a plugin OID. More...
char * | nvticache_get_required_ports (const char *)
| Get the Required ports from a plugin OID. More...
char * | nvticache_get_required_udp_ports (const char *)
| Get the Required udp ports from a plugin OID. More...
int | nvticache_get_category (const char *)
| Get the Category from a plugin OID. More...
int | nvticache_get_timeout (const char *)
| Get the Timeout from a plugin OID. More...
char * | nvticache_get_dependencies (const char *)
| Get the Dependencies from a plugin OID. More...
nvti_t * | nvticache_get_nvt (const char *)
| Get the nvti from a plugin OID. More...
GSList * | nvticache_get_oids (void)
| Get the list of nvti OIDs. More...
size_t | nvticache_count (void)
| Get the number of nvt's in the cache. More...
void | nvticache_delete (const char *)
| Delete NVT from the cache. More...
char * | nvticache_feed_version (void)
| Get the NVT feed version. More...
int | nvticache_check_feed (void)
| Check if the plugins feed was newer than cached feed. More...

## Detailed Description

Protos and data structures for NVT Information Cache.

This file contains the protos for nvticache.c

## Macro Definition Documentation

## NVTICACHE_STR

#define NVTICACHE_STR "nvticache"

## Function Documentation

## nvticache_add()

int nvticache_add | ( | const nvti_t * | nvti,
|  | const char * | filename
| ) |  |

Add a NVT Information to the cache.

Parameters

  nvti | The NVT Information to add
  filename | The name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )

Returns
  0 in case of success, anything else indicates an error.

## nvticache_check()

int nvticache_check | ( | const gchar * | filename | ) |

Check if the nvt for the given filename exists in cache.

Parameters

  filename | The name of the original NVT without the path to the base location of NVTs (e.g. "scriptname1.nasl" or even "subdir1/subdir2/scriptname2.nasl" )

Returns
  1 if nvt is in cache and up to date, 0 otherwise.

## nvticache_check_feed()

int nvticache_check_feed | ( | void |  | ) |

Check if the plugins feed was newer than cached feed.

Returns
  1 if new feed, 0 if matching feeds or error.

## nvticache_count()

size_t nvticache_count | ( | void |  | ) |

Get the number of nvt's in the cache.

Returns
  Number of nvt's.

## nvticache_delete()

void nvticache_delete | ( | const char * | oid | ) |

Delete NVT from the cache.

Parameters

  [in] | oid | OID to match.

## nvticache_feed_version()

char* nvticache_feed_version | ( | void |  | ) |

Get the NVT feed version.

Returns
  Feed version.

## nvticache_get_bids()

char* nvticache_get_bids | ( | const char * | oid | ) |

Get the bids from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  BIDs matching OID, NULL otherwise.

## nvticache_get_category()

int nvticache_get_category | ( | const char * | oid | ) |

Get the Category from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Category matching OID, -1 otherwise.

## nvticache_get_cves()

char* nvticache_get_cves | ( | const char * | oid | ) |

Get the cves from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  CVEs matching OID, NULL otherwise.

## nvticache_get_dependencies()

char* nvticache_get_dependencies | ( | const char * | oid | ) |

Get the Dependencies from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Dependencies matching OID, NULL otherwise.

## nvticache_get_excluded_keys()

char* nvticache_get_excluded_keys | ( | const char * | oid | ) |

Get the Excluded Keys from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Excluded Keys matching OID, NULL otherwise.

## nvticache_get_family()

char* nvticache_get_family | ( | const char * | oid | ) |

Get the family from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Family matching OID, NULL otherwise.

## nvticache_get_filename()

char* nvticache_get_filename | ( | const char * | oid | ) |

Get the filename from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Filanem matching OID, NULL otherwise.

## nvticache_get_kb()

kb_t nvticache_get_kb | ( | void |  | ) |

Return the nvticache kb.

Returns
  Cache kb.

## nvticache_get_mandatory_keys()

char* nvticache_get_mandatory_keys | ( | const char * | oid | ) |

Get the Mandatory Keys from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Mandatory Keys matching OID, NULL otherwise.

## nvticache_get_name()

char* nvticache_get_name | ( | const char * | oid | ) |

Get the name from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Name matching OID, NULL otherwise.

## nvticache_get_nvt()

nvti_t* nvticache_get_nvt | ( | const char * | oid | ) |

Get the nvti from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Full nvti matching OID, NULL otherwise.

## nvticache_get_oid()

char* nvticache_get_oid | ( | const char * | filename | ) |

Get the OID from a plugin filename.

Parameters

  filename | Filename to lookup.

Returns
  OID matching filename if found, NULL otherwise.

## nvticache_get_oids()

GSList* nvticache_get_oids | ( | void |  | ) |

Get the list of nvti OIDs.

Returns
  OIDs list.

## nvticache_get_prefs()

GSList* nvticache_get_prefs | ( | const char * | oid | ) |

Get the prefs from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Prefs matching OID, NULL otherwise.

## nvticache_get_required_keys()

char* nvticache_get_required_keys | ( | const char * | oid | ) |

Get the Required Keys from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Required Keys matching OID, NULL otherwise.

## nvticache_get_required_ports()

char* nvticache_get_required_ports | ( | const char * | oid | ) |

Get the Required ports from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Required ports matching OID, NULL otherwise.

## nvticache_get_required_udp_ports()

char* nvticache_get_required_udp_ports | ( | const char * | oid | ) |

Get the Required udp ports from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Required udp ports matching OID, NULL otherwise.

## nvticache_get_src()

char* nvticache_get_src | ( | const char * | oid | ) |

Get the full source filename of an OID.

Parameters

  oid | The OID to look up.

Returns
  Filename with full path matching OID if found, NULL otherwise.

## nvticache_get_tags()

char* nvticache_get_tags | ( | const char * | oid | ) |

Get the tags from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Tags matching OID, NULL otherwise.

## nvticache_get_timeout()

int nvticache_get_timeout | ( | const char * | oid | ) |

Get the Timeout from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  Timeout matching OID, -1 otherwise.

## nvticache_get_xrefs()

char* nvticache_get_xrefs | ( | const char * | oid | ) |

Get the xrefs from a plugin OID.

Parameters

  [in] | oid | OID to match.

Returns
  XREFs matching OID, NULL otherwise.

## nvticache_init()

int nvticache_init | ( | const char * | src,
|  | const char * | kb_path
| ) |  |

Initializes the nvti cache.

Parameters

  src | The directory that contains the nvt files.
  kb_path | Path to kb socket.

Returns
  0 in case of success, anything else indicates an error.

## nvticache_initialized()

int nvticache_initialized | ( | void |  | ) |

Return whether the nvt cache is initialized.

Returns
  1 if cache is initialized, 0 otherwise.

## nvticache_reset()

void nvticache_reset | ( |  | ) |

Reset connection to KB. To be called after a fork().

## nvticache_save()

void nvticache_save | ( |  | ) |

Save the nvticache to disk.