]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: move from MpmIDs to DetectFlags API
authorVictor Julien <victor@inliniac.net>
Tue, 10 Oct 2017 09:54:02 +0000 (11:54 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Jan 2018 09:13:10 +0000 (10:13 +0100)
src/app-layer-htp.c
src/app-layer-htp.h

index 76c14aa0bc9ecea9064de4763da8800c65e99952..d420214676f85450cff0c5ba297296f03ba0e83f 100644 (file)
@@ -2748,26 +2748,37 @@ static int HTPSetTxDetectState(void *alstate, void *vtx, DetectEngineState *s)
     return 0;
 }
 
-static uint64_t HTPGetTxMpmIDs(void *vtx)
+static uint64_t HTPGetTxDetectFlags(void *vtx, uint8_t dir)
 {
     htp_tx_t *tx = (htp_tx_t *)vtx;
     HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
-    return tx_ud ? tx_ud->mpm_ids : 0;
+    if (tx_ud) {
+        if (dir & STREAM_TOSERVER) {
+            return tx_ud->detect_flags_ts;
+        } else {
+            return tx_ud->detect_flags_tc;
+        }
+    }
+    return 0;
 }
 
-static int HTPSetTxMpmIDs(void *vtx, uint64_t mpm_ids)
+static void HTPSetTxDetectFlags(void *vtx, uint8_t dir, uint64_t detect_flags)
 {
     htp_tx_t *tx = (htp_tx_t *)vtx;
     HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
     if (tx_ud == NULL) {
         tx_ud = HTPMalloc(sizeof(*tx_ud));
         if (unlikely(tx_ud == NULL))
-            return -ENOMEM;
+            return;
         memset(tx_ud, 0, sizeof(*tx_ud));
         htp_tx_set_user_data(tx, tx_ud);
     }
-    tx_ud->mpm_ids = mpm_ids;
-    return 0;
+    if (dir & STREAM_TOSERVER) {
+        tx_ud->detect_flags_ts = detect_flags;
+    } else {
+        tx_ud->detect_flags_tc = detect_flags;
+    }
+    return;
 }
 
 static int HTPRegisterPatternsForProtocolDetection(void)
@@ -2858,8 +2869,8 @@ void RegisterHTPParsers(void)
         AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP,
                                                HTPStateHasTxDetectState,
                                                HTPGetTxDetectState, HTPSetTxDetectState);
-        AppLayerParserRegisterMpmIDsFuncs(IPPROTO_TCP, ALPROTO_HTTP,
-                                               HTPGetTxMpmIDs, HTPSetTxMpmIDs);
+        AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_HTTP,
+                                               HTPGetTxDetectFlags, HTPSetTxDetectFlags);
 
         AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_HTTP, STREAM_TOSERVER,
                                      HTPHandleRequestData);
index 60e89a84f608e7bdf66503995461e7109a1ff20f..3ea4558b97ec2114ecd5995958f784af0f0f299d 100644 (file)
@@ -188,8 +188,9 @@ typedef struct HtpBody_ {
 /** Now the Body Chunks will be stored per transaction, at
   * the tx user data */
 typedef struct HtpTxUserData_ {
-    /** flags to track which mpm has run */
-    uint64_t mpm_ids;
+    /** detection engine flags */
+    uint64_t detect_flags_ts;
+    uint64_t detect_flags_tc;
 
     /* Body of the request (if any) */
     uint8_t request_body_init;