OpenVAS Libraries  9.0.1
Macros | Functions | Variables
nvticache.c File Reference

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

#include <sys/stat.h>
#include "nvticache.h"
#include "kb.h"
#include <string.h>
#include <assert.h>

Macros

#define G_LOG_DOMAIN   "lib nvticache"
 

Functions

int nvticache_initialized (void)
 Return whether the nvt cache is initialized. More...
 
int nvticache_init (const char *cache, const char *src, const char *kb_path)
 Initializes the nvti cache. More...
 
void nvticache_free (void)
 Free the nvti cache. More...
 
nvti_tnvticache_get (const gchar *filename)
 Retrieve NVT Information from the nvt cache for the given filename. More...
 
void nvticache_reset ()
 Reset connection to KB. To be called after a fork(). More...
 
int nvticache_add (const nvti_t *nvti, const char *filename)
 Add a NVT Information to the cache. More...
 
nvti_tnvticache_get_by_name_full (const char *filename)
 Get a full NVTI from the cache file by filename. More...
 
nvti_tnvticache_get_by_oid_full (const char *oid)
 Get a full NVTI from the cache by OID. More...
 
char * nvticache_get_src (const char *oid)
 Get the full source filename of an OID. More...
 
char * nvticache_get_oid (const char *filename)
 Get the OID from a plugin filename. More...
 
char * nvticache_get_name (const char *oid)
 Get the name from a plugin OID. More...
 
char * nvticache_get_required_keys (const char *oid)
 Get the Required Keys from a plugin OID. More...
 
char * nvticache_get_mandatory_keys (const char *oid)
 Get the Mandatory Keys from a plugin OID. More...
 
char * nvticache_get_excluded_keys (const char *oid)
 Get the Excluded Keys from a plugin OID. More...
 
char * nvticache_get_required_udp_ports (const char *oid)
 Get the Required udp ports from a plugin OID. More...
 
char * nvticache_get_required_ports (const char *oid)
 Get the Required ports from a plugin OID. More...
 
char * nvticache_get_dependencies (const char *oid)
 Get the Dependencies from a plugin OID. More...
 
int nvticache_get_category (const char *oid)
 Get the Category from a plugin OID. More...
 
int nvticache_get_timeout (const char *oid)
 Get the Timeout from a plugin OID. More...
 
GSList * nvticache_get_names ()
 Get the list of nvti filenames. More...
 
GSList * nvticache_get_oids ()
 Get the list of nvti OIDs. More...
 

Variables

char * cache_path = NULL
 
char * src_path = NULL
 
kb_t cache_kb = NULL
 

Detailed Description

Implementation of API to handle NVT Info Cache.

This file contains all methods to handle NVT Information Cache (nvticache_t).

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

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib nvticache"

Function Documentation

◆ nvticache_add()

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

Add a NVT Information to the cache.

Parameters
nvtiThe NVT Information to add
filenameThe 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_free()

void nvticache_free ( void  )

Free the nvti cache.

◆ nvticache_get()

nvti_t* nvticache_get ( const gchar *  filename)

Retrieve NVT Information from the nvt cache for the given filename.

Parameters
filenameThe 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
NULL in case the data could not be delivered. Else a nvti structure that should be freed with nvti_free().

◆ nvticache_get_by_name_full()

nvti_t* nvticache_get_by_name_full ( const char *  filename)

Get a full NVTI from the cache file by filename.

Parameters
filenameFilename of nvti to lookup
Returns
A full copy of the NVTI object or NULL if not found.

◆ nvticache_get_by_oid_full()

nvti_t* nvticache_get_by_oid_full ( const char *  oid)

Get a full NVTI from the cache by OID.

Parameters
oidThe OID to look up
Returns
A full copy of the NVTI object or NULL if not found.

◆ nvticache_get_category()

int nvticache_get_category ( const char *  oid)

Get the Category from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Category matching OID, -1 otherwise.

◆ nvticache_get_dependencies()

char* nvticache_get_dependencies ( const char *  oid)

Get the Dependencies from a plugin OID.

Parameters
[in]oidOID 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]oidOID to match.
Returns
Excluded Keys matching OID, NULL otherwise.

◆ nvticache_get_mandatory_keys()

char* nvticache_get_mandatory_keys ( const char *  oid)

Get the Mandatory Keys from a plugin OID.

Parameters
[in]oidOID 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]oidOID to match.
Returns
Name matching OID, NULL otherwise.

◆ nvticache_get_names()

GSList* nvticache_get_names ( void  )

Get the list of nvti filenames.

Returns
Filenames list.

◆ nvticache_get_oid()

char* nvticache_get_oid ( const char *  filename)

Get the OID from a plugin filename.

Parameters
filenameFilename 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_required_keys()

char* nvticache_get_required_keys ( const char *  oid)

Get the Required Keys from a plugin OID.

Parameters
[in]oidOID 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]oidOID 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]oidOID 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
oidThe OID to look up.
Returns
Filename with full path matching OID if found, NULL otherwise.

◆ nvticache_get_timeout()

int nvticache_get_timeout ( const char *  oid)

Get the Timeout from a plugin OID.

Parameters
[in]oidOID to match.
Returns
Timeout matching OID, -1 otherwise.

◆ nvticache_init()

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

Initializes the nvti cache.

Parameters
cacheThe directory where the cache is to be stored.
srcThe directory that contains the nvt files.
kb_pathPath to kb socket.

◆ 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().

Variable Documentation

◆ cache_kb

kb_t cache_kb = NULL

◆ cache_path

char* cache_path = NULL

◆ src_path

char* src_path = NULL