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>
This commit is contained in:
Stig Bjørlykke 2020-07-21 00:22:00 +02:00 committed by Anders Broman
parent 779715a530
commit 70b4dd9f70
1 changed files with 14 additions and 0 deletions

View File

@ -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",