}
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_gettxfiles(tx: *mut std::ffi::c_void, direction: u8) -> AppLayerGetFileState {
+unsafe extern "C" fn nfs_gettxfiles(tx: *mut std::ffi::c_void, direction: u8) -> AppLayerGetFileState {
let tx = cast_pointer!(tx, NFSTransaction);
if let Some(NFSTransactionTypeData::FILE(ref mut tdf)) = tx.type_data {
let tx_dir : u8 = tdf.direction.into();
}
/// Returns *mut NFSState
-#[no_mangle]
-pub extern "C" fn rs_nfs_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
+extern "C" fn nfs_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
let state = NFSState::new();
let boxed = Box::new(state);
SCLogDebug!("allocating state");
/// Params:
/// - state: *mut NFSState as void pointer
-#[no_mangle]
-pub extern "C" fn rs_nfs_state_free(state: *mut std::os::raw::c_void) {
+extern "C" fn nfs_state_free(state: *mut std::os::raw::c_void) {
// Just unbox...
SCLogDebug!("freeing 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.
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_parse_request(flow: *const Flow,
+unsafe extern "C" fn nfs_parse_request(flow: *const Flow,
state: *mut std::os::raw::c_void,
_pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice,
let flow = cast_pointer!(flow, Flow);
if stream_slice.is_gap() {
- return rs_nfs_parse_request_tcp_gap(state, stream_slice.gap_size());
+ return nfs_parse_request_tcp_gap(state, stream_slice.gap_size());
}
SCLogDebug!("parsing {} bytes of request data", stream_slice.len());
state.parse_tcp_data_ts(flow, &stream_slice)
}
-#[no_mangle]
-pub extern "C" fn rs_nfs_parse_request_tcp_gap(
+extern "C" fn nfs_parse_request_tcp_gap(
state: &mut NFSState,
input_len: u32)
-> AppLayerResult
state.parse_tcp_data_ts_gap(input_len)
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_parse_response(flow: *const Flow,
+unsafe extern "C" fn nfs_parse_response(flow: *const Flow,
state: *mut std::os::raw::c_void,
_pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice,
let flow = cast_pointer!(flow, Flow);
if stream_slice.is_gap() {
- return rs_nfs_parse_response_tcp_gap(state, stream_slice.gap_size());
+ return nfs_parse_response_tcp_gap(state, stream_slice.gap_size());
}
SCLogDebug!("parsing {} bytes of response data", stream_slice.len());
state.parse_tcp_data_tc(flow, &stream_slice)
}
-#[no_mangle]
-pub extern "C" fn rs_nfs_parse_response_tcp_gap(
+extern "C" fn nfs_parse_response_tcp_gap(
state: &mut NFSState,
input_len: u32)
-> AppLayerResult
}
/// C binding to parse an NFS/UDP request. Returns 1 on success, -1 on failure.
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_parse_request_udp(f: *const Flow,
+unsafe extern "C" fn nfs_parse_request_udp(f: *const Flow,
state: *mut std::os::raw::c_void,
_pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice,
state.parse_udp_ts(f, &stream_slice)
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_parse_response_udp(f: *const Flow,
+unsafe extern "C" fn nfs_parse_response_udp(f: *const Flow,
state: *mut std::os::raw::c_void,
_pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice,
state.parse_udp_tc(f, &stream_slice)
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_state_get_tx_count(state: *mut std::os::raw::c_void)
+pub unsafe extern "C" fn nfs_state_get_tx_count(state: *mut std::os::raw::c_void)
-> u64
{
let state = cast_pointer!(state, NFSState);
- SCLogDebug!("rs_nfs_state_get_tx_count: returning {}", state.tx_id);
+ SCLogDebug!("nfs_state_get_tx_count: returning {}", state.tx_id);
return state.tx_id;
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_state_get_tx(state: *mut std::os::raw::c_void,
+unsafe extern "C" fn nfs_state_get_tx(state: *mut std::os::raw::c_void,
tx_id: u64)
-> *mut std::os::raw::c_void
{
}
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_state_tx_free(state: *mut std::os::raw::c_void,
+unsafe extern "C" fn nfs_state_tx_free(state: *mut std::os::raw::c_void,
tx_id: u64)
{
let state = cast_pointer!(state, NFSState);
state.free_tx(tx_id);
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_tx_get_alstate_progress(tx: *mut std::os::raw::c_void,
+unsafe extern "C" fn nfs_tx_get_alstate_progress(tx: *mut std::os::raw::c_void,
direction: u8)
-> std::os::raw::c_int
{
}
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_get_tx_data(
+unsafe extern "C" fn nfs_get_tx_data(
tx: *mut std::os::raw::c_void)
-> *mut AppLayerTxData
{
return &mut tx.tx_data;
}
-export_state_data_get!(rs_nfs_get_state_data, NFSState);
+export_state_data_get!(nfs_get_state_data, NFSState);
/// return procedure(s) in the tx. At 0 return the main proc,
/// otherwise get procs from the 'file_additional_procs'.
/// Keep calling until 0 is returned.
#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_tx_get_procedures(tx: &mut NFSTransaction,
+pub unsafe extern "C" fn SCNfsTxGetProcedures(tx: &mut NFSTransaction,
i: u16,
procedure: *mut u32)
-> u8
}
#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_tx_get_version(tx: &mut NFSTransaction,
+pub unsafe extern "C" fn SCNfsTxGetVersion(tx: &mut NFSTransaction,
version: *mut u32)
{
*version = tx.nfs_version as u32;
}
#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_init(context: &'static mut SuricataFileContext)
+pub unsafe extern "C" fn SCNfsInit(context: &'static mut SuricataFileContext)
{
SURICATA_NFS_FILE_CONFIG = Some(context);
}
}
/// MIDSTREAM
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_probe_ms(
+unsafe extern "C" fn nfs_probe_ms(
_flow: *const Flow,
direction: u8, input: *const u8,
len: u32, rdir: *mut u8) -> AppProto
return ALPROTO_UNKNOWN;
}
let slice: &[u8] = build_slice!(input, len as usize);
- SCLogDebug!("rs_nfs_probe_ms: probing direction {:02x}", direction);
+ SCLogDebug!("nfs_probe_ms: probing direction {:02x}", direction);
let mut adirection : u8 = 0;
match nfs_probe_dir(slice, &mut adirection) {
1 => {
}
}
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_probe(_f: *const Flow,
+unsafe extern "C" fn ffi_nfs_probe(_f: *const Flow,
direction: u8,
input: *const u8,
len: u32,
return ALPROTO_UNKNOWN;
}
let slice: &[u8] = build_slice!(input, len as usize);
- SCLogDebug!("rs_nfs_probe: running probe");
+ SCLogDebug!("ffi_nfs_probe: running probe");
match nfs_probe(slice, direction.into()) {
1 => { ALPROTO_NFS },
-1 => { ALPROTO_FAILED },
}
/// TOSERVER probe function
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_probe_udp_ts(_f: *const Flow,
+unsafe extern "C" fn nfs_probe_udp_ts(_f: *const Flow,
_direction: u8,
input: *const u8,
len: u32,
}
/// TOCLIENT probe function
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_probe_udp_tc(_f: *const Flow,
+unsafe extern "C" fn nfs_probe_udp_tc(_f: *const Flow,
_direction: u8,
input: *const u8,
len: u32,
const PARSER_NAME: &[u8] = b"nfs\0";
#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_register_parser() {
+pub unsafe extern "C" fn SCRegisterNfsParser() {
let default_port = CString::new("[2049]").unwrap();
let parser = RustParser {
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
probe_tc: None,
min_depth: 0,
max_depth: 16,
- state_new: rs_nfs_state_new,
- state_free: rs_nfs_state_free,
- tx_free: rs_nfs_state_tx_free,
- parse_ts: rs_nfs_parse_request,
- parse_tc: rs_nfs_parse_response,
- get_tx_count: rs_nfs_state_get_tx_count,
- get_tx: rs_nfs_state_get_tx,
+ state_new: nfs_state_new,
+ state_free: nfs_state_free,
+ tx_free: nfs_state_tx_free,
+ parse_ts: nfs_parse_request,
+ parse_tc: nfs_parse_response,
+ get_tx_count: nfs_state_get_tx_count,
+ get_tx: nfs_state_get_tx,
tx_comp_st_ts: 1,
tx_comp_st_tc: 1,
- tx_get_progress: rs_nfs_tx_get_alstate_progress,
+ tx_get_progress: nfs_tx_get_alstate_progress,
get_eventinfo: Some(NFSEvent::get_event_info),
get_eventinfo_byid : Some(NFSEvent::get_event_info_by_id),
localstorage_new: None,
localstorage_free: None,
- get_tx_files: Some(rs_nfs_gettxfiles),
+ get_tx_files: Some(nfs_gettxfiles),
get_tx_iterator: Some(applayer::state_get_tx_iterator::<NFSState, NFSTransaction>),
- get_tx_data: rs_nfs_get_tx_data,
- get_state_data: rs_nfs_get_state_data,
+ get_tx_data: nfs_get_tx_data,
+ get_state_data: nfs_get_state_data,
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
get_frame_id_by_name: Some(NFSFrameType::ffi_id_from_name),
if midstream {
if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_TCP,
parser.name, ALPROTO_NFS, 0, NFS_MIN_FRAME_LEN,
- rs_nfs_probe_ms, rs_nfs_probe_ms) == 0 {
+ nfs_probe_ms, nfs_probe_ms) == 0 {
SCLogDebug!("No NFSTCP app-layer configuration, enabling NFSTCP detection TCP detection on port {:?}.",
default_port);
/* register 'midstream' probing parsers if midstream is enabled. */
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
default_port.as_ptr(), ALPROTO_NFS, 0,
NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
- rs_nfs_probe_ms, rs_nfs_probe_ms);
+ nfs_probe_ms, nfs_probe_ms);
}
} else {
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
default_port.as_ptr(), ALPROTO_NFS, 0,
NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
- rs_nfs_probe, rs_nfs_probe);
+ ffi_nfs_probe, ffi_nfs_probe);
}
if AppLayerParserConfParserEnabled(
ip_proto_str.as_ptr(),
}
#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_udp_register_parser() {
+pub unsafe extern "C" fn SCRegisterNfsUdpParser() {
let default_port = CString::new("[2049]").unwrap();
let parser = RustParser {
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
probe_tc: None,
min_depth: 0,
max_depth: 16,
- state_new: rs_nfs_state_new,
- state_free: rs_nfs_state_free,
- tx_free: rs_nfs_state_tx_free,
- parse_ts: rs_nfs_parse_request_udp,
- parse_tc: rs_nfs_parse_response_udp,
- get_tx_count: rs_nfs_state_get_tx_count,
- get_tx: rs_nfs_state_get_tx,
+ state_new: nfs_state_new,
+ state_free: nfs_state_free,
+ tx_free: nfs_state_tx_free,
+ parse_ts: nfs_parse_request_udp,
+ parse_tc: nfs_parse_response_udp,
+ get_tx_count: nfs_state_get_tx_count,
+ get_tx: nfs_state_get_tx,
tx_comp_st_ts: 1,
tx_comp_st_tc: 1,
- tx_get_progress: rs_nfs_tx_get_alstate_progress,
+ tx_get_progress: nfs_tx_get_alstate_progress,
get_eventinfo: Some(NFSEvent::get_event_info),
get_eventinfo_byid : Some(NFSEvent::get_event_info_by_id),
localstorage_new: None,
localstorage_free: None,
- get_tx_files: Some(rs_nfs_gettxfiles),
+ get_tx_files: Some(nfs_gettxfiles),
get_tx_iterator: Some(applayer::state_get_tx_iterator::<NFSState, NFSTransaction>),
- get_tx_data: rs_nfs_get_tx_data,
- get_state_data: rs_nfs_get_state_data,
+ get_tx_data: nfs_get_tx_data,
+ get_state_data: nfs_get_state_data,
apply_tx_config: None,
flags: 0,
get_frame_id_by_name: Some(NFSFrameType::ffi_id_from_name),
if AppLayerProtoDetectPPParseConfPorts(ip_proto_str.as_ptr(), IPPROTO_UDP,
parser.name, ALPROTO_NFS, 0, NFS_MIN_FRAME_LEN,
- rs_nfs_probe_udp_ts, rs_nfs_probe_udp_tc) == 0 {
+ nfs_probe_udp_ts, nfs_probe_udp_tc) == 0 {
SCLogDebug!("No NFSUDP app-layer configuration, enabling NFSUDP detection UDP detection on port {:?}.",
default_port);
AppLayerProtoDetectPPRegister(IPPROTO_UDP,
default_port.as_ptr(), ALPROTO_NFS, 0,
NFS_MIN_FRAME_LEN, Direction::ToServer.into(),
- rs_nfs_probe_udp_ts, rs_nfs_probe_udp_tc);
+ nfs_probe_udp_ts, nfs_probe_udp_tc);
}
if AppLayerParserConfParserEnabled(
ip_proto_str.as_ptr(),