Skip to content

Commit

Permalink
mqtt: add reason code support for SUBACK
Browse files Browse the repository at this point in the history
Ticket: #7323
(cherry picked from commit 377d470)
  • Loading branch information
satta authored and jasonish committed Nov 26, 2024
1 parent fccb328 commit 6dde3ee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rust/src/mqtt/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6dde3ee

Please sign in to comment.