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

 SC_ATOMIC_DECLARE (uint64_t, host_memuse)
 
 SC_ATOMIC_DECLARE (uint32_t, host_counter)
 
 SC_ATOMIC_DECLARE (uint32_t, host_prune_idx)
 
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)
 

Variables

HostHashRow * host_hash
 
HostConfig host_config
 

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

◆ CMP_HOST

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

Definition at line 415 of file host.c.

◆ HOST_DEFAULT_HASHSIZE

#define HOST_DEFAULT_HASHSIZE   4096

Definition at line 169 of file host.c.

◆ HOST_DEFAULT_MEMCAP

#define HOST_DEFAULT_MEMCAP   16777216

Definition at line 170 of file host.c.

◆ HOST_DEFAULT_PREALLOC

#define HOST_DEFAULT_PREALLOC   1000

Definition at line 171 of file host.c.

Function Documentation

◆ HostAlloc()

Host* HostAlloc ( void  )

Definition at line 110 of file host.c.

References HOST_CHECK_MEMCAP.

◆ HostCleanup()

void HostCleanup ( void  )

Cleanup the host engine.

Cleanup the host engine from tag and threshold.

Definition at line 351 of file host.c.

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

Here is the call graph for this function:

◆ HostClearMemory()

void HostClearMemory ( Host h)

Definition at line 158 of file host.c.

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

Referenced by HostCleanup(), and HostFree().

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

◆ HostFree()

void HostFree ( Host h)

Definition at line 131 of file host.c.

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

Here is the call graph for this function:

◆ HostGetHostFromHash()

Host* HostGetHostFromHash ( Address a)

Definition at line 507 of file host.c.

Referenced by TagHashAddTag().

Here is the caller graph for this function:

◆ HostGetMemcap()

uint64_t HostGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 82 of file host.c.

References host_config, and SC_ATOMIC_GET.

◆ HostGetMemuse()

uint64_t HostGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 93 of file host.c.

References SC_ATOMIC_GET.

◆ HostInitConfig()

void HostInitConfig ( char  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

Definition at line 175 of file host.c.

References HostStorageSize(), and SCLogDebug.

Here is the call graph for this function:

◆ HostLock()

void HostLock ( Host h)

Definition at line 488 of file host.c.

References Host_::m, and SCMutexLock.

◆ HostLookupHostFromHash()

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 606 of file host.c.

◆ HostMoveToSpare()

void HostMoveToSpare ( Host h)

Definition at line 104 of file host.c.

References HostEnqueue().

Referenced by HostCleanup().

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

◆ HostPrintStats()

void HostPrintStats ( void  )

print some host stats

Warning
Not thread safe

Definition at line 294 of file host.c.

References host_config, SC_ATOMIC_GET, and SCLogPerf.

Referenced by HostShutdown().

Here is the caller graph for this function:

◆ HostRegisterUnittests()

void HostRegisterUnittests ( void  )

Definition at line 738 of file host.c.

References RegisterHostStorageTests().

Here is the call graph for this function:

◆ HostRelease()

void HostRelease ( Host h)

Definition at line 482 of file host.c.

References HostDecrUsecnt, Host_::m, and SCMutexUnlock.

◆ HostSetMemcap()

int HostSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 67 of file host.c.

References host_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ HostShutdown()

void HostShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

Definition at line 307 of file host.c.

References HostDequeue(), and HostPrintStats().

Here is the call graph for this function:

◆ HostSpareQueueGetSize()

uint32_t HostSpareQueueGetSize ( void  )

Definition at line 99 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:

◆ HostUnlock()

void HostUnlock ( Host h)

Definition at line 493 of file host.c.

References Host_::m, and SCMutexUnlock.

◆ SC_ATOMIC_DECLARE() [1/3]

SC_ATOMIC_DECLARE ( uint32_t  ,
host_counter   
)

◆ SC_ATOMIC_DECLARE() [2/3]

SC_ATOMIC_DECLARE ( uint32_t  ,
host_prune_idx   
)

◆ SC_ATOMIC_DECLARE() [3/3]

SC_ATOMIC_DECLARE ( uint64_t  ,
host_memuse   
)

Variable Documentation

◆ host_config

HostConfig host_config

Definition at line 52 of file host.c.

Referenced by HostCleanup(), HostGetMemcap(), HostPrintStats(), HostSetMemcap(), and HostTimeoutHash().

◆ host_hash

HostHashRow* host_hash

host hash table

Definition at line 49 of file host.c.

Referenced by HostCleanup(), and HostTimeoutHash().