suricata
flow-callbacks.h
Go to the documentation of this file.
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#ifndef SURICATA_FLOW_CALLBACKS_H
19#define SURICATA_FLOW_CALLBACKS_H
20
21#include "suricata-common.h"
22#include "flow.h"
23
24/** \brief Function type for flow initialization callbacks.
25 *
26 * Once registered with SCFlowRegisterInitCallback, this function will
27 * be called every time a flow is initialized, or in other words,
28 * every time Suricata picks up a flow.
29 *
30 * \param tv The ThreadVars data structure for the thread creating the
31 * flow.
32 * \param f The newly initialized flow.
33 * \param p The packet related to creating the new flow.
34 * \param user The user data provided during callback registration.
35 */
36typedef void (*SCFlowInitCallbackFn)(ThreadVars *tv, Flow *f, const Packet *p, void *user);
37
38/** \brief Register a flow init callback.
39 *
40 * Register a user provided function to be called every time a flow is
41 * initialized for use.
42 *
43 * \param fn Pointer to function to be called
44 * \param user Additional user data to be passed to callback
45 *
46 * \returns true if callback was registered, otherwise false if the
47 * callback could not be registered due to memory allocation error.
48 */
50
51/** \internal
52 *
53 * Run all registered flow init callbacks.
54 */
56
57/** \brief Function type for flow update callbacks.
58 *
59 * Once registered with SCFlowRegisterUpdateCallback, this function
60 * will be called every time a flow is updated by a packet (basically
61 * everytime a packet is seen on a flow).
62 *
63 * \param tv The ThreadVars data structure for the thread updating the
64 * flow.
65 * \param f The flow being updated.
66 * \param p The packet responsible for the flow update.
67 * \param user The user data provided during callback registration.
68 */
69typedef void (*SCFlowUpdateCallbackFn)(ThreadVars *tv, Flow *f, Packet *p, void *user);
70
71/** \brief Register a flow update callback.
72 *
73 * Register a user provided function to be called everytime a flow is
74 * updated.
75 *
76 * \param fn Pointer to function to be called
77 * \param user Additional user data to be passed to callback
78 *
79 * \returns true if callback was registered, otherwise false if the
80 * callback could not be registered due to memory allocation error.
81 */
83
84/** \internal
85 *
86 * Run all registered flow update callbacks.
87 */
89
90/** \brief Function type for flow finish callbacks.
91 *
92 * Once registered with SCFlowRegisterFinshCallback, this function
93 * will be called when Suricata is done with a flow.
94 *
95 * \param tv The ThreadVars data structure for the thread finishing
96 * the flow.
97 * \param f The flow being finshed.
98 * \param user The user data provided during callback registration.
99 */
100typedef void (*SCFlowFinishCallbackFn)(ThreadVars *tv, Flow *f, void *user);
101
102/** \brief Register a flow init callback.
103 *
104 * Register a user provided function to be called every time a flow is
105 * finished.
106 *
107 * \param fn Pointer to function to be called
108 * \param user Additional user data to be passed to callback
109 *
110 * \returns true if callback was registered, otherwise false if the
111 * callback could not be registered due to memory allocation error.
112 */
114
115/** \internal
116 *
117 * Run all registered flow init callbacks.
118 */
120
121#endif /* SURICATA_FLOW_CALLBACKS_H */
void(* SCFlowFinishCallbackFn)(ThreadVars *tv, Flow *f, void *user)
Function type for flow finish callbacks.
void SCFlowRunUpdateCallbacks(ThreadVars *tv, Flow *f, Packet *p)
bool SCFlowRegisterFinishCallback(SCFlowFinishCallbackFn fn, void *user)
Register a flow init callback.
void(* SCFlowUpdateCallbackFn)(ThreadVars *tv, Flow *f, Packet *p, void *user)
Function type for flow update callbacks.
void SCFlowRunInitCallbacks(ThreadVars *tv, Flow *f, const Packet *p)
bool SCFlowRegisterInitCallback(SCFlowInitCallbackFn fn, void *user)
Register a flow init callback.
void(* SCFlowInitCallbackFn)(ThreadVars *tv, Flow *f, const Packet *p, void *user)
Function type for flow initialization callbacks.
bool SCFlowRegisterUpdateCallback(SCFlowUpdateCallbackFn fn, void *user)
Register a flow update callback.
void SCFlowRunFinishCallbacks(ThreadVars *tv, Flow *f)
ThreadVars * tv
Flow data structure.
Definition flow.h:356
Per thread variable structure.
Definition threadvars.h:58