]>
git.ipfire.org Git - people/ms/suricata.git/blob - src/flow-queue.h
1 /* Copyright (C) 2007-2012 Open Information Security Foundation
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
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.
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
21 * \author Victor Julien <victor@inliniac.net>
24 #ifndef __FLOW_QUEUE_H__
25 #define __FLOW_QUEUE_H__
27 #include "suricata-common.h"
30 /** Spinlocks or Mutex for the flow queues. */
36 #error Cannot enable both FQLOCK_SPIN and FQLOCK_MUTEX
40 typedef struct FlowQueuePrivate_
47 /* Define a queue for storing flows */
48 typedef struct FlowQueue_
50 FlowQueuePrivate priv
;
51 SC_ATOMIC_DECLARE(bool,non_empty
);
54 #elif defined FQLOCK_SPIN
57 #error Enable FQLOCK_SPIN or FQLOCK_MUTEX
65 #define FQLOCK_INIT(q) SCSpinInit(&(q)->s, 0)
66 #define FQLOCK_DESTROY(q) SCSpinDestroy(&(q)->s)
67 #define FQLOCK_LOCK(q) SCSpinLock(&(q)->s)
68 #define FQLOCK_TRYLOCK(q) SCSpinTrylock(&(q)->s)
69 #define FQLOCK_UNLOCK(q) SCSpinUnlock(&(q)->s)
70 #elif defined FQLOCK_MUTEX
71 #define FQLOCK_INIT(q) SCMutexInit(&(q)->m, NULL)
72 #define FQLOCK_DESTROY(q) SCMutexDestroy(&(q)->m)
73 #define FQLOCK_LOCK(q) SCMutexLock(&(q)->m)
74 #define FQLOCK_TRYLOCK(q) SCMutexTrylock(&(q)->m)
75 #define FQLOCK_UNLOCK(q) SCMutexUnlock(&(q)->m)
77 #error Enable FQLOCK_SPIN or FQLOCK_MUTEX
81 FlowQueue
*FlowQueueNew(void);
82 FlowQueue
*FlowQueueInit(FlowQueue
*);
83 void FlowQueueDestroy (FlowQueue
*);
85 void FlowEnqueue (FlowQueue
*, Flow
*);
86 Flow
*FlowDequeue (FlowQueue
*);
87 void FlowQueueRemove(FlowQueue
*fq
, Flow
*f
);
88 void FlowQueueRemoveLock(FlowQueue
*fq
, Flow
*f
);
90 void FlowQueuePrivateAppendFlow(FlowQueuePrivate
*fqc
, Flow
*f
);
91 void FlowQueuePrivatePrependFlow(FlowQueuePrivate
*fqc
, Flow
*f
);
93 void FlowQueueAppendPrivate(FlowQueue
*fq
, FlowQueuePrivate
*fqp
);
94 void FlowQueuePrivateAppendPrivate(FlowQueuePrivate
*dest
, FlowQueuePrivate
*src
);
95 FlowQueuePrivate
FlowQueueExtractPrivate(FlowQueue
*fq
);
96 Flow
*FlowQueuePrivateGetFromTop(FlowQueuePrivate
*fqp
);
98 #endif /* __FLOW_QUEUE_H__ */