]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mqtt: add reason code support for SUBACK
authorSascha Steinbiss <satta@debian.org>
Sun, 20 Oct 2024 09:27:51 +0000 (11:27 +0200)
committerVictor Julien <victor@inliniac.net>
Sun, 1 Dec 2024 06:49:45 +0000 (07:49 +0100)
Ticket: #7323
(cherry picked from commit 377d4705e15aa54ae26176822b23eec0a98bbc59)

rust/src/mqtt/detect.rs

index b47a84f74409a9b35bc0b2ff6bd3011ceda2c254..a34bc7da3906c543ff78b5a5bfe70aff3354125a 100644 (file)
@@ -373,6 +373,27 @@ pub unsafe extern "C" fn rs_mqtt_tx_get_reason_code(tx: &MQTTTransaction, result
 
 #[no_mangle]
 pub extern "C" fn rs_mqtt_tx_unsuback_has_reason_code(tx: &MQTTTransaction, code: u8) -> u8 {
+    for msg in tx.msg.iter() {
+        match msg.op {
+            MQTTOperation::UNSUBACK(ref unsuback) => {
+                if let Some(ref reason_codes) = unsuback.reason_codes {
+                    for rc in reason_codes.iter() {
+                        if *rc == code {
+                            return 1;
+                        }
+                    }
+                }
+            }
+            MQTTOperation::SUBACK(ref suback) => {
+                for rc in suback.qoss.iter() {
+                    if *rc == code {
+                        return 1;
+                    }
+                }
+            }
+            _ => {}
+        }
+    }
     for msg in tx.msg.iter() {
         if let MQTTOperation::UNSUBACK(ref unsuback) = msg.op {
             if let Some(ref reason_codes) = unsuback.reason_codes {