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

Macros

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

Functions

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

Detailed Description

Author
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file util-thash.c.

Macro Definition Documentation

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

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

#define THASH_DEFAULT_HASHSIZE   4096

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

Referenced by THashInit().

#define THASH_DEFAULT_MEMCAP   16777216

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

Referenced by THashInit().

#define THASH_DEFAULT_PREALLOC   1000

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

Referenced by THashInit().

Function Documentation

struct THashDataGetResult THashGetFromHash ( THashTableContext ctx,
void *  data 
)
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 
)
THashData* THashLookupFromHash ( THashTableContext ctx,
void *  data 
)

look up data in the hash

Parameters
datadata to look up
Return values
hLOCKED data or NULL

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

References THashTableContext_::array, THashTableContext_::config, THashData_::data, THashDataConfig_::hash_size, HRLOCK_LOCK, HRLOCK_TRYLOCK, HRLOCK_UNLOCK, THashData_::m, THashData_::next, THashData_::prev, SC_ATOMIC_ADD, SC_ATOMIC_GET, SCMutexLock, SCMutexTrylock, SCMutexUnlock, and THashIncrUsecnt.

Referenced by DatasetsSave().

Here is the caller graph for this function:

void THashShutdown ( THashTableContext ctx)

shutdown the flow engine

Warning
Not thread safe

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

References THashTableContext_::array, BUG_ON, THashTableContext_::config, THashDataConfig_::hash_size, HRLOCK_DESTROY, THashData_::next, SC_ATOMIC_DESTROY, SC_ATOMIC_GET, SC_ATOMIC_SUB, SCFree, SCFreeAligned, and THashTableContext_::spare_q.

Referenced by DatasetGet(), and DatasetsDestroy().

Here is the caller graph for this function:

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

Walk the hash.

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

References THashTableContext_::array, THashTableContext_::config, THashData_::data, THashDataConfig_::hash_size, HRLOCK_LOCK, HRLOCK_UNLOCK, and THashData_::next.

Referenced by DatasetsSave().

Here is the caller graph for this function: