-/* Copyright (C) 2017-2019 Open Information Security Foundation
+/* Copyright (C) 2017-2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
use std;
use std::mem::transmute;
-use crate::applayer::LoggerFlags;
+use crate::applayer::AppLayerTxData;
#[derive(Debug)]
pub struct TFTPTransaction {
pub opcode : u8,
pub filename : String,
pub mode : String,
- pub logged : LoggerFlags,
id: u64,
+ tx_data: AppLayerTxData,
}
pub struct TFTPState {
opcode : opcode,
filename : filename,
mode : mode.to_lowercase(),
- logged : LoggerFlags::new(),
id : 0,
+ tx_data: AppLayerTxData::new(),
}
}
pub fn is_mode_ok(&self) -> bool {
}
}
-#[no_mangle]
-pub extern "C" fn rs_tftp_get_tx_logged(_state: &mut TFTPState,
- tx: &mut TFTPTransaction)
- -> u32 {
- return tx.logged.get();
-}
-
-#[no_mangle]
-pub extern "C" fn rs_tftp_set_tx_logged(_state: &mut TFTPState,
- tx: &mut TFTPTransaction,
- logged: u32) {
- tx.logged.set(logged);
-}
-
#[no_mangle]
pub extern "C" fn rs_tftp_get_tx_cnt(state: &mut TFTPState) -> u64 {
return state.tx_id as u64;
_ => 0
}
}
+
+#[no_mangle]
+pub extern "C" fn rs_tftp_get_tx_data(
+ tx: *mut std::os::raw::c_void)
+ -> *mut AppLayerTxData
+{
+ let tx = cast_pointer!(tx, TFTPTransaction);
+ return &mut tx.tx_data;
+}
-/* Copyright (C) 2017 Open Information Security Foundation
+/* Copyright (C) 2017-2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
return rs_tftp_get_tx(state, tx_id);
}
-static void TFTPSetTxLogged(void *state, void *vtx, uint32_t logger)
-{
- rs_tftp_set_tx_logged(state, vtx, logger);
-}
-
-static LoggerId TFTPGetTxLogged(void *state, void *vtx)
-{
- return rs_tftp_get_tx_logged(state, vtx);
-}
-
/**
* \brief Called by the application layer.
*
AppLayerParserRegisterTxFreeFunc(IPPROTO_UDP, ALPROTO_TFTP,
TFTPStateTxFree);
- AppLayerParserRegisterLoggerFuncs(IPPROTO_UDP, ALPROTO_TFTP,
- TFTPGetTxLogged, TFTPSetTxLogged);
-
/* Register a function to return the current transaction count. */
AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_TFTP,
TFTPGetTxCnt);
TFTPStateGetEventInfo);
AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_TFTP,
TFTPGetEvents);
+
+ AppLayerParserRegisterTxDataFunc(IPPROTO_UDP, ALPROTO_TFTP,
+ rs_tftp_get_tx_data);
}
else {
SCLogDebug("TFTP protocol parsing disabled.");