suricata
Host storage API

Functions

int HostStorageRegister (const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *))
 Register a Host storage. More...
 
int HostSetStorageById (Host *h, int id, void *ptr)
 Store a pointer in a given Host storage. More...
 
void * HostGetStorageById (Host *h, int id)
 Get a value from a given Host storage. More...
 

Detailed Description

The Host storage API is a per-host storage. It is a mean to extend the Host structure with arbitrary data.

You have first to register the storage via HostStorageRegister() during the init of your module. Then you can attach data via HostSetStorageById() and access them via HostGetStorageById().

Function Documentation

void* HostGetStorageById ( Host h,
int  id 
)

Get a value from a given Host storage.

Parameters
ha pointer to the Host
idthe id of the storage (return of HostStorageRegister() call)

Definition at line 84 of file host-storage.c.

References STORAGE_HOST, and StorageGetById().

Referenced by DetectThresholdRegister(), HostBitList(), HostBitsTimedoutCheck(), HostFreeStorage(), HostHasHostBits(), TagHashAddTag(), TagHostHasTag(), TagTimeoutCheck(), ThresholdHostHasThreshold(), ThresholdHostTimeoutCheck(), and ThresholdIPPairTimeoutCheck().

Here is the call graph for this function:

Here is the caller graph for this function:

int HostSetStorageById ( Host h,
int  id,
void *  ptr 
)

Store a pointer in a given Host storage.

Parameters
ha pointer to the Host
idthe id of the storage (return of HostStorageRegister() call)
ptrpointer to the data to store

Definition at line 71 of file host-storage.c.

References STORAGE_HOST, and StorageSetById().

Referenced by HostBitsTimedoutCheck(), HostFreeStorage(), TagHashAddTag(), TagTimeoutCheck(), ThresholdHostTimeoutCheck(), and ThresholdIPPairTimeoutCheck().

Here is the call graph for this function:

Here is the caller graph for this function:

int HostStorageRegister ( const char *  name,
const unsigned int  size,
void *(*)(unsigned int)  Alloc,
void(*)(void *)  Free 
)

Register a Host storage.

Parameters
namethe name of the storage
sizeinteger coding the size of the stored value (sizeof(void *) is best choice here)
Allocallocation function for the storage (can be null)
Freefree function for the new storage
Return values
TheID of the newly register storage that will be used to access data

It has to be called once during the init of the sub system

Definition at line 59 of file host-storage.c.

References STORAGE_HOST, and StorageRegister().

Referenced by HostBitInitCtx(), HostFreeStorage(), TagInitCtx(), and ThresholdInit().

Here is the call graph for this function:

Here is the caller graph for this function: