suricata
defrag-stack.h
Go to the documentation of this file.
1
/* Copyright (C) 2007-2024 Open Information Security Foundation
2
*
3
* You can copy, redistribute or modify this Program under the terms of
4
* the GNU General Public License version 2 as published by the Free
5
* Software Foundation.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* version 2 along with this program; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
* 02110-1301, USA.
16
*/
17
18
/**
19
* \file
20
*
21
* \author Victor Julien <victor@inliniac.net>
22
*/
23
24
#ifndef SURICATA_DEFRAG_QUEUE_H
25
#define SURICATA_DEFRAG_QUEUE_H
26
27
#include "
suricata-common.h
"
28
#include "
defrag.h
"
29
30
/** Spinlocks or Mutex for the defrag tracker queues. */
31
//#define DQLOCK_SPIN
32
#define DQLOCK_MUTEX
33
34
#ifdef DQLOCK_SPIN
35
#ifdef DQLOCK_MUTEX
36
#error Cannot enable both DQLOCK_SPIN and DQLOCK_MUTEX
37
#endif
38
#endif
39
40
/* Define a queue for storing defrag trackers */
41
typedef
struct
DefragTrackerStack_
{
42
DefragTracker
*
s
;
43
uint32_t
len
;
44
#ifdef DBG_PERF
45
uint32_t dbg_maxlen;
46
#endif
/* DBG_PERF */
47
#ifdef DQLOCK_MUTEX
48
SCMutex
m
;
49
#elif defined DQLOCK_SPIN
50
SCSpinlock
s
;
51
#else
52
#error Enable DQLOCK_SPIN or DQLOCK_MUTEX
53
#endif
54
}
DefragTrackerStack
;
55
56
#ifdef DQLOCK_SPIN
57
#define DQLOCK_INIT(q) SCSpinInit(&(q)->s, 0)
58
#define DQLOCK_DESTROY(q) SCSpinDestroy(&(q)->s)
59
#define DQLOCK_LOCK(q) SCSpinLock(&(q)->s)
60
#define DQLOCK_TRYLOCK(q) SCSpinTrylock(&(q)->s)
61
#define DQLOCK_UNLOCK(q) SCSpinUnlock(&(q)->s)
62
#elif defined DQLOCK_MUTEX
63
#define DQLOCK_INIT(q) SCMutexInit(&(q)->m, NULL)
64
#define DQLOCK_DESTROY(q) SCMutexDestroy(&(q)->m)
65
#define DQLOCK_LOCK(q) SCMutexLock(&(q)->m)
66
#define DQLOCK_TRYLOCK(q) SCMutexTrylock(&(q)->m)
67
#define DQLOCK_UNLOCK(q) SCMutexUnlock(&(q)->m)
68
#else
69
#error Enable DQLOCK_SPIN or DQLOCK_MUTEX
70
#endif
71
72
/* prototypes */
73
DefragTrackerStack
*
DefragTrackerStackInit
(
DefragTrackerStack
*);
74
void
DefragTrackerStackDestroy
(
DefragTrackerStack
*);
75
76
void
DefragTrackerEnqueue
(
DefragTrackerStack
*,
DefragTracker
*);
77
DefragTracker
*
DefragTrackerDequeue
(
DefragTrackerStack
*);
78
79
#endif
/* SURICATA_DEFRAG_QUEUE_H */
DefragTrackerStackDestroy
void DefragTrackerStackDestroy(DefragTrackerStack *)
Destroy a tracker queue.
Definition:
defrag-stack.c:46
DefragTrackerStack_::m
SCMutex m
Definition:
defrag-stack.h:48
DefragTracker_
Definition:
defrag.h:84
DefragTrackerEnqueue
void DefragTrackerEnqueue(DefragTrackerStack *, DefragTracker *)
add a tracker to a queue
Definition:
defrag-stack.c:57
defrag.h
DefragTrackerStack_
Definition:
defrag-stack.h:41
DefragTrackerStack_::s
DefragTracker * s
Definition:
defrag-stack.h:42
suricata-common.h
DefragTrackerStack_::len
uint32_t len
Definition:
defrag-stack.h:43
SCSpinlock
#define SCSpinlock
Definition:
threads-debug.h:234
DefragTrackerStackInit
DefragTrackerStack * DefragTrackerStackInit(DefragTrackerStack *)
Definition:
defrag-stack.c:32
DefragTrackerDequeue
DefragTracker * DefragTrackerDequeue(DefragTrackerStack *)
remove a tracker from the queue
Definition:
defrag-stack.c:81
DefragTrackerStack
struct DefragTrackerStack_ DefragTrackerStack
SCMutex
#define SCMutex
Definition:
threads-debug.h:114
src
defrag-stack.h
Generated on Sat Nov 16 2024 23:30:29 for suricata by
1.8.18