diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index aecaf19090..e649b22139 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -1846,6 +1846,20 @@ extern "C" { #[doc = " \\internal\n\n Run all registered flow init callbacks."] pub fn SCFlowRunFinishCallbacks(tv: *mut ThreadVars, f: *mut Flow); } +#[doc = " \\brief Function type for thread intialization callbacks.\n\n Once registered by SCThreadRegisterInitCallback, this function will\n be called for every thread being initialized during Suricata\n startup.\n\n \\param tv The ThreadVars struct that has just been initialized.\n \\param user The user data provided when registering the callback."] +pub type SCThreadInitCallbackFn = ::std::option::Option< + unsafe extern "C" fn(tv: *mut ThreadVars, user: *mut ::std::os::raw::c_void), +>; +extern "C" { + #[doc = " \\brief Register a thread init callback.\n\n Register a user provided function to be called every time a thread is\n initialized for use.\n\n \\param fn Pointer to function to be called\n \\param user Additional user data to be passed to callback\n\n \\returns true if callback was registered, otherwise false if the\n callback could not be registered due to memory allocation error."] + pub fn SCThreadRegisterInitCallback( + fn_: SCThreadInitCallbackFn, user: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + #[doc = " \\internal\n\n Run all registered flow init callbacks."] + pub fn SCThreadRunInitCallbacks(tv: *mut ThreadVars); +} extern "C" { pub fn SCSRepCatGetByShortname(shortname: *const ::std::os::raw::c_char) -> u8; } diff --git a/src/bindgen.h b/src/bindgen.h index 6cbc4881d4..7718d7a7d3 100644 --- a/src/bindgen.h +++ b/src/bindgen.h @@ -64,6 +64,8 @@ #include "flow-bindgen.h" #include "flow-callbacks.h" +#include "thread-callbacks.h" + #include "reputation.h" #include "feature.h" #include "datasets.h" diff --git a/src/thread-callbacks.h b/src/thread-callbacks.h index 5bcd638bf8..9d9af5af5f 100644 --- a/src/thread-callbacks.h +++ b/src/thread-callbacks.h @@ -18,8 +18,9 @@ #ifndef SURICATA_THREAD_CALLBACKS_H #define SURICATA_THREAD_CALLBACKS_H -#include "suricata-common.h" +#ifndef SURICATA_BINDGEN_H #include "threadvars.h" +#endif /** \brief Function type for thread intialization callbacks. *