]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/dns: convert to v2 inspect API
authorVictor Julien <victor@inliniac.net>
Mon, 19 Oct 2020 12:11:26 +0000 (14:11 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 7 Dec 2020 15:01:52 +0000 (16:01 +0100)
src/detect-dns-opcode.c
src/detect-dns-query.c
src/detect-engine-dns.c
src/detect-engine-dns.h

index a08f254276eaf1f5d509098c3edeab84076eafae..bbb58d2ccaa78eef2fd98a3792db1a13c67b260f 100644 (file)
@@ -74,14 +74,12 @@ static int DetectDnsOpcodeMatch(DetectEngineThreadCtx *det_ctx,
     return rs_dns_opcode_match(txv, (void *)ctx, flags);
 }
 
-static int DetectEngineInspectRequestGenericDnsOpcode(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatchData *smd,
-        Flow *f, uint8_t flags, void *alstate,
-        void *txv, uint64_t tx_id)
+static int DetectEngineInspectRequestGenericDnsOpcode(DetectEngineCtx *de_ctx,
+        DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine,
+        const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
-    return DetectEngineInspectGenericList(tv, de_ctx, det_ctx, s, smd,
-       f, flags, alstate, txv, tx_id);
+    return DetectEngineInspectGenericList(
+            NULL, de_ctx, det_ctx, s, engine->smd, f, flags, alstate, txv, tx_id);
 }
 
 void DetectDnsOpcodeRegister(void)
@@ -94,13 +92,11 @@ void DetectDnsOpcodeRegister(void)
     sigmatch_table[DETECT_AL_DNS_OPCODE].AppLayerTxMatch =
         DetectDnsOpcodeMatch;
 
-    DetectAppLayerInspectEngineRegister("dns.opcode",
-            ALPROTO_DNS, SIG_FLAG_TOSERVER, 0,
-            DetectEngineInspectRequestGenericDnsOpcode);
+    DetectAppLayerInspectEngineRegister2("dns.opcode", ALPROTO_DNS, SIG_FLAG_TOSERVER, 0,
+            DetectEngineInspectRequestGenericDnsOpcode, NULL);
 
-    DetectAppLayerInspectEngineRegister("dns.opcode",
-            ALPROTO_DNS, SIG_FLAG_TOCLIENT, 0,
-            DetectEngineInspectRequestGenericDnsOpcode);
+    DetectAppLayerInspectEngineRegister2("dns.opcode", ALPROTO_DNS, SIG_FLAG_TOCLIENT, 0,
+            DetectEngineInspectRequestGenericDnsOpcode, NULL);
 
     dns_opcode_list_id = DetectBufferTypeGetByName("dns.opcode");
 }
index ef7b3a39d68ec7e11ccfd574f05cdc464a4b6574..5e4b5f10517bc6e4909c27581af9c119b0aea1ee 100644 (file)
@@ -232,12 +232,10 @@ void DetectDnsQueryRegister (void)
     g_dns_query_buffer_id = DetectBufferTypeGetByName("dns_query");
 
     /* register these generic engines from here for now */
-    DetectAppLayerInspectEngineRegister("dns_request",
-            ALPROTO_DNS, SIG_FLAG_TOSERVER, 1,
-            DetectEngineInspectDnsRequest);
-    DetectAppLayerInspectEngineRegister("dns_response",
-            ALPROTO_DNS, SIG_FLAG_TOCLIENT, 1,
-            DetectEngineInspectDnsResponse);
+    DetectAppLayerInspectEngineRegister2(
+            "dns_request", ALPROTO_DNS, SIG_FLAG_TOSERVER, 1, DetectEngineInspectDnsRequest, NULL);
+    DetectAppLayerInspectEngineRegister2("dns_response", ALPROTO_DNS, SIG_FLAG_TOCLIENT, 1,
+            DetectEngineInspectDnsResponse, NULL);
 
     DetectBufferTypeSetDescriptionByName("dns_request",
             "dns requests");
index ec412e3a65b0ebd6ff0aed05171e844666dd7c24..77721b3d4193d80522fe5c80b0ea5b26ec454581 100644 (file)
 #include "util-unittest-helper.h"
 #include "util-validate.h"
 
-int DetectEngineInspectDnsRequest(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatchData *smd,
-        Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
+int DetectEngineInspectDnsRequest(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
+        const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f,
+        uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
-    return DetectEngineInspectGenericList(tv, de_ctx, det_ctx, s, smd,
-                                          f, flags, alstate, txv, tx_id);
+    return DetectEngineInspectGenericList(
+            NULL, de_ctx, det_ctx, s, engine->smd, f, flags, alstate, txv, tx_id);
 }
 
-int DetectEngineInspectDnsResponse(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatchData *smd,
-        Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
+int DetectEngineInspectDnsResponse(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
+        const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f,
+        uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 {
-    return DetectEngineInspectGenericList(tv, de_ctx, det_ctx, s, smd,
-                                          f, flags, alstate, txv, tx_id);
+    return DetectEngineInspectGenericList(
+            NULL, de_ctx, det_ctx, s, engine->smd, f, flags, alstate, txv, tx_id);
 }
index 0ffc87c006e0998539bc52a5da428120798eb6f4..ca886e3130c1c3cd0370542caca0dadebb7cdabf 100644 (file)
 #ifndef __DETECT_ENGINE_DNS_H__
 #define __DETECT_ENGINE_DNS_H__
 
-int DetectEngineInspectDnsRequest(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatchData *smd,
-        Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
-int DetectEngineInspectDnsResponse(ThreadVars *tv,
-        DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
-        const Signature *s, const SigMatchData *smd,
-        Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
+int DetectEngineInspectDnsRequest(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
+        const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f,
+        uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
+int DetectEngineInspectDnsResponse(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
+        const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f,
+        uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
 
 #endif /* __DETECT_ENGINE_DNS_H__ */