rust/ffi: move cast_pointer macro to ffi crate

Ticket: 7666
pull/14975/head
Philippe Antoine 8 months ago committed by Victor Julien
parent aae154874b
commit 4a0143c8d4

@ -22,10 +22,10 @@
use super::template::{TemplateTransaction, ALPROTO_TEMPLATE};
use std::os::raw::{c_int, c_void};
use suricata::cast_pointer;
use suricata::core::{STREAM_TOCLIENT, STREAM_TOSERVER};
use suricata::detect::{helper_keyword_register_sticky_buffer, SigTableElmtStickyBuffer};
use suricata::direction::Direction;
use suricata_ffi::cast_pointer;
use suricata_sys::sys::{
DetectEngineCtx, SCDetectBufferSetActiveList, SCDetectHelperBufferMpmRegister,
SCDetectSignatureSetAppProto, Signature,

@ -21,7 +21,7 @@
// use the plugin-facing FFI JsonBuilder wrapper
use super::template::TemplateTransaction;
use suricata::cast_pointer;
use suricata_ffi::cast_pointer;
use suricata_ffi::jsonbuilder::{Error as JsonError, JsonBuilder};
use suricata_sys::sys::SCJsonBuilder;

@ -32,8 +32,8 @@ use suricata::applayer::{
};
use suricata::applayer::{AppLayerResultRust, StreamSliceRust};
use suricata::conf::conf_get;
use suricata::{build_slice, cast_pointer, export_state_data_get, export_tx_data_get};
use suricata_ffi::{SCLogError, SCLogNotice, IPPROTO_TCP};
use suricata::{build_slice, export_state_data_get, export_tx_data_get};
use suricata_ffi::{cast_pointer, SCLogError, SCLogNotice, IPPROTO_TCP};
use suricata_sys::sys::AppProtoEnum::ALPROTO_UNKNOWN;
use suricata_sys::sys::{
AppLayerParser, AppLayerParserState, AppLayerProtocolDetect, AppLayerResult, AppLayerStateData,

@ -22,3 +22,13 @@ pub mod plugin;
pub const IPPROTO_TCP: u8 = 6;
pub const IPPROTO_UDP: u8 = 17;
/// Cast pointer to a variable, as a mutable reference to an object
///
/// UNSAFE !
#[macro_export]
macro_rules! cast_pointer {
($ptr:ident, $ty:ty) => {
&mut *($ptr as *mut $ty)
};
}

@ -39,13 +39,7 @@ pub use suricata_sys::sys::{
#[cfg(not(test))]
use suricata_sys::sys::SCAppLayerDecoderEventsSetEventRaw;
/// Cast pointer to a variable, as a mutable reference to an object
///
/// UNSAFE !
#[macro_export]
macro_rules! cast_pointer {
($ptr:ident, $ty:ty) => ( &mut *($ptr as *mut $ty) );
}
pub use suricata_ffi::cast_pointer;
pub trait StreamSliceRust {
#[cfg(test)]

@ -53,6 +53,8 @@
// example static_mut_refs.
#![allow(unknown_lints)]
#[macro_use]
extern crate suricata_ffi;
#[macro_use]
extern crate bitflags;
extern crate byteorder;

Loading…
Cancel
Save