ltm rule command MQTT return code list
iRule(1) BIG-IP TMSH Manual iRule(1)
MQTT::return_code_list
Get return-code-list of MQTT SUBACK message.
SYNOPSIS
MQTT::return_code_list
DESCRIPTION
This command can be used to get return-code-list of MQTT message. Note that this command does not support a
'set' operation. In order to change the retun-code-list please use 'MQTT::replace type SUBACK'. This command
is valid only for following MQTT message types:
SUBACK
Syntax
MQTT::return_code_list
* Get the return-code-list of MQTT SUBACK message.
Each number in the list should be smaller than 256. Valid values are:
0 : Success - Maximum QoS 0.
1 : Success - Maximum QoS 1.
2 : Success - Maximum QoS 2.
128 : Failure
Other : Reserved for future use.
RETURN VALUE
When called without an argument, this command returns the return-code-list of MQTT SUBACK message.
VALID DURING
MQTT_CLIENT_INGRESS MQTT_SERVER_INGRESS MQTT_CLIENT_DATA MQTT_SERVER_DATA MQTT_CLIENT_EGRESS
MQTT_SERVER_EGRESS
EXAMPLES
#Example: Split SUBSCRIBE with multiple topics into separate SUBSCRIBE messages
when MQTT_CLIENT_INGRESS {
set type [MQTT::type]
switch $type {
"SUBSCRIBE" {
set count [MQTT::topic count]
if { $count > 1 } {
set topiclist [MQTT::topic list]
set qoslist [list]
foreach topic $topiclist {
lappend qoslist [MQTT::topic qos $topic]
}
set packetid [MQTT::packet_id]
set i 0
foreach topic $topiclist {
if { $i == 0 } {
MQTT::replace type SUBSCRIBE packet_id $packetid topic_list $topic [lindex $qoslist $i]
table add -subtable "outstanding_packetid_table" "[client_addr]_[client_port]_${packetid}" $count
} else {
MQTT::insert after type SUBSCRIBE packet_id [expr { ($packetid + 1000 + $i)%65535}] topic_list $topic [lindex $qoslist $i]
}
set i [expr { $i + 1 }]
}
}
}
}
}
when SERVER_CONNECTED {
set suback_count 0
set rclist [list]
}
when MQTT_SERVER_INGRESS {
set type [MQTT::type]
switch $type {
"SUBACK" {
set packetid [MQTT::packet_id]
if { $suback_count == 0 } {
set count [table lookup -subtable "outstanding_packetid_table" "[client_addr]_[client_port]_${packetid}"]
if { $count != "" } {
set suback_count $count
} elseif { [llength $rclist] > 0 } {
MQTT::replace type SUBACK return_code_list $rclist
set rclist [list]
}
}
if { $suback_count > 0 } {
set suback_count [expr { $suback_count - 1}]
lappend rclist [MQTT::return_code_list]
MQTT::drop
}
}
}
}
HINTS
SEE ALSO
CHANGE LOG
@BIGIP-13.0.0 --First introduced the command.
BIG-IP 2020-06-23 iRule(1)