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::*;
/// 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 {
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(),
}
}
}
#[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]
}
-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);
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);
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);