suricata
defrag-stack.c
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
* Defrag tracker queue handler functions
24
*/
25
26
#include "
suricata-common.h
"
27
#include "
defrag-stack.h
"
28
#include "
util-error.h
"
29
#include "
util-debug.h
"
30
#include "
util-print.h
"
31
32
DefragTrackerStack
*
DefragTrackerStackInit
(
DefragTrackerStack
*q)
33
{
34
if
(q != NULL) {
35
memset(q, 0,
sizeof
(
DefragTrackerStack
));
36
DQLOCK_INIT
(q);
37
}
38
return
q;
39
}
40
41
/**
42
* \brief Destroy a tracker queue
43
*
44
* \param q the tracker queue to destroy
45
*/
46
void
DefragTrackerStackDestroy
(
DefragTrackerStack
*q)
47
{
48
DQLOCK_DESTROY
(q);
49
}
50
51
/**
52
* \brief add a tracker to a queue
53
*
54
* \param q queue
55
* \param dt tracker
56
*/
57
void
DefragTrackerEnqueue
(
DefragTrackerStack
*q,
DefragTracker
*dt)
58
{
59
#ifdef DEBUG
60
BUG_ON
(q == NULL || dt == NULL);
61
#endif
62
63
DQLOCK_LOCK
(q);
64
dt->
lnext
= q->
s
;
65
q->
s
= dt;
66
q->
len
++;
67
#ifdef DBG_PERF
68
if
(q->
len
> q->dbg_maxlen)
69
q->dbg_maxlen = q->
len
;
70
#endif
/* DBG_PERF */
71
DQLOCK_UNLOCK
(q);
72
}
73
74
/**
75
* \brief remove a tracker from the queue
76
*
77
* \param q queue
78
*
79
* \retval dt tracker or NULL if empty list.
80
*/
81
DefragTracker
*
DefragTrackerDequeue
(
DefragTrackerStack
*q)
82
{
83
DQLOCK_LOCK
(q);
84
85
DefragTracker
*dt = q->
s
;
86
if
(dt == NULL) {
87
DQLOCK_UNLOCK
(q);
88
return
NULL;
89
}
90
q->
s
= dt->
lnext
;
91
dt->
lnext
= NULL;
92
93
#ifdef DEBUG
94
BUG_ON
(q->
len
== 0);
95
#endif
96
if
(q->
len
> 0)
97
q->
len
--;
98
DQLOCK_UNLOCK
(q);
99
return
dt;
100
}
DefragTrackerDequeue
DefragTracker * DefragTrackerDequeue(DefragTrackerStack *q)
remove a tracker from the queue
Definition:
defrag-stack.c:81
DQLOCK_DESTROY
#define DQLOCK_DESTROY(q)
Definition:
defrag-stack.h:64
DQLOCK_UNLOCK
#define DQLOCK_UNLOCK(q)
Definition:
defrag-stack.h:67
util-debug.h
util-error.h
DQLOCK_INIT
#define DQLOCK_INIT(q)
Definition:
defrag-stack.h:63
DefragTracker_
Definition:
defrag.h:84
util-print.h
DQLOCK_LOCK
#define DQLOCK_LOCK(q)
Definition:
defrag-stack.h:65
BUG_ON
#define BUG_ON(x)
Definition:
suricata-common.h:300
DefragTrackerStack_
Definition:
defrag-stack.h:41
DefragTrackerStack_::s
DefragTracker * s
Definition:
defrag-stack.h:42
DefragTrackerStackDestroy
void DefragTrackerStackDestroy(DefragTrackerStack *q)
Destroy a tracker queue.
Definition:
defrag-stack.c:46
suricata-common.h
defrag-stack.h
DefragTrackerStack_::len
uint32_t len
Definition:
defrag-stack.h:43
DefragTracker_::lnext
struct DefragTracker_ * lnext
Definition:
defrag.h:122
DefragTrackerStackInit
DefragTrackerStack * DefragTrackerStackInit(DefragTrackerStack *q)
Definition:
defrag-stack.c:32
DefragTrackerEnqueue
void DefragTrackerEnqueue(DefragTrackerStack *q, DefragTracker *dt)
add a tracker to a queue
Definition:
defrag-stack.c:57
src
defrag-stack.c
Generated on Sat Nov 16 2024 23:30:29 for suricata by
1.8.18