From: Philippe Antoine Date: Thu, 23 Jan 2025 09:12:59 +0000 (+0100) Subject: rust: AppLayerRegisterParser out of SuricataContext X-Git-Tag: suricata-8.0.0-beta1~524 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b11381d952bf6b316afee94970669e03e243a920;p=thirdparty%2Fsuricata.git rust: AppLayerRegisterParser out of SuricataContext Just use a regular compile time rust export, instead of having a runtime definition through the SuricataContext structure --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index cd75d43933..12bc3d42bf 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -23,7 +23,6 @@ use crate::direction::Direction; use crate::filecontainer::FileContainer; use crate::flow::Flow; use std::os::raw::{c_void,c_char,c_int}; -use crate::core::SC; use std::ffi::CStr; use crate::core::StreamingBufferConfig; @@ -478,12 +477,9 @@ pub type GetFrameNameById = unsafe extern "C" fn(u8) -> *const c_char; extern { pub fn AppLayerRegisterProtocolDetection(parser: *const RustParser, enable_default: c_int) -> AppProto; pub fn AppLayerRegisterParserAlias(parser_name: *const c_char, alias_name: *const c_char); + pub fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProto) -> c_int; } -#[allow(non_snake_case)] -pub unsafe fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProto) -> c_int { - (SC.unwrap().AppLayerRegisterParser)(parser, alproto) -} // Defined in app-layer-detect-proto.h /// cbindgen:ignore diff --git a/rust/src/core.rs b/rust/src/core.rs index 7e1094a39e..a1b74ceaf5 100644 --- a/rust/src/core.rs +++ b/rust/src/core.rs @@ -163,8 +163,6 @@ pub struct SuricataContext { pub FileAppendData: SCFileAppendDataById, pub FileAppendGAP: SCFileAppendGAPById, pub FileContainerRecycle: SCFileContainerRecycle, - - pub AppLayerRegisterParser: extern fn(parser: *const crate::applayer::RustParser, alproto: AppProto) -> std::os::raw::c_int, } #[allow(non_snake_case)] diff --git a/src/rust-context.c b/src/rust-context.c index e63e12ce00..1b7131a65d 100644 --- a/src/rust-context.c +++ b/src/rust-context.c @@ -37,8 +37,6 @@ const SuricataContext suricata_context = { FileAppendDataById, FileAppendGAPById, FileContainerRecycle, - - AppLayerRegisterParser, }; const SuricataContext *SCGetContext(void) diff --git a/src/rust-context.h b/src/rust-context.h index df1179e368..15495c3bea 100644 --- a/src/rust-context.h +++ b/src/rust-context.h @@ -56,9 +56,6 @@ typedef struct SuricataContext_ { int (*FileAppendGAPById)(FileContainer *, const StreamingBufferConfig *, uint32_t track_id, const uint8_t *data, uint32_t data_len); void (*FileContainerRecycle)(FileContainer *ffc, const StreamingBufferConfig *); - - int (*AppLayerRegisterParser)(const struct AppLayerParser *p, AppProto alproto); - } SuricataContext; extern const SuricataContext suricata_context;