suricata
ippair.h File Reference
#include "decode.h"
#include "util-storage.h"
Include dependency graph for ippair.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IPPair_
 
struct  IPPairHashRow_
 
struct  IPPairConfig_
 

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 IPPAIR_VERBOSE   0
 
#define IPPAIR_QUIET   1
 
#define IPPAIR_CHECK_MEMCAP(size)   ((((uint64_t)SC_ATOMIC_GET(ippair_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(ippair_config.memcap)))
 check if a memory alloc would fit in the memcap More...
 
#define IPPairIncrUsecnt(h)   (void)SC_ATOMIC_ADD((h)->use_cnt, 1)
 
#define IPPairDecrUsecnt(h)   (void)SC_ATOMIC_SUB((h)->use_cnt, 1)
 
#define IPPairReference(dst_h_ptr, h)
 
#define IPPairDeReference(src_h_ptr)
 

Typedefs

typedef struct IPPair_ IPPair
 
typedef struct IPPairConfig_ IPPairConfig
 

Functions

struct IPPairHashRow_ __attribute__ ((aligned(CLS))) IPPairHashRow
 
 SC_ATOMIC_DECLARE (uint64_t, ippair_memuse)
 
 SC_ATOMIC_DECLARE (uint32_t, ippair_counter)
 
 SC_ATOMIC_DECLARE (uint32_t, ippair_prune_idx)
 
void IPPairInitConfig (char quiet)
 initialize the configuration More...
 
void IPPairShutdown (void)
 shutdown the flow engine More...
 
void IPPairCleanup (void)
 Cleanup the ippair engine. More...
 
IPPairIPPairLookupIPPairFromHash (Address *, Address *)
 look up a ippair in the hash More...
 
IPPairIPPairGetIPPairFromHash (Address *, Address *)
 
void IPPairRelease (IPPair *)
 
void IPPairLock (IPPair *)
 
void IPPairClearMemory (IPPair *)
 
void IPPairMoveToSpare (IPPair *)
 
uint32_t IPPairSpareQueueGetSize (void)
 
void IPPairPrintStats (void)
 print some ippair stats More...
 
void IPPairRegisterUnittests (void)
 
IPPairIPPairAlloc (void)
 
void IPPairFree (IPPair *)
 
void IPPairUnlock (IPPair *)
 
int IPPairSetMemcap (uint64_t size)
 Update memcap value. More...
 
uint64_t IPPairGetMemcap (void)
 Return memcap value. More...
 
uint64_t IPPairGetMemuse (void)
 Return memuse value. More...
 

Variables

HRLOCK_TYPE lock
 
IPPairhead
 
IPPairtail
 
IPPairHashRow * ippair_hash
 
IPPairConfig ippair_config
 

Detailed Description

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

Definition in file ippair.h.

Macro Definition Documentation

#define HRLOCK_DESTROY (   fb)    SCMutexDestroy(&(fb)->lock)

Definition at line 50 of file ippair.h.

#define HRLOCK_INIT (   fb)    SCMutexInit(&(fb)->lock, NULL)

Definition at line 49 of file ippair.h.

#define HRLOCK_LOCK (   fb)    SCMutexLock(&(fb)->lock)

Definition at line 51 of file ippair.h.

#define HRLOCK_MUTEX

Spinlocks or Mutex for the flow buckets.

Definition at line 32 of file ippair.h.

#define HRLOCK_TRYLOCK (   fb)    SCMutexTrylock(&(fb)->lock)

Definition at line 52 of file ippair.h.

#define HRLOCK_TYPE   SCMutex

Definition at line 48 of file ippair.h.

#define HRLOCK_UNLOCK (   fb)    SCMutexUnlock(&(fb)->lock)

Definition at line 53 of file ippair.h.

#define IPPAIR_CHECK_MEMCAP (   size)    ((((uint64_t)SC_ATOMIC_GET(ippair_memuse) + (uint64_t)(size)) <= SC_ATOMIC_GET(ippair_config.memcap)))

check if a memory alloc would fit in the memcap

Parameters
sizememory allocation size to check
Return values
1it fits
0no fit

Definition at line 106 of file ippair.h.

Referenced by IPPairAlloc(), IPPairCleanup(), and IPPairInitConfig().

#define IPPAIR_QUIET   1

Definition at line 90 of file ippair.h.

Referenced by SCThresholdConfParseFile().

#define IPPAIR_VERBOSE   0

Definition at line 89 of file ippair.h.

#define IPPairDecrUsecnt (   h)    (void)SC_ATOMIC_SUB((h)->use_cnt, 1)

Definition at line 111 of file ippair.h.

Referenced by AppLayerExpectationGetDataId(), and IPPairRelease().

#define IPPairDeReference (   src_h_ptr)
Value:
do { \
if (*(src_h_ptr) != NULL) { \
IPPairDecrUsecnt(*(src_h_ptr)); \
*(src_h_ptr) = NULL; \
} \
} while (0)
#define IPPairDecrUsecnt(h)
Definition: ippair.h:111

Definition at line 121 of file ippair.h.

#define IPPairIncrUsecnt (   h)    (void)SC_ATOMIC_ADD((h)->use_cnt, 1)

Definition at line 109 of file ippair.h.

Referenced by IPPairCleanup(), IPPairGetIPPairFromHash(), and IPPairLookupIPPairFromHash().

#define IPPairReference (   dst_h_ptr,
 
)
Value:
do { \
if ((h) != NULL) { \
*(dst_h_ptr) = h; \
} \
} while (0)
#define IPPairIncrUsecnt(h)
Definition: ippair.h:109

Definition at line 114 of file ippair.h.

Typedef Documentation

typedef struct IPPair_ IPPair
typedef struct IPPairConfig_ IPPairConfig

Function Documentation

struct IPPairHashRow_ __attribute__ ( (aligned(CLS))  )
IPPair* IPPairAlloc ( void  )

Definition at line 102 of file ippair.c.

References IPPAIR_CHECK_MEMCAP, IPPair_::m, SC_ATOMIC_ADD, SC_ATOMIC_INIT, SCMalloc, SCMutexInit, and unlikely.

Referenced by IPPairBitIsnotset(), IPPairFree(), and IPPairInitConfig().

Here is the caller graph for this function:

void IPPairCleanup ( void  )

Cleanup the ippair engine.

Cleanup the ippair engine from tag and threshold.

Definition at line 340 of file ippair.c.

References IPPair_::a, CMP_ADDR, COPY_ADDRESS, Address_::family, IPPairConfig_::hash_rand, IPPairConfig_::hash_size, hashword(), IPPair_::hnext, IPPair_::hprev, HRLOCK_LOCK, HRLOCK_UNLOCK, IPPAIR_CHECK_MEMCAP, ippair_config, ippair_hash, IPPairClearMemory(), IPPairDequeue(), IPPairFreeStorage(), IPPairIncrUsecnt, IPPairMoveToSpare(), IPPair_::m, MAX, MIN, SC_ATOMIC_ADD, SC_ATOMIC_GET, and SCMutexLock.

Referenced by DetectXbitFree(), and IPPairBitIsnotset().

Here is the call graph for this function:

Here is the caller graph for this function:

void IPPairClearMemory ( IPPair )

Definition at line 152 of file ippair.c.

References IPPairFreeStorage(), and IPPairStorageSize().

Referenced by IPPairCleanup(), IPPairFree(), IPPairGetActiveCount(), and IPPairLookupIPPairFromHash().

Here is the call graph for this function:

Here is the caller graph for this function:

void IPPairFree ( IPPair )

Definition at line 124 of file ippair.c.

References IPPair_::a, COPY_ADDRESS, IPPairAlloc(), IPPairClearMemory(), IPPair_::m, SC_ATOMIC_DESTROY, SC_ATOMIC_SUB, SCFree, and SCMutexDestroy.

Referenced by IPPairBitIsnotset(), and IPPairShutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

IPPair* IPPairGetIPPairFromHash ( Address ,
Address  
)
uint64_t IPPairGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 74 of file ippair.c.

References ippair_config, and SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

uint64_t IPPairGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 85 of file ippair.c.

References SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void IPPairLock ( IPPair )

Definition at line 526 of file ippair.c.

References IPPair_::m, and SCMutexLock.

IPPair* IPPairLookupIPPairFromHash ( Address a,
Address b 
)

look up a ippair in the hash

Parameters
aaddress to look up
Return values
hLOCKED ippair or NULL

Definition at line 643 of file ippair.c.

References IPPairConfig_::hash_size, IPPair_::hnext, IPPair_::hprev, HRLOCK_LOCK, HRLOCK_TRYLOCK, HRLOCK_UNLOCK, ippair_config, ippair_hash, IPPairClearMemory(), IPPairIncrUsecnt, IPPair_::m, SC_ATOMIC_ADD, SC_ATOMIC_GET, SCMutexLock, SCMutexTrylock, and SCMutexUnlock.

Referenced by AppLayerExpectationSetup(), and DetectXbitsRegister().

Here is the call graph for this function:

Here is the caller graph for this function:

void IPPairMoveToSpare ( IPPair )

Definition at line 96 of file ippair.c.

References IPPairEnqueue(), and SC_ATOMIC_SUB.

Referenced by IPPairCleanup(), and IPPairGetActiveCount().

Here is the call graph for this function:

Here is the caller graph for this function:

void IPPairPrintStats ( void  )

print some ippair stats

Warning
Not thread safe

Definition at line 283 of file ippair.c.

References ippair_config, SC_ATOMIC_GET, and SCLogPerf.

Referenced by IPPairShutdown().

Here is the caller graph for this function:

void IPPairRegisterUnittests ( void  )

Definition at line 775 of file ippair.c.

References RegisterIPPairStorageTests().

Here is the call graph for this function:

void IPPairRelease ( IPPair )

Definition at line 520 of file ippair.c.

References IPPairDecrUsecnt, IPPair_::m, and SCMutexUnlock.

Referenced by AppLayerExpectationHandle(), DetectXbitsRegister(), IPPairStorageRegister(), and PacketAlertThreshold().

Here is the caller graph for this function:

int IPPairSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 59 of file ippair.c.

References ippair_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void IPPairShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

Definition at line 296 of file ippair.c.

References BUG_ON, IPPairConfig_::hash_size, IPPair_::hnext, HRLOCK_DESTROY, ippair_config, ippair_hash, IPPairDequeue(), IPPairFree(), IPPairPrintStats(), IPPairQueueDestroy(), SC_ATOMIC_DESTROY, SC_ATOMIC_GET, SC_ATOMIC_SUB, and SCFreeAligned.

Referenced by IPPairStorageRegister(), PostRunDeinit(), and SCThresholdConfParseFile().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t IPPairSpareQueueGetSize ( void  )

Definition at line 91 of file ippair.c.

References IPPairQueueLen().

Referenced by IPPairGetSpareCount().

Here is the call graph for this function:

Here is the caller graph for this function:

void IPPairUnlock ( IPPair )

Definition at line 531 of file ippair.c.

References IPPair_::m, and SCMutexUnlock.

Referenced by AppLayerExpectationCreate().

Here is the caller graph for this function:

SC_ATOMIC_DECLARE ( uint64_t  ,
ippair_memuse   
)
SC_ATOMIC_DECLARE ( uint32_t  ,
ippair_counter   
)
SC_ATOMIC_DECLARE ( uint32_t  ,
ippair_prune_idx   
)

Variable Documentation

IPPair* head

Definition at line 777 of file ippair.h.

IPPairHashRow* ippair_hash

Definition at line 776 of file ippair.h.

IPPair* tail

Definition at line 778 of file ippair.h.