suricata
defrag-queue.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2012 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 DefragTrackerQueue_
42 {
45  uint32_t len;
46 #ifdef DBG_PERF
47  uint32_t dbg_maxlen;
48 #endif /* DBG_PERF */
49 #ifdef DQLOCK_MUTEX
51 #elif defined DQLOCK_SPIN
52  SCSpinlock s;
53 #else
54  #error Enable DQLOCK_SPIN or DQLOCK_MUTEX
55 #endif
57 
58 #ifdef DQLOCK_SPIN
59  #define DQLOCK_INIT(q) SCSpinInit(&(q)->s, 0)
60  #define DQLOCK_DESTROY(q) SCSpinDestroy(&(q)->s)
61  #define DQLOCK_LOCK(q) SCSpinLock(&(q)->s)
62  #define DQLOCK_TRYLOCK(q) SCSpinTrylock(&(q)->s)
63  #define DQLOCK_UNLOCK(q) SCSpinUnlock(&(q)->s)
64 #elif defined DQLOCK_MUTEX
65  #define DQLOCK_INIT(q) SCMutexInit(&(q)->m, NULL)
66  #define DQLOCK_DESTROY(q) SCMutexDestroy(&(q)->m)
67  #define DQLOCK_LOCK(q) SCMutexLock(&(q)->m)
68  #define DQLOCK_TRYLOCK(q) SCMutexTrylock(&(q)->m)
69  #define DQLOCK_UNLOCK(q) SCMutexUnlock(&(q)->m)
70 #else
71  #error Enable DQLOCK_SPIN or DQLOCK_MUTEX
72 #endif
73 
74 /* prototypes */
78 
81 
82 #endif /* SURICATA_DEFRAG_QUEUE_H */
DefragTrackerEnqueue
void DefragTrackerEnqueue(DefragTrackerQueue *, DefragTracker *)
add a tracker to a queue
Definition: defrag-queue.c:68
DefragTrackerQueueNew
DefragTrackerQueue * DefragTrackerQueueNew(void)
Definition: defrag-queue.c:41
DefragTrackerQueue_::bot
DefragTracker * bot
Definition: defrag-queue.h:44
DefragTracker_
Definition: defrag.h:86
DefragTrackerQueue
struct DefragTrackerQueue_ DefragTrackerQueue
DefragTrackerQueue_
Definition: defrag-queue.h:42
defrag.h
DefragTrackerQueue_::len
uint32_t len
Definition: defrag-queue.h:45
suricata-common.h
DefragTrackerDequeue
DefragTracker * DefragTrackerDequeue(DefragTrackerQueue *)
remove a tracker from the queue
Definition: defrag-queue.c:101
SCSpinlock
#define SCSpinlock
Definition: threads-debug.h:234
DefragTrackerQueue_::top
DefragTracker * top
Definition: defrag-queue.h:43
SCMutex
#define SCMutex
Definition: threads-debug.h:114
DefragTrackerQueueInit
DefragTrackerQueue * DefragTrackerQueueInit(DefragTrackerQueue *)
Definition: defrag-queue.c:32
DefragTrackerQueue_::m
SCMutex m
Definition: defrag-queue.h:50
DefragTrackerQueueDestroy
void DefragTrackerQueueDestroy(DefragTrackerQueue *)
Destroy a tracker queue.
Definition: defrag-queue.c:57