suricata
Host storage API

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

Functions

HostStorageId HostStorageRegister (const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *))
 Register a Host storage. More...
 
int HostSetStorageById (Host *h, HostStorageId id, void *ptr)
 Store a pointer in a given Host storage. More...
 
void * HostGetStorageById (Host *h, HostStorageId 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

◆ HostGetStorageById()

void* HostGetStorageById ( Host h,
HostStorageId  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 88 of file host-storage.c.

References Host_::storage, STORAGE_HOST, and StorageGetById().

Referenced by HostBitList(), HostBitsTimedoutCheck(), HostHasHostBits(), TagHashAddTag(), TagHostHasTag(), and TagTimeoutCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HostSetStorageById()

int HostSetStorageById ( Host h,
HostStorageId  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 75 of file host-storage.c.

References Host_::storage, STORAGE_HOST, and StorageSetById().

Here is the call graph for this function:

◆ HostStorageRegister()

HostStorageId 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 HostStorageId_::id, STORAGE_HOST, and StorageRegister().

Here is the call graph for this function: