From 7bfef2e1e8dc7cf4ac34f2b9b43bdbc60af2809d Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 10 Jun 2025 09:53:45 +0200 Subject: [PATCH] rust: bindgen AppLayerParserRegisterParserAcceptableDataDirection Ticket: 7667 --- rust/src/applayer.rs | 1 - rust/src/enip/enip.rs | 8 ++++---- rust/sys/src/sys.rs | 5 +++++ src/app-layer-ftp.c | 6 ++++-- src/app-layer-htp.c | 2 +- src/app-layer-parser.c | 4 ++-- src/app-layer-parser.h | 5 ++--- src/app-layer-ssl.c | 3 ++- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 2e473f6c81..6e94c7e44d 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -539,7 +539,6 @@ pub const APP_LAYER_TX_ACCEPT: u8 = BIT_U8!(4); extern "C" { 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); } #[repr(C)] diff --git a/rust/src/enip/enip.rs b/rust/src/enip/enip.rs index 3ff7c4f632..43425882c4 100644 --- a/rust/src/enip/enip.rs +++ b/rust/src/enip/enip.rs @@ -30,8 +30,8 @@ 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, - SCAppLayerProtoDetectConfProtoDetectionEnabled, + AppLayerParserState, AppProto, SCAppLayerParserRegisterParserAcceptableDataDirection, + SCAppLayerParserStateIssetFlag, SCAppLayerProtoDetectConfProtoDetectionEnabled, }; pub(super) static mut ALPROTO_ENIP: AppProto = ALPROTO_UNKNOWN; @@ -653,7 +653,7 @@ pub unsafe extern "C" fn SCEnipRegisterParsers() { let _ = AppLayerRegisterParser(&parser, alproto); } SCLogDebug!("Rust enip parser registered for UDP."); - AppLayerParserRegisterParserAcceptableDataDirection( + SCAppLayerParserRegisterParserAcceptableDataDirection( IPPROTO_UDP, ALPROTO_ENIP, STREAM_TOSERVER | STREAM_TOCLIENT, @@ -678,7 +678,7 @@ pub unsafe extern "C" fn SCEnipRegisterParsers() { let _ = AppLayerRegisterParser(&parser, alproto); } SCLogDebug!("Rust enip parser registered for TCP."); - AppLayerParserRegisterParserAcceptableDataDirection( + SCAppLayerParserRegisterParserAcceptableDataDirection( IPPROTO_TCP, ALPROTO_ENIP, STREAM_TOSERVER | STREAM_TOCLIENT, diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index 3208f2b479..d828f71ef7 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -695,6 +695,11 @@ pub struct AppLayerParserState_ { _unused: [u8; 0], } pub type AppLayerParserState = AppLayerParserState_; +extern "C" { + pub fn SCAppLayerParserRegisterParserAcceptableDataDirection( + ipproto: u8, alproto: AppProto, direction: u8, + ); +} extern "C" { pub fn SCAppLayerParserSetStreamDepth(ipproto: u8, alproto: AppProto, stream_depth: u32); } diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 2458ef78f8..64ea722409 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -1287,7 +1287,8 @@ void RegisterFTPParsers(void) AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_FTP, STREAM_TOCLIENT, FTPParseResponse); AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_FTP, FTPStateAlloc, FTPStateFree); - AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_FTP, STREAM_TOSERVER | STREAM_TOCLIENT); + SCAppLayerParserRegisterParserAcceptableDataDirection( + IPPROTO_TCP, ALPROTO_FTP, STREAM_TOSERVER | STREAM_TOCLIENT); AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTP, FTPStateTransactionFree); @@ -1311,7 +1312,8 @@ void RegisterFTPParsers(void) AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOCLIENT, FTPDataParseResponse); AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateAlloc, FTPDataStateFree); - AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOSERVER | STREAM_TOCLIENT); + SCAppLayerParserRegisterParserAcceptableDataDirection( + IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOSERVER | STREAM_TOCLIENT); AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateTransactionFree); AppLayerParserRegisterGetTxFilesFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateGetTxFiles); diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index a873764d95..f19e1df631 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2659,7 +2659,7 @@ void RegisterHTPParsers(void) /* This parser accepts gaps. */ AppLayerParserRegisterOptionFlags( IPPROTO_TCP, ALPROTO_HTTP1, APP_LAYER_PARSER_OPT_ACCEPT_GAPS); - AppLayerParserRegisterParserAcceptableDataDirection( + SCAppLayerParserRegisterParserAcceptableDataDirection( IPPROTO_TCP, ALPROTO_HTTP1, STREAM_TOSERVER | STREAM_TOCLIENT); /* app-layer-frame-documentation tag start: registering relevant callbacks */ AppLayerParserRegisterGetFrameFuncs( diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 1b6ebecde5..56e018f747 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -412,8 +412,8 @@ int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto, SCReturnInt(0); } -void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, AppProto alproto, - uint8_t direction) +void SCAppLayerParserRegisterParserAcceptableDataDirection( + uint8_t ipproto, AppProto alproto, uint8_t direction) { SCEnter(); diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 04d0d4487b..f38ffc809a 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -171,9 +171,8 @@ int AppLayerParserPreRegister(void (*Register)(void)); int AppLayerParserRegisterParser(uint8_t ipproto, AppProto alproto, uint8_t direction, AppLayerParserFPtr Parser); -void AppLayerParserRegisterParserAcceptableDataDirection(uint8_t ipproto, - AppProto alproto, - uint8_t direction); +void SCAppLayerParserRegisterParserAcceptableDataDirection( + uint8_t ipproto, AppProto alproto, uint8_t direction); void AppLayerParserRegisterOptionFlags(uint8_t ipproto, AppProto alproto, uint32_t flags); void AppLayerParserRegisterStateFuncs(uint8_t ipproto, AppProto alproto, diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index 9f8e3b5619..9ca4b10a2f 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -3231,7 +3231,8 @@ void RegisterSSLParsers(void) AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_TLS, SSLStateAlloc, SSLStateFree); - AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_TLS, STREAM_TOSERVER); + SCAppLayerParserRegisterParserAcceptableDataDirection( + IPPROTO_TCP, ALPROTO_TLS, STREAM_TOSERVER); AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_TLS, SSLStateTransactionFree);