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