dissector/mqtt: Dissect the User Property field

Change-Id: I0a0e484a814a11b785d20fda6eba5c251db98188
Signed-off-by: Flavio Santes <flavio.santes@1byt3.com>
Reviewed-on: https://code.wireshark.org/review/24269
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Flavio Santes 2017-11-06 15:18:42 -05:00 committed by Stig Bjørlykke
parent 9f67e0a0d6
commit af285603ee
1 changed files with 26 additions and 0 deletions

View File

@ -230,6 +230,7 @@ static const value_string match_criteria[] = {
#define PROP_TOPIC_ALIAS 0x23
#define PROP_MAXIMUM_QOS 0x24
#define PROP_RETAIN_AVAILABLE 0x25
#define PROP_USER_PROPERTY 0x26
#define PROP_MAXIMUM_PACKET_SIZE 0x27
#define PROP_WILDCARD_SUBSCRIPTION_AVAILABLE 0x28
#define PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE 0x29
@ -258,6 +259,7 @@ static const value_string mqtt_property_vals[] = {
{ PROP_TOPIC_ALIAS, "Topic Alias" },
{ PROP_MAXIMUM_QOS, "Maximum QoS" },
{ PROP_RETAIN_AVAILABLE, "Retain Available" },
{ PROP_USER_PROPERTY, "User Property" },
{ PROP_MAXIMUM_PACKET_SIZE, "Maximum Packet Size" },
{ PROP_WILDCARD_SUBSCRIPTION_AVAILABLE, "Wildcard Subscription Available" },
{ PROP_SUBSCRIPTION_IDENTIFIER_AVAILABLE, "Subscription Identifier Available" },
@ -335,6 +337,10 @@ static int hf_mqtt_prop_max_qos = -1;
static int hf_mqtt_prop_unknown = -1;
static int hf_mqtt_prop_string_len = -1;
static int hf_mqtt_prop_string = -1;
static int hf_mqtt_prop_key_len = -1;
static int hf_mqtt_prop_key = -1;
static int hf_mqtt_prop_value_len = -1;
static int hf_mqtt_prop_value = -1;
/* Initialize the subtree pointers */
static gint ett_mqtt_hdr = -1;
@ -555,6 +561,10 @@ static guint32 dissect_mqtt_properties(tvbuff_t *tvb, proto_tree *mqtt_tree, gui
case PROP_REASON_STRING:
offset += dissect_string(tvb, mqtt_prop_tree, offset, hf_mqtt_prop_string_len, hf_mqtt_prop_string);
break;
case PROP_USER_PROPERTY:
offset += dissect_string(tvb, mqtt_prop_tree, offset, hf_mqtt_prop_key_len, hf_mqtt_prop_key);
offset += dissect_string(tvb, mqtt_prop_tree, offset, hf_mqtt_prop_value_len, hf_mqtt_prop_value);
break;
default:
proto_tree_add_item(mqtt_prop_tree, hf_mqtt_prop_unknown, tvb, offset, bytes_to_read - offset, ENC_UTF_8|ENC_NA);
offset += (bytes_to_read - offset);
@ -1216,6 +1226,22 @@ void proto_register_mqtt(void)
{ "Value", "mqtt.prop_string",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_prop_key_len,
{ "Key Length", "mqtt.prop_key_len",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_prop_key,
{ "Key", "mqtt.prop_key",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_prop_value_len,
{ "Value Length", "mqtt.prop_value_len",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_mqtt_prop_value,
{ "Value", "mqtt.prop_value",
FT_STRING, BASE_NONE, NULL, 0,
NULL, HFILL }},
};
/* Setup protocol subtree arrays */