ltm rule command MQTT insertΒΆ

iRule(1)					  BIG-IP TMSH Manual					     iRule(1)

MQTT::insert
       Insert an MQTT message

SYNOPSIS
       MQTT::insert (('before' | 'after') (
			       (('type' 'CONNECT') ('client_id' NAME)
						   ('keep_alive' KEEP_ALIVE)?
						   ('clean_session' BOOLEAN)?
						   ('protocol_name' NAME)?
						   ('protocol_version' VERSION)?
						   ('username' NAME)?
						   ('password' PASSWORD)?
						   ('will_topic' TOPIC)?
						   ('will_message' CONTENT)?
						   ('will_qos' ('0' | '1' | '2'))?
						   ('will_retain' BOOLEAN)?) |
			       (('type' 'CONNACK') ('return_code' RETURN_CODE)
						   ('session_present' BOOLEAN)?) |
			       (('type' 'PUBLISH') ('topic' TOPIC) ('payload' CONTENT)
						   (('qos' '0') | (('qos' ('1' | '2')) ('packet_id' PACKETID)))?
						   ('dup' BOOLEAN)?
						   ('retain' BOOLEAN)?) |
			       (('type' ('PUBACK' | 'PUBREC' | 'PUBREL' | 'PUBCOMP')) ('packet_id' PACKETID)) |
			       (('type' 'SUBSCRIBE') ('packet_id' PACKETID)
						   ('topic_list'  (TOPIC ('0' | '1' | '2'))+)?) |
			       (('type' 'SUBACK') ('packet_id' PACKETID) ('return_code_list' (RETURN_CODE)+)) |
			       (('type' 'UNSUBSCRIBE') ('packet_id' PACKETID) ('topic_list' (TOPIC ('0' | '1' |
       '2'))+)) |
			       (('type' 'UNSUBACK') ('packet_id' PACKETID)) |
			       (('type' ('PINGREQ' | 'PINGRESP' | 'DISCONNECT')))
			      ))

DESCRIPTION
       This command can be used to insert an MQTT message before or after current message.  Since
       MQTT_CLIENT_SHUTDOWN event does not have current message only 'MQTT::insert after' is supported for it.

       This command is valid for all MQTT message types:

	   CONNECT, CONNACK,
	   PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP,
	   SUBSCRIBE, SUBACK,
	   UNSUBSCRIBE, UNSUBACK,
	   PINGREQ, PINGRESP,
	   DISCONNECT

       Syntax

       MQTT::insert (before | after) type CONNECT client_id 
				     [keep_alive ] [clean_session (0 | 1)]
				     [protocol_name ] [protocol_version ]
				     [username ] [password ]
				     [will_topic ] [will_message ]
				     [will_qos (0 | 1 |2)] [will_retain (0 | 1)]
	   * The client_id is required parameter.
	     keep_alive  must be smaller than 65536.
	     Default values for optional parameters are:
	       keep_alive	    -: 60 seconds.
	       clean_session	   -: 1
	       protocol_name	   -: MQTT
	       protocol_version    -: 4
	       username 	   -: ""
	       password 	   -: ""
	       will_topic	   -: ""
	       will_message	   -: ""
	       will_qos 	   -: 0
	       will_retain	   -: 0

       MQTT::insert (before | after) type CONNACK return_code 
				     [ session_present  ]

	   * The  values must be set to one of the following:.
		   0 - Connection Accepted.
		   1 - Connection Refused, unacceptable protocol version.
		   2 - Connection Refused, identifier rejected.
		   3 - Connection Refused, Server unavailable.
		   4 - Connection Refused, bad username or password.
		   5 - Connection Refused, not authorized.
	     The  can be set to 0 or 1. The default value is 0.

       MQTT::insert (before | after) type PUBLISH topic  payload 
				     [{qos 0} | {qos (1 | 2) packet_id } ]
				     [dup (0 | 1)]
				     [retain (0 | 1)]

	   * For PUBLISH, the topic and payload are required parameters. If qos is 1 or 2, then packet_id must also be specified.
	      must be smaller than 65536.
	     Default values for optional parameters are:
		   qos	       -: 0
		   dup	       -: 0
		   retain      -: 0

       MQTT::insert (before | after) type PUBACK  packet_id  MQTT::insert (before | after) type
       PUBREC  packet_id  MQTT::insert (before | after) type PUBREL  packet_id 
       MQTT::insert (before | after) type PUBCOMP packet_id 
	   * For PUBACK, PUBREC, PUBREL, and PUBCOMP, packet_id is a required parameter. No other parameter should be
       specified.
	      must be smaller than 65536.

       MQTT::insert (before | after) type SUBSCRIBE packet_id  topic_list { }+
	   * For SUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be specified.
	      must be smaller than 65536.  can only be 0,1, or 2.

       MQTT::insert (before | after) type SUBACK packet_id  return_code_list {}+
	   * For SUBACK, packet_id and return_code_list are required parameters. No other parameter should be
       specified.
	      must be smaller than 65536.

       MQTT::insert (before | after) type UNSUBSCRIBE packet_id  topic_list { }+
	   * For UNSUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be
       specified.
	     Please note that  values will be ignored. It is required to make format of topic_list same between
       SUBSCRIBE and UNSUBSCRIBE.
	     UNSUBSCRIBE does not need the qos.

       MQTT::insert (before | after) type UNSUBACK packet_id 
	   * For UNSUBACK, packet_id is required parameter.

       MQTT::insert (before | after) type PINGREQ
	   * For PINGREQ should be used with no parameter.

       MQTT::insert (before | after) type PINGRESP
	   * For PINGRESP should be used with no parameter.

       MQTT::insert (before | after) type DISCONNECT
	   * For DISCONNECT should be used with no parameter.

RETURN VALUE
       None.

VALID DURING
       MQTT_CLIENT_INGRESS MQTT_SERVER_INGRESS MQTT_CLIENT_DATA MQTT_SERVER_DATA

EXAMPLES
	#Example: Auto subscribe for a topic
	when MQTT_CLIENT_INGRESS {
	    set type [MQTT::type]
	    switch $type {
	       "CONNECT" {
		    MQTT::insert after type SUBSCRIBE packet_id 1001 topic_list "/Mandatory/Topic" 0
	       }
	    }
	}

	when MQTT_SERVER_INGRESS {
	    set type [MQTT::type]
	    switch $type {
	       "SUBACK" {
		  if { [MQTT::packet_id > 1000] } {
		     MQTT::drop
		  }
	       }
	    }
	}

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-13.0.0 --First introduced the command.

BIG-IP						      2020-06-23					     iRule(1)