ltm rule command MQTT respondΒΆ

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



MQTT::respond
       Transmit MQTT message to sender

SYNOPSIS
       MQTT::respond ( (('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 transmit MQTT message back to sender of the
       incoming message.  If called from MQTT_CLIENT_INGRESS message will be
       sent to the client.  If called from MQTT_SERVER_INGRESS message will be
       sent to the server.  Please note that current message will be forwarded
       to destination. Use MQTT::drop to drop the current message.  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::respond 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::respond 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::respond type PUBACK  packet_id  MQTT::respond
       type PUBREC  packet_id  MQTT::respond type PUBREL
       packet_id  MQTT::respond 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::respond 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::respond 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::respond 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::respond type UNSUBACK packet_id 
	   * For UNSUBACK, packet_id is required parameter.

       MQTT::respond type PINGREQ
	   * For PINGREQ should be used with no parameter.

       MQTT::respond type PINGRESP
	   * For PINGRESP should be used with no parameter.

       MQTT::respond 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
	Enrich MQTT username with SSL client-certificate common name, reject unauthorized accesses:
	when CLIENT_ACCEPTED {
	    set cn ""
	}

	when CLIENTSSL_CLIENTCERT {
	    set cn [ lindex [ split [lindex [ split [X509::subject [SSL::cert 0]] "," ] 0 ] "=" ] 1 ]
	    log local0. "Client Cert Common Name: $cn"
	}

	when MQTT_CLIENT_INGRESS {
	    if {[MQTT::type] == "CONNECT"} {
		if {$cn == ""} {
		    MQTT::drop
		    MQTT::respond type CONNACK return_code 5
		} else {
		    set user [MQTT::username]
		    MQTT::username "$cn:$user"
		}
	    }
	}

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



BIG-IP				  2017-01-31			      iRule(1)