suricata
host.c File Reference
#include "suricata-common.h"
#include "conf.h"
#include "util-debug.h"
#include "host.h"
#include "host-storage.h"
#include "host-bit.h"
#include "util-random.h"
#include "util-misc.h"
#include "util-byte.h"
#include "host-queue.h"
#include "detect-tag.h"
#include "detect-engine-tag.h"
#include "detect-engine-threshold.h"
#include "util-hash-lookup3.h"
Include dependency graph for host.c:

Go to the source code of this file.

Macros

#define HOST_DEFAULT_HASHSIZE   4096
 
#define HOST_DEFAULT_MEMCAP   16777216
 
#define HOST_DEFAULT_PREALLOC   1000
 
#define CMP_HOST(h, a)   (CMP_ADDR(&(h)->a, (a)))
 

Functions

int HostSetMemcap (uint64_t size)
 Update memcap value. More...
 
uint64_t HostGetMemcap (void)
 Return memcap value. More...
 
uint64_t HostGetMemuse (void)
 Return memuse value. More...
 
uint32_t HostSpareQueueGetSize (void)
 
void HostMoveToSpare (Host *h)
 
HostHostAlloc (void)
 
void HostFree (Host *h)
 
void HostClearMemory (Host *h)
 
void HostInitConfig (char quiet)
 initialize the configuration More...
 
void HostPrintStats (void)
 print some host stats More...
 
void HostShutdown (void)
 shutdown the flow engine More...
 
void HostCleanup (void)
 Cleanup the host engine. More...
 
void HostRelease (Host *h)
 
void HostLock (Host *h)
 
void HostUnlock (Host *h)
 
HostHostGetHostFromHash (Address *a)
 
HostHostLookupHostFromHash (Address *a)
 look up a host in the hash More...
 
void HostRegisterUnittests (void)
 

Detailed Description

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

Information about hosts.

Definition in file host.c.

Macro Definition Documentation

#define CMP_HOST (   h,
 
)    (CMP_ADDR(&(h)->a, (a)))

Definition at line 408 of file host.c.

#define HOST_DEFAULT_HASHSIZE   4096

Definition at line 162 of file host.c.

Referenced by HostInitConfig().

#define HOST_DEFAULT_MEMCAP   16777216

Definition at line 163 of file host.c.

Referenced by HostInitConfig().

#define HOST_DEFAULT_PREALLOC   1000

Definition at line 164 of file host.c.

Referenced by HostInitConfig().

Function Documentation

Host* HostAlloc ( void  )

Definition at line 103 of file host.c.

References HOST_CHECK_MEMCAP, Host_::m, SC_ATOMIC_ADD, SC_ATOMIC_INIT, SCMalloc, SCMutexInit, and unlikely.

Referenced by HostBitList(), HostFree(), and HostInitConfig().

Here is the caller graph for this function:

void HostCleanup ( void  )

Cleanup the host engine.

Cleanup the host engine from tag and threshold.

Definition at line 344 of file host.c.

References Address_::family, HostConfig_::hash_rand, HostConfig_::hash_size, hashword(), Host_::hnext, host_config, host_hash, HostClearMemory(), HostFreeStorage(), HostMoveToSpare(), Host_::hprev, HRLOCK_LOCK, HRLOCK_UNLOCK, Host_::iprep, and SC_ATOMIC_GET.

Referenced by DetectHostbitFree(), DetectXbitFree(), HostBitList(), and PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void HostClearMemory ( Host h)

Definition at line 151 of file host.c.

References HostFreeStorage(), HostStorageSize(), Host_::iprep, and SCFree.

Referenced by HostCleanup(), HostFree(), HostGetActiveCount(), and HostLookupHostFromHash().

Here is the call graph for this function:

Here is the caller graph for this function:

void HostFree ( Host h)

Definition at line 124 of file host.c.

References Host_::a, COPY_ADDRESS, HostAlloc(), HostClearMemory(), Host_::m, SC_ATOMIC_DESTROY, SC_ATOMIC_SUB, SCFree, and SCMutexDestroy.

Referenced by HostBitList(), and HostShutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

Host* HostGetHostFromHash ( Address a)
uint64_t HostGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 75 of file host.c.

References host_config, and SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

uint64_t HostGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 86 of file host.c.

References SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void HostLock ( Host h)

Definition at line 481 of file host.c.

References Host_::m, and SCMutexLock.

Referenced by DetectHostbitsRegister(), and DetectIPRepRegister().

Here is the caller graph for this function:

Host* HostLookupHostFromHash ( Address a)

look up a host in the hash

Parameters
aaddress to look up
Return values
hLOCKED host or NULL

Definition at line 599 of file host.c.

References HostConfig_::hash_size, Host_::hnext, host_config, host_hash, HostClearMemory(), HostIncrUsecnt, Host_::hprev, HRLOCK_LOCK, HRLOCK_TRYLOCK, HRLOCK_UNLOCK, Host_::m, SC_ATOMIC_ADD, SC_ATOMIC_GET, SCMutexLock, SCMutexTrylock, and SCMutexUnlock.

Referenced by DetectHostbitsRegister(), DetectIPRepRegister(), DetectThresholdRegister(), TagHandlePacket(), TagTimeoutCheck(), and UnixSocketPcapFile().

Here is the call graph for this function:

Here is the caller graph for this function:

void HostMoveToSpare ( Host h)

Definition at line 97 of file host.c.

References HostEnqueue(), and SC_ATOMIC_SUB.

Referenced by HostCleanup(), and HostGetActiveCount().

Here is the call graph for this function:

Here is the caller graph for this function:

void HostPrintStats ( void  )

print some host stats

Warning
Not thread safe

Definition at line 287 of file host.c.

References host_config, SC_ATOMIC_GET, and SCLogPerf.

Referenced by HostShutdown(), and SRepInit().

Here is the caller graph for this function:

void HostRegisterUnittests ( void  )

Definition at line 731 of file host.c.

References RegisterHostStorageTests().

Here is the call graph for this function:

void HostRelease ( Host h)
int HostSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 60 of file host.c.

References host_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void HostShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

Definition at line 300 of file host.c.

References BUG_ON, HostConfig_::hash_size, Host_::hnext, host_config, host_hash, HostDequeue(), HostFree(), HostPrintStats(), HostQueueDestroy(), HRLOCK_DESTROY, SC_ATOMIC_DESTROY, SC_ATOMIC_GET, SC_ATOMIC_SUB, and SCFreeAligned.

Referenced by DetectDetectionFilterRegister(), DetectIPRepFree(), DetectThresholdRegister(), GlobalsInitPreConfig(), HostFreeStorage(), SCThresholdConfParseFile(), and TagTimeoutCheck().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t HostSpareQueueGetSize ( void  )

Definition at line 92 of file host.c.

References HostQueueLen().

Referenced by HostGetSpareCount().

Here is the call graph for this function:

Here is the caller graph for this function:

void HostUnlock ( Host h)

Definition at line 486 of file host.c.

References Host_::m, and SCMutexUnlock.

Referenced by DetectHostbitsRegister(), and UnixSocketPcapFile().

Here is the caller graph for this function: