rust: bindgen AppLayerParserSetStreamDepth

Ticket: 7667
This commit is contained in:
Philippe Antoine 2025-06-10 09:49:10 +02:00 committed by Victor Julien
parent b29d46d81f
commit 1ff4dbfc24
7 changed files with 13 additions and 11 deletions

View file

@ -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);

View file

@ -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::<usize>() {

View file

@ -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");

View file

@ -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) {

View file

@ -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);
}

View file

@ -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();

View file

@ -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);