From 70b4dd9f703f44ad2fefe02d856f1906aa8aa139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 21 Jul 2020 00:22:00 +0200 Subject: [PATCH] mqtt: Add default protocol version setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ping-Bug: 16722 Change-Id: I0e3327e8b0215cf3a7319238f9d67a78806d7476 Reviewed-on: https://code.wireshark.org/review/37917 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-mqtt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/epan/dissectors/packet-mqtt.c b/epan/dissectors/packet-mqtt.c index 0ec87ce3f5..e802b5a058 100644 --- a/epan/dissectors/packet-mqtt.c +++ b/epan/dissectors/packet-mqtt.c @@ -96,6 +96,13 @@ static const value_string mqtt_protocol_version_vals[] = { { 0, NULL } }; +static const enum_val_t mqtt_protocol_version_enumvals[] = { + { "v31", "MQTT v3.1", MQTT_PROTO_V31 }, + { "v311", "MQTT v3.1.1", MQTT_PROTO_V311 }, + { "v50", "MQTT v5.0", MQTT_PROTO_V50 }, + { NULL, NULL, 0 } +}; + static const value_string mqtt_msgtype_vals[] = { { MQTT_RESERVED, "Reserved" }, { MQTT_CONNECT, "Connect Command" }, @@ -494,6 +501,7 @@ static const value_string mqtt_reason_code_auth_vals[] = { static mqtt_message_decode_t *mqtt_message_decodes; static guint num_mqtt_message_decodes; +static gint default_protocol_version = MQTT_PROTO_V311; static dissector_handle_t mqtt_handle; @@ -979,6 +987,7 @@ static int dissect_mqtt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi if (mqtt == NULL) { mqtt = wmem_new0(wmem_file_scope(), mqtt_conv_t); + mqtt->runtime_proto_version = default_protocol_version; conversation_add_proto_data(conv, proto_mqtt, mqtt); mqtt->topic_alias_map = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal); } @@ -1797,6 +1806,11 @@ void proto_register_mqtt(void) "A table that enumerates custom message decodes to be used for a certain topic", message_uat); + prefs_register_enum_preference(mqtt_module, "default_version", + "Default Version", + "Select the MQTT version to use as protocol version if the CONNECT packet is not captured", + &default_protocol_version, mqtt_protocol_version_enumvals, FALSE); + prefs_register_bool_preference(mqtt_module, "show_msg_as_text", "Show Message as text", "Show Publish Message as text",