/src/suricata7/src/tm-queuehandlers.c
Line | Count | Source |
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 | | |
37 | | Tmqh tmqh_table[TMQH_SIZE]; |
38 | | |
39 | | void TmqhSetup (void) |
40 | 71 | { |
41 | 71 | memset(&tmqh_table, 0, sizeof(tmqh_table)); |
42 | | |
43 | 71 | TmqhSimpleRegister(); |
44 | 71 | TmqhPacketpoolRegister(); |
45 | 71 | TmqhFlowRegister(); |
46 | 71 | } |
47 | | |
48 | | /** \brief Clean up registration time allocs */ |
49 | | void TmqhCleanup(void) |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | int TmqhNameToID(const char *name) |
54 | 4 | { |
55 | 12 | for (int i = 0; i < TMQH_SIZE; i++) { |
56 | 12 | if (tmqh_table[i].name != NULL) { |
57 | 8 | if (strcmp(name, tmqh_table[i].name) == 0) |
58 | 4 | return i; |
59 | 8 | } |
60 | 12 | } |
61 | | |
62 | 0 | return -1; |
63 | 4 | } |
64 | | |
65 | | Tmqh *TmqhGetQueueHandlerByName(const char *name) |
66 | 4 | { |
67 | 12 | for (int i = 0; i < TMQH_SIZE; i++) { |
68 | 12 | if (tmqh_table[i].name != NULL) { |
69 | 8 | if (strcmp(name, tmqh_table[i].name) == 0) |
70 | 4 | return &tmqh_table[i]; |
71 | 8 | } |
72 | 12 | } |
73 | | |
74 | 0 | return NULL; |
75 | 4 | } |
76 | | |
77 | | Tmqh *TmqhGetQueueHandlerByID(const int id) |
78 | 0 | { |
79 | 0 | if (id <= 0 || id >= TMQH_SIZE) |
80 | 0 | return NULL; |
81 | | |
82 | 0 | return &tmqh_table[id]; |
83 | 0 | } |