rust: move AppLayerGetTxIterTuple definition to C

and bindgen it to rust

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerGetTxIterTuple
pull/14758/head
Philippe Antoine 6 months ago committed by Victor Julien
parent 64d29fcd1c
commit 41f543ca35

@ -149,6 +149,7 @@ if HAVE_BINDGEN
--allowlist-type 'AppLayerGetFileState' \
--allowlist-type 'AppLayerGetTxIterState' \
--allowlist-type 'AppLayerStateData' \
--allowlist-type 'AppLayerGetTxIterTuple' \
--allowlist-function 'SC.*' \
--allowlist-var 'SC.*' \
--opaque-type 'SCConfNode' \

@ -32,7 +32,7 @@ use suricata_sys::sys::{
DetectEngineState, GenericVar,
};
pub use suricata_sys::sys::{AppLayerGetFileState, AppLayerStateData};
pub use suricata_sys::sys::{AppLayerGetFileState, AppLayerStateData, AppLayerGetTxIterTuple};
#[cfg(not(test))]
use suricata_sys::sys::{
SCAppLayerDecoderEventsFreeEvents, SCAppLayerDecoderEventsSetEventRaw, SCDetectEngineStateFree,
@ -544,20 +544,18 @@ pub const _APP_LAYER_TX_INSPECTED_TS: u8 = BIT_U8!(2);
pub const _APP_LAYER_TX_INSPECTED_TC: u8 = BIT_U8!(3);
pub const APP_LAYER_TX_ACCEPT: u8 = BIT_U8!(4);
#[repr(C)]
pub struct AppLayerGetTxIterTuple {
tx_ptr: *mut std::os::raw::c_void,
tx_id: u64,
has_next: bool,
pub trait AppLayerGetTxIterTupleRust {
fn with_values(tx_ptr: *mut std::os::raw::c_void, tx_id: u64, has_next: bool) -> Self;
fn not_found() -> Self;
}
impl AppLayerGetTxIterTuple {
pub fn with_values(tx_ptr: *mut std::os::raw::c_void, tx_id: u64, has_next: bool) -> AppLayerGetTxIterTuple {
impl AppLayerGetTxIterTupleRust for AppLayerGetTxIterTuple {
fn with_values(tx_ptr: *mut std::os::raw::c_void, tx_id: u64, has_next: bool) -> AppLayerGetTxIterTuple {
AppLayerGetTxIterTuple {
tx_ptr, tx_id, has_next,
}
}
pub fn not_found() -> AppLayerGetTxIterTuple {
fn not_found() -> AppLayerGetTxIterTuple {
AppLayerGetTxIterTuple {
tx_ptr: std::ptr::null_mut(), tx_id: 0, has_next: false,
}

@ -1039,6 +1039,22 @@ impl Default for AppLayerGetTxIterState {
pub struct AppLayerStateData {
pub file_flags: u16,
}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct AppLayerGetTxIterTuple {
pub tx_ptr: *mut ::std::os::raw::c_void,
pub tx_id: u64,
pub has_next: bool,
}
impl Default for AppLayerGetTxIterTuple {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
extern "C" {
pub fn SCAppLayerParserReallocCtx(alproto: AppProto) -> ::std::os::raw::c_int;
}

@ -141,6 +141,12 @@ typedef struct AppLayerStateData {
uint16_t file_flags;
} AppLayerStateData;
typedef struct AppLayerGetTxIterTuple {
void *tx_ptr;
uint64_t tx_id;
bool has_next;
} AppLayerGetTxIterTuple;
/** \brief tx iterator prototype */
typedef AppLayerGetTxIterTuple (*AppLayerGetTxIteratorFunc)
(const uint8_t ipproto, const AppProto alproto,

Loading…
Cancel
Save