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

SCLiveDevStorageId SCLiveDevStorageRegister (const char *name, void(*Free)(void *))
 Register a LiveDevice storage. More...
 
int SCLiveDevSetStorageById (LiveDevice *d, SCLiveDevStorageId id, void *ptr)
 Store a pointer in a given LiveDevice storage. More...
 
void * SCLiveDevGetStorageById (LiveDevice *d, SCLiveDevStorageId 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 SCLiveDevStorageRegister() during the init of your module. Then you can attach data via SCLiveDevSetStorageById() and access them via SCLiveDevGetStorageById().

Function Documentation

◆ SCLiveDevGetStorageById()

void* SCLiveDevGetStorageById ( LiveDevice d,
SCLiveDevStorageId  id 
)

Get a value from a given LiveDevice storage.

Parameters
da pointer to the LiveDevice
idthe id of the storage (return of SCLiveDevStorageRegister() call)

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

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

Referenced by LiveDevAddBypassFail(), LiveDevAddBypassStats(), LiveDevAddBypassSuccess(), and LiveDevSubBypassStats().

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

◆ SCLiveDevSetStorageById()

int SCLiveDevSetStorageById ( LiveDevice d,
SCLiveDevStorageId  id,
void *  ptr 
)

Store a pointer in a given LiveDevice storage.

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

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

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

Referenced by LiveDevUseBypass().

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

◆ SCLiveDevStorageRegister()

SCLiveDevStorageId SCLiveDevStorageRegister ( const char *  name,
void(*)(void *)  Free 
)

Register a LiveDevice storage.

Parameters
namethe name of the storage
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 device-storage.c.

References LiveDevStorageId_::id, name, SCStorageRegister(), and STORAGE_DEVICE.

Here is the call graph for this function: