suricata
Device storage API

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...
 

Detailed Description

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().

Function Documentation

◆ LiveDevGetStorageById()

void* LiveDevGetStorageById ( LiveDevice d,
LiveDevStorageId  id 
)

Get a value from a given LiveDevice storage.

Parameters
da pointer to the LiveDevice
idthe 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().

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

◆ LiveDevSetStorageById()

int LiveDevSetStorageById ( LiveDevice d,
LiveDevStorageId  id,
void *  ptr 
)

Store a pointer in a given LiveDevice storage.

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

Definition at line 76 of file device-storage.c.

References LiveDevice_::storage, STORAGE_DEVICE, and StorageSetById().

Referenced by LiveDevUseBypass().

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

◆ LiveDevStorageRegister()

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

Register a LiveDevice 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 60 of file device-storage.c.

References LiveDevStorageId_::id, STORAGE_DEVICE, and StorageRegister().

Here is the call graph for this function: