28 #include "../base/nvti.h" 32 #include <sys/types.h> 37 #define KB_PATH_DEFAULT "/tmp/redis.sock" 133 char *(*kb_get_str) (
kb_t,
const char *);
149 GSList *(*kb_get_nvt_oids) (
kb_t);
157 char *(*kb_pop_str) (
kb_t,
const char *);
274 kb_find (
const char *kb_path,
const char *key)
595 static inline GSList *
static int kb_flush(kb_t kb, const char *except)
Flush all the KB's content. Delete all namespaces.
kb_nvt_pos
Possible positions of nvt values in cache list.
nvti_t *(* kb_get_nvt_all)(kb_t, const char *)
static int kb_item_push_str(kb_t kb, const char *name, const char *value)
Push a new value under a given key.
const struct kb_operations * KBDefaultOperations
Default KB operations. No selection mechanism is provided yet since there's only one implementation (...
struct kb_item *(* kb_get_all)(kb_t, const char *)
void kb_item_free(struct kb_item *)
Release a KB item (or a list).
static int kb_delete(kb_t kb)
Delete all entries and release ownership on the namespace.
static int kb_item_set_int(kb_t kb, const char *name, int val)
Set (replace) a new entry under a given name.
static int kb_item_get_int(kb_t kb, const char *name)
Get a single KB integer item.
int(* kb_push_str)(kb_t, const char *, const char *)
kb_t(* kb_direct_conn)(const char *, const int)
The structure of a information record that corresponds to a NVT.
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
int(* kb_set_str)(kb_t, const char *, const char *, size_t)
static int kb_item_add_int(kb_t kb, const char *name, int val)
Insert (append) a new entry under a given name.
KB interface. Functions provided by an implementation. All functions have to be provided,...
static struct kb_item * kb_item_get_all(kb_t kb, const char *name)
Get all items stored under a given name.
static nvti_t * kb_nvt_get_all(kb_t kb, const char *oid)
Get a full NVT.
char *(* kb_pop_str)(kb_t, const char *)
struct kb_item *(* kb_get_single)(kb_t, const char *, enum kb_item_type)
int(* kb_get_int)(kb_t, const char *)
static int kb_get_kb_index(kb_t kb)
Return the kb index.
int(* kb_lnk_reset)(kb_t)
static int kb_new(kb_t *kb, const char *kb_path)
Initialize a new Knowledge Base object.
int(* kb_del_items)(kb_t, const char *)
int(* kb_add_str_unique)(kb_t, const char *, const char *, size_t)
int(* kb_flush)(kb_t, const char *)
int(* kb_get_kb_index)(kb_t)
Top-level KB. This is to be inherited by KB implementations.
const struct kb_operations * kb_ops
struct kb_item *(* kb_get_pattern)(kb_t, const char *)
int(* kb_add_int)(kb_t, const char *, int)
char *(* kb_get_nvt)(kb_t, const char *, enum kb_nvt_pos)
static int kb_del_items(kb_t kb, const char *name)
Delete all entries under a given name.
static int kb_nvt_add(kb_t kb, const nvti_t *nvt, const char *filename)
Insert a new nvt.
static struct kb_item * kb_item_get_pattern(kb_t kb, const char *pattern)
Get all items stored under a given pattern.
static int kb_item_add_int_unique(kb_t kb, const char *name, int val)
Insert (append) a new unique entry under a given name.
static struct kb_item * kb_item_get_single(kb_t kb, const char *name, enum kb_item_type type)
Get a single KB element.
static int kb_item_add_str(kb_t kb, const char *name, const char *str, size_t len)
Insert (append) a new entry under a given name.
static GSList * kb_nvt_get_oids(kb_t kb)
Get list of NVT OIDs.
kb_item_type
Possible type of a kb_item.
static char * kb_item_get_str(kb_t kb, const char *name)
Get a single KB string item.
static int kb_item_add_str_unique(kb_t kb, const char *name, const char *str, size_t len)
Insert (append) a new unique entry under a given name.
static size_t kb_item_count(kb_t kb, const char *pattern)
Count all items stored under a given pattern.
int(* kb_add_nvt)(kb_t, const nvti_t *, const char *)
int(* kb_set_int)(kb_t, const char *, int)
int(* kb_add_str)(kb_t, const char *, const char *, size_t)
static char * kb_item_pop_str(kb_t kb, const char *name)
Pop a single KB string item.
kb_t(* kb_find)(const char *, const char *)
static kb_t kb_direct_conn(const char *kb_path, const int kb_index)
Connect to a Knowledge Base object which has the given kb_index.
int(* kb_add_int_unique)(kb_t, const char *, int)
struct kb * kb_t
type abstraction to hide KB internals.
static int kb_save(kb_t kb)
Save all the KB's content.
static int kb_lnk_reset(kb_t kb)
Reset connection to the KB. This is called after each fork() to make sure connections aren't shared b...
GSList *(* kb_get_nvt_oids)(kb_t)
char *(* kb_get_str)(kb_t, const char *)
static kb_t kb_find(const char *kb_path, const char *key)
Find an existing Knowledge Base object with key.
static char * kb_nvt_get(kb_t kb, const char *oid, enum kb_nvt_pos position)
Get field of a NVT.
size_t(* kb_count)(kb_t, const char *)
static int kb_item_set_str(kb_t kb, const char *name, const char *str, size_t len)
Set (replace) a new entry under a given name.
int(* kb_new)(kb_t *, const char *)