suricata
|
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... | |
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().
void* HostGetStorageById | ( | Host * | h, |
HostStorageId | id | ||
) |
Get a value from a given Host storage.
h | a pointer to the Host |
id | the 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().
int HostSetStorageById | ( | Host * | h, |
HostStorageId | id, | ||
void * | ptr | ||
) |
Store a pointer in a given Host storage.
h | a pointer to the Host |
id | the id of the storage (return of HostStorageRegister() call) |
ptr | pointer to the data to store |
Definition at line 75 of file host-storage.c.
References Host_::storage, STORAGE_HOST, and StorageSetById().
HostStorageId HostStorageRegister | ( | const char * | name, |
const unsigned int | size, | ||
void *(*)(unsigned int) | Alloc, | ||
void(*)(void *) | Free | ||
) |
Register a Host storage.
name | the name of the storage |
size | integer coding the size of the stored value (sizeof(void *) is best choice here) |
Alloc | allocation function for the storage (can be null) |
Free | free function for the new storage |
The | ID 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().