use nfs::nfs2_records::*;
use nfs::nfs3_records::*;
-pub static mut SURICATA_NFS3_FILE_CONFIG: Option<&'static SuricataFileContext> = None;
+pub static mut SURICATA_NFS_FILE_CONFIG: Option<&'static SuricataFileContext> = None;
/*
* Record parsing.
#[derive(Debug)]
pub struct NFSTransaction {
pub id: u64, /// internal id
- pub xid: u32, /// nfs3 req/reply pair id
+ pub xid: u32, /// nfs req/reply pair id
pub procedure: u32,
/// file name of the object we're dealing with. In case of RENAME
/// this is the 'from' or original name.
flags: u16, name: &Vec<u8>, data: &[u8],
chunk_offset: u64, chunk_size: u32, fill_bytes: u8, is_last: bool, xid: &u32)
{
- match unsafe {SURICATA_NFS3_FILE_CONFIG} {
+ match unsafe {SURICATA_NFS_FILE_CONFIG} {
Some(sfcm) => {
ft.new_chunk(sfcm, files, flags, &name, data, chunk_offset,
chunk_size, fill_bytes, is_last, xid); }
let mut cnt = 0;
while cur_i.len() > 0 {
cnt += 1;
- match nfs3_probe(cur_i, STREAM_TOSERVER) {
+ match nfs_probe(cur_i, STREAM_TOSERVER) {
1 => {
SCLogDebug!("expected data found");
self.ts_gap = false;
let mut cnt = 0;
while cur_i.len() > 0 {
cnt += 1;
- match nfs3_probe(cur_i, STREAM_TOCLIENT) {
+ match nfs_probe(cur_i, STREAM_TOCLIENT) {
1 => {
SCLogDebug!("expected data found");
self.tc_gap = false;
/// Returns *mut NFSState
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_new() -> *mut libc::c_void {
+pub extern "C" fn rs_nfs_state_new() -> *mut libc::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_nfs3_state_free(state: *mut libc::c_void) {
+pub extern "C" fn rs_nfs_state_free(state: *mut libc::c_void) {
// Just unbox...
SCLogDebug!("freeing state");
- let mut nfs3_state: Box<NFSState> = unsafe{transmute(state)};
- nfs3_state.free();
+ let mut nfs_state: Box<NFSState> = unsafe{transmute(state)};
+ nfs_state.free();
}
/// C binding parse a NFS TCP request. Returns 1 on success, -1 on failure.
/// C binding parse a DNS request. Returns 1 on success, -1 on failure.
#[no_mangle]
-pub extern "C" fn rs_nfs3_parse_request_udp(_flow: *mut Flow,
+pub extern "C" fn rs_nfs_parse_request_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
input: *mut libc::uint8_t,
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_parse_response_udp(_flow: *mut Flow,
+pub extern "C" fn rs_nfs_parse_response_udp(_flow: *mut Flow,
state: &mut NFSState,
_pstate: *mut libc::c_void,
input: *mut libc::uint8_t,
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_get_tx_count(state: &mut NFSState)
+pub extern "C" fn rs_nfs_state_get_tx_count(state: &mut NFSState)
-> libc::uint64_t
{
- SCLogDebug!("rs_nfs3_state_get_tx_count: returning {}", state.tx_id);
+ SCLogDebug!("rs_nfs_state_get_tx_count: returning {}", state.tx_id);
return state.tx_id;
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_get_tx(state: &mut NFSState,
+pub extern "C" fn rs_nfs_state_get_tx(state: &mut NFSState,
tx_id: libc::uint64_t)
-> *mut NFSTransaction
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_tx_free(state: &mut NFSState,
+pub extern "C" fn rs_nfs_state_tx_free(state: &mut NFSState,
tx_id: libc::uint64_t)
{
state.free_tx(tx_id);
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_progress_completion_status(
+pub extern "C" fn rs_nfs_state_progress_completion_status(
_direction: libc::uint8_t)
-> libc::c_int
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_tx_get_alstate_progress(tx: &mut NFSTransaction,
+pub extern "C" fn rs_nfs_tx_get_alstate_progress(tx: &mut NFSTransaction,
direction: libc::uint8_t)
-> libc::uint8_t
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_tx_set_logged(_state: &mut NFSState,
+pub extern "C" fn rs_nfs_tx_set_logged(_state: &mut NFSState,
tx: &mut NFSTransaction,
logged: libc::uint32_t)
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_tx_get_logged(_state: &mut NFSState,
+pub extern "C" fn rs_nfs_tx_get_logged(_state: &mut NFSState,
tx: &mut NFSTransaction)
-> u32
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_set_tx_detect_state(
+pub extern "C" fn rs_nfs_state_set_tx_detect_state(
tx: &mut NFSTransaction,
de_state: &mut DetectEngineState)
{
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_state_get_tx_detect_state(
+pub extern "C" fn rs_nfs_state_get_tx_detect_state(
tx: &mut NFSTransaction)
-> *mut DetectEngineState
{
/// otherwise get procs from the 'file_additional_procs'.
/// Keep calling until 0 is returned.
#[no_mangle]
-pub extern "C" fn rs_nfs3_tx_get_procedures(tx: &mut NFSTransaction,
- i: libc::uint16_t,
- procedure: *mut libc::uint32_t)
- -> libc::uint8_t
+pub extern "C" fn rs_nfs_tx_get_procedures(tx: &mut NFSTransaction,
+ i: libc::uint16_t,
+ procedure: *mut libc::uint32_t)
+ -> libc::uint8_t
{
if i == 0 {
unsafe {
#[no_mangle]
pub extern "C" fn rs_nfs_tx_get_version(tx: &mut NFSTransaction,
- version: *mut libc::uint32_t)
+ version: *mut libc::uint32_t)
{
unsafe {
*version = tx.nfs_version as libc::uint32_t;
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_init(context: &'static mut SuricataFileContext)
+pub extern "C" fn rs_nfs_init(context: &'static mut SuricataFileContext)
{
unsafe {
- SURICATA_NFS3_FILE_CONFIG = Some(context);
+ SURICATA_NFS_FILE_CONFIG = Some(context);
}
}
-pub fn nfs3_probe(i: &[u8], direction: u8) -> i8 {
+pub fn nfs_probe(i: &[u8], direction: u8) -> i8 {
if direction == STREAM_TOCLIENT {
match parse_rpc_reply(i) {
IResult::Done(_, ref rpc) => {
}
}
-pub fn nfs3_probe_udp(i: &[u8], direction: u8) -> i8 {
+pub fn nfs_probe_udp(i: &[u8], direction: u8) -> i8 {
if direction == STREAM_TOCLIENT {
match parse_rpc_udp_reply(i) {
IResult::Done(_, ref rpc) => {
let slice: &[u8] = unsafe {
std::slice::from_raw_parts(input as *mut u8, len as usize)
};
- return nfs3_probe(slice, STREAM_TOSERVER);
+ return nfs_probe(slice, STREAM_TOSERVER);
}
+
/// TOCLIENT probe function
#[no_mangle]
pub extern "C" fn rs_nfs_probe_tc(input: *const libc::uint8_t, len: libc::uint32_t)
let slice: &[u8] = unsafe {
std::slice::from_raw_parts(input as *mut u8, len as usize)
};
- return nfs3_probe(slice, STREAM_TOCLIENT);
+ return nfs_probe(slice, STREAM_TOCLIENT);
}
/// TOSERVER probe function
let slice: &[u8] = unsafe {
std::slice::from_raw_parts(input as *mut u8, len as usize)
};
- return nfs3_probe_udp(slice, STREAM_TOSERVER);
+ return nfs_probe_udp(slice, STREAM_TOSERVER);
}
+
/// TOCLIENT probe function
#[no_mangle]
pub extern "C" fn rs_nfs_probe_udp_tc(input: *const libc::uint8_t, len: libc::uint32_t)
let slice: &[u8] = unsafe {
std::slice::from_raw_parts(input as *mut u8, len as usize)
};
- return nfs3_probe_udp(slice, STREAM_TOCLIENT);
+ return nfs_probe_udp(slice, STREAM_TOCLIENT);
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_getfiles(direction: u8, ptr: *mut NFSState) -> * mut FileContainer {
+pub extern "C" fn rs_nfs_getfiles(direction: u8, ptr: *mut NFSState) -> * mut FileContainer {
if ptr.is_null() { panic!("NULL ptr"); };
let parser = unsafe { &mut *ptr };
parser.getfiles(direction)
}
#[no_mangle]
-pub extern "C" fn rs_nfs3_setfileflags(direction: u8, ptr: *mut NFSState, flags: u16) {
+pub extern "C" fn rs_nfs_setfileflags(direction: u8, ptr: *mut NFSState, flags: u16) {
if ptr.is_null() { panic!("NULL ptr"); };
let parser = unsafe { &mut *ptr };
SCLogDebug!("direction {} flags {}", direction, flags);
static void *NFSTCPStateAlloc(void)
{
- return rs_nfs3_state_new();
+ return rs_nfs_state_new();
}
static void NFSTCPStateFree(void *state)
{
- rs_nfs3_state_free(state);
+ rs_nfs_state_free(state);
}
/**
*/
static void NFSTCPStateTxFree(void *state, uint64_t tx_id)
{
- rs_nfs3_state_tx_free(state, tx_id);
+ rs_nfs_state_tx_free(state, tx_id);
}
static int NFSTCPStateGetEventInfo(const char *event_name, int *event_id,
void *local_data, const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOSERVER);
- rs_nfs3_setfileflags(0, state, file_flags);
+ rs_nfs_setfileflags(0, state, file_flags);
int res;
if (input == NULL && input_len > 0) {
const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOCLIENT);
- rs_nfs3_setfileflags(1, state, file_flags);
+ rs_nfs_setfileflags(1, state, file_flags);
int res;
if (input == NULL && input_len > 0) {
static uint64_t NFSTCPGetTxCnt(void *state)
{
- return rs_nfs3_state_get_tx_count(state);
+ return rs_nfs_state_get_tx_count(state);
}
static void *NFSTCPGetTx(void *state, uint64_t tx_id)
{
- return rs_nfs3_state_get_tx(state, tx_id);
+ return rs_nfs_state_get_tx(state, tx_id);
}
static AppLayerGetTxIterTuple RustNFSTCPGetTxIterator(
static void NFSTCPSetTxLogged(void *state, void *vtx, LoggerId logged)
{
- rs_nfs3_tx_set_logged(state, vtx, logged);
+ rs_nfs_tx_set_logged(state, vtx, logged);
}
static LoggerId NFSTCPGetTxLogged(void *state, void *vtx)
{
- return rs_nfs3_tx_get_logged(state, vtx);
+ return rs_nfs_tx_get_logged(state, vtx);
}
/**
* In most cases 1 can be returned here.
*/
static int NFSTCPGetAlstateProgressCompletionStatus(uint8_t direction) {
- return rs_nfs3_state_progress_completion_status(direction);
+ return rs_nfs_state_progress_completion_status(direction);
}
/**
*/
static int NFSTCPGetStateProgress(void *tx, uint8_t direction)
{
- return rs_nfs3_tx_get_alstate_progress(tx, direction);
+ return rs_nfs_tx_get_alstate_progress(tx, direction);
}
/**
*/
static DetectEngineState *NFSTCPGetTxDetectState(void *vtx)
{
- return rs_nfs3_state_get_tx_detect_state(vtx);
+ return rs_nfs_state_get_tx_detect_state(vtx);
}
/**
*/
static int NFSTCPSetTxDetectState(void *vtx, DetectEngineState *s)
{
- rs_nfs3_state_set_tx_detect_state(vtx, s);
+ rs_nfs_state_set_tx_detect_state(vtx, s);
return 0;
}
static FileContainer *NFSTCPGetFiles(void *state, uint8_t direction)
{
- return rs_nfs3_getfiles(direction, state);
+ return rs_nfs_getfiles(direction, state);
}
static void NFSTCPSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
* the configuration file then it will be enabled by default. */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
- rs_nfs3_init(&sfc);
+ rs_nfs_init(&sfc);
SCLogDebug("NFSTCP TCP protocol detection enabled.");
*
* Example rule:
*
- * alert nfs3 any any -> any any (msg:"SURICATA NFS empty message"; \
+ * alert nfs any any -> any any (msg:"SURICATA NFS empty message"; \
* app-layer-event:nfs.empty_message; sid:X; rev:Y;)
*/
enum {
static void *NFSStateAlloc(void)
{
- return rs_nfs3_state_new();
+ return rs_nfs_state_new();
}
static void NFSStateFree(void *state)
{
- rs_nfs3_state_free(state);
+ rs_nfs_state_free(state);
}
/**
*/
static void NFSStateTxFree(void *state, uint64_t tx_id)
{
- rs_nfs3_state_tx_free(state, tx_id);
+ rs_nfs_state_tx_free(state, tx_id);
}
static int NFSStateGetEventInfo(const char *event_name, int *event_id,
void *local_data, const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOSERVER);
- rs_nfs3_setfileflags(0, state, file_flags);
+ rs_nfs_setfileflags(0, state, file_flags);
- return rs_nfs3_parse_request_udp(f, state, pstate, input, input_len, local_data);
+ return rs_nfs_parse_request_udp(f, state, pstate, input, input_len, local_data);
}
static int NFSParseResponse(Flow *f, void *state, AppLayerParserState *pstate,
const uint8_t flags)
{
uint16_t file_flags = FileFlowToFlags(f, STREAM_TOCLIENT);
- rs_nfs3_setfileflags(1, state, file_flags);
+ rs_nfs_setfileflags(1, state, file_flags);
- return rs_nfs3_parse_response_udp(f, state, pstate, input, input_len, local_data);
+ return rs_nfs_parse_response_udp(f, state, pstate, input, input_len, local_data);
}
static uint64_t NFSGetTxCnt(void *state)
{
- return rs_nfs3_state_get_tx_count(state);
+ return rs_nfs_state_get_tx_count(state);
}
static void *NFSGetTx(void *state, uint64_t tx_id)
{
- return rs_nfs3_state_get_tx(state, tx_id);
+ return rs_nfs_state_get_tx(state, tx_id);
}
static AppLayerGetTxIterTuple RustNFSGetTxIterator(
static void NFSSetTxLogged(void *state, void *vtx, LoggerId logged)
{
- rs_nfs3_tx_set_logged(state, vtx, logged);
+ rs_nfs_tx_set_logged(state, vtx, logged);
}
static LoggerId NFSGetTxLogged(void *state, void *vtx)
{
- return rs_nfs3_tx_get_logged(state, vtx);
+ return rs_nfs_tx_get_logged(state, vtx);
}
/**
* In most cases 1 can be returned here.
*/
static int NFSGetAlstateProgressCompletionStatus(uint8_t direction) {
- return rs_nfs3_state_progress_completion_status(direction);
+ return rs_nfs_state_progress_completion_status(direction);
}
/**
*/
static int NFSGetStateProgress(void *tx, uint8_t direction)
{
- return rs_nfs3_tx_get_alstate_progress(tx, direction);
+ return rs_nfs_tx_get_alstate_progress(tx, direction);
}
/**
*/
static DetectEngineState *NFSGetTxDetectState(void *vtx)
{
- return rs_nfs3_state_get_tx_detect_state(vtx);
+ return rs_nfs_state_get_tx_detect_state(vtx);
}
/**
*/
static int NFSSetTxDetectState(void *vtx, DetectEngineState *s)
{
- rs_nfs3_state_set_tx_detect_state(vtx, s);
+ rs_nfs_state_set_tx_detect_state(vtx, s);
return 0;
}
static FileContainer *NFSGetFiles(void *state, uint8_t direction)
{
- return rs_nfs3_getfiles(direction, state);
+ return rs_nfs_getfiles(direction, state);
}
static void NFSSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
* the configuration file then it will be enabled by default. */
if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) {
- rs_nfs3_init(&sfc);
+ rs_nfs_init(&sfc);
SCLogDebug("NFS UDP protocol detection enabled.");
uint16_t i;
for (i = 0; i < 256; i++) {
uint32_t procedure;
- if (rs_nfs3_tx_get_procedures(txv, i, &procedure) == 1) {
+ if (rs_nfs_tx_get_procedures(txv, i, &procedure) == 1) {
SCLogDebug("proc %u mode %u lo %u hi %u",
procedure, dd->mode, dd->lo, dd->hi);
if (ProcedureMatch(procedure, dd->mode, dd->lo, dd->hi))