]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: remove DetectFlags API. Replaced by AppLayerTxData
authorVictor Julien <victor@inliniac.net>
Sun, 7 Jun 2020 14:45:40 +0000 (16:45 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 11 Jul 2020 06:37:40 +0000 (08:37 +0200)
rust/src/applayer.rs
src/app-layer-parser.c
src/app-layer-parser.h
src/app-layer-register.c
src/detect.c

index da7c78971daff159ca2e87e255dc5e12a72e91f3..f4ad113dcc7c9422a98bf0ad30c3bd7a2e0a0eac 100644 (file)
@@ -18,7 +18,6 @@
 //! Parser registration functions and common interface
 
 use std;
-use crate::core::{STREAM_TOSERVER};
 use crate::core::{DetectEngineState,Flow,AppLayerEventType,AppLayerDecoderEvents,AppProto};
 use crate::filecontainer::FileContainer;
 use crate::applayer;
@@ -408,49 +407,3 @@ macro_rules!export_tx_set_detect_state {
         }
     )
 }
-
-#[derive(Debug,Default)]
-pub struct TxDetectFlags {
-    ts: u64,
-    tc: u64,
-}
-
-impl TxDetectFlags {
-    pub fn set(&mut self, direction: u8, flags: u64) {
-        if direction & STREAM_TOSERVER != 0 {
-            self.ts = flags;
-        } else {
-            self.tc = flags;
-        }
-    }
-
-    pub fn get(&self, direction: u8) -> u64 {
-        if (direction & STREAM_TOSERVER) != 0 {
-            self.ts
-        } else {
-            self.tc
-        }
-    }
-}
-
-#[macro_export]
-macro_rules!export_tx_detect_flags_set {
-    ($name:ident, $type:ty) => {
-        #[no_mangle]
-        pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void, direction: u8, flags: u64) {
-            let tx = &mut *(tx as *mut $type);
-            tx.detect_flags.set(direction, flags);
-        }
-    }
-}
-
-#[macro_export]
-macro_rules!export_tx_detect_flags_get {
-    ($name:ident, $type:ty) => {
-        #[no_mangle]
-        pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void, direction: u8) -> u64 {
-            let tx = &mut *(tx as *mut $type);
-            return tx.detect_flags.get(direction);
-        }
-    }
-}
index c312d9b30cc6a262a2f666998b74da0d3ba9e08c..bb3c3872fd913322f65efdc05d721631f358e059 100644 (file)
@@ -120,8 +120,6 @@ typedef struct AppLayerParserProtoCtx_
     DetectEngineState *(*GetTxDetectState)(void *tx);
     int (*SetTxDetectState)(void *tx, DetectEngineState *);
 
-    uint64_t (*GetTxDetectFlags)(void *tx, uint8_t dir);
-    void (*SetTxDetectFlags)(void *tx, uint8_t dir, uint64_t);
     AppLayerTxData *(*GetTxData)(void *tx);
     bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
 
@@ -566,18 +564,6 @@ void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
     SCReturn;
 }
 
-void AppLayerParserRegisterDetectFlagsFuncs(uint8_t ipproto, AppProto alproto,
-        uint64_t(*GetTxDetectFlags)(void *tx, uint8_t dir),
-        void (*SetTxDetectFlags)(void *tx, uint8_t dir, uint64_t))
-{
-    SCEnter();
-
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectFlags = GetTxDetectFlags;
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectFlags = SetTxDetectFlags;
-
-    SCReturn;
-}
-
 void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto,
         AppLayerTxData *(*GetTxData)(void *tx))
 {
@@ -717,7 +703,7 @@ static inline uint64_t GetTxDetectFlags(const uint8_t ipproto, const AppProto al
     if (txd != NULL) {
         detect_flags = (dir & STREAM_TOSERVER) ? txd->detect_flags_ts : txd->detect_flags_tc;
     } else {
-        detect_flags = AppLayerParserGetTxDetectFlags(ipproto, alproto, tx, dir);
+        detect_flags = 0;
     }
     return detect_flags;
 }
@@ -731,8 +717,6 @@ static inline void SetTxDetectFlags(const uint8_t ipproto, const AppProto alprot
         } else {
             txd->detect_flags_tc = detect_flags;
         }
-    } else {
-        AppLayerParserSetTxDetectFlags(ipproto, alproto, tx, dir, detect_flags);
     }
 }
 
@@ -895,7 +879,7 @@ void AppLayerParserTransactionsCleanup(Flow *f)
     if (unlikely(p->StateTransactionFree == NULL))
         SCReturn;
 
-    const bool has_tx_detect_flags = (p->GetTxDetectFlags != NULL || p->GetTxData != NULL);
+    const bool has_tx_detect_flags = (p->GetTxData != NULL);
     const uint8_t ipproto = f->proto;
     const AppProto alproto = f->alproto;
     void * const alstate = f->alstate;
@@ -1144,9 +1128,6 @@ bool AppLayerParserSupportsTxDetectFlags(AppProto alproto)
 {
     SCEnter();
     for (uint8_t p = 0; p < FLOW_PROTO_APPLAYER_MAX; p++) {
-        if (alp_ctx.ctxs[p][alproto].GetTxDetectFlags != NULL) {
-            SCReturnBool(true);
-        }
         if (alp_ctx.ctxs[p][alproto].GetTxData != NULL) {
             SCReturnBool(true);
         }
@@ -1154,25 +1135,6 @@ bool AppLayerParserSupportsTxDetectFlags(AppProto alproto)
     SCReturnBool(false);
 }
 
-uint64_t AppLayerParserGetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir)
-{
-    SCEnter();
-    uint64_t flags = 0;
-    if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectFlags != NULL) {
-        flags = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectFlags(tx, dir);
-    }
-    SCReturnUInt(flags);
-}
-
-void AppLayerParserSetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir, uint64_t flags)
-{
-    SCEnter();
-    if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectFlags != NULL) {
-        alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectFlags(tx, dir, flags);
-    }
-    SCReturn;
-}
-
 AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
 {
     SCEnter();
@@ -1543,9 +1505,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
     if (!(BOTH_SET_OR_BOTH_UNSET(ctx->GetTxDetectState, ctx->SetTxDetectState))) {
         goto bad;
     }
-    if (!(BOTH_SET_OR_BOTH_UNSET(ctx->GetTxDetectFlags, ctx->SetTxDetectFlags))) {
-        goto bad;
-    }
 
     return;
 bad:
index 933d570e58d075e645e159327470d32dbefd62a6..e8f00f5691d3655fd29da0d1e76a68f09ee599fa 100644 (file)
@@ -182,9 +182,6 @@ void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
 void AppLayerParserRegisterGetStreamDepth(uint8_t ipproto,
                                           AppProto alproto,
                                           uint32_t (*GetStreamDepth)(void));
-void AppLayerParserRegisterDetectFlagsFuncs(uint8_t ipproto, AppProto alproto,
-        uint64_t(*GetTxDetectFlags)(void *tx, uint8_t dir),
-        void (*SetTxDetectFlags)(void *tx, uint8_t dir, uint64_t));
 void AppLayerParserRegisterSetStreamDepthFlag(uint8_t ipproto, AppProto alproto,
         void (*SetStreamDepthFlag)(void *tx, uint8_t flags));
 
@@ -234,8 +231,6 @@ int AppLayerParserHasTxDetectState(uint8_t ipproto, AppProto alproto, void *alst
 DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx);
 int AppLayerParserSetTxDetectState(const Flow *f, void *tx, DetectEngineState *s);
 
-uint64_t AppLayerParserGetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir);
-void AppLayerParserSetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir, uint64_t);
 bool AppLayerParserSupportsTxDetectFlags(AppProto alproto);
 
 AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx);
index 41bf9f37532a7e13beed7d8719dbe65222366405..961f0dfcb4ce30ee6b3c2c4fb43506963cd87efb 100644 (file)
@@ -166,11 +166,6 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
                 p->GetTxIterator);
     }
 
-    if (p->SetTxDetectFlags && p->GetTxDetectFlags) {
-        AppLayerParserRegisterDetectFlagsFuncs(p->ip_proto, alproto,
-                p->GetTxDetectFlags, p->SetTxDetectFlags);
-    }
-
     if (p->GetTxData) {
         AppLayerParserRegisterTxDataFunc(p->ip_proto, alproto,
                 p->GetTxData);
index fe0e55406e9b51a54a3cdda465e452eaae6fc511..1223720e286b24d42801853f6453a6252fe3f26d 100644 (file)
@@ -1238,7 +1238,7 @@ static DetectTransaction GetDetectTx(const uint8_t ipproto, const AppProto alpro
     if (txd != NULL) {
         detect_flags = (flow_flags & STREAM_TOSERVER) ? txd->detect_flags_ts : txd->detect_flags_tc;
     } else {
-        detect_flags = AppLayerParserGetTxDetectFlags(ipproto, alproto, tx_ptr, flow_flags);
+        detect_flags = 0;
     }
     if (detect_flags & APP_LAYER_TX_INSPECTED_FLAG) {
         SCLogDebug("%"PRIu64" tx already fully inspected for %s. Flags %016"PRIx64,
@@ -1278,9 +1278,6 @@ static inline void StoreDetectFlags(DetectTransaction *tx, const uint8_t flow_fl
         } else {
             txd->detect_flags_tc = detect_flags;
         }
-    } else {
-        AppLayerParserSetTxDetectFlags(ipproto, alproto, tx->tx_ptr,
-                flow_flags, detect_flags);
     }
 }