• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22550237931

01 Mar 2026 06:56PM UTC coverage: 64.812% (-8.9%) from 73.687%
22550237931

Pull #14920

github

web-flow
Merge e05854a6d into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

561 of 789 new or added lines in 4 files covered. (71.1%)

23225 existing lines in 498 files now uncovered.

131605 of 203055 relevant lines covered (64.81%)

2328818.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.97
/src/tm-modules.c
1
/* Copyright (C) 2007-2024 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
 * Thread Module functions
24
 */
25

26
#include "tm-modules.h"
27
#include "util-debug.h"
28

29
TmModule tmm_modules[TMM_SIZE];
30

31
void TmModuleDebugList(void)
32
{
29✔
33
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
1,160✔
34
        TmModule *t = &tmm_modules[i];
1,131✔
35

36
        if (t->name == NULL)
1,131✔
37
            continue;
377✔
38

39
        SCLogDebug("%s:%p", t->name, t->Func);
754✔
40
    }
754✔
41
}
29✔
42

43
/** \brief get a tm module ptr by name
44
 *  \param name name string
45
 *  \retval ptr to the module or NULL */
46
TmModule *TmModuleGetByName(const char *name)
47
{
260✔
48
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
5,135✔
49
        TmModule *t = &tmm_modules[i];
5,135✔
50

51
        if (t->name == NULL)
5,135✔
52
            continue;
536✔
53

54
        if (strcmp(t->name, name) == 0)
4,599✔
55
            return t;
260✔
56
    }
4,599✔
57

58
    return NULL;
×
59
}
260✔
60

61
/**
62
 * \brief Returns a TM Module by its id.
63
 *
64
 * \param id Id of the TM Module to return.
65
 *
66
 * \retval Pointer of the module to be returned if available;
67
 *         NULL if unavailable.
68
 */
69
TmModule *TmModuleGetById(int id)
70
{
952✔
71
    if (id < 0 || id >= TMM_SIZE) {
952✔
72
        SCLogError("Threading module with the id "
×
73
                   "\"%d\" doesn't exist",
×
74
                id);
×
75
        return NULL;
×
76
    }
×
77

78
    return &tmm_modules[id];
952✔
79
}
952✔
80

81
/**
82
 * \brief Given a TM Module, returns its id.
83
 *
84
 * \param tm Pointer to the TM Module.
85
 *
86
 * \retval id of the TM Module if available; -1 if unavailable.
87
 */
88
int TmModuleGetIDForTM(TmModule *tm)
89
{
260✔
90
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
5,135✔
91
        TmModule *t = &tmm_modules[i];
5,135✔
92

93
        if (t->name == NULL)
5,135✔
94
            continue;
536✔
95

96
        if (strcmp(t->name, tm->name) == 0)
4,599✔
97
            return i;
260✔
98
    }
4,599✔
99

100
    return -1;
×
101
}
260✔
102

103

104
void TmModuleRunInit(void)
105
{
29✔
106
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
1,160✔
107
        TmModule *t = &tmm_modules[i];
1,131✔
108

109
        if (t->name == NULL)
1,131✔
110
            continue;
145✔
111

112
        if (t->Init == NULL)
986✔
113
            continue;
986✔
114

115
        t->Init();
×
116
    }
×
117
}
29✔
118

119
void TmModuleRunDeInit(void)
120
{
22✔
121
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
880✔
122
        TmModule *t = &tmm_modules[i];
858✔
123

124
        if (t->name == NULL)
858✔
125
            continue;
109✔
126

127
        if (t->DeInit == NULL)
749✔
128
            continue;
749✔
129

130
        t->DeInit();
×
131
    }
×
132
}
22✔
133

134
/** \brief register all unittests for the tm modules */
135
void TmModuleRegisterTests(void)
UNCOV
136
{
×
137
#ifdef UNITTESTS
138
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
139
        TmModule *t = &tmm_modules[i];
140

141
        if (t->name == NULL)
142
            continue;
143

144
        g_ut_modules++;
145

146

147
        if (t->RegisterTests == NULL) {
148
            if (coverage_unittests)
149
                SCLogWarning("threading module %s has no unittest "
150
                             "registration function.",
151
                        t->name);
152
        } else {
153
            t->RegisterTests();
154
            g_ut_covered++;
155
        }
156
    }
157
#endif /* UNITTESTS */
UNCOV
158
}
×
159

160
#ifdef PROFILING
161
#define CASE_CODE(E)  case E: return #E
162

163
/**
164
 * \brief Maps the TmmId, to its string equivalent
165
 *
166
 * \param id tmm id
167
 *
168
 * \retval string equivalent for the tmm id
169
 */
170
const char * TmModuleTmmIdToString(TmmId id)
171
{
172
    switch (id) {
173
        CASE_CODE (TMM_FLOWWORKER);
174
        CASE_CODE (TMM_RECEIVENFLOG);
175
        CASE_CODE (TMM_DECODENFLOG);
176
        CASE_CODE (TMM_DECODENFQ);
177
        CASE_CODE (TMM_VERDICTNFQ);
178
        CASE_CODE (TMM_RECEIVENFQ);
179
        CASE_CODE (TMM_RECEIVEPCAP);
180
        CASE_CODE (TMM_RECEIVEPCAPFILE);
181
        CASE_CODE (TMM_DECODEPCAP);
182
        CASE_CODE(TMM_DECODEPCAPFILE);
183
        CASE_CODE(TMM_RECEIVEDPDK);
184
        CASE_CODE(TMM_DECODEDPDK);
185
        CASE_CODE(TMM_DECODELIB);
186
        CASE_CODE (TMM_RECEIVEPLUGIN);
187
        CASE_CODE (TMM_DECODEPLUGIN);
188
        CASE_CODE (TMM_RESPONDREJECT);
189
        CASE_CODE (TMM_DECODEIPFW);
190
        CASE_CODE (TMM_VERDICTIPFW);
191
        CASE_CODE (TMM_RECEIVEIPFW);
192
        CASE_CODE (TMM_RECEIVEERFFILE);
193
        CASE_CODE (TMM_DECODEERFFILE);
194
        CASE_CODE (TMM_RECEIVEERFDAG);
195
        CASE_CODE(TMM_DECODEERFDAG);
196
        CASE_CODE (TMM_RECEIVEAFP);
197
        CASE_CODE(TMM_RECEIVEAFXDP);
198
        CASE_CODE (TMM_ALERTPCAPINFO);
199
        CASE_CODE (TMM_DECODEAFP);
200
        CASE_CODE(TMM_DECODEAFXDP);
201
        CASE_CODE (TMM_STATSLOGGER);
202
        CASE_CODE (TMM_FLOWMANAGER);
203
        CASE_CODE (TMM_FLOWRECYCLER);
204
        CASE_CODE (TMM_BYPASSEDFLOWMANAGER);
205
        CASE_CODE (TMM_UNIXMANAGER);
206
        CASE_CODE (TMM_DETECTLOADER);
207
        CASE_CODE (TMM_RECEIVENETMAP);
208
        CASE_CODE (TMM_DECODENETMAP);
209
        CASE_CODE (TMM_RECEIVEWINDIVERT);
210
        CASE_CODE (TMM_VERDICTWINDIVERT);
211
        CASE_CODE (TMM_DECODEWINDIVERT);
212

213
        CASE_CODE (TMM_SIZE);
214
    }
215
    return "<unknown>";
216
}
217
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc