From: Philippe Antoine Date: Tue, 10 Jun 2025 07:49:10 +0000 (+0200) Subject: rust: bindgen AppLayerParserSetStreamDepth X-Git-Tag: suricata-8.0.0-rc1~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ff4dbfc2485532e44de2faf8e1b74f9ab797882;p=thirdparty%2Fsuricata.git rust: bindgen AppLayerParserSetStreamDepth Ticket: 7667 --- diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index c68a3b88cc..2e473f6c81 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -537,7 +537,6 @@ pub const APP_LAYER_TX_ACCEPT: u8 = BIT_U8!(4); /// cbindgen:ignore extern "C" { - pub fn AppLayerParserSetStreamDepth(ipproto: u8, alproto: AppProto, stream_depth: u32); pub fn AppLayerParserConfParserEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int; pub fn AppLayerParserRegisterLogger(pproto: u8, alproto: AppProto); pub fn AppLayerParserRegisterParserAcceptableDataDirection(ipproto: u8, alproto: AppProto, dir: u8); diff --git a/rust/src/pgsql/pgsql.rs b/rust/src/pgsql/pgsql.rs index bc5c701a2d..42720ca231 100644 --- a/rust/src/pgsql/pgsql.rs +++ b/rust/src/pgsql/pgsql.rs @@ -31,7 +31,7 @@ use std; use std::collections::VecDeque; use std::ffi::CString; use suricata_sys::sys::{ - AppLayerParserState, AppProto, SCAppLayerParserStateIssetFlag, + AppLayerParserState, AppProto, SCAppLayerParserSetStreamDepth, SCAppLayerParserStateIssetFlag, SCAppLayerProtoDetectConfProtoDetectionEnabled, SCAppLayerRequestProtocolTLSUpgrade, }; @@ -975,7 +975,7 @@ pub unsafe extern "C" fn SCRegisterPgsqlParser() { SCLogError!("Invalid depth value"); } } - AppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_PGSQL, stream_depth) + SCAppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_PGSQL, stream_depth) } if let Some(val) = conf_get("app-layer.protocols.pgsql.max-tx") { if let Ok(v) = val.parse::() { diff --git a/rust/src/pop3/pop3.rs b/rust/src/pop3/pop3.rs index 018d0a3127..33d36203e5 100644 --- a/rust/src/pop3/pop3.rs +++ b/rust/src/pop3/pop3.rs @@ -29,7 +29,7 @@ use std::collections::VecDeque; use std::ffi::CString; use std::os::raw::{c_char, c_int, c_void}; use suricata_sys::sys::{ - AppLayerParserState, AppProto, SCAppLayerParserStateIssetFlag, + AppLayerParserState, AppProto, SCAppLayerParserSetStreamDepth, SCAppLayerParserStateIssetFlag, SCAppLayerProtoDetectConfProtoDetectionEnabled, SCAppLayerRequestProtocolTLSUpgrade, }; @@ -525,7 +525,7 @@ pub unsafe extern "C" fn SCRegisterPop3Parser() { match get_memval(val) { Ok(retval) => { let stream_depth = retval as u32; - AppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_POP3, stream_depth); + SCAppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_POP3, stream_depth); } Err(_) => { SCLogError!("Invalid depth value"); diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 269c0483b5..3f231ee436 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -35,9 +35,9 @@ use nom7::error::{make_error, ErrorKind}; use lru::LruCache; use suricata_sys::sys::{ - AppLayerParserState, AppProto, SCAppLayerProtoDetectConfProtoDetectionEnabled, - SCAppLayerProtoDetectPMRegisterPatternCSwPP, SCAppLayerProtoDetectPPParseConfPorts, - SCAppLayerProtoDetectPPRegister, + AppLayerParserState, AppProto, SCAppLayerParserSetStreamDepth, + SCAppLayerProtoDetectConfProtoDetectionEnabled, SCAppLayerProtoDetectPMRegisterPatternCSwPP, + SCAppLayerProtoDetectPPParseConfPorts, SCAppLayerProtoDetectPPRegister, }; use std::num::NonZeroUsize; @@ -2405,7 +2405,7 @@ pub unsafe extern "C" fn SCRegisterSmbParser() { Err(_) => { SCLogError!("Invalid depth value"); } } } - AppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_SMB, stream_depth); + SCAppLayerParserSetStreamDepth(IPPROTO_TCP, ALPROTO_SMB, stream_depth); let retval = conf_get("app-layer.protocols.smb.max-read-size"); if let Some(val) = retval { match get_memval(val) { diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index 47c54734be..3208f2b479 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -695,6 +695,9 @@ pub struct AppLayerParserState_ { _unused: [u8; 0], } pub type AppLayerParserState = AppLayerParserState_; +extern "C" { + pub fn SCAppLayerParserSetStreamDepth(ipproto: u8, alproto: AppProto, stream_depth: u32); +} extern "C" { pub fn SCAppLayerParserStateSetFlag(pstate: *mut AppLayerParserState, flag: u16); } diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 1af0bc6ce2..1b6ebecde5 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1566,7 +1566,7 @@ void AppLayerParserTriggerRawStreamInspection(Flow *f, int direction) SCReturn; } -void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth) +void SCAppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth) { SCEnter(); diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index b4c33581d5..04d0d4487b 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -275,7 +275,7 @@ bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate); int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto); LoggerId AppLayerParserProtocolGetLoggerBits(uint8_t ipproto, AppProto alproto); void AppLayerParserTriggerRawStreamInspection(Flow *f, int direction); -void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth); +void SCAppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth); uint32_t AppLayerParserGetStreamDepth(const Flow *f); void AppLayerParserSetStreamDepthFlag(uint8_t ipproto, AppProto alproto, void *state, uint64_t tx_id, uint8_t flags); int AppLayerParserIsEnabled(AppProto alproto);