rust: remove libc crate dependency

Use std::os::raw instead.
pull/3998/head
Victor Julien 7 years ago
parent 28ed0d3a18
commit 3f6624bf16

@ -16,7 +16,6 @@ debug = []
[dependencies]
nom = "4.2"
libc = "^0.2.36"
crc = "1.8"
der-parser = "1.1"
kerberos-parser = "0.2"

@ -57,19 +57,19 @@ type_map = {
"u32" :"uint32_t",
"u64" :"uint64_t",
"libc::c_void": "void",
"std::os::raw::c_void": "void",
"c_void": "void",
"libc::c_char": "char",
"libc::c_int": "int",
"std::os::raw::c_char": "char",
"std::os::raw::c_int": "int",
"c_int": "int",
"libc::int8_t": "int8_t",
"libc::int32_t": "int32_t",
"std::os::raw::int8_t": "int8_t",
"std::os::raw::int32_t": "int32_t",
"libc::uint8_t": "uint8_t",
"libc::uint16_t": "uint16_t",
"libc::uint32_t": "uint32_t",
"libc::uint64_t": "uint64_t",
"std::os::raw::uint8_t": "uint8_t",
"std::os::raw::uint16_t": "uint16_t",
"std::os::raw::uint32_t": "uint32_t",
"std::os::raw::uint64_t": "uint64_t",
"SuricataContext": "SuricataContext",
"SuricataFileContext": "SuricataFileContext",

@ -15,18 +15,17 @@
* 02110-1301, USA.
*/
extern crate libc;
use std;
#[repr(C)]
pub struct AppLayerGetTxIterTuple {
tx_ptr: *mut libc::c_void,
tx_ptr: *mut std::os::raw::c_void,
tx_id: u64,
has_next: bool,
}
impl AppLayerGetTxIterTuple {
pub fn with_values(tx_ptr: *mut libc::c_void, tx_id: u64, has_next: bool) -> AppLayerGetTxIterTuple {
pub fn with_values(tx_ptr: *mut std::os::raw::c_void, tx_id: u64, has_next: bool) -> AppLayerGetTxIterTuple {
AppLayerGetTxIterTuple {
tx_ptr: tx_ptr, tx_id: tx_id, has_next: has_next,
}
@ -67,7 +66,7 @@ impl LoggerFlags {
macro_rules!export_tx_get_detect_state {
($name:ident, $type:ty) => (
#[no_mangle]
pub extern "C" fn $name(tx: *mut libc::c_void)
pub extern "C" fn $name(tx: *mut std::os::raw::c_void)
-> *mut core::DetectEngineState
{
let tx = cast_pointer!(tx, $type);
@ -88,8 +87,8 @@ macro_rules!export_tx_get_detect_state {
macro_rules!export_tx_set_detect_state {
($name:ident, $type:ty) => (
#[no_mangle]
pub extern "C" fn $name(tx: *mut libc::c_void,
de_state: &mut core::DetectEngineState) -> libc::c_int
pub extern "C" fn $name(tx: *mut std::os::raw::c_void,
de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
{
let tx = cast_pointer!(tx, $type);
tx.de_state = Some(de_state);

@ -15,7 +15,6 @@
* 02110-1301, USA.
*/
use libc;
use std;
use json::*;
use super::template::TemplateTransaction;
@ -32,7 +31,7 @@ fn log_template(tx: &TemplateTransaction) -> Option<Json> {
}
#[no_mangle]
pub extern "C" fn rs_template_logger_log(tx: *mut libc::c_void) -> *mut JsonT {
pub extern "C" fn rs_template_logger_log(tx: *mut std::os::raw::c_void) -> *mut JsonT {
let tx = cast_pointer!(tx, TemplateTransaction);
match log_template(tx) {
Some(js) => js.unwrap(),

@ -17,7 +17,6 @@
use std;
use core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
use libc;
use log::*;
use std::mem::transmute;
use applayer::{self, LoggerFlags};
@ -273,21 +272,21 @@ pub extern "C" fn rs_template_probing_parser(
}
#[no_mangle]
pub extern "C" fn rs_template_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_template_state_new() -> *mut std::os::raw::c_void {
let state = TemplateState::new();
let boxed = Box::new(state);
return unsafe { transmute(boxed) };
}
#[no_mangle]
pub extern "C" fn rs_template_state_free(state: *mut libc::c_void) {
pub extern "C" fn rs_template_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
let _drop: Box<TemplateState> = unsafe { transmute(state) };
}
#[no_mangle]
pub extern "C" fn rs_template_state_tx_free(
state: *mut libc::c_void,
state: *mut std::os::raw::c_void,
tx_id: u64,
) {
let state = cast_pointer!(state, TemplateState);
@ -297,11 +296,11 @@ pub extern "C" fn rs_template_state_tx_free(
#[no_mangle]
pub extern "C" fn rs_template_parse_request(
_flow: *const 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 eof = unsafe {
@ -327,11 +326,11 @@ pub extern "C" fn rs_template_parse_request(
#[no_mangle]
pub extern "C" fn rs_template_parse_response(
_flow: *const 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 _eof = unsafe {
@ -351,9 +350,9 @@ pub extern "C" fn rs_template_parse_response(
#[no_mangle]
pub extern "C" fn rs_template_state_get_tx(
state: *mut libc::c_void,
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, TemplateState);
match state.get_tx(tx_id) {
Some(tx) => {
@ -367,7 +366,7 @@ pub extern "C" fn rs_template_state_get_tx(
#[no_mangle]
pub extern "C" fn rs_template_state_get_tx_count(
state: *mut libc::c_void,
state: *mut std::os::raw::c_void,
) -> u64 {
let state = cast_pointer!(state, TemplateState);
return state.tx_id;
@ -376,16 +375,16 @@ pub extern "C" fn rs_template_state_get_tx_count(
#[no_mangle]
pub extern "C" fn rs_template_state_progress_completion_status(
_direction: u8,
) -> libc::c_int {
) -> std::os::raw::c_int {
// This parser uses 1 to signal transaction completion status.
return 1;
}
#[no_mangle]
pub extern "C" fn rs_template_tx_get_alstate_progress(
tx: *mut libc::c_void,
tx: *mut std::os::raw::c_void,
_direction: u8,
) -> libc::c_int {
) -> std::os::raw::c_int {
let tx = cast_pointer!(tx, TemplateTransaction);
// Transaction is done if we have a response.
@ -397,8 +396,8 @@ pub extern "C" fn rs_template_tx_get_alstate_progress(
#[no_mangle]
pub extern "C" fn rs_template_tx_get_logged(
_state: *mut libc::c_void,
tx: *mut libc::c_void,
_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
) -> u32 {
let tx = cast_pointer!(tx, TemplateTransaction);
return tx.logged.get();
@ -406,8 +405,8 @@ pub extern "C" fn rs_template_tx_get_logged(
#[no_mangle]
pub extern "C" fn rs_template_tx_set_logged(
_state: *mut libc::c_void,
tx: *mut libc::c_void,
_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
logged: u32,
) {
let tx = cast_pointer!(tx, TemplateTransaction);
@ -416,7 +415,7 @@ pub extern "C" fn rs_template_tx_set_logged(
#[no_mangle]
pub extern "C" fn rs_template_state_get_events(
tx: *mut libc::c_void
tx: *mut std::os::raw::c_void
) -> *mut core::AppLayerDecoderEvents {
let tx = cast_pointer!(tx, TemplateTransaction);
return tx.events;
@ -424,10 +423,10 @@ pub extern "C" fn rs_template_state_get_events(
#[no_mangle]
pub extern "C" fn rs_template_state_get_event_info(
_event_name: *const libc::c_char,
_event_id: *mut libc::c_int,
_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 {
return -1;
}
@ -435,7 +434,7 @@ pub extern "C" fn rs_template_state_get_event_info(
pub extern "C" fn rs_template_state_get_tx_iterator(
_ipproto: u8,
_alproto: AppProto,
state: *mut libc::c_void,
state: *mut std::os::raw::c_void,
min_tx_id: u64,
_max_tx_id: u64,
istate: &mut u64,
@ -463,7 +462,7 @@ pub extern "C" fn rs_template_state_get_tx_iterator(
/// pointer to the request buffer from C for detection.
#[no_mangle]
pub extern "C" fn rs_template_get_request_buffer(
tx: *mut libc::c_void,
tx: *mut std::os::raw::c_void,
buf: *mut *const u8,
len: *mut u32,
) -> u8
@ -484,7 +483,7 @@ pub extern "C" fn rs_template_get_request_buffer(
/// Get the response buffer for a transaction from C.
#[no_mangle]
pub extern "C" fn rs_template_get_response_buffer(
tx: *mut libc::c_void,
tx: *mut std::os::raw::c_void,
buf: *mut *const u8,
len: *mut u32,
) -> u8
@ -509,7 +508,7 @@ const PARSER_NAME: &'static [u8] = b"template-rust\0";
pub unsafe extern "C" fn rs_template_register_parser() {
let default_port = CString::new("[7000]").unwrap();
let 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: IPPROTO_TCP,
probe_ts: rs_template_probing_parser,

@ -17,8 +17,7 @@
// This file exposes items from the core "C" code to Rust.
extern crate libc;
use std;
use filecontainer::*;
/// Opaque C types.
@ -27,7 +26,7 @@ pub enum DetectEngineState {}
pub enum AppLayerDecoderEvents {}
// From app-layer-events.h
pub type AppLayerEventType = libc::c_int;
pub type AppLayerEventType = std::os::raw::c_int;
pub const APP_LAYER_EVENT_TYPE_TRANSACTION : i32 = 1;
pub const APP_LAYER_EVENT_TYPE_PACKET : i32 = 2;
@ -41,7 +40,7 @@ pub const STREAM_DEPTH: u8 = 0x20;
pub const STREAM_MIDSTREAM:u8 = 0x40;
// Application layer protocol identifiers (app-layer-protos.h)
pub type AppProto = libc::c_int;
pub type AppProto = std::os::raw::c_int;
pub const ALPROTO_UNKNOWN : AppProto = 0;
pub static mut ALPROTO_FAILED : AppProto = 0; // updated during init
@ -64,12 +63,12 @@ extern {
#[allow(non_snake_case)]
pub type SCLogMessageFunc =
extern "C" fn(level: libc::c_int,
filename: *const libc::c_char,
line: libc::c_uint,
function: *const libc::c_char,
code: libc::c_int,
message: *const libc::c_char) -> libc::c_int;
extern "C" fn(level: std::os::raw::c_int,
filename: *const std::os::raw::c_char,
line: std::os::raw::c_uint,
function: *const std::os::raw::c_char,
code: std::os::raw::c_int,
message: *const std::os::raw::c_char) -> std::os::raw::c_int;
pub type DetectEngineStateFreeFunc =
extern "C" fn(state: *mut DetectEngineState);

@ -20,7 +20,6 @@ use core;
use core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_UDP};
use core::{sc_detect_engine_state_free, sc_app_layer_decoder_events_free_events};
use dhcp::parser::*;
use libc;
use log::*;
use parser::*;
use std;
@ -240,22 +239,22 @@ pub extern "C" fn rs_dhcp_probing_parser(_flow: *const Flow,
}
#[no_mangle]
pub extern "C" fn rs_dhcp_tx_get_alstate_progress(_tx: *mut libc::c_void,
_direction: u8) -> libc::c_int {
pub extern "C" fn rs_dhcp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
_direction: u8) -> std::os::raw::c_int {
// As this is a stateless parser, simply use 1.
return 1;
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_progress_completion_status(
_direction: u8) -> libc::c_int {
_direction: u8) -> std::os::raw::c_int {
// The presence of a transaction means we are complete.
return 1;
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_get_tx(state: *mut libc::c_void,
tx_id: u64) -> *mut libc::c_void {
pub extern "C" fn rs_dhcp_state_get_tx(state: *mut std::os::raw::c_void,
tx_id: u64) -> *mut std::os::raw::c_void {
let state = cast_pointer!(state, DHCPState);
match state.get_tx(tx_id) {
Some(tx) => {
@ -268,18 +267,18 @@ pub extern "C" fn rs_dhcp_state_get_tx(state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_get_tx_count(state: *mut libc::c_void) -> u64 {
pub extern "C" fn rs_dhcp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
let state = cast_pointer!(state, DHCPState);
return state.tx_id;
}
#[no_mangle]
pub extern "C" fn rs_dhcp_parse(_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 state = cast_pointer!(state, DHCPState);
let buf = build_slice!(input, input_len as usize);
@ -291,7 +290,7 @@ pub extern "C" fn rs_dhcp_parse(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_dhcp_state_tx_free(
state: *mut libc::c_void,
state: *mut std::os::raw::c_void,
tx_id: u64)
{
let state = cast_pointer!(state, DHCPState);
@ -299,7 +298,7 @@ pub extern "C" fn rs_dhcp_state_tx_free(
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_dhcp_state_new() -> *mut std::os::raw::c_void {
let state = DHCPState::new();
let boxed = Box::new(state);
return unsafe {
@ -308,27 +307,27 @@ pub extern "C" fn rs_dhcp_state_new() -> *mut libc::c_void {
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_free(state: *mut libc::c_void) {
pub extern "C" fn rs_dhcp_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
let _drop: Box<DHCPState> = unsafe { transmute(state) };
}
#[no_mangle]
pub extern "C" fn rs_dhcp_tx_get_logged(_state: *mut libc::c_void, tx: *mut libc::c_void) -> u32 {
pub extern "C" fn rs_dhcp_tx_get_logged(_state: *mut std::os::raw::c_void, tx: *mut std::os::raw::c_void) -> u32 {
let tx = cast_pointer!(tx, DHCPTransaction);
return tx.logged.get();
}
#[no_mangle]
pub extern "C" fn rs_dhcp_tx_set_logged(_state: *mut libc::c_void,
tx: *mut libc::c_void,
pub extern "C" fn rs_dhcp_tx_set_logged(_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
logged: u32) {
let tx = cast_pointer!(tx, DHCPTransaction);
tx.logged.set(logged);
}
#[no_mangle]
pub extern "C" fn rs_dhcp_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_dhcp_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut core::AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, DHCPTransaction);
@ -337,10 +336,10 @@ pub extern "C" fn rs_dhcp_state_get_events(tx: *mut libc::c_void)
#[no_mangle]
pub extern "C" fn rs_dhcp_state_get_event_info(
event_name: *const libc::c_char,
event_id: *mut libc::c_int,
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;
@ -358,7 +357,7 @@ pub extern "C" fn rs_dhcp_state_get_event_info(
};
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
}
@ -367,7 +366,7 @@ pub extern "C" fn rs_dhcp_state_get_event_info(
pub extern "C" fn rs_dhcp_state_get_tx_iterator(
_ipproto: u8,
_alproto: AppProto,
state: *mut libc::c_void,
state: *mut std::os::raw::c_void,
min_tx_id: u64,
_max_tx_id: u64,
istate: &mut u64)
@ -394,7 +393,7 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
SCLogDebug!("Registering DHCP parser.");
let ports = CString::new("[67,68]").unwrap();
let 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: ports.as_ptr(),
ipproto: IPPROTO_UDP,
probe_ts: rs_dhcp_probing_parser,

@ -15,8 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
use std;
use std::os::raw::c_void;
@ -255,20 +253,20 @@ fn format_addr_hex(input: &Vec<u8>) -> String {
}
#[no_mangle]
pub extern "C" fn rs_dhcp_logger_new(conf: *const c_void) -> *mut libc::c_void {
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)};
}
#[no_mangle]
pub extern "C" fn rs_dhcp_logger_free(logger: *mut libc::c_void) {
pub extern "C" fn rs_dhcp_logger_free(logger: *mut std::os::raw::c_void) {
let _: Box<DHCPLogger> = unsafe{std::mem::transmute(logger)};
}
#[no_mangle]
pub extern "C" fn rs_dhcp_logger_log(logger: *mut libc::c_void,
tx: *mut libc::c_void) -> *mut JsonT {
pub extern "C" fn rs_dhcp_logger_log(logger: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void) -> *mut JsonT {
let logger = cast_pointer!(logger, DHCPLogger);
let tx = cast_pointer!(tx, DHCPTransaction);
match logger.log(tx) {

@ -15,7 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
extern crate nom;
use std;
@ -537,7 +536,7 @@ pub fn probe_tcp(input: &[u8]) -> bool {
/// Returns *mut DNSState
#[no_mangle]
pub extern "C" fn rs_dns_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_dns_state_new() -> *mut std::os::raw::c_void {
let state = DNSState::new();
let boxed = Box::new(state);
return unsafe{transmute(boxed)};
@ -545,7 +544,7 @@ pub extern "C" fn rs_dns_state_new() -> *mut libc::c_void {
/// Returns *mut DNSState
#[no_mangle]
pub extern "C" fn rs_dns_state_tcp_new() -> *mut libc::c_void {
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)};
@ -554,7 +553,7 @@ pub extern "C" fn rs_dns_state_tcp_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut DNSState as void pointer
#[no_mangle]
pub extern "C" fn rs_dns_state_free(state: *mut libc::c_void) {
pub extern "C" fn rs_dns_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
let _drop: Box<DNSState> = unsafe{transmute(state)};
}
@ -570,10 +569,10 @@ pub extern "C" fn rs_dns_state_tx_free(state: &mut DNSState,
#[no_mangle]
pub extern "C" fn rs_dns_parse_request(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8 {
let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)};
if state.parse_request(buf) {
@ -586,10 +585,10 @@ pub extern "C" fn rs_dns_parse_request(_flow: *mut core::Flow,
#[no_mangle]
pub extern "C" fn rs_dns_parse_response(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8 {
let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)};
if state.parse_response(buf) {
@ -603,10 +602,10 @@ pub extern "C" fn rs_dns_parse_response(_flow: *mut core::Flow,
#[no_mangle]
pub extern "C" fn rs_dns_parse_request_tcp(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8 {
if input_len > 0 {
if input != std::ptr::null_mut() {
@ -622,10 +621,10 @@ pub extern "C" fn rs_dns_parse_request_tcp(_flow: *mut core::Flow,
#[no_mangle]
pub extern "C" fn rs_dns_parse_response_tcp(_flow: *mut core::Flow,
state: &mut DNSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8 {
if input_len > 0 {
if input != std::ptr::null_mut() {
@ -641,7 +640,7 @@ pub extern "C" fn rs_dns_parse_response_tcp(_flow: *mut core::Flow,
#[no_mangle]
pub extern "C" fn rs_dns_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
SCLogDebug!("rs_dns_state_progress_completion_status");
return 1;
@ -745,7 +744,7 @@ pub extern "C" fn rs_dns_state_get_tx_detect_state(
}
#[no_mangle]
pub extern "C" fn rs_dns_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_dns_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut core::AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, DNSTransaction);

@ -15,8 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
use std;
use std::string::String;
use std::collections::HashMap;

@ -15,9 +15,8 @@
* 02110-1301, USA.
*/
extern crate libc;
use std::ptr;
use libc::{c_void};
use std::os::raw::{c_void};
use log::*;
use core::*;

@ -28,7 +28,6 @@
* The tracker does continue to follow the file.
*/
extern crate libc;
use log::*;
use core::*;
use std::collections::HashMap;

@ -15,7 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
extern crate nom;
use nom::digit;

@ -23,7 +23,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};
@ -431,7 +430,7 @@ impl Drop for IKEV2Transaction {
/// Returns *mut IKEV2State
#[no_mangle]
pub extern "C" fn rs_ikev2_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_ikev2_state_new() -> *mut std::os::raw::c_void {
let state = IKEV2State::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
@ -440,7 +439,7 @@ pub extern "C" fn rs_ikev2_state_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut IKEV2State as void pointer
#[no_mangle]
pub extern "C" fn rs_ikev2_state_free(state: *mut libc::c_void) {
pub extern "C" fn rs_ikev2_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
let mut ikev2_state: Box<IKEV2State> = unsafe{std::mem::transmute(state)};
ikev2_state.free();
@ -448,11 +447,11 @@ pub extern "C" fn rs_ikev2_state_free(state: *mut libc::c_void) {
#[no_mangle]
pub extern "C" fn rs_ikev2_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,IKEV2State);
@ -461,11 +460,11 @@ pub extern "C" fn rs_ikev2_parse_request(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_ikev2_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,IKEV2State);
@ -481,9 +480,9 @@ pub extern "C" fn rs_ikev2_parse_response(_flow: *const core::Flow,
}
#[no_mangle]
pub extern "C" fn rs_ikev2_state_get_tx(state: *mut libc::c_void,
pub extern "C" fn rs_ikev2_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,IKEV2State);
match state.get_tx_by_id(tx_id) {
@ -493,7 +492,7 @@ pub extern "C" fn rs_ikev2_state_get_tx(state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_ikev2_state_get_tx_count(state: *mut libc::c_void)
pub extern "C" fn rs_ikev2_state_get_tx_count(state: *mut std::os::raw::c_void)
-> u64
{
let state = cast_pointer!(state,IKEV2State);
@ -501,7 +500,7 @@ pub extern "C" fn rs_ikev2_state_get_tx_count(state: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_ikev2_state_tx_free(state: *mut libc::c_void,
pub extern "C" fn rs_ikev2_state_tx_free(state: *mut std::os::raw::c_void,
tx_id: u64)
{
let state = cast_pointer!(state,IKEV2State);
@ -511,15 +510,15 @@ pub extern "C" fn rs_ikev2_state_tx_free(state: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_ikev2_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
return 1;
}
#[no_mangle]
pub extern "C" fn rs_ikev2_tx_get_alstate_progress(_tx: *mut libc::c_void,
pub extern "C" fn rs_ikev2_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
1
}
@ -529,8 +528,8 @@ pub extern "C" fn rs_ikev2_tx_get_alstate_progress(_tx: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_ikev2_tx_set_logged(_state: *mut libc::c_void,
tx: *mut libc::c_void,
pub extern "C" fn rs_ikev2_tx_set_logged(_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
logged: u32)
{
let tx = cast_pointer!(tx,IKEV2Transaction);
@ -538,8 +537,8 @@ pub extern "C" fn rs_ikev2_tx_set_logged(_state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_ikev2_tx_get_logged(_state: *mut libc::c_void,
tx: *mut libc::c_void)
pub extern "C" fn rs_ikev2_tx_get_logged(_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void)
-> u32
{
let tx = cast_pointer!(tx,IKEV2Transaction);
@ -549,8 +548,8 @@ pub extern "C" fn rs_ikev2_tx_get_logged(_state: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_ikev2_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,IKEV2Transaction);
tx.de_state = Some(de_state);
@ -559,7 +558,7 @@ pub extern "C" fn rs_ikev2_state_set_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_ikev2_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,IKEV2Transaction);
@ -571,7 +570,7 @@ pub extern "C" fn rs_ikev2_state_get_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_ikev2_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_ikev2_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut core::AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, IKEV2Transaction);
@ -579,10 +578,10 @@ pub extern "C" fn rs_ikev2_state_get_events(tx: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_ikev2_state_get_event_info(event_name: *const libc::c_char,
event_id: *mut libc::c_int,
pub extern "C" fn rs_ikev2_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) };
@ -606,7 +605,7 @@ pub extern "C" fn rs_ikev2_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
}
@ -655,7 +654,7 @@ const PARSER_NAME : &'static [u8] = b"ikev2\0";
pub unsafe extern "C" fn rs_register_ikev2_parser() {
let default_port = CString::new("500").unwrap();
let 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_ikev2_probing_parser,

@ -17,7 +17,6 @@
// written by Pierre Chifflier <chifflier@wzdftpd.net>
use libc;
use std;
use std::ffi::{CStr,CString};
use nom;
@ -265,7 +264,7 @@ pub fn test_weak_encryption(alg:EncryptionType) -> bool {
/// Returns *mut KRB5State
#[no_mangle]
pub extern "C" fn rs_krb5_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_krb5_state_new() -> *mut std::os::raw::c_void {
let state = KRB5State::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
@ -274,16 +273,16 @@ pub extern "C" fn rs_krb5_state_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut KRB5State as void pointer
#[no_mangle]
pub extern "C" fn rs_krb5_state_free(state: *mut libc::c_void) {
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)};
state.free();
}
#[no_mangle]
pub extern "C" fn rs_krb5_state_get_tx(state: *mut libc::c_void,
pub extern "C" fn rs_krb5_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,KRB5State);
match state.get_tx_by_id(tx_id) {
@ -293,7 +292,7 @@ pub extern "C" fn rs_krb5_state_get_tx(state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_krb5_state_get_tx_count(state: *mut libc::c_void)
pub extern "C" fn rs_krb5_state_get_tx_count(state: *mut std::os::raw::c_void)
-> u64
{
let state = cast_pointer!(state,KRB5State);
@ -301,7 +300,7 @@ pub extern "C" fn rs_krb5_state_get_tx_count(state: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_krb5_state_tx_free(state: *mut libc::c_void,
pub extern "C" fn rs_krb5_state_tx_free(state: *mut std::os::raw::c_void,
tx_id: u64)
{
let state = cast_pointer!(state,KRB5State);
@ -311,22 +310,22 @@ pub extern "C" fn rs_krb5_state_tx_free(state: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_krb5_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
return 1;
}
#[no_mangle]
pub extern "C" fn rs_krb5_tx_get_alstate_progress(_tx: *mut libc::c_void,
pub extern "C" fn rs_krb5_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
1
}
#[no_mangle]
pub extern "C" fn rs_krb5_tx_set_logged(_state: *mut libc::c_void,
tx: *mut libc::c_void,
pub extern "C" fn rs_krb5_tx_set_logged(_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void,
logged: u32)
{
let tx = cast_pointer!(tx,KRB5Transaction);
@ -334,8 +333,8 @@ pub extern "C" fn rs_krb5_tx_set_logged(_state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_krb5_tx_get_logged(_state: *mut libc::c_void,
tx: *mut libc::c_void)
pub extern "C" fn rs_krb5_tx_get_logged(_state: *mut std::os::raw::c_void,
tx: *mut std::os::raw::c_void)
-> u32
{
let tx = cast_pointer!(tx,KRB5Transaction);
@ -345,8 +344,8 @@ pub extern "C" fn rs_krb5_tx_get_logged(_state: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_krb5_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,KRB5Transaction);
tx.de_state = Some(de_state);
@ -355,7 +354,7 @@ pub extern "C" fn rs_krb5_state_set_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_krb5_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,KRB5Transaction);
@ -367,7 +366,7 @@ pub extern "C" fn rs_krb5_state_get_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_krb5_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_krb5_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut core::AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, KRB5Transaction);
@ -375,10 +374,10 @@ pub extern "C" fn rs_krb5_state_get_events(tx: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_krb5_state_get_event_info(event_name: *const libc::c_char,
event_id: *mut libc::c_int,
pub extern "C" fn rs_krb5_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) };
@ -394,7 +393,7 @@ pub extern "C" fn rs_krb5_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
}
@ -464,11 +463,11 @@ pub extern "C" fn rs_krb5_probing_parser_tcp(_flow: *const Flow,
#[no_mangle]
pub extern "C" fn rs_krb5_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,KRB5State);
@ -477,11 +476,11 @@ pub extern "C" fn rs_krb5_parse_request(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_krb5_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,KRB5State);
@ -490,11 +489,11 @@ pub extern "C" fn rs_krb5_parse_response(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_krb5_parse_request_tcp(_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 {
if input_len < 4 { return -1; }
let buf = build_slice!(input,input_len as usize);
@ -548,11 +547,11 @@ pub extern "C" fn rs_krb5_parse_request_tcp(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_krb5_parse_response_tcp(_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 {
if input_len < 4 { return -1; }
let buf = build_slice!(input,input_len as usize);
@ -611,7 +610,7 @@ const PARSER_NAME : &'static [u8] = b"krb5\0";
pub unsafe extern "C" fn rs_register_krb5_parser() {
let default_port = CString::new("88").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_krb5_probing_parser,

@ -17,8 +17,6 @@
#![cfg_attr(feature = "strict", deny(warnings))]
extern crate libc;
#[macro_use]
extern crate nom;

@ -15,8 +15,7 @@
* 02110-1301, USA.
*/
extern crate libc;
use std;
use std::ffi::CString;
use std::path::Path;
@ -148,10 +147,10 @@ pub fn log_set_level(level: Level) {
/// Rust unit tests).
pub fn sc_log_message(level: Level,
filename: &str,
line: libc::c_uint,
line: std::os::raw::c_uint,
function: &str,
code: libc::c_int,
message: &str) -> libc::c_int
code: std::os::raw::c_int,
message: &str) -> std::os::raw::c_int
{
unsafe {
if let Some(c) = SC {

@ -15,8 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
use std::string::String;
use json::*;
use nfs::types::*;

@ -18,7 +18,6 @@
// written by Victor Julien
// TCP buffering code written by Pierre Chifflier
extern crate libc;
use std;
use std::mem::transmute;
use std::collections::{HashMap};
@ -1339,7 +1338,7 @@ impl NFSState {
/// Returns *mut NFSState
#[no_mangle]
pub extern "C" fn rs_nfs_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_nfs_state_new() -> *mut std::os::raw::c_void {
let state = NFSState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
@ -1349,7 +1348,7 @@ pub extern "C" fn rs_nfs_state_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut NFSState as void pointer
#[no_mangle]
pub extern "C" fn rs_nfs_state_free(state: *mut libc::c_void) {
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)};
@ -1360,10 +1359,10 @@ pub extern "C" fn rs_nfs_state_free(state: *mut libc::c_void) {
#[no_mangle]
pub extern "C" fn rs_nfs_parse_request(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8
{
let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)};
@ -1391,10 +1390,10 @@ pub extern "C" fn rs_nfs_parse_request_tcp_gap(
#[no_mangle]
pub extern "C" fn rs_nfs_parse_response(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8
{
SCLogDebug!("parsing {} bytes of response data", input_len);
@ -1423,10 +1422,10 @@ pub extern "C" fn rs_nfs_parse_response_tcp_gap(
#[no_mangle]
pub extern "C" fn rs_nfs_parse_request_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8
{
let buf = unsafe{std::slice::from_raw_parts(input, input_len as usize)};
@ -1442,10 +1441,10 @@ pub extern "C" fn rs_nfs_parse_request_udp(_flow: *mut Flow,
#[no_mangle]
pub extern "C" fn rs_nfs_parse_response_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void)
_data: *mut std::os::raw::c_void)
-> i8
{
SCLogDebug!("parsing {} bytes of response data", input_len);
@ -1511,7 +1510,7 @@ pub extern "C" fn rs_nfs_state_tx_free(state: &mut NFSState,
#[no_mangle]
pub extern "C" fn rs_nfs_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
return 1;
}
@ -1601,7 +1600,7 @@ pub extern "C" fn rs_nfs_tx_get_detect_flags(
}
#[no_mangle]
pub extern "C" fn rs_nfs_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_nfs_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, NFSTransaction);
@ -1609,8 +1608,8 @@ pub extern "C" fn rs_nfs_state_get_events(tx: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_nfs_state_get_event_info_by_id(event_id: libc::c_int,
event_name: *mut *const libc::c_char,
pub extern "C" fn rs_nfs_state_get_event_info_by_id(event_id: std::os::raw::c_int,
event_name: *mut *const std::os::raw::c_char,
event_type: *mut AppLayerEventType)
-> i8
{
@ -1621,7 +1620,7 @@ pub extern "C" fn rs_nfs_state_get_event_info_by_id(event_id: libc::c_int,
NFSEvent::UnsupportedVersion => { "unsupported_version\0" },
};
unsafe{
*event_name = estr.as_ptr() as *const libc::c_char;
*event_name = estr.as_ptr() as *const std::os::raw::c_char;
*event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
};
0
@ -1630,8 +1629,8 @@ pub extern "C" fn rs_nfs_state_get_event_info_by_id(event_id: libc::c_int,
}
}
#[no_mangle]
pub extern "C" fn rs_nfs_state_get_event_info(event_name: *const libc::c_char,
event_id: *mut libc::c_int,
pub extern "C" fn rs_nfs_state_get_event_info(event_name: *const std::os::raw::c_char,
event_id: *mut std::os::raw::c_int,
event_type: *mut AppLayerEventType)
-> i8
{
@ -1650,7 +1649,7 @@ pub extern "C" fn rs_nfs_state_get_event_info(event_name: *const libc::c_char,
};
unsafe{
*event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
*event_id = event as libc::c_int;
*event_id = event as std::os::raw::c_int;
};
0
}

@ -17,8 +17,6 @@
// written by Victor Julien
extern crate libc;
use nom;
use nom::be_u32;

@ -23,7 +23,6 @@ use core;
use core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED};
use applayer;
use parser::*;
use libc;
use std;
use std::ffi::{CStr,CString};
@ -174,7 +173,7 @@ impl Drop for NTPTransaction {
/// Returns *mut NTPState
#[no_mangle]
pub extern "C" fn rs_ntp_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_ntp_state_new() -> *mut std::os::raw::c_void {
let state = NTPState::new();
let boxed = Box::new(state);
return unsafe{std::mem::transmute(boxed)};
@ -183,7 +182,7 @@ pub extern "C" fn rs_ntp_state_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut NTPState as void pointer
#[no_mangle]
pub extern "C" fn rs_ntp_state_free(state: *mut libc::c_void) {
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)};
ntp_state.free();
@ -191,11 +190,11 @@ pub extern "C" fn rs_ntp_state_free(state: *mut libc::c_void) {
#[no_mangle]
pub extern "C" fn rs_ntp_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,NTPState);
@ -204,11 +203,11 @@ pub extern "C" fn rs_ntp_parse_request(_flow: *const core::Flow,
#[no_mangle]
pub extern "C" fn rs_ntp_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,NTPState);
@ -216,9 +215,9 @@ pub extern "C" fn rs_ntp_parse_response(_flow: *const core::Flow,
}
#[no_mangle]
pub extern "C" fn rs_ntp_state_get_tx(state: *mut libc::c_void,
pub extern "C" fn rs_ntp_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,NTPState);
match state.get_tx_by_id(tx_id) {
@ -228,7 +227,7 @@ pub extern "C" fn rs_ntp_state_get_tx(state: *mut libc::c_void,
}
#[no_mangle]
pub extern "C" fn rs_ntp_state_get_tx_count(state: *mut libc::c_void)
pub extern "C" fn rs_ntp_state_get_tx_count(state: *mut std::os::raw::c_void)
-> u64
{
let state = cast_pointer!(state,NTPState);
@ -236,7 +235,7 @@ pub extern "C" fn rs_ntp_state_get_tx_count(state: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_ntp_state_tx_free(state: *mut libc::c_void,
pub extern "C" fn rs_ntp_state_tx_free(state: *mut std::os::raw::c_void,
tx_id: u64)
{
let state = cast_pointer!(state,NTPState);
@ -246,15 +245,15 @@ pub extern "C" fn rs_ntp_state_tx_free(state: *mut libc::c_void,
#[no_mangle]
pub extern "C" fn rs_ntp_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
return 1;
}
#[no_mangle]
pub extern "C" fn rs_ntp_tx_get_alstate_progress(_tx: *mut libc::c_void,
pub extern "C" fn rs_ntp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
1
}
@ -282,8 +281,8 @@ pub extern "C" fn rs_ntp_tx_get_logged(_state: &mut NTPState,
#[no_mangle]
pub extern "C" fn rs_ntp_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,NTPTransaction);
tx.de_state = Some(de_state);
@ -292,7 +291,7 @@ pub extern "C" fn rs_ntp_state_set_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_ntp_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,NTPTransaction);
@ -304,7 +303,7 @@ pub extern "C" fn rs_ntp_state_get_tx_detect_state(
#[no_mangle]
pub extern "C" fn rs_ntp_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_ntp_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut core::AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, NTPTransaction);
@ -312,10 +311,10 @@ pub extern "C" fn rs_ntp_state_get_events(tx: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_ntp_state_get_event_info(event_name: *const libc::c_char,
event_id: *mut libc::c_int,
pub extern "C" fn rs_ntp_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) };
@ -330,7 +329,7 @@ pub extern "C" fn rs_ntp_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
}
@ -369,7 +368,7 @@ const PARSER_NAME : &'static [u8] = b"ntp\0";
pub unsafe extern "C" fn rs_register_ntp_parser() {
let default_port = CString::new("123").unwrap();
let 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 : ntp_probing_parser,

@ -23,7 +23,7 @@ use core::{DetectEngineState,Flow,AppLayerEventType,AppLayerDecoderEvents,AppPro
use filecontainer::FileContainer;
use applayer;
use libc::{c_void,c_char,c_int};
use std::os::raw::{c_void,c_char,c_int};
use applayer::{AppLayerGetTxIterTuple};
/// Rust parser declaration

@ -16,7 +16,6 @@
*/
// written by Victor Julien
extern crate libc;
use log::*;

@ -15,8 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
use std;
use std::ptr;
use core::*;

@ -15,8 +15,6 @@
* 02110-1301, USA.
*/
extern crate libc;
use std::str;
use std::string::String;
use json::*;

@ -24,7 +24,7 @@
*/
// written by Victor Julien
extern crate libc;
use std;
use std::mem::transmute;
use std::str;
@ -1774,7 +1774,7 @@ impl SMBState {
/// Returns *mut SMBState
#[no_mangle]
pub extern "C" fn rs_smb_state_new() -> *mut libc::c_void {
pub extern "C" fn rs_smb_state_new() -> *mut std::os::raw::c_void {
let state = SMBState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
@ -1784,7 +1784,7 @@ pub extern "C" fn rs_smb_state_new() -> *mut libc::c_void {
/// Params:
/// - state: *mut SMBState as void pointer
#[no_mangle]
pub extern "C" fn rs_smb_state_free(state: *mut libc::c_void) {
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)};
@ -1795,10 +1795,10 @@ pub extern "C" fn rs_smb_state_free(state: *mut libc::c_void) {
#[no_mangle]
pub extern "C" fn rs_smb_parse_request_tcp(_flow: *mut Flow,
state: &mut SMBState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void,
_data: *mut std::os::raw::c_void,
flags: u8)
-> i8
{
@ -1833,10 +1833,10 @@ pub extern "C" fn rs_smb_parse_request_tcp_gap(
#[no_mangle]
pub extern "C" fn rs_smb_parse_response_tcp(_flow: *mut Flow,
state: &mut SMBState,
_pstate: *mut libc::c_void,
_pstate: *mut std::os::raw::c_void,
input: *mut u8,
input_len: u32,
_data: *mut libc::c_void,
_data: *mut std::os::raw::c_void,
flags: u8)
-> i8
{
@ -2004,7 +2004,7 @@ pub extern "C" fn rs_smb_state_tx_free(state: &mut SMBState,
#[no_mangle]
pub extern "C" fn rs_smb_state_progress_completion_status(
_direction: u8)
-> libc::c_int
-> std::os::raw::c_int
{
return 1;
}
@ -2104,7 +2104,7 @@ pub extern "C" fn rs_smb_state_truncate(
}
#[no_mangle]
pub extern "C" fn rs_smb_state_get_events(tx: *mut libc::c_void)
pub extern "C" fn rs_smb_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut AppLayerDecoderEvents
{
let tx = cast_pointer!(tx, SMBTransaction);
@ -2112,8 +2112,8 @@ pub extern "C" fn rs_smb_state_get_events(tx: *mut libc::c_void)
}
#[no_mangle]
pub extern "C" fn rs_smb_state_get_event_info(event_name: *const libc::c_char,
event_id: *mut libc::c_int,
pub extern "C" fn rs_smb_state_get_event_info(event_name: *const std::os::raw::c_char,
event_id: *mut std::os::raw::c_int,
event_type: *mut AppLayerEventType)
-> i8
{
@ -2129,7 +2129,7 @@ pub extern "C" fn rs_smb_state_get_event_info(event_name: *const libc::c_char,
};
unsafe {
*event_type = APP_LAYER_EVENT_TYPE_TRANSACTION;
*event_id = event as libc::c_int;
*event_id = event as std::os::raw::c_int;
};
if event == -1 {
return -1;

@ -19,8 +19,6 @@
* - check all parsers for calls on non-SUCCESS status
*/
extern crate libc;
use nom;
use core::*;

@ -17,8 +17,6 @@
// written by Clément Galland <clement.galland@epita.fr>
extern crate libc;
use json::*;
use tftp::tftp::*;

@ -17,7 +17,6 @@
// written by Clément Galland <clement.galland@epita.fr>
extern crate libc;
extern crate nom;
use std::str;
@ -74,14 +73,14 @@ impl TFTPTransaction {
}
#[no_mangle]
pub extern "C" fn rs_tftp_state_alloc() -> *mut libc::c_void {
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)};
}
#[no_mangle]
pub extern "C" fn rs_tftp_state_free(state: *mut libc::c_void) {
pub extern "C" fn rs_tftp_state_free(state: *mut std::os::raw::c_void) {
let _state : Box<TFTPState> = unsafe{transmute(state)};
}
@ -93,7 +92,7 @@ pub extern "C" fn rs_tftp_state_tx_free(state: &mut TFTPState,
#[no_mangle]
pub extern "C" fn rs_tftp_get_tx(state: &mut TFTPState,
tx_id: u64) -> *mut libc::c_void {
tx_id: u64) -> *mut std::os::raw::c_void {
match state.get_tx_by_id(tx_id) {
Some(tx) => unsafe{std::mem::transmute(tx)},
None => std::ptr::null_mut(),

Loading…
Cancel
Save