]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
app-layer: add logger flags to AppLayerTxData
authorVictor Julien <victor@inliniac.net>
Tue, 26 May 2020 10:39:44 +0000 (12:39 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 11 Jul 2020 06:37:40 +0000 (08:37 +0200)
rust/src/applayer.rs
src/output-tx.c

index 3514b5ef006d288896c5337adf3593704f139036..7e4d3732b5e7b46f88140fd3db455b9343d31919 100644 (file)
@@ -54,12 +54,16 @@ impl AppLayerTxConfig {
 pub struct AppLayerTxData {
     /// config: log flags
     pub config: AppLayerTxConfig,
+
+    /// logger flags for tx logging api
+    logged: LoggerFlags,
 }
 
 impl AppLayerTxData {
     pub fn new() -> Self {
         Self {
             config: AppLayerTxConfig::new(),
+            logged: LoggerFlags::new(),
         }
     }
 }
@@ -339,7 +343,8 @@ impl AppLayerGetTxIterTuple {
 }
 
 /// LoggerFlags tracks which loggers have already been executed.
-#[derive(Debug)]
+#[repr(C)]
+#[derive(Debug,PartialEq)]
 pub struct LoggerFlags {
     flags: u32,
 }
index b091b751e8e2988bc527a36162a8d9453af3c383..99ad08b9152a81a61bd6ce8a493fa86233c3075e 100644 (file)
@@ -207,6 +207,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
             break;
         void * const tx = ires.tx_ptr;
         tx_id = ires.tx_id;
+        AppLayerTxData *txd = AppLayerParserGetTxData(ipproto, alproto, tx);
 
         if (list[ALPROTO_UNKNOWN] != 0) {
             OutputTxLogList0(tv, op_thread_data, p, f, tx, tx_id);
@@ -214,7 +215,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
                 goto next_tx;
         }
 
-        LoggerId tx_logged = AppLayerParserGetTxLogged(f, alstate, tx);
+        LoggerId tx_logged = txd ? txd->logged.flags : AppLayerParserGetTxLogged(f, alstate, tx);
         const LoggerId tx_logged_old = tx_logged;
         SCLogDebug("logger: expect %08x, have %08x", logger_expectation, tx_logged);
         if (tx_logged == logger_expectation) {
@@ -286,8 +287,12 @@ next_logger:
         if (tx_logged != tx_logged_old) {
             SCLogDebug("logger: storing %08x (was %08x)",
                 tx_logged, tx_logged_old);
-            AppLayerParserSetTxLogged(p->proto, alproto, alstate, tx,
-                    tx_logged);
+            if (txd != NULL) {
+                txd->logged.flags |= tx_logged;
+            } else {
+                AppLayerParserSetTxLogged(p->proto, alproto, alstate, tx,
+                        tx_logged);
+            }
         }
 
         /* If all loggers logged set a flag and update the last tx_id