rust: remove wrapper LoggerFlags struct definition

just use an u32 out of the box.
Will make bindgen like easier
pull/14639/head
Philippe Antoine 7 months ago committed by Victor Julien
parent f663be5983
commit 4e64de3b3b

@ -124,7 +124,7 @@ pub struct AppLayerTxData {
flags: u8,
/// logger flags for tx logging api
logged: LoggerFlags,
logged: u32,
/// track file open/logs so we can know how long to keep the tx
pub files_opened: u32,
@ -203,7 +203,7 @@ impl AppLayerTxData {
pub fn new() -> Self {
Self {
config: AppLayerTxConfig::new(),
logged: LoggerFlags::new(),
logged: 0,
files_opened: 0,
files_logged: 0,
files_stored: 0,
@ -230,7 +230,7 @@ impl AppLayerTxData {
};
Self {
config: AppLayerTxConfig::new(),
logged: LoggerFlags::new(),
logged: 0,
files_opened: 0,
files_logged: 0,
files_stored: 0,
@ -589,29 +589,6 @@ impl AppLayerGetTxIterTuple {
}
}
/// LoggerFlags tracks which loggers have already been executed.
#[repr(C)]
#[derive(Default, Debug,PartialEq, Eq)]
pub struct LoggerFlags {
flags: u32,
}
impl LoggerFlags {
pub fn new() -> Self {
Default::default()
}
pub fn get(&self) -> u32 {
self.flags
}
pub fn set(&mut self, bits: u32) {
self.flags = bits;
}
}
/// AppLayerEvent trait that will be implemented on enums that
/// derive AppLayerEvent.
pub trait AppLayerEvent {

@ -741,7 +741,7 @@ inline uint8_t AppLayerParserGetTxDetectProgress(AppLayerTxData *txd, const uint
static inline uint32_t GetTxLogged(AppLayerTxData *txd)
{
return txd->logged.flags;
return txd->logged;
}
void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate,

@ -224,12 +224,12 @@ static inline void OutputTxLogFiles(ThreadVars *tv, OutputFileLoggerThreadData *
if (!is_file_tx || tx_done) {
SCLogDebug("is_file_tx %d tx_done %d", is_file_tx, tx_done);
if (file_td) {
txd->logged.flags |= BIT_U32(LOGGER_FILE);
SCLogDebug("setting LOGGER_FILE => %08x", txd->logged.flags);
txd->logged |= BIT_U32(LOGGER_FILE);
SCLogDebug("setting LOGGER_FILE => %08x", txd->logged);
}
if (filedata_td) {
txd->logged.flags |= BIT_U32(LOGGER_FILEDATA);
SCLogDebug("setting LOGGER_FILEDATA => %08x", txd->logged.flags);
txd->logged |= BIT_U32(LOGGER_FILEDATA);
SCLogDebug("setting LOGGER_FILEDATA => %08x", txd->logged);
}
} else {
SCLogDebug("pcap_cnt %" PRIu64 " flow %p tx %p tx_id %" PRIu64
@ -452,16 +452,16 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
}
} else if (support_files) {
if (op_thread_data->file) {
txd->logged.flags |= BIT_U32(LOGGER_FILE);
SCLogDebug("not a file_tx: setting LOGGER_FILE => %08x", txd->logged.flags);
txd->logged |= BIT_U32(LOGGER_FILE);
SCLogDebug("not a file_tx: setting LOGGER_FILE => %08x", txd->logged);
}
if (op_thread_data->filedata) {
txd->logged.flags |= BIT_U32(LOGGER_FILEDATA);
SCLogDebug("not a file_tx: setting LOGGER_FILEDATA => %08x", txd->logged.flags);
txd->logged |= BIT_U32(LOGGER_FILEDATA);
SCLogDebug("not a file_tx: setting LOGGER_FILEDATA => %08x", txd->logged);
}
}
}
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, txd->logged.flags);
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, txd->logged);
if (!txd->updated_tc && !txd->updated_ts && !(tx_progress_ts == complete_ts) &&
!(tx_progress_tc == complete_tc) && !ts_eof && !tc_eof) {
gap = true;
@ -479,20 +479,20 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
if (txd->config.log_flags & BIT_U8(CONFIG_TYPE_TX)) {
SCLogDebug("SKIP tx %p/%"PRIu64, tx, tx_id);
// so that AppLayerParserTransactionsCleanup can clean this tx
txd->logged.flags |= logger_expectation;
txd->logged |= logger_expectation;
goto next_tx;
}
if (txd->logged.flags == logger_expectation) {
if (txd->logged == logger_expectation) {
SCLogDebug("fully logged");
/* tx already fully logged */
goto next_tx;
}
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, txd->logged.flags);
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, txd->logged);
const OutputTxLogger *logger = list[alproto];
const OutputLoggerThreadStore *store = op_thread_data->store[alproto];
struct Ctx ctx = { .tx_logged = txd->logged.flags, .tx_logged_old = txd->logged.flags };
struct Ctx ctx = { .tx_logged = txd->logged, .tx_logged_old = txd->logged };
SCLogDebug("logger: expect %08x, have %08x", logger_expectation, ctx.tx_logged);
OutputTxLogCallLoggers(tv, op_thread_data, logger, store, p, f, alstate, tx, tx_id, alproto,
@ -502,7 +502,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
if (ctx.tx_logged != ctx.tx_logged_old) {
SCLogDebug("logger: storing %08x (was %08x)", ctx.tx_logged, ctx.tx_logged_old);
DEBUG_VALIDATE_BUG_ON(txd == NULL);
txd->logged.flags |= ctx.tx_logged;
txd->logged |= ctx.tx_logged;
}
/* If all loggers logged set a flag and update the last tx_id

Loading…
Cancel
Save