mirror of
https://github.com/OISF/suricata.git
synced 2026-05-28 04:32:12 -04:00
storage: remove the size registration parameter
Some checks are pending
builds / Prepare dependencies (push) Waiting to run
builds / Prepare cbindgen (push) Waiting to run
builds / AlmaLinux 10 (schema, plugins) (push) Blocked by required conditions
builds / AlmaLinux 9 (schema, rust-checks) (push) Blocked by required conditions
builds / AlmaLinux 9 Test Templates (push) Blocked by required conditions
builds / Build RPMs (push) Blocked by required conditions
builds / AlmaLinux 8 (push) Blocked by required conditions
builds / CentOS Stream 9 (push) Blocked by required conditions
builds / Fedora 43 (Suricata Verify codecov) (push) Blocked by required conditions
builds / Fedora 43 (clang, debug, asan, wshadow, rust-strict, systemd) (push) Blocked by required conditions
builds / Fedora 43 (gcc, debug, flto, asan, wshadow, rust-strict) (push) Blocked by required conditions
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Blocked by required conditions
builds / AlmaLinux 9 (no jansson) (push) Blocked by required conditions
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Blocked by required conditions
builds / Ubuntu 24.04 (cocci) (push) Blocked by required conditions
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Blocked by required conditions
builds / Ubuntu 24.04 (unittests coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (unix socket mode coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket and dpdk coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Blocked by required conditions
builds / Ubuntu 24.04 (fuzz corpus coverage) (push) Blocked by required conditions
builds / Ubuntu 20.04 (-DNDEBUG) (push) Blocked by required conditions
builds / Ubuntu 20.04 (unsupported rust) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Debug Validation) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Fuzz) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Netmap build) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Blocked by required conditions
builds / Ubuntu 22.04 (DPDK Build) (push) Blocked by required conditions
builds / Debian 12 (xdp) (push) Blocked by required conditions
builds / Debian 13 (xdp) (push) Blocked by required conditions
builds / Ubuntu 22.04 Dist Builder (push) Blocked by required conditions
builds / Debian 12 MSRV (push) Blocked by required conditions
builds / Debian 11 (push) Blocked by required conditions
builds / MacOS Latest (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (NPcap) (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (libpcap) (push) Blocked by required conditions
builds / Windows MSYS2 UCRT64 (libpcap) (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Blocked by required conditions
builds / PF_RING (push) Blocked by required conditions
CodeQL (Rust/C) / Analyze (push) Waiting to run
docs / Prepare dependencies (push) Waiting to run
docs / Prepare cbindgen (push) Waiting to run
docs / Ubuntu 22.04 Dist Builder (push) Blocked by required conditions
Nix Env Build / tests (push) Waiting to run
Scan-build / Scan-build (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
builds / Prepare dependencies (push) Waiting to run
builds / Prepare cbindgen (push) Waiting to run
builds / AlmaLinux 10 (schema, plugins) (push) Blocked by required conditions
builds / AlmaLinux 9 (schema, rust-checks) (push) Blocked by required conditions
builds / AlmaLinux 9 Test Templates (push) Blocked by required conditions
builds / Build RPMs (push) Blocked by required conditions
builds / AlmaLinux 8 (push) Blocked by required conditions
builds / CentOS Stream 9 (push) Blocked by required conditions
builds / Fedora 43 (Suricata Verify codecov) (push) Blocked by required conditions
builds / Fedora 43 (clang, debug, asan, wshadow, rust-strict, systemd) (push) Blocked by required conditions
builds / Fedora 43 (gcc, debug, flto, asan, wshadow, rust-strict) (push) Blocked by required conditions
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Blocked by required conditions
builds / AlmaLinux 9 (no jansson) (push) Blocked by required conditions
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Blocked by required conditions
builds / Ubuntu 24.04 (cocci) (push) Blocked by required conditions
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Blocked by required conditions
builds / Ubuntu 24.04 (unittests coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (unix socket mode coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket and dpdk coverage) (push) Blocked by required conditions
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Blocked by required conditions
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Blocked by required conditions
builds / Ubuntu 24.04 (fuzz corpus coverage) (push) Blocked by required conditions
builds / Ubuntu 20.04 (-DNDEBUG) (push) Blocked by required conditions
builds / Ubuntu 20.04 (unsupported rust) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Debug Validation) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Fuzz) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Netmap build) (push) Blocked by required conditions
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Blocked by required conditions
builds / Ubuntu 22.04 (DPDK Build) (push) Blocked by required conditions
builds / Debian 12 (xdp) (push) Blocked by required conditions
builds / Debian 13 (xdp) (push) Blocked by required conditions
builds / Ubuntu 22.04 Dist Builder (push) Blocked by required conditions
builds / Debian 12 MSRV (push) Blocked by required conditions
builds / Debian 11 (push) Blocked by required conditions
builds / MacOS Latest (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (NPcap) (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (libpcap) (push) Blocked by required conditions
builds / Windows MSYS2 UCRT64 (libpcap) (push) Blocked by required conditions
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Blocked by required conditions
builds / PF_RING (push) Blocked by required conditions
CodeQL (Rust/C) / Analyze (push) Waiting to run
docs / Prepare dependencies (push) Waiting to run
docs / Prepare cbindgen (push) Waiting to run
docs / Ubuntu 22.04 Dist Builder (push) Blocked by required conditions
Nix Env Build / tests (push) Waiting to run
Scan-build / Scan-build (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
With the Alloc callback gone, the size is no longer needed.
This commit is contained in:
parent
f337cd573b
commit
cd9993c568
22 changed files with 62 additions and 83 deletions
|
|
@ -573,13 +573,13 @@ static void NdpiInit(void)
|
|||
SCLogDebug("Initializing nDPI plugin");
|
||||
|
||||
/* Register thread storage. */
|
||||
thread_storage_id = ThreadStorageRegister("ndpi", sizeof(void *), ThreadStorageFree);
|
||||
thread_storage_id = ThreadStorageRegister("ndpi", ThreadStorageFree);
|
||||
if (thread_storage_id.id < 0) {
|
||||
FatalError("Failed to register nDPI thread storage");
|
||||
}
|
||||
|
||||
/* Register flow storage. */
|
||||
flow_storage_id = FlowStorageRegister("ndpi", sizeof(void *), FlowStorageFree);
|
||||
flow_storage_id = FlowStorageRegister("ndpi", FlowStorageFree);
|
||||
if (flow_storage_id.id < 0) {
|
||||
FatalError("Failed to register nDPI flow storage");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,8 @@ uint64_t ExpectationGetCounter(void)
|
|||
|
||||
void AppLayerExpectationSetup(void)
|
||||
{
|
||||
g_ippair_expectation_id =
|
||||
IPPairStorageRegister("expectation", sizeof(void *), ExpectationListFree);
|
||||
g_flow_expectation_id = FlowStorageRegister("expectation", sizeof(void *), ExpectationDataFree);
|
||||
g_ippair_expectation_id = IPPairStorageRegister("expectation", ExpectationListFree);
|
||||
g_flow_expectation_id = FlowStorageRegister("expectation", ExpectationDataFree);
|
||||
SC_ATOMIC_INIT(expectation_count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ void TagInitCtx(void)
|
|||
{
|
||||
SC_ATOMIC_INIT(num_tags);
|
||||
|
||||
host_tag_id = HostStorageRegister("tag", sizeof(void *), DetectTagDataListFree);
|
||||
host_tag_id = HostStorageRegister("tag", DetectTagDataListFree);
|
||||
if (host_tag_id.id == -1) {
|
||||
FatalError("Can't initiate host storage for tag");
|
||||
}
|
||||
flow_tag_id = FlowStorageRegister("tag", sizeof(void *), DetectTagDataListFree);
|
||||
flow_tag_id = FlowStorageRegister("tag", DetectTagDataListFree);
|
||||
if (flow_tag_id.id == -1) {
|
||||
FatalError("Can't initiate flow storage for tag");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ unsigned int LiveDevStorageSize(void)
|
|||
* \brief Register a LiveDevice storage
|
||||
*
|
||||
* \param name the name of the storage
|
||||
* \param size integer coding the size of the stored value (sizeof(void *) is expected here)
|
||||
* \param Free free function for the new storage
|
||||
*
|
||||
* \retval The ID of the newly register storage that will be used to access data
|
||||
|
|
@ -57,10 +56,9 @@ unsigned int LiveDevStorageSize(void)
|
|||
* It has to be called once during the init of the sub system
|
||||
*/
|
||||
|
||||
LiveDevStorageId LiveDevStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *))
|
||||
LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *))
|
||||
{
|
||||
int id = StorageRegister(STORAGE_DEVICE, name, size, Free);
|
||||
int id = StorageRegister(STORAGE_DEVICE, name, Free);
|
||||
LiveDevStorageId ldsi = { .id = id };
|
||||
return ldsi;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr);
|
|||
|
||||
void LiveDevFreeStorage(LiveDevice *d);
|
||||
|
||||
LiveDevStorageId LiveDevStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *));
|
||||
LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *));
|
||||
|
||||
#endif /* SURICATA_DEVICE_STORAGE_H */
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ void FlowFreeStorage(Flow *f)
|
|||
StorageFreeAll(f->storage, STORAGE_FLOW);
|
||||
}
|
||||
|
||||
FlowStorageId FlowStorageRegister(const char *name, const unsigned int size, void (*Free)(void *))
|
||||
FlowStorageId FlowStorageRegister(const char *name, void (*Free)(void *))
|
||||
{
|
||||
int id = StorageRegister(STORAGE_FLOW, name, size, Free);
|
||||
int id = StorageRegister(STORAGE_FLOW, name, Free);
|
||||
FlowStorageId fsi = { .id = id };
|
||||
return fsi;
|
||||
}
|
||||
|
|
@ -78,11 +78,11 @@ static int FlowStorageTest01(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
FlowStorageId id1 = FlowStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id1 = FlowStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
FlowStorageId id2 = FlowStorageRegister("variable", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id2 = FlowStorageRegister("variable", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
FlowStorageId id3 = FlowStorageRegister("store", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id3 = FlowStorageRegister("store", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -128,7 +128,7 @@ static int FlowStorageTest02(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
FlowStorageId id1 = FlowStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id1 = FlowStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -159,11 +159,11 @@ static int FlowStorageTest03(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
FlowStorageId id1 = FlowStorageRegister("test1", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id1 = FlowStorageRegister("test1", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
FlowStorageId id2 = FlowStorageRegister("test2", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id2 = FlowStorageRegister("test2", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
FlowStorageId id3 = FlowStorageRegister("test3", sizeof(void *), StorageTestFree);
|
||||
FlowStorageId id3 = FlowStorageRegister("test3", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,6 @@ void FlowFreeStorage(Flow *h);
|
|||
|
||||
void RegisterFlowStorageTests(void);
|
||||
|
||||
FlowStorageId FlowStorageRegister(const char *name, const unsigned int size, void (*Free)(void *));
|
||||
FlowStorageId FlowStorageRegister(const char *name, void (*Free)(void *));
|
||||
|
||||
#endif /* SURICATA_FLOW_STORAGE_H */
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ static void FlowBypassFree(void *x)
|
|||
|
||||
void RegisterFlowBypassInfo(void)
|
||||
{
|
||||
g_bypass_info_id = FlowStorageRegister("bypass_counters", sizeof(void *), FlowBypassFree);
|
||||
g_bypass_info_id = FlowStorageRegister("bypass_counters", FlowBypassFree);
|
||||
}
|
||||
|
||||
void FlowEndCountersRegister(ThreadVars *t, FlowEndCounters *fec)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void HostBitFreeAll(void *store)
|
|||
|
||||
void HostBitInitCtx(void)
|
||||
{
|
||||
host_bit_id = HostStorageRegister("bit", sizeof(void *), HostBitFreeAll);
|
||||
host_bit_id = HostStorageRegister("bit", HostBitFreeAll);
|
||||
if (host_bit_id.id == -1) {
|
||||
FatalError("Can't initiate host storage for bits");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ unsigned int HostStorageSize(void)
|
|||
* \brief Register a Host storage
|
||||
*
|
||||
* \param name the name of the storage
|
||||
* \param size integer coding the size of the stored value (sizeof(void *) is expected here)
|
||||
* \param Free free function for the new storage
|
||||
*
|
||||
* \retval The ID of the newly register storage that will be used to access data
|
||||
|
|
@ -55,9 +54,9 @@ unsigned int HostStorageSize(void)
|
|||
* It has to be called once during the init of the sub system
|
||||
*/
|
||||
|
||||
HostStorageId HostStorageRegister(const char *name, const unsigned int size, void (*Free)(void *))
|
||||
HostStorageId HostStorageRegister(const char *name, void (*Free)(void *))
|
||||
{
|
||||
int id = StorageRegister(STORAGE_HOST, name, size, Free);
|
||||
int id = StorageRegister(STORAGE_HOST, name, Free);
|
||||
HostStorageId hsi = { .id = id };
|
||||
return hsi;
|
||||
}
|
||||
|
|
@ -114,11 +113,11 @@ static int HostStorageTest01(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
HostStorageId id1 = HostStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id1 = HostStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
HostStorageId id2 = HostStorageRegister("variable", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id2 = HostStorageRegister("variable", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
HostStorageId id3 = HostStorageRegister("store", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id3 = HostStorageRegister("store", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -168,7 +167,7 @@ static int HostStorageTest02(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
HostStorageId id1 = HostStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id1 = HostStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -204,11 +203,11 @@ static int HostStorageTest03(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
HostStorageId id1 = HostStorageRegister("test1", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id1 = HostStorageRegister("test1", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
HostStorageId id2 = HostStorageRegister("test2", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id2 = HostStorageRegister("test2", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
HostStorageId id3 = HostStorageRegister("test3", sizeof(void *), StorageTestFree);
|
||||
HostStorageId id3 = HostStorageRegister("test3", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,6 @@ void HostFreeStorage(Host *h);
|
|||
|
||||
void RegisterHostStorageTests(void);
|
||||
|
||||
HostStorageId HostStorageRegister(const char *name, const unsigned int size, void (*Free)(void *));
|
||||
HostStorageId HostStorageRegister(const char *name, void (*Free)(void *));
|
||||
|
||||
#endif /* SURICATA_HOST_STORAGE_H */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static void XBitFreeAll(void *store)
|
|||
|
||||
void IPPairBitInitCtx(void)
|
||||
{
|
||||
g_ippair_bit_storage_id = IPPairStorageRegister("bit", sizeof(void *), XBitFreeAll);
|
||||
g_ippair_bit_storage_id = IPPairStorageRegister("bit", XBitFreeAll);
|
||||
if (g_ippair_bit_storage_id.id == -1) {
|
||||
FatalError("Can't initiate ippair storage for bits");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,10 +48,9 @@ void IPPairFreeStorage(IPPair *h)
|
|||
StorageFreeAll(h->storage, STORAGE_IPPAIR);
|
||||
}
|
||||
|
||||
IPPairStorageId IPPairStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *))
|
||||
IPPairStorageId IPPairStorageRegister(const char *name, void (*Free)(void *))
|
||||
{
|
||||
int id = StorageRegister(STORAGE_IPPAIR, name, size, Free);
|
||||
int id = StorageRegister(STORAGE_IPPAIR, name, Free);
|
||||
IPPairStorageId ippsi = { .id = id };
|
||||
return ippsi;
|
||||
}
|
||||
|
|
@ -69,11 +68,11 @@ static int IPPairStorageTest01(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
IPPairStorageId id2 = IPPairStorageRegister("variable", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id2 = IPPairStorageRegister("variable", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
IPPairStorageId id3 = IPPairStorageRegister("store", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id3 = IPPairStorageRegister("store", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -125,7 +124,7 @@ static int IPPairStorageTest02(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -164,11 +163,11 @@ static int IPPairStorageTest03(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test1", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id1 = IPPairStorageRegister("test1", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
IPPairStorageId id2 = IPPairStorageRegister("test2", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id2 = IPPairStorageRegister("test2", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
IPPairStorageId id3 = IPPairStorageRegister("test3", sizeof(void *), StorageTestFree);
|
||||
IPPairStorageId id3 = IPPairStorageRegister("test3", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ void IPPairFreeStorage(IPPair *h);
|
|||
|
||||
void RegisterIPPairStorageTests(void);
|
||||
|
||||
IPPairStorageId IPPairStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *));
|
||||
IPPairStorageId IPPairStorageRegister(const char *name, void (*Free)(void *));
|
||||
|
||||
#endif /* SURICATA_IPPAIR_STORAGE_H */
|
||||
|
|
|
|||
|
|
@ -48,10 +48,9 @@ void ThreadFreeStorage(ThreadVars *tv)
|
|||
StorageFreeAll(tv->storage, storage_type);
|
||||
}
|
||||
|
||||
ThreadStorageId ThreadStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *))
|
||||
ThreadStorageId ThreadStorageRegister(const char *name, void (*Free)(void *))
|
||||
{
|
||||
int id = StorageRegister(storage_type, name, size, Free);
|
||||
int id = StorageRegister(storage_type, name, Free);
|
||||
ThreadStorageId tsi = { .id = id };
|
||||
return tsi;
|
||||
}
|
||||
|
|
@ -68,13 +67,13 @@ static int ThreadStorageTest01(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
ThreadStorageId id2 = ThreadStorageRegister("variable", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id2 = ThreadStorageRegister("variable", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
|
||||
ThreadStorageId id3 = ThreadStorageRegister("store", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id3 = ThreadStorageRegister("store", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -123,7 +122,7 @@ static int ThreadStorageTest02(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
@ -153,13 +152,13 @@ static int ThreadStorageTest03(void)
|
|||
StorageCleanup();
|
||||
StorageInit();
|
||||
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test1", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id1 = ThreadStorageRegister("test1", StorageTestFree);
|
||||
FAIL_IF(id1.id < 0);
|
||||
|
||||
ThreadStorageId id2 = ThreadStorageRegister("test2", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id2 = ThreadStorageRegister("test2", StorageTestFree);
|
||||
FAIL_IF(id2.id < 0);
|
||||
|
||||
ThreadStorageId id3 = ThreadStorageRegister("test3", sizeof(void *), StorageTestFree);
|
||||
ThreadStorageId id3 = ThreadStorageRegister("test3", StorageTestFree);
|
||||
FAIL_IF(id3.id < 0);
|
||||
|
||||
FAIL_IF(StorageFinalize() < 0);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ void ThreadFreeStorage(ThreadVars *tv);
|
|||
|
||||
void RegisterThreadStorageTests(void);
|
||||
|
||||
ThreadStorageId ThreadStorageRegister(
|
||||
const char *name, const unsigned int size, void (*Free)(void *));
|
||||
ThreadStorageId ThreadStorageRegister(const char *name, void (*Free)(void *));
|
||||
|
||||
#endif /* SURICATA_THREAD_STORAGE_H */
|
||||
|
|
|
|||
|
|
@ -484,8 +484,7 @@ static void LiveDevExtensionFree(void *x)
|
|||
*/
|
||||
void LiveDevRegisterExtension(void)
|
||||
{
|
||||
g_bypass_storage_id =
|
||||
LiveDevStorageRegister("bypass_stats", sizeof(void *), LiveDevExtensionFree);
|
||||
g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", LiveDevExtensionFree);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -929,8 +929,8 @@ int EBPFCheckBypassedFlowCreate(ThreadVars *th_v, struct timespec *curtime, void
|
|||
|
||||
void EBPFRegisterExtension(void)
|
||||
{
|
||||
g_livedev_storage_id = LiveDevStorageRegister("bpfmap", sizeof(void *), BpfMapsInfoFree);
|
||||
g_flow_storage_id = FlowStorageRegister("bypassedlist", sizeof(void *), BypassedListFree);
|
||||
g_livedev_storage_id = LiveDevStorageRegister("bpfmap", BpfMapsInfoFree);
|
||||
g_flow_storage_id = FlowStorageRegister("bypassedlist", BypassedListFree);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void FlowRateRegisterFlowStorage(void)
|
|||
}
|
||||
flow_rate_config.interval = SCTIME_ADD_SECS(interval, secs);
|
||||
|
||||
g_flowrate_storage_id = FlowStorageRegister("flowrate", sizeof(void *), FlowRateStoreFree);
|
||||
g_flowrate_storage_id = FlowStorageRegister("flowrate", FlowRateStoreFree);
|
||||
}
|
||||
|
||||
bool FlowRateStorageEnabled(void)
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ void MacSetRegisterFlowStorage(void)
|
|||
const char *ethernet =
|
||||
SCConfNodeLookupChildValue(node->head.tqh_first, "ethernet");
|
||||
if (ethernet != NULL && SCConfValIsTrue(ethernet)) {
|
||||
g_macset_storage_id = FlowStorageRegister(
|
||||
"macset", sizeof(void *), (void (*)(void *))MacSetFree);
|
||||
g_macset_storage_id =
|
||||
FlowStorageRegister("macset", (void (*)(void *))MacSetFree);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
typedef struct StorageMapping_ {
|
||||
const char *name;
|
||||
StorageEnum type; // host, flow, tx, stream, ssn, etc
|
||||
unsigned int size;
|
||||
void (*Free)(void *);
|
||||
} StorageMapping;
|
||||
|
||||
|
|
@ -98,14 +97,12 @@ void StorageCleanup(void)
|
|||
storage_list = NULL;
|
||||
}
|
||||
|
||||
int StorageRegister(
|
||||
const StorageEnum type, const char *name, const unsigned int size, void (*Free)(void *))
|
||||
int StorageRegister(const StorageEnum type, const char *name, void (*Free)(void *))
|
||||
{
|
||||
if (storage_registration_closed)
|
||||
return -1;
|
||||
|
||||
if (type >= STORAGE_MAX || name == NULL || strlen(name) == 0 || size == 0 ||
|
||||
size != sizeof(void *) || Free == NULL)
|
||||
if (type >= STORAGE_MAX || name == NULL || strlen(name) == 0 || Free == NULL)
|
||||
return -1;
|
||||
|
||||
StorageList *list = storage_list;
|
||||
|
|
@ -126,7 +123,6 @@ int StorageRegister(
|
|||
|
||||
entry->map.type = type;
|
||||
entry->map.name = name;
|
||||
entry->map.size = size;
|
||||
entry->map.Free = Free;
|
||||
|
||||
entry->id = storage_max_id[type]++;
|
||||
|
|
@ -168,7 +164,6 @@ int StorageFinalize(void)
|
|||
if (storage_map[entry->map.type] != NULL) {
|
||||
storage_map[entry->map.type][entry->id].name = entry->map.name;
|
||||
storage_map[entry->map.type][entry->id].type = entry->map.type;
|
||||
storage_map[entry->map.type][entry->id].size = entry->map.size;
|
||||
storage_map[entry->map.type][entry->id].Free = entry->map.Free;
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +181,7 @@ int StorageFinalize(void)
|
|||
int j;
|
||||
for (j = 0; j < storage_max_id[i]; j++) {
|
||||
StorageMapping *m = &storage_map[i][j];
|
||||
SCLogDebug("type \"%s\" name \"%s\" size \"%"PRIuMAX"\"",
|
||||
StoragePrintType(m->type), m->name, (uintmax_t)m->size);
|
||||
SCLogDebug("type \"%s\" name \"%s\"", StoragePrintType(m->type), m->name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,14 +48,9 @@ void StorageCleanup(void);
|
|||
*
|
||||
* \param type type from StorageEnum
|
||||
* \param name name
|
||||
* \param size size of the per instance storage
|
||||
* \param Free free function for per instance storage
|
||||
*
|
||||
* \note if size == ptr size (so sizeof(void *)) and Alloc == NULL the API just
|
||||
* gives the caller a ptr to store something it alloc'ed itself.
|
||||
*/
|
||||
int StorageRegister(
|
||||
const StorageEnum type, const char *name, const unsigned int size, void (*Free)(void *));
|
||||
int StorageRegister(const StorageEnum type, const char *name, void (*Free)(void *));
|
||||
int StorageFinalize(void);
|
||||
|
||||
unsigned int StorageGetCnt(const StorageEnum type);
|
||||
|
|
|
|||
Loading…
Reference in a new issue