smb: support AppLayerTxData

pull/5169/head
Victor Julien 5 years ago
parent 7a7805cde6
commit 77a95eddd9

@ -37,7 +37,7 @@ use nom;
use crate::core::*;
use crate::log::*;
use crate::applayer;
use crate::applayer::{LoggerFlags, AppLayerResult};
use crate::applayer::{AppLayerResult, AppLayerTxData};
use crate::smb::nbss_records::*;
use crate::smb::smb1_records::*;
@ -561,12 +561,9 @@ pub struct SMBTransaction {
/// Command specific data
pub type_data: Option<SMBTransactionTypeData>,
/// detection engine flags for use by detection engine
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 SMBTransaction {
@ -578,11 +575,9 @@ impl SMBTransaction {
request_done: false,
response_done: false,
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(),
}
}
@ -2071,45 +2066,12 @@ pub extern "C" fn rs_smb_tx_get_alstate_progress(tx: &mut SMBTransaction,
}
#[no_mangle]
pub extern "C" fn rs_smb_tx_set_logged(_state: &mut SMBState,
tx: &mut SMBTransaction,
bits: u32)
pub extern "C" fn rs_smb_get_tx_data(
tx: *mut std::os::raw::c_void)
-> *mut AppLayerTxData
{
tx.logged.set(bits);
}
#[no_mangle]
pub extern "C" fn rs_smb_tx_get_logged(_state: &mut SMBState,
tx: &mut SMBTransaction)
-> u32
{
return tx.logged.get();
}
#[no_mangle]
pub extern "C" fn rs_smb_tx_set_detect_flags(
tx: &mut SMBTransaction,
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_smb_tx_get_detect_flags(
tx: &mut SMBTransaction,
direction: u8)
-> u64
{
if (direction & STREAM_TOSERVER) != 0 {
return tx.detect_flags_ts as u64;
} else {
return tx.detect_flags_tc as u64;
}
let tx = cast_pointer!(tx, SMBTransaction);
return &mut tx.tx_data;
}
#[no_mangle]

@ -149,16 +149,6 @@ static AppLayerGetTxIterTuple SMBGetTxIterator(
}
static void SMBSetTxLogged(void *alstate, void *tx, uint32_t logger)
{
rs_smb_tx_set_logged(alstate, tx, logger);
}
static LoggerId SMBGetTxLogged(void *alstate, void *tx)
{
return rs_smb_tx_get_logged(alstate, tx);
}
static void SMBStateTransactionFree(void *state, uint64_t tx_id)
{
rs_smb_state_tx_free(state, tx_id);
@ -197,16 +187,6 @@ static int SMBGetEventInfo(const char *event_name, int *event_id,
return rs_smb_state_get_event_info(event_name, event_id, event_type);
}
static void SMBSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
{
rs_smb_tx_set_detect_flags(tx, dir, flags);
}
static uint64_t SMBGetDetectFlags(void *tx, uint8_t dir)
{
return rs_smb_tx_get_detect_flags(tx, dir);
}
static void SMBStateTruncate(void *state, uint8_t direction)
{
return rs_smb_state_truncate(state, direction);
@ -310,18 +290,16 @@ void RegisterSMBParsers(void)
AppLayerParserRegisterGetTxIterator(IPPROTO_TCP, ALPROTO_SMB, SMBGetTxIterator);
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_SMB,
SMBGetTxCnt);
AppLayerParserRegisterLoggerFuncs(IPPROTO_TCP, ALPROTO_SMB,
SMBGetTxLogged, SMBSetTxLogged);
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_SMB,
SMBGetAlstateProgress);
AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_SMB,
rs_smb_state_progress_completion_status);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_SMB,
SMBGetDetectFlags, SMBSetDetectFlags);
AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_SMB,
SMBStateTruncate);
AppLayerParserRegisterGetFilesFunc(IPPROTO_TCP, ALPROTO_SMB, SMBGetFiles);
AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_SMB, rs_smb_get_tx_data);
/* This parser accepts gaps. */
AppLayerParserRegisterOptionFlags(IPPROTO_TCP, ALPROTO_SMB,
APP_LAYER_PARSER_OPT_ACCEPT_GAPS);

Loading…
Cancel
Save