From: Philippe Antoine Date: Wed, 2 Apr 2025 12:24:53 +0000 (+0200) Subject: detect: rename with prefix SCSigTablePreRegister X-Git-Tag: suricata-8.0.0-beta1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b271b3f5b06d4e47072e4a8aa5e37b7889df22d;p=thirdparty%2Fsuricata.git detect: rename with prefix SCSigTablePreRegister to make it available to rust via bindgen --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 8faed5c284..1a1e1f92dc 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -491,12 +491,6 @@ pub type ApplyTxConfigFn = unsafe extern "C" fn (*mut c_void, *mut c_void, c_int pub type GetFrameIdByName = unsafe extern "C" fn(*const c_char) -> c_int; pub type GetFrameNameById = unsafe extern "C" fn(u8) -> *const c_char; -// Defined in detect-engine-register.h -/// cbindgen:ignore -extern "C" { - pub fn SigTablePreRegister(cb: unsafe extern "C" fn ()); -} - // Defined in app-layer-register.h /// cbindgen:ignore extern "C" { diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 34847eb682..2271a93142 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -34,7 +34,7 @@ use nom7::{Err, IResult}; use nom7::error::{ErrorKind, make_error}; use suricata_sys::sys::{ AppProto, AppProtoNewProtoFromString, EveJsonTxLoggerRegistrationData, - SCOutputJsonLogDirection, SCOutputEvePreRegisterLogger, + SCOutputJsonLogDirection, SCOutputEvePreRegisterLogger, SCSigTablePreRegister, }; #[derive(AppLayerEvent)] @@ -418,7 +418,7 @@ pub unsafe extern "C" fn SCRegisterSnmpParser() { LogTx: Some(snmp_log_json_response), }; SCOutputEvePreRegisterLogger(reg_data); - SigTablePreRegister(detect_snmp_register); + SCSigTablePreRegister(Some(detect_snmp_register)); if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 { // port 161 _ = AppLayerRegisterProtocolDetection(&parser, 1); diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index 2a3dcf5266..ae4902812b 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -171,6 +171,11 @@ extern "C" { reg_data: EveJsonTxLoggerRegistrationData, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn SCSigTablePreRegister( + KeywordsRegister: ::std::option::Option, + ) -> ::std::os::raw::c_int; +} #[doc = " Structure of a configuration parameter."] #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/src/bindgen.h b/src/bindgen.h index a568685b2c..6ff6dc038a 100644 --- a/src/bindgen.h +++ b/src/bindgen.h @@ -32,6 +32,7 @@ #include "app-layer-protos.h" #include "suricata-plugin.h" #include "output-eve-bindgen.h" +#include "detect-engine-register.h" #include "conf.h" diff --git a/src/detect-engine-register.c b/src/detect-engine-register.c index d2e9e566e6..e575f3a61b 100644 --- a/src/detect-engine-register.c +++ b/src/detect-engine-register.c @@ -476,7 +476,7 @@ static size_t preregistered_callbacks_cap = 0; // When an app-layer plugin is loaded, it wants to register its keywords // But the plugin is loaded before keywords can register // The preregistration callbacks will later be called by SigTableSetup -int SigTablePreRegister(void (*KeywordsRegister)(void)) +int SCSigTablePreRegister(void (*KeywordsRegister)(void)) { if (preregistered_callbacks_nb == preregistered_callbacks_cap) { void *tmp = SCRealloc(PreregisteredCallbacks, diff --git a/src/detect-engine-register.h b/src/detect-engine-register.h index 64355e04e4..2f19793a8a 100644 --- a/src/detect-engine-register.h +++ b/src/detect-engine-register.h @@ -24,8 +24,6 @@ #ifndef SURICATA_DETECT_ENGINE_REGISTER_H #define SURICATA_DETECT_ENGINE_REGISTER_H -#include "suricata-common.h" - enum DetectKeywordId { DETECT_SID, DETECT_PRIORITY, @@ -350,7 +348,7 @@ int SigTableList(const char *keyword); void SigTableCleanup(void); void SigTableInit(void); void SigTableSetup(void); -int SigTablePreRegister(void (*KeywordsRegister)(void)); +int SCSigTablePreRegister(void (*KeywordsRegister)(void)); void SigTableRegisterTests(void); bool SigTableHasKeyword(const char *keyword); diff --git a/src/detect-smb-ntlmssp.c b/src/detect-smb-ntlmssp.c index b6d07ded3e..644704400e 100644 --- a/src/detect-smb-ntlmssp.c +++ b/src/detect-smb-ntlmssp.c @@ -22,8 +22,8 @@ * */ -#include "detect-engine-register.h" #include "suricata-common.h" +#include "detect-engine-register.h" #include "detect.h" #include "detect-parse.h" diff --git a/src/util-plugin.c b/src/util-plugin.c index 564c1f5dba..6081590a36 100644 --- a/src/util-plugin.c +++ b/src/util-plugin.c @@ -171,7 +171,7 @@ int SCPluginRegisterAppLayer(SCAppLayerPlugin *plugin) } } if (plugin->KeywordsRegister) { - if (SigTablePreRegister(plugin->KeywordsRegister) != 0) { + if (SCSigTablePreRegister(plugin->KeywordsRegister) != 0) { return 1; } }