aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mqtt.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2020-07-21 00:22:00 +0200
committerAnders Broman <a.broman58@gmail.com>2020-07-21 04:36:14 +0000
commit70b4dd9f703f44ad2fefe02d856f1906aa8aa139 (patch)
tree8df7d0f152e6e6e6dcda873e39a8fe4d5cdab494 /epan/dissectors/packet-mqtt.c
parent779715a53058c7da1b8b57b78bd781d63f0c9ea7 (diff)
mqtt: Add default protocol version setting
Ping-Bug: 16722 Change-Id: I0e3327e8b0215cf3a7319238f9d67a78806d7476 Reviewed-on: https://code.wireshark.org/review/37917 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-mqtt.c')
-rw-r--r--epan/dissectors/packet-mqtt.c14
1 files changed, 14 insertions, 0 deletions
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",