suricata
util-storage.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Storage
 

Typedefs

typedef enum StorageEnum_ StorageEnum
 
typedef struct Storage Storage
 

Enumerations

enum  StorageEnum_ {
  STORAGE_HOST, STORAGE_FLOW, STORAGE_IPPAIR, STORAGE_DEVICE,
  STORAGE_THREAD, STORAGE_MAX
}
 

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 (const StorageEnum type)
 
unsigned int SCStorageGetSize (const 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 * SCStorageAllocByIdPrealloc (Storage *storage, StorageEnum type, int id)
 AllocById func for prealloc'd base storage (storage ptrs are part of another memory block) More...
 
void SCStorageFreeById (Storage *storage, const StorageEnum type, const int id)
 
void SCStorageFreeAll (Storage *storage, const StorageEnum type)
 

Detailed Description

Typedef Documentation

◆ Storage

typedef struct Storage Storage

void ptr array for now

◆ StorageEnum

typedef enum StorageEnum_ StorageEnum

Enumeration Type Documentation

◆ StorageEnum_

Enumerator
STORAGE_HOST 
STORAGE_FLOW 
STORAGE_IPPAIR 
STORAGE_DEVICE 
STORAGE_THREAD 
STORAGE_MAX 

Definition at line 29 of file util-storage.h.

Function Documentation

◆ SCStorageAllocByIdPrealloc()

void* SCStorageAllocByIdPrealloc ( Storage storage,
StorageEnum  type,
int  id 
)

AllocById func for prealloc'd base storage (storage ptrs are part of another memory block)

◆ 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,
const 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,
const StorageEnum  type,
const 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 ( const 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: