use crate::log::*;
use crate::applayer;
-use crate::applayer::{LoggerFlags, AppLayerResult};
+use crate::applayer::{AppLayerResult, AppLayerTxData};
use crate::core::*;
use crate::filetracker::*;
use crate::filecontainer::*;
/// attempt failed.
pub type_data: Option<NFSTransactionTypeData>,
- detect_flags_ts: u64,
- detect_flags_tc: u64,
-
- pub logged: LoggerFlags,
pub de_state: Option<*mut DetectEngineState>,
pub events: *mut AppLayerDecoderEvents,
+
+ pub tx_data: AppLayerTxData,
}
impl NFSTransaction {
file_tx_direction: 0,
file_handle:Vec::new(),
type_data: None,
- detect_flags_ts: 0,
- detect_flags_tc: 0,
- logged: LoggerFlags::new(),
de_state: None,
events: std::ptr::null_mut(),
+ tx_data: AppLayerTxData::new(),
}
}
}
#[no_mangle]
-pub extern "C" fn rs_nfs_tx_set_logged(_state: &mut NFSState,
- tx: &mut NFSTransaction,
- logged: u32)
-{
- tx.logged.set(logged);
-}
-
-#[no_mangle]
-pub extern "C" fn rs_nfs_tx_get_logged(_state: &mut NFSState,
- tx: &mut NFSTransaction)
- -> u32
+pub extern "C" fn rs_nfs_get_tx_data(
+ tx: *mut std::os::raw::c_void)
+ -> *mut AppLayerTxData
{
- return tx.logged.get();
+ let tx = cast_pointer!(tx, NFSTransaction);
+ return &mut tx.tx_data;
}
#[no_mangle]
}
}
-#[no_mangle]
-pub extern "C" fn rs_nfs_tx_set_detect_flags(
- tx: &mut NFSTransaction,
- direction: u8,
- flags: u64)
-{
- if (direction & STREAM_TOSERVER) != 0 {
- tx.detect_flags_ts = flags as u64;
- } else {
- tx.detect_flags_tc = flags as u64;
- }
-}
-
-#[no_mangle]
-pub extern "C" fn rs_nfs_tx_get_detect_flags(
- tx: &mut NFSTransaction,
- direction: u8)
- -> u64
-{
- if (direction & STREAM_TOSERVER) != 0 {
- return tx.detect_flags_ts as u64;
- } else {
- return tx.detect_flags_tc as u64;
- }
-}
-
#[no_mangle]
pub extern "C" fn rs_nfs_state_get_events(tx: *mut std::os::raw::c_void)
-> *mut AppLayerDecoderEvents
return rs_nfs_state_get_tx_iterator(alstate, min_tx_id, (uint64_t *)istate);
}
-static void NFSTCPSetTxLogged(void *state, void *vtx, LoggerId logged)
-{
- rs_nfs_tx_set_logged(state, vtx, logged);
-}
-
-static LoggerId NFSTCPGetTxLogged(void *state, void *vtx)
-{
- return rs_nfs_tx_get_logged(state, vtx);
-}
-
/**
* \brief Called by the application layer.
*
return rs_nfs_getfiles(direction, state);
}
-static void NFSTCPSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
-{
- rs_nfs_tx_set_detect_flags(tx, dir, flags);
-}
-
-static uint64_t NFSTCPGetDetectFlags(void *tx, uint8_t dir)
-{
- return rs_nfs_tx_get_detect_flags(tx, dir);
-}
-
static StreamingBufferConfig sbcfg = STREAMING_BUFFER_CONFIG_INITIALIZER;
static SuricataFileContext sfc = { &sbcfg };
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_NFS,
NFSTCPStateTxFree);
- AppLayerParserRegisterLoggerFuncs(IPPROTO_TCP, ALPROTO_NFS,
- NFSTCPGetTxLogged, NFSTCPSetTxLogged);
-
/* Register a function to return the current transaction count. */
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_NFS,
NFSTCPGetTxCnt);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_NFS,
NFSTCPGetEvents);
- AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_NFS,
- NFSTCPGetDetectFlags, NFSTCPSetDetectFlags);
+ AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_NFS,
+ rs_nfs_get_tx_data);
/* This parser accepts gaps. */
AppLayerParserRegisterOptionFlags(IPPROTO_TCP, ALPROTO_NFS,
return rs_nfs_state_get_tx_iterator(alstate, min_tx_id, (uint64_t *)istate);
}
-static void NFSSetTxLogged(void *state, void *vtx, LoggerId logged)
-{
- rs_nfs_tx_set_logged(state, vtx, logged);
-}
-
-static LoggerId NFSGetTxLogged(void *state, void *vtx)
-{
- return rs_nfs_tx_get_logged(state, vtx);
-}
-
/**
* \brief Called by the application layer.
*
return rs_nfs_getfiles(direction, state);
}
-static void NFSSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
-{
- rs_nfs_tx_set_detect_flags(tx, dir, flags);
-}
-
-static uint64_t NFSGetDetectFlags(void *tx, uint8_t dir)
-{
- return rs_nfs_tx_get_detect_flags(tx, dir);
-}
-
static StreamingBufferConfig sbcfg = STREAMING_BUFFER_CONFIG_INITIALIZER;
static SuricataFileContext sfc = { &sbcfg };
AppLayerParserRegisterTxFreeFunc(IPPROTO_UDP, ALPROTO_NFS,
NFSStateTxFree);
- AppLayerParserRegisterLoggerFuncs(IPPROTO_UDP, ALPROTO_NFS,
- NFSGetTxLogged, NFSSetTxLogged);
-
/* Register a function to return the current transaction count. */
AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_NFS,
NFSGetTxCnt);
AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_NFS,
NFSGetEvents);
- AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_UDP, ALPROTO_NFS,
- NFSGetDetectFlags, NFSSetDetectFlags);
-
+ AppLayerParserRegisterTxDataFunc(IPPROTO_UDP, ALPROTO_NFS,
+ rs_nfs_get_tx_data);
}
else {
SCLogNotice("NFS protocol parsing disabled.");