suricata
|
Go to the source code of this file.
Data Structures | |
struct | Host_ |
struct | HostHashRow_ |
struct | HostConfig_ |
Macros | |
#define | HRLOCK_MUTEX |
#define | HRLOCK_TYPE SCMutex |
#define | HRLOCK_INIT(fb) SCMutexInit(&(fb)->lock, NULL) |
#define | HRLOCK_DESTROY(fb) SCMutexDestroy(&(fb)->lock) |
#define | HRLOCK_LOCK(fb) SCMutexLock(&(fb)->lock) |
#define | HRLOCK_TRYLOCK(fb) SCMutexTrylock(&(fb)->lock) |
#define | HRLOCK_UNLOCK(fb) SCMutexUnlock(&(fb)->lock) |
#define | HOST_VERBOSE 0 |
#define | HOST_QUIET 1 |
#define | HOST_CHECK_MEMCAP(size) ((((uint64_t)SC_ATOMIC_GET(host_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(host_config.memcap))) |
check if a memory alloc would fit in the memcap More... | |
#define | HostIncrUsecnt(h) (void)SC_ATOMIC_ADD((h)->use_cnt, 1) |
#define | HostDecrUsecnt(h) (void)SC_ATOMIC_SUB((h)->use_cnt, 1) |
#define | HostReference(dst_h_ptr, h) |
#define | HostDeReference(src_h_ptr) |
Typedefs | |
typedef struct Host_ | Host |
typedef struct HostConfig_ | HostConfig |
Functions | |
struct HostHashRow_ | __attribute__ ((aligned(CLS))) HostHashRow |
SC_ATOMIC_DECLARE (uint64_t, host_memuse) | |
SC_ATOMIC_DECLARE (uint32_t, host_counter) | |
SC_ATOMIC_DECLARE (uint32_t, host_prune_idx) | |
void | HostInitConfig (char quiet) |
initialize the configuration More... | |
void | HostShutdown (void) |
shutdown the flow engine More... | |
void | HostCleanup (void) |
Cleanup the host engine. More... | |
Host * | HostLookupHostFromHash (Address *) |
look up a host in the hash More... | |
Host * | HostGetHostFromHash (Address *) |
void | HostRelease (Host *) |
void | HostLock (Host *) |
void | HostClearMemory (Host *) |
void | HostMoveToSpare (Host *) |
uint32_t | HostSpareQueueGetSize (void) |
void | HostPrintStats (void) |
print some host stats More... | |
void | HostRegisterUnittests (void) |
Host * | HostAlloc (void) |
void | HostFree (Host *) |
void | HostUnlock (Host *h) |
int | HostSetMemcap (uint64_t) |
Update memcap value. More... | |
uint64_t | HostGetMemcap (void) |
Return memcap value. More... | |
uint64_t | HostGetMemuse (void) |
Return memuse value. More... | |
Variables | |
HRLOCK_TYPE | lock |
Host * | head |
Host * | tail |
HostHashRow * | host_hash |
HostConfig | host_config |
Definition in file host.h.
#define HOST_CHECK_MEMCAP | ( | size | ) | ((((uint64_t)SC_ATOMIC_GET(host_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(host_config.memcap))) |
check if a memory alloc would fit in the memcap
size | memory allocation size to check |
1 | it fits |
0 | no fit |
Definition at line 109 of file host.h.
Referenced by HostAlloc(), and HostInitConfig().
#define HOST_QUIET 1 |
Definition at line 93 of file host.h.
Referenced by DetectDetectionFilterRegister(), DetectIPRepFree(), DetectThresholdRegister(), and SCThresholdConfParseFile().
#define HOST_VERBOSE 0 |
Definition at line 92 of file host.h.
Referenced by PostRunDeinit().
#define HostDecrUsecnt | ( | h | ) | (void)SC_ATOMIC_SUB((h)->use_cnt, 1) |
Definition at line 114 of file host.h.
Referenced by HostRelease(), and SRepHostTimedOut().
#define HostDeReference | ( | src_h_ptr | ) |
#define HostIncrUsecnt | ( | h | ) | (void)SC_ATOMIC_ADD((h)->use_cnt, 1) |
Definition at line 112 of file host.h.
Referenced by HostGetHostFromHash(), HostLookupHostFromHash(), and SRepLoadFileFromFD().
#define HostReference | ( | dst_h_ptr, | |
h | |||
) |
Definition at line 117 of file host.h.
Referenced by DetectIPRepRegister().
#define HRLOCK_DESTROY | ( | fb | ) | SCMutexDestroy(&(fb)->lock) |
Definition at line 50 of file host.h.
Referenced by HostShutdown(), and IPPairShutdown().
#define HRLOCK_INIT | ( | fb | ) | SCMutexInit(&(fb)->lock, NULL) |
Definition at line 49 of file host.h.
Referenced by HostInitConfig(), and IPPairInitConfig().
#define HRLOCK_LOCK | ( | fb | ) | SCMutexLock(&(fb)->lock) |
Definition at line 51 of file host.h.
Referenced by HostCleanup(), HostGetHostFromHash(), HostLookupHostFromHash(), IPPairCleanup(), IPPairGetIPPairFromHash(), and IPPairLookupIPPairFromHash().
#define HRLOCK_TRYLOCK | ( | fb | ) | SCMutexTrylock(&(fb)->lock) |
Definition at line 52 of file host.h.
Referenced by HostLookupHostFromHash(), HostTimeoutHash(), IPPairLookupIPPairFromHash(), and IPPairTimeoutHash().
#define HRLOCK_UNLOCK | ( | fb | ) | SCMutexUnlock(&(fb)->lock) |
Definition at line 53 of file host.h.
Referenced by HostCleanup(), HostGetHostFromHash(), HostLookupHostFromHash(), HostTimeoutHash(), IPPairCleanup(), IPPairGetIPPairFromHash(), IPPairLookupIPPairFromHash(), and IPPairTimeoutHash().
typedef struct HostConfig_ HostConfig |
struct HostHashRow_ __attribute__ | ( | (aligned(CLS)) | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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().
SC_ATOMIC_DECLARE | ( | uint64_t | , |
host_memuse | |||
) |
SC_ATOMIC_DECLARE | ( | uint32_t | , |
host_counter | |||
) |
SC_ATOMIC_DECLARE | ( | uint32_t | , |
host_prune_idx | |||
) |
HostConfig host_config |
Definition at line 131 of file host.h.
Referenced by HostCleanup(), HostGetMemcap(), HostInitConfig(), HostLookupHostFromHash(), HostPrintStats(), HostSetMemcap(), HostShutdown(), and HostTimeoutHash().
HostHashRow* host_hash |
host hash table
Definition at line 90 of file host.h.
Referenced by HostCleanup(), HostGetHostFromHash(), HostInitConfig(), HostLookupHostFromHash(), HostShutdown(), and HostTimeoutHash().
HRLOCK_TYPE lock |