From: Jeff Lucovsky Date: Sat, 8 Jun 2019 13:17:37 +0000 (-0400) Subject: rust/snmp: fix libc deprecation warnings X-Git-Tag: suricata-5.0.0-rc1~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=643864a8f58dbf10e2a3f3b7080ff6ee0a429a38;p=thirdparty%2Fsuricata.git rust/snmp: fix libc deprecation warnings --- diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 7a5c75ef73..86bbc928a9 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -22,7 +22,6 @@ use core; use core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED,STREAM_TOSERVER,STREAM_TOCLIENT}; use applayer; use parser::*; -use libc; use std; use std::ffi::{CStr,CString}; use std::mem::transmute; @@ -300,7 +299,7 @@ impl Drop for SNMPTransaction { /// Returns *mut SNMPState #[no_mangle] -pub extern "C" fn rs_snmp_state_new() -> *mut libc::c_void { +pub extern "C" fn rs_snmp_state_new() -> *mut std::os::raw::c_void { let state = SNMPState::new(); let boxed = Box::new(state); return unsafe{std::mem::transmute(boxed)}; @@ -309,7 +308,7 @@ pub extern "C" fn rs_snmp_state_new() -> *mut libc::c_void { /// Params: /// - state: *mut SNMPState as void pointer #[no_mangle] -pub extern "C" fn rs_snmp_state_free(state: *mut libc::c_void) { +pub extern "C" fn rs_snmp_state_free(state: *mut std::os::raw::c_void) { // Just unbox... let mut snmp_state: Box = unsafe{std::mem::transmute(state)}; snmp_state.free(); @@ -317,11 +316,11 @@ pub extern "C" fn rs_snmp_state_free(state: *mut libc::c_void) { #[no_mangle] pub extern "C" fn rs_snmp_parse_request(_flow: *const core::Flow, - state: *mut libc::c_void, - _pstate: *mut libc::c_void, + state: *mut std::os::raw::c_void, + _pstate: *mut std::os::raw::c_void, input: *const u8, input_len: u32, - _data: *const libc::c_void, + _data: *const std::os::raw::c_void, _flags: u8) -> i32 { let buf = build_slice!(input,input_len as usize); let state = cast_pointer!(state,SNMPState); @@ -330,11 +329,11 @@ pub extern "C" fn rs_snmp_parse_request(_flow: *const core::Flow, #[no_mangle] pub extern "C" fn rs_snmp_parse_response(_flow: *const core::Flow, - state: *mut libc::c_void, - _pstate: *mut libc::c_void, + state: *mut std::os::raw::c_void, + _pstate: *mut std::os::raw::c_void, input: *const u8, input_len: u32, - _data: *const libc::c_void, + _data: *const std::os::raw::c_void, _flags: u8) -> i32 { let buf = build_slice!(input,input_len as usize); let state = cast_pointer!(state,SNMPState); @@ -342,9 +341,9 @@ pub extern "C" fn rs_snmp_parse_response(_flow: *const core::Flow, } #[no_mangle] -pub extern "C" fn rs_snmp_state_get_tx(state: *mut libc::c_void, +pub extern "C" fn rs_snmp_state_get_tx(state: *mut std::os::raw::c_void, tx_id: u64) - -> *mut libc::c_void + -> *mut std::os::raw::c_void { let state = cast_pointer!(state,SNMPState); match state.get_tx_by_id(tx_id) { @@ -354,7 +353,7 @@ pub extern "C" fn rs_snmp_state_get_tx(state: *mut libc::c_void, } #[no_mangle] -pub extern "C" fn rs_snmp_state_get_tx_count(state: *mut libc::c_void) +pub extern "C" fn rs_snmp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { let state = cast_pointer!(state,SNMPState); @@ -362,7 +361,7 @@ pub extern "C" fn rs_snmp_state_get_tx_count(state: *mut libc::c_void) } #[no_mangle] -pub extern "C" fn rs_snmp_state_tx_free(state: *mut libc::c_void, +pub extern "C" fn rs_snmp_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { let state = cast_pointer!(state,SNMPState); @@ -372,15 +371,15 @@ pub extern "C" fn rs_snmp_state_tx_free(state: *mut libc::c_void, #[no_mangle] pub extern "C" fn rs_snmp_state_progress_completion_status( _direction: u8) - -> libc::c_int + -> std::os::raw::c_int { return 1; } #[no_mangle] -pub extern "C" fn rs_snmp_tx_get_alstate_progress(_tx: *mut libc::c_void, +pub extern "C" fn rs_snmp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void, _direction: u8) - -> libc::c_int + -> std::os::raw::c_int { 1 } @@ -390,8 +389,8 @@ pub extern "C" fn rs_snmp_tx_get_alstate_progress(_tx: *mut libc::c_void, #[no_mangle] -pub extern "C" fn rs_snmp_tx_set_logged(_state: *mut libc::c_void, - tx: *mut libc::c_void, +pub extern "C" fn rs_snmp_tx_set_logged(_state: *mut std::os::raw::c_void, + tx: *mut std::os::raw::c_void, logged: u32) { let tx = cast_pointer!(tx,SNMPTransaction); @@ -399,8 +398,8 @@ pub extern "C" fn rs_snmp_tx_set_logged(_state: *mut libc::c_void, } #[no_mangle] -pub extern "C" fn rs_snmp_tx_get_logged(_state: *mut libc::c_void, - tx: *mut libc::c_void) +pub extern "C" fn rs_snmp_tx_get_logged(_state: *mut std::os::raw::c_void, + tx: *mut std::os::raw::c_void) -> u32 { let tx = cast_pointer!(tx,SNMPTransaction); @@ -410,8 +409,8 @@ pub extern "C" fn rs_snmp_tx_get_logged(_state: *mut libc::c_void, #[no_mangle] pub extern "C" fn rs_snmp_state_set_tx_detect_state( - tx: *mut libc::c_void, - de_state: &mut core::DetectEngineState) -> libc::c_int + tx: *mut std::os::raw::c_void, + de_state: &mut core::DetectEngineState) -> std::os::raw::c_int { let tx = cast_pointer!(tx,SNMPTransaction); tx.de_state = Some(de_state); @@ -420,7 +419,7 @@ pub extern "C" fn rs_snmp_state_set_tx_detect_state( #[no_mangle] pub extern "C" fn rs_snmp_state_get_tx_detect_state( - tx: *mut libc::c_void) + tx: *mut std::os::raw::c_void) -> *mut core::DetectEngineState { let tx = cast_pointer!(tx,SNMPTransaction); @@ -432,22 +431,18 @@ pub extern "C" fn rs_snmp_state_get_tx_detect_state( #[no_mangle] -pub extern "C" fn rs_snmp_state_get_events(state: *mut libc::c_void, - tx_id: u64) - -> *mut core::AppLayerDecoderEvents +pub extern "C" fn rs_snmp_state_get_events(tx: *mut std::os::raw::c_void) + -> *mut core::AppLayerDecoderEvents { - let state = cast_pointer!(state,SNMPState); - match state.get_tx_by_id(tx_id) { - Some(tx) => tx.events, - _ => std::ptr::null_mut(), - } + let tx = cast_pointer!(tx, SNMPTransaction); + return tx.events; } #[no_mangle] -pub extern "C" fn rs_snmp_state_get_event_info(event_name: *const libc::c_char, - event_id: *mut libc::c_int, +pub extern "C" fn rs_snmp_state_get_event_info(event_name: *const std::os::raw::c_char, + event_id: *mut std::os::raw::c_int, event_type: *mut core::AppLayerEventType) - -> libc::c_int + -> std::os::raw::c_int { if event_name == std::ptr::null() { return -1; } let c_event_name: &CStr = unsafe { CStr::from_ptr(event_name) }; @@ -463,7 +458,7 @@ pub extern "C" fn rs_snmp_state_get_event_info(event_name: *const libc::c_char, }; unsafe{ *event_type = core::APP_LAYER_EVENT_TYPE_TRANSACTION; - *event_id = event as libc::c_int; + *event_id = event as std::os::raw::c_int; }; 0 } @@ -492,7 +487,7 @@ pub extern "C" fn rs_snmp_state_get_tx_iterator( #[no_mangle] pub extern "C" fn rs_snmp_get_tx_iterator(_ipproto: u8, _alproto: AppProto, - alstate: *mut libc::c_void, + alstate: *mut std::os::raw::c_void, min_tx_id: u64, _max_tx_id: u64, istate: &mut u64) -> applayer::AppLayerGetTxIterTuple @@ -562,7 +557,7 @@ const PARSER_NAME : &'static [u8] = b"snmp\0"; pub unsafe extern "C" fn rs_register_snmp_parser() { let default_port = CString::new("161").unwrap(); let mut parser = RustParser { - name : PARSER_NAME.as_ptr() as *const libc::c_char, + name : PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port : default_port.as_ptr(), ipproto : core::IPPROTO_UDP, probe_ts : rs_snmp_probing_parser,