suricata
defrag-hash.c File Reference
#include "suricata-common.h"
#include "conf.h"
#include "defrag-hash.h"
#include "defrag-stack.h"
#include "defrag-config.h"
#include "defrag-timeout.h"
#include "util-random.h"
#include "util-byte.h"
#include "util-misc.h"
#include "util-hash-lookup3.h"
#include "util-validate.h"
Include dependency graph for defrag-hash.c:

Go to the source code of this file.

Data Structures

struct  DefragHashKey4_
 
struct  DefragHashKey6_
 

Macros

#define DefragTrackerIncrUsecnt(dt)   SC_ATOMIC_ADD((dt)->use_cnt, 1)
 
#define DefragTrackerDecrUsecnt(dt)   SC_ATOMIC_SUB((dt)->use_cnt, 1)
 
#define DEFRAG_DEFAULT_HASHSIZE   4096
 
#define DEFRAG_DEFAULT_MEMCAP   16777216
 
#define DEFRAG_DEFAULT_PREALLOC   1000
 
#define CMP_DEFRAGTRACKER(d1, d2, id)
 

Typedefs

typedef struct DefragHashKey4_ DefragHashKey4
 
typedef struct DefragHashKey6_ DefragHashKey6
 

Functions

 SC_ATOMIC_DECLARE (uint64_t, defrag_memuse)
 
 SC_ATOMIC_DECLARE (unsigned int, defragtracker_counter)
 
 SC_ATOMIC_DECLARE (unsigned int, defragtracker_prune_idx)
 
int DefragTrackerSetMemcap (uint64_t size)
 Update memcap value. More...
 
uint64_t DefragTrackerGetMemcap (void)
 Return memcap value. More...
 
uint64_t DefragTrackerGetMemuse (void)
 Return memuse value. More...
 
enum ExceptionPolicy DefragGetMemcapExceptionPolicy (void)
 
void DefragTrackerMoveToSpare (DefragTracker *h)
 
void DefragTrackerRelease (DefragTracker *t)
 
void DefragTrackerClearMemory (DefragTracker *dt)
 
void DefragInitConfig (bool quiet)
 initialize the configuration More...
 
void DefragHashShutdown (void)
 shutdown the flow engine More...
 
DefragTrackerDefragGetTrackerFromHash (ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
 
DefragTrackerDefragLookupTrackerFromHash (Packet *p)
 look up a tracker in the hash More...
 

Variables

DefragTrackerHashRowdefragtracker_hash
 
DefragConfig defrag_config
 

Macro Definition Documentation

◆ CMP_DEFRAGTRACKER

#define CMP_DEFRAGTRACKER (   d1,
  d2,
  id 
)
Value:
(((CMP_ADDR(&(d1)->src_addr, &(d2)->src) && CMP_ADDR(&(d1)->dst_addr, &(d2)->dst)) || \
(CMP_ADDR(&(d1)->src_addr, &(d2)->dst) && CMP_ADDR(&(d1)->dst_addr, &(d2)->src))) && \
(d1)->proto == PacketGetIPProto(d2) && (d1)->id == (id) && \
(d1)->vlan_id[0] == (d2)->vlan_id[0] && (d1)->vlan_id[1] == (d2)->vlan_id[1] && \
(d1)->vlan_id[2] == (d2)->vlan_id[2])

Definition at line 437 of file defrag-hash.c.

◆ DEFRAG_DEFAULT_HASHSIZE

#define DEFRAG_DEFAULT_HASHSIZE   4096

Definition at line 164 of file defrag-hash.c.

◆ DEFRAG_DEFAULT_MEMCAP

#define DEFRAG_DEFAULT_MEMCAP   16777216

Definition at line 165 of file defrag-hash.c.

◆ DEFRAG_DEFAULT_PREALLOC

#define DEFRAG_DEFAULT_PREALLOC   1000

Definition at line 166 of file defrag-hash.c.

◆ DefragTrackerDecrUsecnt

#define DefragTrackerDecrUsecnt (   dt)    SC_ATOMIC_SUB((dt)->use_cnt, 1)

Definition at line 125 of file defrag-hash.c.

◆ DefragTrackerIncrUsecnt

#define DefragTrackerIncrUsecnt (   dt)    SC_ATOMIC_ADD((dt)->use_cnt, 1)

Definition at line 123 of file defrag-hash.c.

Typedef Documentation

◆ DefragHashKey4

◆ DefragHashKey6

Function Documentation

◆ DefragGetMemcapExceptionPolicy()

enum ExceptionPolicy DefragGetMemcapExceptionPolicy ( void  )

Definition at line 74 of file defrag-hash.c.

◆ DefragGetTrackerFromHash()

DefragTracker* DefragGetTrackerFromHash ( ThreadVars tv,
DecodeThreadVars dtv,
Packet p 
)

Definition at line 529 of file defrag-hash.c.

◆ DefragHashShutdown()

void DefragHashShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

Definition at line 296 of file defrag-hash.c.

References DefragTrackerDequeue().

Referenced by DefragDestroy().

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

◆ DefragInitConfig()

void DefragInitConfig ( bool  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

Definition at line 169 of file defrag-hash.c.

References defrag_config, DefragTrackerStackInit(), SC_ATOMIC_INIT, and SCLogDebug.

Here is the call graph for this function:

◆ DefragLookupTrackerFromHash()

DefragTracker* DefragLookupTrackerFromHash ( Packet p)

look up a tracker in the hash

Parameters
aaddress to look up
Return values
hLOCKED tracker or NULL

Definition at line 624 of file defrag-hash.c.

◆ DefragTrackerClearMemory()

void DefragTrackerClearMemory ( DefragTracker dt)

Definition at line 158 of file defrag-hash.c.

References DefragTrackerFreeFrags().

Here is the call graph for this function:

◆ DefragTrackerGetMemcap()

uint64_t DefragTrackerGetMemcap ( void  )

Return memcap value.

Return values
memcapvalue

Definition at line 63 of file defrag-hash.c.

References defrag_config, and SC_ATOMIC_GET.

◆ DefragTrackerGetMemuse()

uint64_t DefragTrackerGetMemuse ( void  )

Return memuse value.

Return values
memusevalue

Definition at line 74 of file defrag-hash.c.

References SC_ATOMIC_GET.

◆ DefragTrackerMoveToSpare()

void DefragTrackerMoveToSpare ( DefragTracker h)

Definition at line 85 of file defrag-hash.c.

References DefragTrackerEnqueue().

Here is the call graph for this function:

◆ DefragTrackerRelease()

void DefragTrackerRelease ( DefragTracker t)

Definition at line 152 of file defrag-hash.c.

References DefragTrackerDecrUsecnt, DefragTracker_::lock, and SCMutexUnlock.

◆ DefragTrackerSetMemcap()

int DefragTrackerSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 48 of file defrag-hash.c.

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ SC_ATOMIC_DECLARE() [1/3]

SC_ATOMIC_DECLARE ( uint64_t  ,
defrag_memuse   
)

◆ SC_ATOMIC_DECLARE() [2/3]

SC_ATOMIC_DECLARE ( unsigned int  ,
defragtracker_counter   
)

◆ SC_ATOMIC_DECLARE() [3/3]

SC_ATOMIC_DECLARE ( unsigned int  ,
defragtracker_prune_idx   
)

Variable Documentation

◆ defrag_config

◆ defragtracker_hash

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

Definition at line 31 of file defrag-hash.c.

Referenced by DefragTimeoutHash().

proto
uint8_t proto
Definition: decode-template.h:0
CMP_ADDR
#define CMP_ADDR(a1, a2)
Definition: decode.h:218
src
uint16_t src
Definition: app-layer-dnp3.h:5
dst
uint16_t dst
Definition: app-layer-dnp3.h:4