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

jasonish / suricata / 22785952221

06 Mar 2026 11:16PM UTC coverage: 67.722% (-11.5%) from 79.244%
22785952221

push

github

jasonish
github-ci: add schema ordering check for yaml schema

158908 of 234646 relevant lines covered (67.72%)

6673126.15 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
{
2,219✔
33
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
88,760✔
34
        TmModule *t = &tmm_modules[i];
86,541✔
35

36
        if (t->name == NULL)
86,541✔
37
            continue;
28,847✔
38

39
        SCLogDebug("%s:%p", t->name, t->Func);
57,694✔
40
    }
57,694✔
41
}
2,219✔
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
{
27,500✔
48
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
310,040✔
49
        TmModule *t = &tmm_modules[i];
310,040✔
50

51
        if (t->name == NULL)
310,040✔
52
            continue;
21,202✔
53

54
        if (strcmp(t->name, name) == 0)
288,838✔
55
            return t;
27,500✔
56
    }
288,838✔
57

58
    return NULL;
×
59
}
27,500✔
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
{
180,809✔
71
    if (id < 0 || id >= TMM_SIZE) {
180,809✔
72
        SCLogError("Threading module with the id "
×
73
                   "\"%d\" doesn't exist",
×
74
                id);
×
75
        return NULL;
×
76
    }
×
77

78
    return &tmm_modules[id];
180,809✔
79
}
180,809✔
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
{
27,500✔
90
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
310,040✔
91
        TmModule *t = &tmm_modules[i];
310,040✔
92

93
        if (t->name == NULL)
310,040✔
94
            continue;
21,202✔
95

96
        if (strcmp(t->name, tm->name) == 0)
288,838✔
97
            return i;
27,500✔
98
    }
288,838✔
99

100
    return -1;
×
101
}
27,500✔
102

103

104
void TmModuleRunInit(void)
105
{
2,219✔
106
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
88,760✔
107
        TmModule *t = &tmm_modules[i];
86,541✔
108

109
        if (t->name == NULL)
86,541✔
110
            continue;
11,095✔
111

112
        if (t->Init == NULL)
75,446✔
113
            continue;
75,446✔
114

115
        t->Init();
×
116
    }
×
117
}
2,219✔
118

119
void TmModuleRunDeInit(void)
120
{
2,137✔
121
    for (uint16_t i = 0; i < TMM_SIZE; i++) {
85,480✔
122
        TmModule *t = &tmm_modules[i];
83,343✔
123

124
        if (t->name == NULL)
83,343✔
125
            continue;
10,681✔
126

127
        if (t->DeInit == NULL)
72,662✔
128
            continue;
72,662✔
129

130
        t->DeInit();
×
131
    }
×
132
}
2,137✔
133

134
/** \brief register all unittests for the tm modules */
135
void TmModuleRegisterTests(void)
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 */
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