util-thash.c File Reference
#include "suricata-common.h"
#include "conf.h"
#include "util-debug.h"
#include "util-thash.h"
#include "util-random.h"
#include "util-misc.h"
#include "util-byte.h"
#include "util-hash-lookup3.h"
Include dependency graph for util-thash.c:

Go to the source code of this file.


#define THASH_DEFAULT_MEMCAP   16777216
#define GET_VAR(prefix, name)   snprintf(varname, sizeof(varname), "%s.%s", (prefix), (name))


THashDataQueueTHashDataQueueNew (void)
THashTableContextTHashInit (const char *cnf_prefix, size_t data_size, int(*DataSet)(void *, void *), void(*DataFree)(void *), uint32_t(*DataHash)(void *), bool(*DataCompare)(void *, void *), bool reset_memcap, uint64_t memcap, uint32_t hashsize)
void THashConsolidateMemcap (THashTableContext *ctx)
void THashShutdown (THashTableContext *ctx)
 shutdown the flow engine More...
int THashWalk (THashTableContext *ctx, THashFormatFunc FormatterFunc, THashOutputFunc OutputterFunc, void *output_ctx)
 Walk the hash. More...
void THashCleanup (THashTableContext *ctx)
 Cleanup the thash engine. More...
struct THashDataGetResult THashGetFromHash (THashTableContext *ctx, void *data)
THashDataTHashLookupFromHash (THashTableContext *ctx, void *data)
 look up data in the hash More...
int THashRemoveFromHash (THashTableContext *ctx, void *data)

Detailed Description

Victor Julien

Definition in file util-thash.c.

Macro Definition Documentation


#define GET_VAR (   prefix,
)    snprintf(varname, sizeof(varname), "%s.%s", (prefix), (name))

Definition at line 203 of file util-thash.c.



Definition at line 199 of file util-thash.c.


#define THASH_DEFAULT_MEMCAP   16777216

Definition at line 200 of file util-thash.c.



Definition at line 201 of file util-thash.c.

Function Documentation

◆ THashCleanup()

void THashCleanup ( THashTableContext ctx)

Cleanup the thash engine.

Cleanup the thash engine from tag and threshold.

Definition at line 415 of file util-thash.c.

References THashTableContext_::array, THashTableContext_::config, THashDataConfig_::hash_size, HRLOCK_LOCK, THashData_::next, THashData_::prev, and SC_ATOMIC_GET.

◆ THashConsolidateMemcap()

void THashConsolidateMemcap ( THashTableContext ctx)

◆ THashDataQueueNew()

THashDataQueue* THashDataQueueNew ( void  )

Definition at line 55 of file util-thash.c.

References SC_ERR_FATAL, SCLogError, and SCMalloc.

◆ THashGetFromHash()

struct THashDataGetResult THashGetFromHash ( THashTableContext ctx,
void *  data 

Definition at line 482 of file util-thash.c.

◆ THashInit()

THashTableContext* THashInit ( const char *  cnf_prefix,
size_t  data_size,
int(*)(void *, void *)  DataSet,
void(*)(void *)  DataFree,
uint32_t(*)(void *)  DataHash,
bool(*)(void *, void *)  DataCompare,
bool  reset_memcap,
uint64_t  memcap,
uint32_t  hashsize 

◆ THashLookupFromHash()

THashData* THashLookupFromHash ( THashTableContext ctx,
void *  data 

look up data in the hash

datadata to look up
Return values
hLOCKED data or NULL

Definition at line 639 of file util-thash.c.

◆ THashRemoveFromHash()

int THashRemoveFromHash ( THashTableContext ctx,
void *  data 
Return values
int-1 not found
int0 found, but it was busy (ref cnt)
int1 found and removed

Definition at line 774 of file util-thash.c.

◆ THashShutdown()

void THashShutdown ( THashTableContext ctx)

shutdown the flow engine

Not thread safe

Definition at line 345 of file util-thash.c.

◆ THashWalk()

int THashWalk ( THashTableContext ctx,
THashFormatFunc  FormatterFunc,
THashOutputFunc  OutputterFunc,
void *  output_ctx