suricata
|
#include "suricata-common.h"
#include "util-unittest.h"
#include "util-storage.h"
#include "util-debug.h"
Go to the source code of this file.
Data Structures | |
struct | StorageMapping_ |
struct | StorageList_ |
list of StorageMapping used at registration time More... | |
struct | StorageTest02Data |
Typedefs | |
typedef struct StorageMapping_ | StorageMapping |
typedef struct StorageList_ | StorageList |
list of StorageMapping used at registration time More... | |
Functions | |
void | StorageInit (void) |
void | StorageCleanup (void) |
int | StorageRegister (const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *)) |
Register new storage. More... | |
int | StorageFinalize (void) |
unsigned int | StorageGetCnt (StorageEnum type) |
unsigned int | StorageGetSize (StorageEnum type) |
get the size of the void array used to store the pointers More... | |
void * | StorageGetById (const Storage *storage, const StorageEnum type, const int id) |
get storage for id More... | |
int | StorageSetById (Storage *storage, const StorageEnum type, const int id, void *ptr) |
set storage for id More... | |
void * | StorageAllocByIdPrealloc (Storage *storage, StorageEnum type, int id) |
AllocById func for prealloc'd base storage (storage ptrs are part of another memory block) More... | |
void * | StorageAllocById (Storage **storage, StorageEnum type, int id) |
AllocById func for when we manage the Storage ptr itself. More... | |
void | StorageFreeById (Storage *storage, StorageEnum type, int id) |
void | StorageFreeAll (Storage *storage, StorageEnum type) |
void | StorageFree (Storage **storage, StorageEnum type) |
void | StorageRegisterTests (void) |
Storage API
Definition in file util-storage.c.
typedef struct StorageList_ StorageList |
list of StorageMapping used at registration time
typedef struct StorageMapping_ StorageMapping |
void* StorageAllocById | ( | Storage ** | storage, |
StorageEnum | type, | ||
int | id | ||
) |
AllocById func for when we manage the Storage ptr itself.
Definition at line 258 of file util-storage.c.
References BUG_ON.
void* StorageAllocByIdPrealloc | ( | Storage * | storage, |
StorageEnum | type, | ||
int | id | ||
) |
AllocById func for prealloc'd base storage (storage ptrs are part of another memory block)
Definition at line 240 of file util-storage.c.
References BUG_ON.
Referenced by FlowAllocStorageById(), HostAllocStorageById(), IPPairAllocStorageById(), and LiveDevAllocStorageById().
void StorageCleanup | ( | void | ) |
Definition at line 76 of file util-storage.c.
int StorageFinalize | ( | void | ) |
Definition at line 140 of file util-storage.c.
Referenced by RunUnittests().
void StorageFree | ( | Storage ** | storage, |
StorageEnum | type | ||
) |
Definition at line 334 of file util-storage.c.
References BUG_ON.
void StorageFreeAll | ( | Storage * | storage, |
StorageEnum | type | ||
) |
Definition at line 311 of file util-storage.c.
References BUG_ON.
Referenced by FlowFreeStorage(), HostFreeStorage(), IPPairFreeStorage(), and LiveDevFreeStorage().
void StorageFreeById | ( | Storage * | storage, |
StorageEnum | type, | ||
int | id | ||
) |
Definition at line 289 of file util-storage.c.
References BUG_ON.
Referenced by FlowFreeStorageById(), HostFreeStorageById(), IPPairFreeStorageById(), and LiveDevFreeStorageById().
void* StorageGetById | ( | const Storage * | storage, |
const StorageEnum | type, | ||
const int | id | ||
) |
get storage for id
Definition at line 217 of file util-storage.c.
References BUG_ON.
Referenced by FlowGetStorageById(), HostGetStorageById(), IPPairGetStorageById(), and LiveDevGetStorageById().
unsigned int StorageGetCnt | ( | StorageEnum | type | ) |
Definition at line 201 of file util-storage.c.
unsigned int StorageGetSize | ( | StorageEnum | type | ) |
get the size of the void array used to store the pointers
size | size in bytes, can return 0 if not storage is needed |
Definition at line 212 of file util-storage.c.
Referenced by FlowStorageSize(), HostStorageSize(), IPPairStorageSize(), and LiveDevStorageSize().
void StorageInit | ( | void | ) |
Definition at line 68 of file util-storage.c.
Referenced by PostConfLoadedSetup(), and RunUnittests().
int StorageRegister | ( | const StorageEnum | type, |
const char * | name, | ||
const unsigned int | size, | ||
void *(*)(unsigned int) | Alloc, | ||
void(*)(void *) | Free | ||
) |
Register new storage.
type | type from StorageEnum |
name | name |
size | size of the per instance storage |
Alloc | alloc function for per instance storage |
Free | free function for per instance storage |
Definition at line 100 of file util-storage.c.
Referenced by FlowStorageRegister(), HostStorageRegister(), IPPairStorageRegister(), and LiveDevStorageRegister().
void StorageRegisterTests | ( | void | ) |
Definition at line 546 of file util-storage.c.
References UtRegisterTest().
int StorageSetById | ( | Storage * | storage, |
const StorageEnum | type, | ||
const int | id, | ||
void * | ptr | ||
) |
set storage for id
Definition at line 228 of file util-storage.c.
References BUG_ON.
Referenced by FlowSetStorageById(), HostSetStorageById(), IPPairSetStorageById(), and LiveDevSetStorageById().