suricata
defrag-hash.c File Reference
#include "suricata-common.h"
#include "conf.h"
#include "defrag-hash.h"
#include "defrag-queue.h"
#include "defrag-config.h"
#include "util-random.h"
#include "util-byte.h"
#include "util-misc.h"
#include "util-hash-lookup3.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...
 
uint32_t DefragTrackerSpareQueueGetSize (void)
 
void DefragTrackerMoveToSpare (DefragTracker *h)
 
void DefragTrackerRelease (DefragTracker *t)
 
void DefragTrackerClearMemory (DefragTracker *dt)
 
void DefragInitConfig (char quiet)
 initialize the configuration More...
 
void DefragHashShutdown (void)
 shutdown the flow engine More...
 
DefragTrackerDefragGetTrackerFromHash (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 == IP_GET_IPPROTO(d2) && \
(d1)->id == (id) && \
(d1)->vlan_id[0] == (d2)->vlan_id[0] && \
(d1)->vlan_id[1] == (d2)->vlan_id[1])

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

◆ DEFRAG_DEFAULT_HASHSIZE

#define DEFRAG_DEFAULT_HASHSIZE   4096

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

◆ DEFRAG_DEFAULT_MEMCAP

#define DEFRAG_DEFAULT_MEMCAP   16777216

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

◆ DEFRAG_DEFAULT_PREALLOC

#define DEFRAG_DEFAULT_PREALLOC   1000

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

◆ DefragTrackerDecrUsecnt

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

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

◆ DefragTrackerIncrUsecnt

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

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

Typedef Documentation

◆ DefragHashKey4

◆ DefragHashKey6

Function Documentation

◆ DefragGetTrackerFromHash()

DefragTracker* DefragGetTrackerFromHash ( Packet p)

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

◆ DefragHashShutdown()

void DefragHashShutdown ( void  )

shutdown the flow engine

Warning
Not thread safe

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

Referenced by DefragDestroy().

Here is the caller graph for this function:

◆ DefragInitConfig()

void DefragInitConfig ( char  quiet)

initialize the configuration

Warning
Not thread safe

set config values for memcap, prealloc and hash_size

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

References defrag_config, DefragTrackerQueueInit(), 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 625 of file defrag-hash.c.

◆ DefragTrackerClearMemory()

void DefragTrackerClearMemory ( DefragTracker dt)

Definition at line 156 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 60 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 71 of file defrag-hash.c.

References SC_ATOMIC_GET.

◆ DefragTrackerMoveToSpare()

void DefragTrackerMoveToSpare ( DefragTracker h)

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

References DefragTrackerEnqueue().

Here is the call graph for this function:

◆ DefragTrackerRelease()

void DefragTrackerRelease ( DefragTracker t)

Definition at line 150 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 45 of file defrag-hash.c.

References defrag_config, SC_ATOMIC_GET, and SC_ATOMIC_SET.

◆ DefragTrackerSpareQueueGetSize()

uint32_t DefragTrackerSpareQueueGetSize ( void  )

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

References DefragTrackerQueueLen().

Here is the call graph for this function:

◆ 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

DefragConfig defrag_config

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

Referenced by DefragInitConfig(), DefragTrackerGetMemcap(), and DefragTrackerSetMemcap().

◆ defragtracker_hash

DefragTrackerHashRow* defragtracker_hash

defrag tracker hash table

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

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