diff --git a/rust/Makefile.am b/rust/Makefile.am index d547d8e3e4..24df1a0b49 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -148,6 +148,7 @@ if HAVE_BINDGEN --allowlist-type 'AppLayerEventType' \ --allowlist-type 'AppLayerGetFileState' \ --allowlist-type 'AppLayerGetTxIterState' \ + --allowlist-type 'AppLayerStateData' \ --allowlist-function 'SC.*' \ --allowlist-var 'SC.*' \ --opaque-type 'SCConfNode' \ diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index ac69659a64..88f7c6c995 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -31,7 +31,8 @@ use suricata_sys::sys::{ AppLayerDecoderEvents, AppLayerGetTxIterState, AppLayerParserState, AppProto, DetectEngineState, GenericVar, }; -pub use suricata_sys::sys::AppLayerGetFileState; + +pub use suricata_sys::sys::{AppLayerGetFileState, AppLayerStateData}; #[cfg(not(test))] use suricata_sys::sys::{ SCAppLayerDecoderEventsFreeEvents, SCAppLayerDecoderEventsSetEventRaw, SCDetectEngineStateFree, @@ -299,20 +300,6 @@ macro_rules!export_tx_data_get { } } -#[repr(C)] -#[derive(Default,Debug,PartialEq, Eq,Copy,Clone)] -pub struct AppLayerStateData { - pub file_flags: u16, -} - -impl AppLayerStateData { - pub fn new() -> Self { - Self { - file_flags: 0, - } - } -} - #[macro_export] macro_rules!export_state_data_get { ($name:ident, $type:ty) => { diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 77c41547ef..ce12dfb489 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -596,7 +596,7 @@ impl Default for HTTP2State { impl HTTP2State { pub fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, request_frame_size: 0, response_frame_size: 0, diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index 4843d85589..5e51570f3d 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -114,7 +114,7 @@ impl Default for KRB5State { impl KRB5State { pub fn new() -> KRB5State { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), req_id: 0, record_ts: 0, defrag_buf_ts: Vec::new(), diff --git a/rust/src/ldap/ldap.rs b/rust/src/ldap/ldap.rs index 8bd78763c6..bc41c47cf8 100644 --- a/rust/src/ldap/ldap.rs +++ b/rust/src/ldap/ldap.rs @@ -120,7 +120,7 @@ impl State for LdapState { impl LdapState { pub fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, transactions: VecDeque::new(), request_frame: None, diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index c96a7f6e2b..40dd03670a 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -139,7 +139,7 @@ impl Default for MQTTState { impl MQTTState { pub fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, protocol_version: 0, transactions: VecDeque::new(), diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index c668303582..f74c03a1e1 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -417,7 +417,7 @@ impl NFSState { /// Allocation function for a new TLS parser instance pub fn new() -> NFSState { NFSState { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), requestmap: HashMap::new(), namemap: HashMap::new(), transactions: Vec::new(), diff --git a/rust/src/pgsql/pgsql.rs b/rust/src/pgsql/pgsql.rs index 9e4318906a..2986aede42 100644 --- a/rust/src/pgsql/pgsql.rs +++ b/rust/src/pgsql/pgsql.rs @@ -183,7 +183,7 @@ impl Default for PgsqlState { impl PgsqlState { fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, transactions: VecDeque::new(), request_gap: false, diff --git a/rust/src/quic/quic.rs b/rust/src/quic/quic.rs index a94c485ec6..c5e96cda36 100644 --- a/rust/src/quic/quic.rs +++ b/rust/src/quic/quic.rs @@ -141,7 +141,7 @@ pub struct QuicState { impl Default for QuicState { fn default() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), max_tx_id: 0, keys: None, crypto_frag_tc: Vec::new(), diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index e0f5c577b4..49ef9efd8b 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -132,7 +132,7 @@ impl State for RdpState { impl RdpState { fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), next_id: 0, transactions: VecDeque::new(), tls_parsing: false, diff --git a/rust/src/rfb/rfb.rs b/rust/src/rfb/rfb.rs index 61aea008a4..e834dd22d4 100644 --- a/rust/src/rfb/rfb.rs +++ b/rust/src/rfb/rfb.rs @@ -137,7 +137,7 @@ impl Default for RFBState { impl RFBState { pub fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, transactions: Vec::new(), state: parser::RFBGlobalState::TCServerProtocolVersion, diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 5cb09fd505..ed7a60e391 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -797,7 +797,7 @@ impl SMBState { /// Allocation function for a new TLS parser instance pub fn new() -> Self { Self { - state_data:AppLayerStateData::new(), + state_data:AppLayerStateData::default(), ssn2vec_cache:LruCache::new(NonZeroUsize::new(unsafe { SMB_CFG_MAX_SSN2VEC_CACHE_SIZE }).unwrap()), guid2name_cache:LruCache::new(NonZeroUsize::new(unsafe { SMB_CFG_MAX_GUID_CACHE_SIZE }).unwrap()), read_offset_cache:LruCache::new(NonZeroUsize::new(unsafe { SMB_CFG_MAX_READ_OFFSET_CACHE_SIZE }).unwrap()), diff --git a/rust/src/telnet/telnet.rs b/rust/src/telnet/telnet.rs index 9d9a6d3ad9..cc533acba9 100644 --- a/rust/src/telnet/telnet.rs +++ b/rust/src/telnet/telnet.rs @@ -98,7 +98,7 @@ impl Default for TelnetState { impl TelnetState { pub fn new() -> Self { Self { - state_data: AppLayerStateData::new(), + state_data: AppLayerStateData::default(), tx_id: 0, transactions: Vec::new(), request_gap: false, diff --git a/rust/src/tftp/tftp.rs b/rust/src/tftp/tftp.rs index 294734b007..f6a95cbadd 100644 --- a/rust/src/tftp/tftp.rs +++ b/rust/src/tftp/tftp.rs @@ -89,7 +89,7 @@ impl TFTPTransaction { #[no_mangle] pub extern "C" fn SCTftpStateAlloc() -> *mut std::os::raw::c_void { - let state = TFTPState { state_data: AppLayerStateData::new(), transactions : Vec::new(), tx_id: 0, }; + let state = TFTPState { state_data: AppLayerStateData::default(), transactions : Vec::new(), tx_id: 0, }; let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; } diff --git a/rust/sys/src/sys.rs b/rust/sys/src/sys.rs index e179f0e1cc..ca3feb3436 100644 --- a/rust/sys/src/sys.rs +++ b/rust/sys/src/sys.rs @@ -1034,6 +1034,11 @@ impl Default for AppLayerGetTxIterState { } } } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] +pub struct AppLayerStateData { + pub file_flags: u16, +} extern "C" { pub fn SCAppLayerParserReallocCtx(alproto: AppProto) -> ::std::os::raw::c_int; } diff --git a/src/app-layer-dnp3.h b/src/app-layer-dnp3.h index ab77198080..ffbd3bece0 100644 --- a/src/app-layer-dnp3.h +++ b/src/app-layer-dnp3.h @@ -25,6 +25,7 @@ #define SURICATA_APP_LAYER_DNP3_H #include "rust.h" +#include "app-layer-parser.h" #if __BYTE_ORDER == __BIG_ENDIAN #include "util-byte.h" #endif diff --git a/src/app-layer-ftp.h b/src/app-layer-ftp.h index 99252137bc..e8e621bef0 100644 --- a/src/app-layer-ftp.h +++ b/src/app-layer-ftp.h @@ -26,6 +26,7 @@ #define SURICATA_APP_LAYER_FTP_H #include "rust.h" +#include "app-layer-parser.h" struct FtpCommand; diff --git a/src/app-layer-htp.h b/src/app-layer-htp.h index 145c014b8c..9d3502d481 100644 --- a/src/app-layer-htp.h +++ b/src/app-layer-htp.h @@ -34,6 +34,7 @@ #define SURICATA_APP_LAYER_HTP_H #include "rust.h" +#include "app-layer-parser.h" #include "app-layer-frames.h" #include "htp/htp_rs.h" diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 36c66626aa..dc2d9662ee 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -41,7 +41,6 @@ typedef struct AppLayerResult AppLayerResult; typedef struct AppLayerGetTxIterTuple AppLayerGetTxIterTuple; typedef struct AppLayerGetFileState AppLayerGetFileState; typedef struct AppLayerTxData AppLayerTxData; -typedef struct AppLayerStateData AppLayerStateData; typedef struct AppLayerTxConfig AppLayerTxConfig; /* Flags for AppLayerParserState. */ @@ -138,6 +137,10 @@ typedef struct AppLayerGetTxIterState { } un; } AppLayerGetTxIterState; +typedef struct AppLayerStateData { + uint16_t file_flags; +} AppLayerStateData; + /** \brief tx iterator prototype */ typedef AppLayerGetTxIterTuple (*AppLayerGetTxIteratorFunc) (const uint8_t ipproto, const AppProto alproto, diff --git a/src/app-layer-smtp.h b/src/app-layer-smtp.h index 69e29a041e..29b4ae7fdc 100644 --- a/src/app-layer-smtp.h +++ b/src/app-layer-smtp.h @@ -25,6 +25,7 @@ #define SURICATA_APP_LAYER_SMTP_H #include "rust.h" +#include "app-layer-parser.h" #include "app-layer-frames.h" #include "util-streaming-buffer.h" diff --git a/src/app-layer-ssl.h b/src/app-layer-ssl.h index 46eb5bc078..bb8cc7c816 100644 --- a/src/app-layer-ssl.h +++ b/src/app-layer-ssl.h @@ -28,6 +28,7 @@ #include "util-ja3.h" #include "rust.h" +#include "app-layer-parser.h" enum TlsFrameTypes { TLS_FRAME_PDU = 0, /**< whole PDU, so header + data */ diff --git a/src/rust.h b/src/rust.h index 10ff59349b..c0fe00add5 100644 --- a/src/rust.h +++ b/src/rust.h @@ -24,6 +24,7 @@ typedef struct Dataset Dataset; typedef struct DetectEngineState_ DetectEngineState; typedef enum AppLayerEventType AppLayerEventType; +typedef struct AppLayerStateData AppLayerStateData; // may be improved by smaller include #include "detect.h"