OpenVAS Libraries  9.0.3
kb_redis.c File Reference

Contains specialized structures and functions to use redis as a KB server. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <hiredis/hiredis.h>
#include <glib.h>
#include "kb.h"
Include dependency graph for kb_redis.c:

Go to the source code of this file.

Data Structures

struct  kb_redis
 Subclass of struct kb, it contains the redis-specific fields, such as the redis context, current DB (namespace) id and the server socket path. More...
 
struct  redis_tx
 Redis transaction handle. More...
 

Macros

#define _GNU_SOURCE
 
#define G_LOG_DOMAIN   "lib kb_redis"
 
#define GLOBAL_DBINDEX_NAME   "OpenVAS.__GlobalDBIndex"
 Name of the namespace usage bitmap in redis. More...
 
#define KB_RETRY_DELAY   60
 Number of seconds to wait for between two attempts to acquire a KB namespace. More...
 
#define redis_kb(__kb)   ((struct kb_redis *)(__kb))
 
#define MAX_DB_INDEX__24   1000
 

Functions

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

Variables

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

Detailed Description

Contains specialized structures and functions to use redis as a KB server.

Definition in file kb_redis.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 27 of file kb_redis.c.

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib kb_redis"

Definition at line 46 of file kb_redis.c.

◆ GLOBAL_DBINDEX_NAME

#define GLOBAL_DBINDEX_NAME   "OpenVAS.__GlobalDBIndex"

Name of the namespace usage bitmap in redis.

Definition at line 59 of file kb_redis.c.

◆ KB_RETRY_DELAY

#define KB_RETRY_DELAY   60

Number of seconds to wait for between two attempts to acquire a KB namespace.

Definition at line 65 of file kb_redis.c.

◆ MAX_DB_INDEX__24

#define MAX_DB_INDEX__24   1000

Definition at line 135 of file kb_redis.c.

◆ redis_kb

#define redis_kb (   __kb)    ((struct kb_redis *)(__kb))

Definition at line 84 of file kb_redis.c.

Function Documentation

◆ kb_item_free()

void kb_item_free ( struct kb_item item)

Release a KB item (or a list).

Definition at line 501 of file kb_redis.c.

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
enum kb_item_type type
Definition: kb.h:83
char * v_str
Definition: kb.h:87

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

Variable Documentation

◆ KBDefaultOperations

const struct kb_operations* KBDefaultOperations = &KBRedisOperations

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.