use std;
use crate::core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
-use std::mem::transmute;
use crate::applayer::{self, *};
use std::ffi::CString;
use nom;
pub extern "C" fn rs_template_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = TemplateState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut std::os::raw::c_void;
}
#[no_mangle]
pub extern "C" fn rs_template_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let _drop: Box<TemplateState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut TemplateState) });
}
#[no_mangle]
let state = cast_pointer!(state, TemplateState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, TemplateState);
match state.tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(
c_tx,
out_tx_id,
* 02110-1301, USA.
*/
-use std::mem::transmute;
use crate::applayer::*;
use crate::core::{self, *};
use crate::dcerpc::parser;
pub extern "C" fn rs_dcerpc_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: core::AppProto) -> *mut std::os::raw::c_void {
let state = DCERPCState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_dcerpc_state_free(state: *mut std::os::raw::c_void) {
- let _state: Box<DCERPCState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut DCERPCState)} );
}
#[no_mangle]
) -> *mut std::os::raw::c_void {
let dce_state = cast_pointer!(vtx, DCERPCState);
match dce_state.get_tx(tx_id) {
- Some(tx) => unsafe { transmute(tx) },
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}
* 02110-1301, USA.
*/
-use std::mem::transmute;
-
use crate::applayer::*;
use crate::core;
use crate::dcerpc::dcerpc::{
#[no_mangle]
pub extern "C" fn rs_dcerpc_udp_state_free(state: *mut std::os::raw::c_void) {
- let _drop: Box<DCERPCUDPState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut DCERPCUDPState) });
}
#[no_mangle]
pub extern "C" fn rs_dcerpc_udp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: core::AppProto) -> *mut std::os::raw::c_void {
let state = DCERPCUDPState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
let dce_state = cast_pointer!(state, DCERPCUDPState);
match dce_state.get_tx(tx_id) {
Some(tx) => {
- return unsafe{ transmute(tx) };
+ return tx as *const _ as *mut _;
},
None => {
return std::ptr::null_mut();
};
match parse_iface_data(&arg) {
- Ok(detect) => std::mem::transmute(Box::new(detect)),
+ Ok(detect) => Box::into_raw(Box::new(detect)) as *mut _,
Err(_) => std::ptr::null_mut(),
}
}
#[no_mangle]
pub unsafe extern "C" fn rs_dcerpc_iface_free(ptr: *mut c_void) {
if ptr != std::ptr::null_mut() {
- let _: Box<DCEIfaceData> = std::mem::transmute(ptr);
+ std::mem::drop(Box::from_raw(ptr as *mut DCEIfaceData));
}
}
};
match parse_opnum_data(&arg) {
- Ok(detect) => std::mem::transmute(Box::new(detect)),
+ Ok(detect) => Box::into_raw(Box::new(detect)) as *mut _,
Err(_) => std::ptr::null_mut(),
}
}
#[no_mangle]
pub unsafe extern "C" fn rs_dcerpc_opnum_free(ptr: *mut c_void) {
if ptr != std::ptr::null_mut() {
- let _: Box<DCEOpnumData> = std::mem::transmute(ptr);
+ std::mem::drop(Box::from_raw(ptr as *mut DCEOpnumData));
}
}
use crate::dhcp::parser::*;
use std;
use std::ffi::{CStr,CString};
-use std::mem::transmute;
static mut ALPROTO_DHCP: AppProto = ALPROTO_UNKNOWN;
let state = cast_pointer!(state, DHCPState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
pub extern "C" fn rs_dhcp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = DHCPState::new();
let boxed = Box::new(state);
- return unsafe {
- transmute(boxed)
- };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let _drop: Box<DHCPState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut DHCPState) });
}
#[no_mangle]
let state = cast_pointer!(state, DHCPState);
match state.get_tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(
c_tx, out_tx_id, has_next);
return ires;
pub extern "C" fn rs_dhcp_logger_new(conf: *const c_void) -> *mut std::os::raw::c_void {
let conf = ConfNode::wrap(conf);
let boxed = Box::new(DHCPLogger::new(conf));
- return unsafe{std::mem::transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_dhcp_logger_free(logger: *mut std::os::raw::c_void) {
- let _: Box<DHCPLogger> = unsafe{std::mem::transmute(logger)};
+ std::mem::drop(unsafe { Box::from_raw(logger as *mut DHCPLogger) });
}
#[no_mangle]
};
match parse_opcode(&arg) {
- Ok(detect) => std::mem::transmute(Box::new(detect)),
+ Ok(detect) => Box::into_raw(Box::new(detect)) as *mut _,
Err(_) => std::ptr::null_mut(),
}
}
#[no_mangle]
pub unsafe extern "C" fn rs_dns_detect_opcode_free(ptr: *mut c_void) {
if ptr != std::ptr::null_mut() {
- let _: Box<DetectDnsOpcode> = std::mem::transmute(ptr);
+ std::mem::drop(Box::from_raw(ptr as *mut DetectDnsOpcode));
}
}
use std;
use std::ffi::CString;
-use std::mem::transmute;
use std::collections::HashMap;
use std::collections::VecDeque;
pub extern "C" fn rs_dns_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = DNSState::new();
let boxed = Box::new(state);
- return unsafe{transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Returns *mut DNSState
pub extern "C" fn rs_dns_state_tcp_new() -> *mut std::os::raw::c_void {
let state = DNSState::new_tcp();
let boxed = Box::new(state);
- return unsafe{transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
#[no_mangle]
pub extern "C" fn rs_dns_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
- let _drop: Box<DNSState> = unsafe{transmute(state)};
+ std::mem::drop(unsafe { Box::from_raw(state as *mut DNSState) });
}
#[no_mangle]
let state = cast_pointer!(state, DNSState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe{transmute(tx)};
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
use super::parser;
use crate::core::STREAM_TOSERVER;
use std::ffi::CStr;
-use std::mem::transmute;
use std::str::FromStr;
fn http2_tx_has_frametype(
if let Ok(s) = ft_name.to_str() {
if let Ok((_, ctx)) = parser::http2_parse_settingsctx(s) {
let boxed = Box::new(ctx);
- return transmute(boxed); //unsafe
+ return Box::into_raw(boxed) as *mut _;
}
}
return std::ptr::null_mut();
#[no_mangle]
pub unsafe extern "C" fn rs_http2_detect_settingsctx_free(ctx: *mut std::os::raw::c_void) {
// Just unbox...
- let _ctx: Box<parser::DetectHTTP2settingsSigCtx> = transmute(ctx);
+ std::mem::drop(Box::from_raw(ctx as *mut parser::DetectHTTP2settingsSigCtx));
}
fn http2_detect_settings_match(
if let Ok(s) = ft_name.to_str() {
if let Ok((_, ctx)) = parser::detect_parse_u64(s) {
let boxed = Box::new(ctx);
- return transmute(boxed); //unsafe
+ return Box::into_raw(boxed) as *mut _;
}
}
return std::ptr::null_mut();
#[no_mangle]
pub unsafe extern "C" fn rs_detect_u64_free(ctx: *mut std::os::raw::c_void) {
// Just unbox...
- let _ctx: Box<parser::DetectU64Data> = transmute(ctx);
+ std::mem::drop(Box::from_raw(ctx as *mut parser::DetectU64Data));
}
fn http2_detect_sizeupdate_match(
use std::ffi::{CStr, CString};
use std::fmt;
use std::io;
-use std::mem::transmute;
static mut ALPROTO_HTTP2: AppProto = ALPROTO_UNKNOWN;
) -> *mut std::os::raw::c_void {
let state = HTTP2State::new();
let boxed = Box::new(state);
- let r = unsafe { transmute(boxed) };
+ let r = Box::into_raw(boxed) as *mut _;
if orig_state != std::ptr::null_mut() {
//we could check ALPROTO_HTTP1 == orig_proto
unsafe {
#[no_mangle]
pub extern "C" fn rs_http2_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let mut state: Box<HTTP2State> = unsafe { transmute(state) };
+ let mut state: Box<HTTP2State> = unsafe { Box::from_raw(state as _) };
state.free();
}
let state = cast_pointer!(state, HTTP2State);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, HTTP2State);
match state.tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
use std;
use std::collections::HashSet;
use std::ffi::{CStr, CString};
-use std::mem::transmute;
#[repr(u32)]
pub enum IkeEvent {
) -> *mut std::os::raw::c_void {
let state = IKEState::default();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_ike_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
- let _drop: Box<IKEState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut IKEState) });
}
#[no_mangle]
let state = cast_pointer!(state, IKEState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, IKEState);
match state.tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
pub extern "C" fn rs_krb5_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = KRB5State::new();
let boxed = Box::new(state);
- return unsafe{std::mem::transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
/// - state: *mut KRB5State as void pointer
#[no_mangle]
pub extern "C" fn rs_krb5_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let mut state: Box<KRB5State> = unsafe{std::mem::transmute(state)};
+ let mut state: Box<KRB5State> = unsafe{Box::from_raw(state as _)};
state.free();
}
{
let state = cast_pointer!(state,KRB5State);
match state.get_tx_by_id(tx_id) {
- Some(tx) => unsafe{std::mem::transmute(tx)},
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}
use nom;
use std;
use std::ffi::{CStr,CString};
-use std::mem::transmute;
// Used as a special pseudo packet identifier to denote the first CONNECT
// packet in a connection. Note that there is no risk of collision with a
pub extern "C" fn rs_mqtt_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = MQTTState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_mqtt_state_free(state: *mut std::os::raw::c_void) {
- let _drop: Box<MQTTState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut MQTTState) });
}
#[no_mangle]
let state = cast_pointer!(state, MQTTState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, MQTTState);
match state.tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
use std;
use std::cmp;
-use std::mem::transmute;
use std::collections::{HashMap};
use std::ffi::{CStr, CString};
let state = NFSState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
- return unsafe{transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
pub extern "C" fn rs_nfs_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
SCLogDebug!("freeing state");
- let mut _nfs_state: Box<NFSState> = unsafe{transmute(state)};
+ std::mem::drop(unsafe { Box::from_raw(state as *mut NFSState) });
}
/// C binding parse a NFS TCP request. Returns 1 on success, -1 on failure.
let state = cast_pointer!(state, NFSState);
match state.get_tx_by_id(tx_id) {
Some(tx) => {
- return unsafe{transmute(tx)};
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, NFSState);
match state.get_tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
pub extern "C" fn rs_ntp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = NTPState::new();
let boxed = Box::new(state);
- return unsafe{std::mem::transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
/// - state: *mut NTPState as void pointer
#[no_mangle]
pub extern "C" fn rs_ntp_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let mut ntp_state: Box<NTPState> = unsafe{std::mem::transmute(state)};
+ let mut ntp_state = unsafe{ Box::from_raw(state as *mut NTPState) };
ntp_state.free();
}
{
let state = cast_pointer!(state,NTPState);
match state.get_tx_by_id(tx_id) {
- Some(tx) => unsafe{std::mem::transmute(tx)},
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}
use crate::rdp::parser::*;
use nom;
use std;
-use std::mem::transmute;
use tls_parser::{parse_tls_plaintext, TlsMessage, TlsMessageHandshake, TlsRecordType};
static mut ALPROTO_RDP: AppProto = ALPROTO_UNKNOWN;
let state = cast_pointer!(state, RdpState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
pub extern "C" fn rs_rdp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = RdpState::new();
let boxed = Box::new(state);
- return unsafe { std::mem::transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_rdp_state_free(state: *mut std::os::raw::c_void) {
- let _drop: Box<RdpState> = unsafe { std::mem::transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut RdpState) });
}
#[no_mangle]
use std;
use std::ffi::CString;
-use std::mem::transmute;
use crate::core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
use crate::applayer;
use crate::applayer::*;
pub extern "C" fn rs_rfb_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = RFBState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_rfb_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
- let _drop: Box<RFBState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut RFBState) });
}
#[no_mangle]
let state = cast_pointer!(state, RFBState);
match state.get_tx(tx_id) {
Some(tx) => {
- return unsafe { transmute(tx) };
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, RFBState);
match state.tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(
c_tx,
out_tx_id,
pub extern "C" fn rs_sip_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SIPState::new();
let boxed = Box::new(state);
- return unsafe { std::mem::transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_sip_state_free(state: *mut std::os::raw::c_void) {
- let mut state: Box<SIPState> = unsafe { std::mem::transmute(state) };
+ let mut state = unsafe { Box::from_raw(state as *mut SIPState) };
state.free();
}
) -> *mut std::os::raw::c_void {
let state = cast_pointer!(state, SIPState);
match state.get_tx_by_id(tx_id) {
- Some(tx) => unsafe { std::mem::transmute(tx) },
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}
// written by Victor Julien
use std;
-use std::mem::transmute;
use std::str;
use std::ffi::{self, CStr, CString};
let state = SMBState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
- return unsafe{transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
/// - state: *mut SMBState as void pointer
#[no_mangle]
pub extern "C" fn rs_smb_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
SCLogDebug!("freeing state");
- let mut smb_state: Box<SMBState> = unsafe{transmute(state)};
+ let mut smb_state = unsafe { Box::from_raw(state as *mut SMBState) };
smb_state.free();
}
let state = cast_pointer!(state, SMBState);
match state.get_tx_by_id(tx_id) {
Some(tx) => {
- return unsafe{transmute(tx)};
+ return tx as *const _ as *mut _;
}
None => {
return std::ptr::null_mut();
let state = cast_pointer!(state, SMBState);
match state.get_tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
use crate::applayer::{self, *};
use std;
use std::ffi::{CStr,CString};
-use std::mem::transmute;
use der_parser::ber::BerObjectContent;
use der_parser::der::parse_der_sequence;
pub extern "C" fn rs_snmp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SNMPState::new();
let boxed = Box::new(state);
- return unsafe{std::mem::transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
/// Params:
/// - state: *mut SNMPState as void pointer
#[no_mangle]
pub extern "C" fn rs_snmp_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let mut snmp_state: Box<SNMPState> = unsafe{std::mem::transmute(state)};
+ let mut snmp_state = unsafe{ Box::from_raw(state as *mut SNMPState) };
snmp_state.free();
}
{
let state = cast_pointer!(state,SNMPState);
match state.get_tx_by_id(tx_id) {
- Some(tx) => unsafe{std::mem::transmute(tx)},
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}
{
match state.get_tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
let state = cast_pointer!(alstate,SNMPState);
match state.get_tx_iterator(min_tx_id, istate) {
Some((tx, out_tx_id, has_next)) => {
- let c_tx = unsafe { transmute(tx) };
+ let c_tx = tx as *const _ as *mut _;
let ires = applayer::AppLayerGetTxIterTuple::with_values(c_tx, out_tx_id, has_next);
return ires;
}
use crate::core::STREAM_TOSERVER;
use crate::core::{self, AppProto, Flow, ALPROTO_UNKNOWN, IPPROTO_TCP};
use std::ffi::{CStr, CString};
-use std::mem::transmute;
use std::sync::atomic::{AtomicBool, Ordering};
static mut ALPROTO_SSH: AppProto = ALPROTO_UNKNOWN;
pub extern "C" fn rs_ssh_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = SSHState::new();
let boxed = Box::new(state);
- return unsafe { transmute(boxed) };
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_ssh_state_free(state: *mut std::os::raw::c_void) {
- // Just unbox...
- let _drop: Box<SSHState> = unsafe { transmute(state) };
+ std::mem::drop(unsafe { Box::from_raw(state as *mut SSHState) });
}
#[no_mangle]
state: *mut std::os::raw::c_void, _tx_id: u64,
) -> *mut std::os::raw::c_void {
let state = cast_pointer!(state, SSHState);
- return unsafe { transmute(&state.transaction) };
+ return &state.transaction as *const _ as *mut _;
}
#[no_mangle]
use std::str;
use std;
-use std::mem::transmute;
use nom::*;
use crate::applayer::AppLayerTxData;
pub extern "C" fn rs_tftp_state_alloc() -> *mut std::os::raw::c_void {
let state = TFTPState { transactions : Vec::new(), tx_id: 0, };
let boxed = Box::new(state);
- return unsafe{transmute(boxed)};
+ return Box::into_raw(boxed) as *mut _;
}
#[no_mangle]
pub extern "C" fn rs_tftp_state_free(state: *mut std::os::raw::c_void) {
- let _state : Box<TFTPState> = unsafe{transmute(state)};
+ std::mem::drop(unsafe { Box::from_raw(state as *mut TFTPState) });
}
#[no_mangle]
pub extern "C" fn rs_tftp_get_tx(state: &mut TFTPState,
tx_id: u64) -> *mut std::os::raw::c_void {
match state.get_tx_by_id(tx_id) {
- Some(tx) => unsafe{std::mem::transmute(tx)},
+ Some(tx) => tx as *const _ as *mut _,
None => std::ptr::null_mut(),
}
}