suricata
|
The device storage API is a per-device storage. It is a mean to extend the LiveDevice structure with arbitrary data. More...
Functions | |
LiveDevStorageId | LiveDevStorageRegister (const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *)) |
Register a LiveDevice storage. More... | |
int | LiveDevSetStorageById (LiveDevice *d, LiveDevStorageId id, void *ptr) |
Store a pointer in a given LiveDevice storage. More... | |
void * | LiveDevGetStorageById (LiveDevice *d, LiveDevStorageId id) |
Get a value from a given LiveDevice storage. More... | |
The device storage API is a per-device storage. It is a mean to extend the LiveDevice structure with arbitrary data.
You have first to register the storage via LiveDevStorageRegister() during the init of your module. Then you can attach data via LiveDevSetStorageById() and access them via LiveDevGetStorageById().
void* LiveDevGetStorageById | ( | LiveDevice * | d, |
LiveDevStorageId | id | ||
) |
Get a value from a given LiveDevice storage.
d | a pointer to the LiveDevice |
id | the id of the storage (return of LiveDevStorageRegister() call) |
Definition at line 89 of file device-storage.c.
References LiveDevice_::storage, STORAGE_DEVICE, and StorageGetById().
Referenced by LiveDevAddBypassFail(), LiveDevAddBypassStats(), LiveDevAddBypassSuccess(), and LiveDevSubBypassStats().
int LiveDevSetStorageById | ( | LiveDevice * | d, |
LiveDevStorageId | id, | ||
void * | ptr | ||
) |
Store a pointer in a given LiveDevice storage.
d | a pointer to the LiveDevice |
id | the id of the storage (return of HostStorageRegister() call) |
ptr | pointer to the data to store |
Definition at line 76 of file device-storage.c.
References LiveDevice_::storage, STORAGE_DEVICE, and StorageSetById().
Referenced by LiveDevUseBypass().
LiveDevStorageId LiveDevStorageRegister | ( | const char * | name, |
const unsigned int | size, | ||
void *(*)(unsigned int) | Alloc, | ||
void(*)(void *) | Free | ||
) |
Register a LiveDevice 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 60 of file device-storage.c.
References LiveDevStorageId_::id, STORAGE_DEVICE, and StorageRegister().