suricata
tm-queuehandlers.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 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  * Master Queue Handler
24  */
25 
26 #include "suricata-common.h"
27 #include "packet-queue.h"
28 #include "decode.h"
29 #include "threads.h"
30 #include "threadvars.h"
31 
32 #include "tm-queuehandlers.h"
33 #include "tmqh-simple.h"
34 #include "tmqh-packetpool.h"
35 #include "tmqh-flow.h"
36 
38 
39 void TmqhSetup (void)
40 {
41  memset(&tmqh_table, 0, sizeof(tmqh_table));
42 
46 }
47 
48 /** \brief Clean up registration time allocs */
49 void TmqhCleanup(void)
50 {
51 }
52 
53 int TmqhNameToID(const char *name)
54 {
55  for (int i = 0; i < TMQH_SIZE; i++) {
56  if (tmqh_table[i].name != NULL) {
57  if (strcmp(name, tmqh_table[i].name) == 0)
58  return i;
59  }
60  }
61 
62  return -1;
63 }
64 
65 Tmqh *TmqhGetQueueHandlerByName(const char *name)
66 {
67  for (int i = 0; i < TMQH_SIZE; i++) {
68  if (tmqh_table[i].name != NULL) {
69  if (strcmp(name, tmqh_table[i].name) == 0)
70  return &tmqh_table[i];
71  }
72  }
73 
74  return NULL;
75 }
76 
78 {
79  if (id <= 0 || id >= TMQH_SIZE)
80  return NULL;
81 
82  return &tmqh_table[id];
83 }
TMQH_SIZE
@ TMQH_SIZE
Definition: tm-queuehandlers.h:33
TmqhNameToID
int TmqhNameToID(const char *name)
Definition: tm-queuehandlers.c:53
threads.h
packet-queue.h
tmqh-packetpool.h
TmqhFlowRegister
void TmqhFlowRegister(void)
Definition: tmqh-flow.c:49
decode.h
tmqh-simple.h
tm-queuehandlers.h
TmqhPacketpoolRegister
void TmqhPacketpoolRegister(void)
TmqhPacketpoolRegister \initonly.
Definition: tmqh-packetpool.c:132
TmqhCleanup
void TmqhCleanup(void)
Clean up registration time allocs.
Definition: tm-queuehandlers.c:49
suricata-common.h
tmqh_table
Tmqh tmqh_table[TMQH_SIZE]
Definition: tm-queuehandlers.c:37
TmqhSetup
void TmqhSetup(void)
Definition: tm-queuehandlers.c:39
threadvars.h
TmqhGetQueueHandlerByID
Tmqh * TmqhGetQueueHandlerByID(const int id)
Definition: tm-queuehandlers.c:77
TmqhSimpleRegister
void TmqhSimpleRegister(void)
Definition: tmqh-simple.c:39
tmqh-flow.h
TmqhGetQueueHandlerByName
Tmqh * TmqhGetQueueHandlerByName(const char *name)
Definition: tm-queuehandlers.c:65
Tmqh_
Definition: tm-queuehandlers.h:36