nfs: support AppLayerTxData

pull/5169/head
Victor Julien 6 years ago
parent fb3bdd8cf3
commit 7a7805cde6

@ -27,7 +27,7 @@ use nom;
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::*;
@ -179,12 +179,10 @@ pub struct NFSTransaction {
/// 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 {
@ -209,11 +207,9 @@ 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(),
}
}
@ -1572,19 +1568,12 @@ pub extern "C" fn rs_nfs_tx_get_alstate_progress(tx: &mut NFSTransaction,
}
#[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]
@ -1612,32 +1601,6 @@ pub extern "C" fn rs_nfs_state_get_tx_detect_state(
}
}
#[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

@ -208,16 +208,6 @@ static AppLayerGetTxIterTuple RustNFSTCPGetTxIterator(
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.
*
@ -267,16 +257,6 @@ static FileContainer *NFSTCPGetFiles(void *state, uint8_t direction)
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 };
@ -353,9 +333,6 @@ void RegisterNFSTCPParsers(void)
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);
@ -385,8 +362,8 @@ void RegisterNFSTCPParsers(void)
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,

@ -178,16 +178,6 @@ static AppLayerGetTxIterTuple RustNFSGetTxIterator(
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.
*
@ -237,16 +227,6 @@ static FileContainer *NFSGetFiles(void *state, uint8_t direction)
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 };
@ -317,9 +297,6 @@ void RegisterNFSUDPParsers(void)
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);
@ -349,9 +326,8 @@ void RegisterNFSUDPParsers(void)
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.");

Loading…
Cancel
Save