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

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

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

10.67
/src/flow-callbacks.c
1
/* Copyright (C) 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
#include "flow-callbacks.h"
19

20
typedef struct FlowInitCallback_ {
21
    SCFlowInitCallbackFn Callback;
22
    void *user;
23
    struct FlowInitCallback_ *next;
24
} FlowInitCallback;
25

26
static FlowInitCallback *init_callbacks = NULL;
27

28
typedef struct FlowUpdateCallback_ {
29
    SCFlowUpdateCallbackFn Callback;
30
    void *user;
31
    struct FlowUpdateCallback_ *next;
32
} FlowUpdateCallback;
33

34
static FlowUpdateCallback *update_callbacks = NULL;
35

36
typedef struct FlowFinishCallback_ {
37
    SCFlowFinishCallbackFn Callback;
38
    void *user;
39
    struct FlowFinishCallback_ *next;
40
} FlowFinishCallback;
41

42
static FlowFinishCallback *finish_callbacks = NULL;
43

44
bool SCFlowRegisterInitCallback(SCFlowInitCallbackFn fn, void *user)
45
{
×
46
    FlowInitCallback *cb = SCCalloc(1, sizeof(*cb));
×
47
    if (cb == NULL) {
×
48
        return false;
×
49
    }
×
50
    cb->Callback = fn;
×
51
    cb->user = user;
×
52
    if (init_callbacks == NULL) {
×
53
        init_callbacks = cb;
×
54
    } else {
×
55
        FlowInitCallback *current = init_callbacks;
×
56
        while (current->next != NULL) {
×
57
            current = current->next;
×
58
        }
×
59
        current->next = cb;
×
60
    }
×
61
    return true;
×
62
}
×
63

64
void SCFlowRunInitCallbacks(ThreadVars *tv, Flow *f, const Packet *p)
65
{
63,336✔
66
    FlowInitCallback *cb = init_callbacks;
63,336✔
67
    while (cb != NULL) {
63,336✔
68
        cb->Callback(tv, f, p, cb->user);
×
69
        cb = cb->next;
×
70
    }
×
71
}
63,336✔
72

73
bool SCFlowRegisterUpdateCallback(SCFlowUpdateCallbackFn fn, void *user)
74
{
×
75
    FlowUpdateCallback *cb = SCCalloc(1, sizeof(*cb));
×
76
    if (cb == NULL) {
×
77
        return false;
×
78
    }
×
79
    cb->Callback = fn;
×
80
    cb->user = user;
×
81
    if (update_callbacks == NULL) {
×
82
        update_callbacks = cb;
×
83
    } else {
×
84
        FlowUpdateCallback *current = update_callbacks;
×
85
        while (current->next != NULL) {
×
86
            current = current->next;
×
87
        }
×
88
        current->next = cb;
×
89
    }
×
90
    return true;
×
91
}
×
92

93
void SCFlowRunUpdateCallbacks(ThreadVars *tv, Flow *f, Packet *p)
94
{
1,260,570✔
95
    FlowUpdateCallback *cb = update_callbacks;
1,260,570✔
96
    while (cb != NULL) {
1,260,570✔
97
        cb->Callback(tv, f, p, cb->user);
×
98
        cb = cb->next;
×
99
    }
×
100
}
1,260,570✔
101

102
bool SCFlowRegisterFinishCallback(SCFlowFinishCallbackFn fn, void *user)
103
{
×
104
    FlowFinishCallback *cb = SCCalloc(1, sizeof(*cb));
×
105
    if (cb == NULL) {
×
106
        return false;
×
107
    }
×
108
    cb->Callback = fn;
×
109
    cb->user = user;
×
110
    if (finish_callbacks == NULL) {
×
111
        finish_callbacks = cb;
×
112
    } else {
×
113
        FlowFinishCallback *current = finish_callbacks;
×
114
        while (current->next != NULL) {
×
115
            current = current->next;
×
116
        }
×
117
        current->next = cb;
×
118
    }
×
119
    return true;
×
120
}
×
121

122
void SCFlowRunFinishCallbacks(ThreadVars *tv, Flow *f)
UNCOV
123
{
×
UNCOV
124
    FlowFinishCallback *cb = finish_callbacks;
×
UNCOV
125
    while (cb != NULL) {
×
126
        cb->Callback(tv, f, cb->user);
×
127
        cb = cb->next;
×
128
    }
×
UNCOV
129
}
×
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