suricata
util-storage.c File Reference
#include "suricata-common.h"
#include "util-unittest.h"
#include "util-storage.h"
#include "util-debug.h"
Include dependency graph for util-storage.c:

Go to the source code of this file.

Data Structures

struct  StorageMapping_
 
struct  StorageList_
 list of StorageMapping used at registration time More...
 

Typedefs

typedef struct StorageMapping_ StorageMapping
 
typedef struct StorageList_ StorageList
 list of StorageMapping used at registration time More...
 

Functions

void SCStorageInit (void)
 
void SCStorageCleanup (void)
 
int SCStorageRegister (const StorageEnum type, const char *name, void(*Free)(void *))
 Register new storage. More...
 
int SCStorageFinalize (void)
 
unsigned int SCStorageGetCnt (StorageEnum type)
 
unsigned int SCStorageGetSize (StorageEnum type)
 get the size of the void array used to store the pointers More...
 
void * SCStorageGetById (const Storage *storage, const StorageEnum type, const int id)
 get storage for id More...
 
int SCStorageSetById (Storage *storage, const StorageEnum type, const int id, void *ptr)
 set storage for id More...
 
void SCStorageFreeById (Storage *storage, StorageEnum type, int id)
 
void SCStorageFreeAll (Storage *storage, StorageEnum type)
 

Detailed Description

Typedef Documentation

◆ StorageList

typedef struct StorageList_ StorageList

list of StorageMapping used at registration time

◆ StorageMapping

Function Documentation

◆ SCStorageCleanup()

void SCStorageCleanup ( void  )

Definition at line 76 of file util-storage.c.

◆ SCStorageFinalize()

int SCStorageFinalize ( void  )

Definition at line 135 of file util-storage.c.

Referenced by RunUnittests().

Here is the caller graph for this function:

◆ SCStorageFreeAll()

void SCStorageFreeAll ( Storage storage,
StorageEnum  type 
)

Definition at line 252 of file util-storage.c.

References BUG_ON.

Referenced by SCFlowFreeStorage(), SCHostFreeStorage(), SCIPPairFreeStorage(), SCLiveDevFreeStorage(), and SCThreadFreeStorage().

Here is the caller graph for this function:

◆ SCStorageFreeById()

void SCStorageFreeById ( Storage storage,
StorageEnum  type,
int  id 
)

Definition at line 230 of file util-storage.c.

References BUG_ON.

Referenced by SCFlowFreeStorageById(), and SCThreadFreeStorageById().

Here is the caller graph for this function:

◆ SCStorageGetById()

void* SCStorageGetById ( const Storage storage,
const StorageEnum  type,
const int  id 
)

get storage for id

Definition at line 207 of file util-storage.c.

References BUG_ON.

Referenced by SCFlowGetStorageById(), SCHostGetStorageById(), SCIPPairGetStorageById(), SCLiveDevGetStorageById(), and SCThreadGetStorageById().

Here is the caller graph for this function:

◆ SCStorageGetCnt()

unsigned int SCStorageGetCnt ( StorageEnum  type)

Definition at line 191 of file util-storage.c.

◆ SCStorageGetSize()

unsigned int SCStorageGetSize ( StorageEnum  type)

get the size of the void array used to store the pointers

Return values
sizesize in bytes, can return 0 if not storage is needed
Todo:
we could return -1 when registration isn't closed yet, however this will break lots of tests currently, so not doing it now

Definition at line 202 of file util-storage.c.

Referenced by SCFlowStorageSize(), SCHostStorageSize(), SCIPPairStorageSize(), SCLiveDevStorageSize(), and SCThreadStorageSize().

Here is the caller graph for this function:

◆ SCStorageInit()

void SCStorageInit ( void  )

Definition at line 68 of file util-storage.c.

Referenced by PostConfLoadedSetup(), and RunUnittests().

Here is the caller graph for this function:

◆ SCStorageRegister()

int SCStorageRegister ( const StorageEnum  type,
const char *  name,
void(*)(void *)  Free 
)

Register new storage.

Parameters
typetype from StorageEnum
namename
Freefree function for per instance storage

Definition at line 100 of file util-storage.c.

Referenced by SCFlowStorageRegister(), SCHostStorageRegister(), SCIPPairStorageRegister(), SCLiveDevStorageRegister(), and SCThreadStorageRegister().

Here is the caller graph for this function:

◆ SCStorageSetById()

int SCStorageSetById ( Storage storage,
const StorageEnum  type,
const int  id,
void *  ptr 
)

set storage for id

Definition at line 218 of file util-storage.c.

References BUG_ON.

Referenced by SCFlowSetStorageById(), SCHostSetStorageById(), SCIPPairSetStorageById(), SCLiveDevSetStorageById(), and SCThreadSetStorageById().

Here is the caller graph for this function: