]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/dns: implement detect_flags API
authorVictor Julien <victor@inliniac.net>
Fri, 13 Oct 2017 06:12:21 +0000 (08:12 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 19 Jan 2018 09:13:23 +0000 (10:13 +0100)
rust/src/dns/dns.rs
src/app-layer-dns-udp-rust.c

index 4f62c644f4ae302aed877fc713971bf4cfa88e92..19e877c7030baa4b6209a49b3c336f31a4c471a4 100644 (file)
@@ -179,6 +179,8 @@ pub struct DNSTransaction {
     pub id: u64,
     pub request: Option<DNSRequest>,
     pub response: Option<DNSResponse>,
+    detect_flags_ts: u64,
+    detect_flags_tc: u64,
     pub logged: LoggerFlags,
     pub de_state: Option<*mut core::DetectEngineState>,
     pub events: *mut core::AppLayerDecoderEvents,
@@ -191,6 +193,8 @@ impl DNSTransaction {
             id: 0,
             request: None,
             response: None,
+            detect_flags_ts: 0,
+            detect_flags_tc: 0,
             logged: LoggerFlags::new(),
             de_state: None,
             events: std::ptr::null_mut(),
@@ -684,6 +688,30 @@ pub extern "C" fn rs_dns_tx_get_alstate_progress(_tx: &mut DNSTransaction,
     return 1;
 }
 
+#[no_mangle]
+pub extern "C" fn rs_dns_tx_set_detect_flags(tx: &mut DNSTransaction,
+                                             dir: libc::uint8_t,
+                                             flags: libc::uint64_t)
+{
+    if dir & core::STREAM_TOSERVER != 0 {
+        tx.detect_flags_ts = flags as u64;
+    } else {
+        tx.detect_flags_tc = flags as u64;
+    }
+}
+
+#[no_mangle]
+pub extern "C" fn rs_dns_tx_get_detect_flags(tx: &mut DNSTransaction,
+                                             dir: libc::uint8_t)
+                                       -> libc::uint64_t
+{
+    if dir & core::STREAM_TOSERVER != 0 {
+        return tx.detect_flags_ts as libc::uint64_t;
+    } else {
+        return tx.detect_flags_tc as libc::uint64_t;
+    }
+}
+
 #[no_mangle]
 pub extern "C" fn rs_dns_tx_set_logged(_state: &mut DNSState,
                                        tx: &mut DNSTransaction,
index f1dcff228aebadcb346d932774e8f05bce46add8..895e285242357c809cb6266be3472a169f9d8d65 100644 (file)
@@ -112,6 +112,17 @@ static int RustDNSSetTxDetectState(void *state, void *tx,
     return 0;
 }
 
+static void RustDNSSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
+{
+    rs_dns_tx_set_detect_flags(tx, dir, flags);
+}
+
+static uint64_t RustDNSGetDetectFlags(void *tx, uint8_t dir)
+{
+    return rs_dns_tx_get_detect_flags(tx, dir);
+}
+
+
 static int RustDNSHasEvents(void *state)
 {
     return rs_dns_state_has_events(state);
@@ -172,6 +183,8 @@ void RegisterRustDNSUDPParsers(void)
         AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DNS,
                 RustDNSStateHasTxDetectState, RustDNSGetTxDetectState,
                 RustDNSSetTxDetectState);
+        AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_UDP, ALPROTO_DNS,
+                RustDNSGetDetectFlags, RustDNSSetDetectFlags);
 
         AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_DNS, RustDNSGetTx);
         AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_DNS,