OpenVAS Libraries  9.0.3
kb.h File Reference
#include <assert.h>
#include "../base/nvti.h"
Include dependency graph for kb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  kb_item
 Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked list. More...
 
struct  kb
 Top-level KB. This is to be inherited by KB implementations. More...
 
struct  kb_operations
 KB interface. Functions provided by an implementation. All functions have to be provided, there is no default/fallback. These functions should be called via the corresponding static inline wrappers below. See the wrappers for the documentation. More...
 

Macros

#define KB_PATH_DEFAULT   "/tmp/redis.sock"
 Default KB location. More...
 

Typedefs

typedef struct kbkb_t
 type abstraction to hide KB internals. More...
 

Enumerations

enum  kb_item_type { KB_TYPE_UNSPEC, KB_TYPE_INT, KB_TYPE_STR, KB_TYPE_CNT }
 Possible type of a kb_item. More...
 
enum  kb_nvt_pos {
  NVT_FILENAME_POS, NVT_REQUIRED_KEYS_POS, NVT_MANDATORY_KEYS_POS, NVT_EXCLUDED_KEYS_POS,
  NVT_REQUIRED_UDP_PORTS_POS, NVT_REQUIRED_PORTS_POS, NVT_DEPENDENCIES_POS, NVT_TAGS_POS,
  NVT_CVES_POS, NVT_BIDS_POS, NVT_XREFS_POS, NVT_CATEGORY_POS,
  NVT_TIMEOUT_POS, NVT_FAMILY_POS, NVT_COPYRIGHT_POS, NVT_NAME_POS,
  NVT_VERSION_POS
}
 Possible positions of nvt values in cache list. More...
 

Functions

void kb_item_free (struct kb_item *)
 Release a KB item (or a list). More...
 

Variables

const struct kb_operationsKBDefaultOperations
 Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based). More...
 

Macro Definition Documentation

◆ KB_PATH_DEFAULT

#define KB_PATH_DEFAULT   "/tmp/redis.sock"

Default KB location.

TODO This should eventually be expressed as an URI when/if multiple KB backends are supported (e.g.: redis:///tmp/redis.sock).

Definition at line 40 of file kb.h.

Typedef Documentation

◆ kb_t

typedef struct kb* kb_t

type abstraction to hide KB internals.

Definition at line 110 of file kb.h.

Enumeration Type Documentation

◆ kb_item_type

Possible type of a kb_item.

Enumerator
KB_TYPE_UNSPEC 

Ignore the value (name/presence test).

KB_TYPE_INT 

The kb_items v should then be interpreted as int.

KB_TYPE_STR 

The kb_items v should then be interpreted as char*.

KB_TYPE_CNT 

Definition at line 46 of file kb.h.

46  {
48  KB_TYPE_INT,
49  KB_TYPE_STR,
50  /* -- */
52 };
Definition: kb.h:49
Definition: kb.h:51
Definition: kb.h:48

◆ kb_nvt_pos

enum kb_nvt_pos

Possible positions of nvt values in cache list.

Enumerator
NVT_FILENAME_POS 
NVT_REQUIRED_KEYS_POS 
NVT_MANDATORY_KEYS_POS 
NVT_EXCLUDED_KEYS_POS 
NVT_REQUIRED_UDP_PORTS_POS 
NVT_REQUIRED_PORTS_POS 
NVT_DEPENDENCIES_POS 
NVT_TAGS_POS 
NVT_CVES_POS 
NVT_BIDS_POS 
NVT_XREFS_POS 
NVT_CATEGORY_POS 
NVT_TIMEOUT_POS 
NVT_FAMILY_POS 
NVT_COPYRIGHT_POS 
NVT_NAME_POS 
NVT_VERSION_POS 

Definition at line 57 of file kb.h.

Function Documentation

◆ kb_item_free()

void kb_item_free ( struct kb_item )

Release a KB item (or a list).

Definition at line 501 of file kb_redis.c.

References KB_TYPE_STR, kb_item::next, kb_item::type, and kb_item::v_str.

502 {
503  while (item != NULL)
504  {
505  struct kb_item *next;
506 
507  next = item->next;
508  if (item->type == KB_TYPE_STR && item->v_str != NULL)
509  g_free (item->v_str);
510  g_free (item);
511  item = next;
512  }
513 }
Definition: kb.h:49
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
Definition: kb.h:81
struct kb_item * next
Definition: kb.h:91

Variable Documentation

◆ KBDefaultOperations

const struct kb_operations* KBDefaultOperations

Default KB operations. No selection mechanism is provided yet since there's only one implementation (redis-based).

Definition at line 1228 of file kb_redis.c.