From: Sascha Steinbiss Date: Sun, 20 Oct 2024 09:27:51 +0000 (+0200) Subject: mqtt: add reason code support for SUBACK X-Git-Tag: suricata-7.0.8~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378b9bb55d0df898e0837335a6ed5ef2730083c0;p=thirdparty%2Fsuricata.git mqtt: add reason code support for SUBACK Ticket: #7323 (cherry picked from commit 377d4705e15aa54ae26176822b23eec0a98bbc59) --- diff --git a/rust/src/mqtt/detect.rs b/rust/src/mqtt/detect.rs index b47a84f744..a34bc7da39 100644 --- a/rust/src/mqtt/detect.rs +++ b/rust/src/mqtt/detect.rs @@ -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 {