suricata
ippair-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_IPPAIR_QUEUE_H
25
#define SURICATA_IPPAIR_QUEUE_H
26
27
#include "
suricata-common.h
"
28
#include "
ippair.h
"
29
30
/** Spinlocks or Mutex for the ippair queues. */
31
//#define HQLOCK_SPIN
32
#define HQLOCK_MUTEX
33
34
#ifdef HQLOCK_SPIN
35
#ifdef HQLOCK_MUTEX
36
#error Cannot enable both HQLOCK_SPIN and HQLOCK_MUTEX
37
#endif
38
#endif
39
40
/* Define a queue for storing ippairs */
41
typedef
struct
IPPairQueue_
42
{
43
IPPair
*
top
;
44
IPPair
*
bot
;
45
uint32_t
len
;
46
#ifdef DBG_PERF
47
uint32_t dbg_maxlen;
48
#endif
/* DBG_PERF */
49
#ifdef HQLOCK_MUTEX
50
SCMutex
m
;
51
#elif defined HQLOCK_SPIN
52
SCSpinlock
s;
53
#else
54
#error Enable HQLOCK_SPIN or HQLOCK_MUTEX
55
#endif
56
}
IPPairQueue
;
57
58
#ifdef HQLOCK_SPIN
59
#define HQLOCK_INIT(q) SCSpinInit(&(q)->s, 0)
60
#define HQLOCK_DESTROY(q) SCSpinDestroy(&(q)->s)
61
#define HQLOCK_LOCK(q) SCSpinLock(&(q)->s)
62
#define HQLOCK_TRYLOCK(q) SCSpinTrylock(&(q)->s)
63
#define HQLOCK_UNLOCK(q) SCSpinUnlock(&(q)->s)
64
#elif defined HQLOCK_MUTEX
65
#define HQLOCK_INIT(q) SCMutexInit(&(q)->m, NULL)
66
#define HQLOCK_DESTROY(q) SCMutexDestroy(&(q)->m)
67
#define HQLOCK_LOCK(q) SCMutexLock(&(q)->m)
68
#define HQLOCK_TRYLOCK(q) SCMutexTrylock(&(q)->m)
69
#define HQLOCK_UNLOCK(q) SCMutexUnlock(&(q)->m)
70
#else
71
#error Enable HQLOCK_SPIN or HQLOCK_MUTEX
72
#endif
73
74
/* prototypes */
75
IPPairQueue
*
IPPairQueueNew
(
void
);
76
IPPairQueue
*
IPPairQueueInit
(
IPPairQueue
*);
77
void
IPPairQueueDestroy
(
IPPairQueue
*);
78
79
void
IPPairEnqueue
(
IPPairQueue
*,
IPPair
*);
80
IPPair
*
IPPairDequeue
(
IPPairQueue
*);
81
82
#endif
/* SURICATA_IPPAIR_QUEUE_H */
IPPairQueueDestroy
void IPPairQueueDestroy(IPPairQueue *)
Destroy a ippair queue.
Definition:
ippair-queue.c:58
ippair.h
IPPairQueue_::len
uint32_t len
Definition:
ippair-queue.h:45
IPPairQueueNew
IPPairQueue * IPPairQueueNew(void)
Definition:
ippair-queue.c:42
IPPairQueue_::top
IPPair * top
Definition:
ippair-queue.h:43
IPPairQueueInit
IPPairQueue * IPPairQueueInit(IPPairQueue *)
Definition:
ippair-queue.c:33
IPPairQueue_
Definition:
ippair-queue.h:42
IPPairDequeue
IPPair * IPPairDequeue(IPPairQueue *)
remove a ippair from the queue
Definition:
ippair-queue.c:102
suricata-common.h
IPPair_
Definition:
ippair.h:58
IPPairQueue
struct IPPairQueue_ IPPairQueue
SCSpinlock
#define SCSpinlock
Definition:
threads-debug.h:234
IPPairEnqueue
void IPPairEnqueue(IPPairQueue *, IPPair *)
add a ippair to a queue
Definition:
ippair-queue.c:69
IPPairQueue_::m
SCMutex m
Definition:
ippair-queue.h:50
IPPairQueue_::bot
IPPair * bot
Definition:
ippair-queue.h:44
SCMutex
#define SCMutex
Definition:
threads-debug.h:114
src
ippair-queue.h
Generated on Sat Nov 23 2024 23:30:33 for suricata by
1.8.18