suricata
|
#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"
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) |
Host * | HostAlloc (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) |
Host * | HostGetHostFromHash (Address *a) |
Host * | HostLookupHostFromHash (Address *a) |
look up a host in the hash More... | |
void | HostRegisterUnittests (void) |
Information about hosts.
Definition in 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().
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().
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().
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().
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().
Definition at line 500 of file host.c.
References Host_::hnext, host_hash, HostIncrUsecnt, Host_::hprev, HRLOCK_LOCK, HRLOCK_UNLOCK, Host_::m, and SCMutexLock.
Referenced by DetectHostbitsRegister(), HostFreeStorage(), PacketAlertThreshold(), SRepLoadFileFromFD(), TagHashAddTag(), and UnixSocketPcapFile().
uint64_t HostGetMemcap | ( | void | ) |
Return memcap value.
memcap | value |
Definition at line 75 of file host.c.
References host_config, and SC_ATOMIC_GET.
Referenced by RunModeUnixSocketGetDefaultMode().
uint64_t HostGetMemuse | ( | void | ) |
Return memuse value.
memuse | value |
Definition at line 86 of file host.c.
References SC_ATOMIC_GET.
Referenced by RunModeUnixSocketGetDefaultMode().
void HostInitConfig | ( | char | quiet | ) |
initialize the configuration
set config values for memcap, prealloc and hash_size
Definition at line 168 of file host.c.
References ByteExtractStringUint32(), CLS, ConfGetValue(), FALSE, HostConfig_::hash_rand, HostConfig_::hash_size, HOST_CHECK_MEMCAP, host_config, HOST_DEFAULT_HASHSIZE, HOST_DEFAULT_MEMCAP, HOST_DEFAULT_PREALLOC, host_hash, HostAlloc(), HostEnqueue(), HostQueueInit(), HostStorageSize(), HRLOCK_INIT, HostQueue_::len, ParseSizeStringU64(), HostConfig_::prealloc, RandomGet(), SC_ATOMIC_ADD, SC_ATOMIC_GET, SC_ATOMIC_INIT, SC_ATOMIC_SET, SC_ERR_FATAL, SC_ERR_HOST_INIT, SC_ERR_SIZE_PARSE, SCLogDebug, SCLogError, SCMallocAligned, unlikely, and WarnInvalidConfEntry.
Referenced by DetectDetectionFilterRegister(), DetectHostbitFree(), DetectIPRepFree(), DetectThresholdRegister(), DetectXbitFree(), HostBitList(), HostFreeStorage(), PostRunDeinit(), SCThresholdConfParseFile(), and TagTimeoutCheck().
void HostLock | ( | Host * | h | ) |
Definition at line 481 of file host.c.
References Host_::m, and SCMutexLock.
Referenced by DetectHostbitsRegister(), and DetectIPRepRegister().
look up a host in the hash
a | address to look up |
h | LOCKED 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().
void HostMoveToSpare | ( | Host * | h | ) |
Definition at line 97 of file host.c.
References HostEnqueue(), and SC_ATOMIC_SUB.
Referenced by HostCleanup(), and HostGetActiveCount().
void HostPrintStats | ( | void | ) |
print some host stats
Definition at line 287 of file host.c.
References host_config, SC_ATOMIC_GET, and SCLogPerf.
Referenced by HostShutdown(), and SRepInit().
void HostRegisterUnittests | ( | void | ) |
Definition at line 731 of file host.c.
References RegisterHostStorageTests().
void HostRelease | ( | Host * | h | ) |
Definition at line 475 of file host.c.
References HostDecrUsecnt, Host_::m, and SCMutexUnlock.
Referenced by DetectIPRepRegister(), DetectThresholdRegister(), HostFreeStorage(), PacketAlertThreshold(), SRepLoadFileFromFD(), TagHandlePacket(), TagHashAddTag(), and TagTimeoutCheck().
int HostSetMemcap | ( | uint64_t | size | ) |
Update memcap value.
size | new memcap value |
Definition at line 60 of file host.c.
References host_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.
Referenced by RunModeUnixSocketGetDefaultMode().
void HostShutdown | ( | void | ) |
shutdown the flow engine
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().
uint32_t HostSpareQueueGetSize | ( | void | ) |
Definition at line 92 of file host.c.
References HostQueueLen().
Referenced by HostGetSpareCount().
void HostUnlock | ( | Host * | h | ) |
Definition at line 486 of file host.c.
References Host_::m, and SCMutexUnlock.
Referenced by DetectHostbitsRegister(), and UnixSocketPcapFile().